Commit 4946d601 by cahrens

Verify children are rendered before allowing drop into collapsed parent.

TNL-56
parent a3c2a54b
...@@ -260,6 +260,10 @@ define(["jquery", "jquery.ui", "underscore", "gettext", "js/views/feedback_notif ...@@ -260,6 +260,10 @@ define(["jquery", "jquery.ui", "underscore", "gettext", "js/views/feedback_notif
}, },
expandElement: function (ele) { expandElement: function (ele) {
// Verify all children of the element are rendered.
var ensureChildrenRendered = ele.data('ensureChildrenRendered');
if (_.isFunction(ensureChildrenRendered)) { ensureChildrenRendered(); }
// Update classes.
ele.removeClass(this.collapsedClass); ele.removeClass(this.collapsedClass);
ele.find('.expand-collapse').first().removeClass('expand').addClass('collapse'); ele.find('.expand-collapse').first().removeClass('expand').addClass('collapse');
}, },
...@@ -354,7 +358,8 @@ define(["jquery", "jquery.ui", "underscore", "gettext", "js/views/feedback_notif ...@@ -354,7 +358,8 @@ define(["jquery", "jquery.ui", "underscore", "gettext", "js/views/feedback_notif
handleClass: null, handleClass: null,
droppableClass: null, droppableClass: null,
parentLocationSelector: null, parentLocationSelector: null,
refresh: null refresh: null,
ensureChildrenRendered: null
}, options); }, options);
if ($(element).data('droppable-class') !== options.droppableClass) { if ($(element).data('droppable-class') !== options.droppableClass) {
...@@ -362,7 +367,8 @@ define(["jquery", "jquery.ui", "underscore", "gettext", "js/views/feedback_notif ...@@ -362,7 +367,8 @@ define(["jquery", "jquery.ui", "underscore", "gettext", "js/views/feedback_notif
'droppable-class': options.droppableClass, 'droppable-class': options.droppableClass,
'parent-location-selector': options.parentLocationSelector, 'parent-location-selector': options.parentLocationSelector,
'child-selector': options.type, 'child-selector': options.type,
'refresh': options.refresh 'refresh': options.refresh,
'ensureChildrenRendered': options.ensureChildrenRendered
}); });
draggable = new Draggabilly(element, { draggable = new Draggabilly(element, {
......
...@@ -168,7 +168,8 @@ define(["jquery", "underscore", "js/views/xblock_outline", "js/views/utils/view_ ...@@ -168,7 +168,8 @@ define(["jquery", "underscore", "js/views/xblock_outline", "js/views/utils/view_
handleClass: '.section-drag-handle', handleClass: '.section-drag-handle',
droppableClass: 'ol.list-sections', droppableClass: 'ol.list-sections',
parentLocationSelector: 'article.outline', parentLocationSelector: 'article.outline',
refresh: this.refreshWithCollapsedState.bind(this) refresh: this.refreshWithCollapsedState.bind(this),
ensureChildrenRendered: this.ensureChildrenRendered.bind(this)
}); });
} }
else if ($(element).hasClass("outline-subsection")) { else if ($(element).hasClass("outline-subsection")) {
...@@ -177,7 +178,8 @@ define(["jquery", "underscore", "js/views/xblock_outline", "js/views/utils/view_ ...@@ -177,7 +178,8 @@ define(["jquery", "underscore", "js/views/xblock_outline", "js/views/utils/view_
handleClass: '.subsection-drag-handle', handleClass: '.subsection-drag-handle',
droppableClass: 'ol.list-subsections', droppableClass: 'ol.list-subsections',
parentLocationSelector: 'li.outline-section', parentLocationSelector: 'li.outline-section',
refresh: this.refreshWithCollapsedState.bind(this) refresh: this.refreshWithCollapsedState.bind(this),
ensureChildrenRendered: this.ensureChildrenRendered.bind(this)
}); });
} }
else if ($(element).hasClass("outline-unit")) { else if ($(element).hasClass("outline-unit")) {
...@@ -186,7 +188,8 @@ define(["jquery", "underscore", "js/views/xblock_outline", "js/views/utils/view_ ...@@ -186,7 +188,8 @@ define(["jquery", "underscore", "js/views/xblock_outline", "js/views/utils/view_
handleClass: '.unit-drag-handle', handleClass: '.unit-drag-handle',
droppableClass: 'ol.list-units', droppableClass: 'ol.list-units',
parentLocationSelector: 'li.outline-subsection', parentLocationSelector: 'li.outline-subsection',
refresh: this.refreshWithCollapsedState.bind(this) refresh: this.refreshWithCollapsedState.bind(this),
ensureChildrenRendered: this.ensureChildrenRendered.bind(this)
}); });
} }
} }
......
...@@ -149,10 +149,17 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/ ...@@ -149,10 +149,17 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
} }
} }
// Ensure that the children have been rendered before expanding // Ensure that the children have been rendered before expanding
if (this.shouldRenderChildren() && !this.renderedChildren) { this.ensureChildrenRendered();
BaseView.prototype.toggleExpandCollapse.call(this, event);
},
/**
* Verifies that the children are rendered (if they should be).
*/
ensureChildrenRendered: function() {
if (!this.renderedChildren && this.shouldRenderChildren()) {
this.renderChildren(); this.renderChildren();
} }
BaseView.prototype.toggleExpandCollapse.call(this, 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