Commit 14be4310 by David Baumgold

Add confirmation step for deleting a textbook

parent 9de2dc51
...@@ -75,7 +75,7 @@ CMS.Views.TextbookShow = Backbone.View.extend({ ...@@ -75,7 +75,7 @@ CMS.Views.TextbookShow = Backbone.View.extend({
tagName: "li", tagName: "li",
events: { events: {
"click .edit": "editTextbook", "click .edit": "editTextbook",
"click .delete": "delete", "click .delete": "confirmDelete",
"click .show-chapters": "showChapters", "click .show-chapters": "showChapters",
"click .hide-chapters": "hideChapters" "click .hide-chapters": "hideChapters"
}, },
...@@ -87,24 +87,44 @@ CMS.Views.TextbookShow = Backbone.View.extend({ ...@@ -87,24 +87,44 @@ CMS.Views.TextbookShow = Backbone.View.extend({
if(e && e.preventDefault) { e.preventDefault(); } if(e && e.preventDefault) { e.preventDefault(); }
this.model.collection.trigger("editOne", this.model); this.model.collection.trigger("editOne", this.model);
}, },
delete: function(e) { confirmDelete: function(e) {
if(e && e.preventDefault) { e.preventDefault(); } if(e && e.preventDefault) { e.preventDefault(); }
var collection = this.model.collection; var textbook = this.model, collection = this.model.collection;
collection.remove(this.model); var msg = new CMS.Models.WarningMessage({
msg = new CMS.Models.SystemFeedback({ title: _.str.sprintf(gettext("Delete “%s”?"),
intent: "saving", textbook.escape('name')),
title: gettext("Deleting…") 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: {
notif = new CMS.Views.Notification({ primary: {
model: msg, text: gettext("Delete"),
closeIcon: false, click: function(view) {
minShown: 1250 view.hide();
}); collection.remove(textbook);
collection.save({ var delmsg = new CMS.Models.SystemFeedback({
complete: function() { intent: "saving",
notif.hide(); title: gettext("Deleting…")
});
var notif = new CMS.Views.Notification({
model: delmsg,
closeIcon: false,
minShown: 1250
});
collection.save({
complete: function() {
notif.hide();
}
});
}
},
secondary: [{
text: gettext("Cancel"),
click: function(view) {
view.hide();
}
}]
} }
}); });
var prompt = new CMS.Views.Prompt({model: msg});
}, },
showChapters: function(e) { showChapters: function(e) {
if(e && e.preventDefault) { e.preventDefault(); } 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