Commit 14be4310 by David Baumgold

Add confirmation step for deleting a textbook

parent 9de2dc51
......@@ -75,7 +75,7 @@ CMS.Views.TextbookShow = Backbone.View.extend({
tagName: "li",
events: {
"click .edit": "editTextbook",
"click .delete": "delete",
"click .delete": "confirmDelete",
"click .show-chapters": "showChapters",
"click .hide-chapters": "hideChapters"
},
......@@ -87,16 +87,25 @@ CMS.Views.TextbookShow = Backbone.View.extend({
if(e && e.preventDefault) { e.preventDefault(); }
this.model.collection.trigger("editOne", this.model);
},
delete: function(e) {
confirmDelete: function(e) {
if(e && e.preventDefault) { e.preventDefault(); }
var collection = this.model.collection;
collection.remove(this.model);
msg = new CMS.Models.SystemFeedback({
var textbook = this.model, collection = this.model.collection;
var msg = new CMS.Models.WarningMessage({
title: _.str.sprintf(gettext("Delete “%s”?"),
textbook.escape('name')),
message: gettext("Deleting a textbook cannot be undone and once deleted any reference to it in your courseware's navigation will also be removed."),
actions: {
primary: {
text: gettext("Delete"),
click: function(view) {
view.hide();
collection.remove(textbook);
var delmsg = new CMS.Models.SystemFeedback({
intent: "saving",
title: gettext("Deleting…")
});
notif = new CMS.Views.Notification({
model: msg,
var notif = new CMS.Views.Notification({
model: delmsg,
closeIcon: false,
minShown: 1250
});
......@@ -105,6 +114,17 @@ CMS.Views.TextbookShow = Backbone.View.extend({
notif.hide();
}
});
}
},
secondary: [{
text: gettext("Cancel"),
click: function(view) {
view.hide();
}
}]
}
});
var prompt = new CMS.Views.Prompt({model: msg});
},
showChapters: function(e) {
if(e && e.preventDefault) { e.preventDefault(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment