Commit ce06e7f7 by Ben McMorran Committed by cahrens

Fix delete messages in course outline

STUD-2019
parent 9d44417c
......@@ -67,14 +67,20 @@ define(["jquery", "underscore", "gettext", "js/views/utils/view_utils", "js/util
/**
* Deletes the specified xblock.
* @param xblockInfo The model for the xblock to be deleted.
* @param xblockType A string representing the type of the xblock to be deleted.
* @returns {jQuery promise} A promise representing the deletion of the xblock.
*/
deleteXBlock = function(xblockInfo) {
deleteXBlock = function(xblockInfo, xblockType) {
var deletion = $.Deferred(),
url = ModuleUtils.getUpdateUrl(xblockInfo.id);
ViewUtils.confirmThenRunOperation(gettext('Delete this component?'),
gettext('Deleting this component is permanent and cannot be undone.'),
gettext('Yes, delete this component'),
url = ModuleUtils.getUpdateUrl(xblockInfo.id),
xblockType = xblockType || gettext('component');
ViewUtils.confirmThenRunOperation(
interpolate(gettext('Delete this %(xblock_type)s?'), { xblock_type: xblockType }, true),
interpolate(
gettext('Deleting this %(xblock_type)s is permanent and cannot be undone.'),
{ xblock_type: xblockType }, true
),
interpolate(gettext('Yes, delete this %(xblock_type)s'), { xblock_type: xblockType }, true),
function() {
ViewUtils.runOperationShowingMessage(gettext('Deleting…'),
function() {
......
......@@ -167,14 +167,14 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
});
},
getXBlockType: function(category, parentInfo) {
getXBlockType: function(category, parentInfo, translate) {
var xblockType = category;
if (category === 'chapter') {
xblockType = 'section';
xblockType = translate ? gettext('section') : 'section';
} else if (category === 'sequential') {
xblockType = 'subsection';
xblockType = translate ? gettext('subsection') : 'subsection';
} else if (category === 'vertical' && (!parentInfo || parentInfo.get('category') === 'sequential')) {
xblockType = 'unit';
xblockType = translate ? gettext('unit') : 'unit';
}
return xblockType;
},
......@@ -243,7 +243,8 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
var self = this,
parentView = this.parentView;
event.preventDefault();
XBlockViewUtils.deleteXBlock(this.model).done(function() {
var xblockType = this.getXBlockType(this.model.get('category'), parentView.model, true);
XBlockViewUtils.deleteXBlock(this.model, xblockType).done(function() {
if (parentView) {
parentView.onChildDeleted(self, event);
}
......
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