Commit 37da3999 by cahrens

Update unit test based on changes in master.

parent 8e00f6dc
...@@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes, ...@@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes,
in roughly chronological order, most recent first. Add your entries at or near in roughly chronological order, most recent first. Add your entries at or near
the top. Include a label indicating the component affected. the top. Include a label indicating the component affected.
Studio: Add drag-and-drop support to the container page. STUD-1309.
Common: Add extensible third-party auth module. Common: Add extensible third-party auth module.
Blades: Handle situation if no response were sent from XQueue to LMS in Matlab Blades: Handle situation if no response were sent from XQueue to LMS in Matlab
......
...@@ -12,7 +12,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers ...@@ -12,7 +12,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
beforeEach(function () { beforeEach(function () {
edit_helpers.installEditTemplates(); edit_helpers.installEditTemplates();
appendSetFixtures('<div class="xblock" data-locator="mock-xblock" data-display-name="Mock XBlock"></div>'); appendSetFixtures('<div class="xblock" data-locator="mock-xblock"></div>');
model = new XBlockInfo({ model = new XBlockInfo({
id: 'testCourse/branch/draft/block/verticalFFF', id: 'testCourse/branch/draft/block/verticalFFF',
display_name: 'Test Unit', display_name: 'Test Unit',
......
...@@ -4,8 +4,8 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext", ...@@ -4,8 +4,8 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
xblockReady: function () { xblockReady: function () {
XBlockView.prototype.xblockReady.call(this); XBlockView.prototype.xblockReady.call(this);
var verticalContainer = $(this.$el).find('.vertical-container'), var verticalContainer = this.$('.vertical-container'),
alreadySortable = $(this.$el).find('.ui-sortable'), alreadySortable = this.$('.ui-sortable'),
newParent, newParent,
oldParent, oldParent,
self = this; self = this;
...@@ -16,6 +16,8 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext", ...@@ -16,6 +16,8 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
handle: '.drag-handle', handle: '.drag-handle',
stop: function (event, ui) { stop: function (event, ui) {
var saving, hideSaving, removeFromParent;
console.log('stop'); console.log('stop');
if (oldParent === undefined) { if (oldParent === undefined) {
...@@ -24,12 +26,12 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext", ...@@ -24,12 +26,12 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
return; return;
} }
var saving = new NotificationView.Mini({ saving = new NotificationView.Mini({
title: gettext('Saving&hellip;') title: gettext('Saving&hellip;')
}); });
saving.show(); saving.show();
var hideSaving = function () { hideSaving = function () {
saving.hide(); saving.hide();
}; };
...@@ -37,12 +39,11 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext", ...@@ -37,12 +39,11 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
// add to new container before deleting from old to // add to new container before deleting from old to
// avoid creating an orphan if the addition fails. // avoid creating an orphan if the addition fails.
if (newParent) { if (newParent) {
var removeFromParent = oldParent; removeFromParent = oldParent;
self.reorder(newParent, function () { self.reorder(newParent, function () {
self.reorder(removeFromParent, hideSaving); self.reorder(removeFromParent, hideSaving);
}); });
} } else {
else {
// No new parent, only reordering within same container. // No new parent, only reordering within same container.
self.reorder(oldParent, hideSaving); self.reorder(oldParent, hideSaving);
} }
...@@ -60,8 +61,7 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext", ...@@ -60,8 +61,7 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
if (ui.sender) { if (ui.sender) {
// Move to a new container (the addition part). // Move to a new container (the addition part).
newParent = parent; newParent = parent;
} } else {
else {
// Reorder inside a container, or deletion when moving to new container. // Reorder inside a container, or deletion when moving to new container.
oldParent = parent; oldParent = parent;
} }
...@@ -79,16 +79,18 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext", ...@@ -79,16 +79,18 @@ define(["jquery", "underscore", "js/views/xblock", "js/utils/module", "gettext",
}, },
reorder: function (targetParent, successCallback) { reorder: function (targetParent, successCallback) {
var children, childLocators;
console.log('calling reorder for ' + targetParent.data('locator')); console.log('calling reorder for ' + targetParent.data('locator'));
// Find descendants with class "wrapper-xblock" whose parent == targetParent. // Find descendants with class "wrapper-xblock" whose parent == targetParent.
// This is necessary to filter our grandchildren, great-grandchildren, etc. // This is necessary to filter our grandchildren, great-grandchildren, etc.
var children = targetParent.find('.wrapper-xblock').filter(function () { children = targetParent.find('.wrapper-xblock').filter(function () {
var parent = $(this).parent().closest('.wrapper-xblock'); var parent = $(this).parent().closest('.wrapper-xblock');
return parent.data('locator') === targetParent.data('locator'); return parent.data('locator') === targetParent.data('locator');
}); });
var childLocators = _.map( childLocators = _.map(
children, children,
function (child) { function (child) {
return $(child).data('locator'); return $(child).data('locator');
......
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