Fixed DeleteComponent on Container Page.
This commit is contained in:
committed by
Calen Pennington
parent
29f7fe14fb
commit
21ddc7db00
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user