diff --git a/cms/static/js/spec/views/pages/container_spec.js b/cms/static/js/spec/views/pages/container_spec.js index 78b0428bb4..2227751cb6 100644 --- a/cms/static/js/spec/views/pages/container_spec.js +++ b/cms/static/js/spec/views/pages/container_spec.js @@ -218,10 +218,15 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers clickDelete(componentIndex); create_sinon.respondWithJson(requests, {}); - // expect request URL to contain given component's id - expect(lastRequest().url).toMatch( + // first request contains given component's id (to delete the component) + expect(requests[requests.length - 2].url).toMatch( new RegExp("locator-component-" + GROUP_TO_TEST + (componentIndex + 1)) ); + + // second request contains parent's id (to remove as child) + expect(lastRequest().url).toMatch( + new RegExp("locator-group-" + GROUP_TO_TEST) + ); }; deleteComponentWithSuccess = function(componentIndex) { diff --git a/cms/static/js/views/container.js b/cms/static/js/views/container.js index d10dbfb728..e29381e9b1 100644 --- a/cms/static/js/views/container.js +++ b/cms/static/js/views/container.js @@ -41,12 +41,12 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext", // avoid creating an orphan if the addition fails. if (newParent) { removeFromParent = oldParent; - self.reorder(newParent, function () { - self.reorder(removeFromParent, hideSaving); + self.updateChildren(newParent, function () { + self.updateChildren(removeFromParent, hideSaving); }); } else { // No new parent, only reordering within same container. - self.reorder(oldParent, hideSaving); + self.updateChildren(oldParent, hideSaving); } oldParent = undefined; @@ -79,7 +79,7 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext", }); }, - reorder: function (targetParent, successCallback) { + updateChildren: function (targetParent, successCallback) { var children, childLocators; // Find descendants with class "studio-xblock-wrapper" whose parent === targetParent. diff --git a/cms/static/js/views/pages/container.js b/cms/static/js/views/pages/container.js index cc91a3e242..b1715ea425 100644 --- a/cms/static/js/views/pages/container.js +++ b/cms/static/js/views/pages/container.js @@ -152,9 +152,12 @@ define(["jquery", "underscore", "gettext", "js/views/feedback_notification", type: 'DELETE', url: self.getURLRoot() + "/" + xblockElement.data('locator') + "?" + - $.param({recurse: true, all_versions: true}) + $.param({recurse: true, all_versions: false}) }).success(function() { + // get the parent so we can remove this component from its parent. + var parent = self.findXBlockElement(xblockElement.parent()); xblockElement.remove(); + self.xblockView.updateChildren(parent); }); }); });