Difficulty selectbox in Studio (based on new XBlockAside functionality). Include:
- adaptation asides to be imported from the XML - updating SplitMongo to handle XBlockAsides (CRUD operations) - updating Studio to handle XBlockAsides handler calls - updating xblock/core.js to properly init XBlockAsides JavaScript
This commit is contained in:
@@ -331,7 +331,8 @@ define(["jquery", "underscore", "gettext", "js/views/pages/base_page", "common/j
|
||||
success: function() {
|
||||
self.onXBlockRefresh(temporaryView, block_added, is_duplicate);
|
||||
temporaryView.unbind(); // Remove the temporary view
|
||||
}
|
||||
},
|
||||
initRuntimeData: this
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -30,6 +30,13 @@ define(["jquery", "underscore", "common/js/components/utils/view_utils", "js/vie
|
||||
});
|
||||
},
|
||||
|
||||
initRuntimeData: function(xblock, options) {
|
||||
if (options && options.initRuntimeData && xblock && xblock.runtime && !xblock.runtime.page) {
|
||||
xblock.runtime.page = options.initRuntimeData;
|
||||
}
|
||||
return xblock;
|
||||
},
|
||||
|
||||
handleXBlockFragment: function(fragment, options) {
|
||||
var self = this,
|
||||
wrapper = this.$el,
|
||||
@@ -44,8 +51,14 @@ define(["jquery", "underscore", "common/js/components/utils/view_utils", "js/vie
|
||||
xblockElement = self.$('.xblock').first();
|
||||
try {
|
||||
xblock = XBlock.initializeBlock(xblockElement);
|
||||
self.xblock = xblock;
|
||||
self.xblockReady(xblock);
|
||||
self.xblock = self.initRuntimeData(xblock, options);
|
||||
self.xblockReady(self.xblock);
|
||||
self.$('.xblock_asides-v1').each(function() {
|
||||
if (!$(this).hasClass('xblock-initialized')) {
|
||||
var aside = XBlock.initializeBlock($(this));
|
||||
self.initRuntimeData(aside, options);
|
||||
}
|
||||
});
|
||||
if (successCallback) {
|
||||
successCallback(xblock);
|
||||
}
|
||||
@@ -76,6 +89,15 @@ define(["jquery", "underscore", "common/js/components/utils/view_utils", "js/vie
|
||||
var runtime = this.xblock && this.xblock.runtime;
|
||||
if (runtime) {
|
||||
runtime.notify(eventName, data);
|
||||
} else if (this.xblock) {
|
||||
var xblock_children = this.xblock.element && $(this.xblock.element).prop('xblock_children');
|
||||
if (xblock_children) {
|
||||
$(xblock_children).each(function () {
|
||||
if (this.runtime) {
|
||||
this.runtime.notify(eventName, data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
40
cms/static/js/xblock_asides/structured_tags.js
Normal file
40
cms/static/js/xblock_asides/structured_tags.js
Normal file
@@ -0,0 +1,40 @@
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
function StructuredTagsView(runtime, element) {
|
||||
|
||||
var $element = $(element);
|
||||
|
||||
$element.find("select").each(function() {
|
||||
var loader = this;
|
||||
var sts = $(this).attr('structured-tags-select-init');
|
||||
|
||||
if (typeof sts === typeof undefined || sts === false) {
|
||||
$(this).attr('structured-tags-select-init', 1);
|
||||
$(this).change(function(e) {
|
||||
e.preventDefault();
|
||||
var selectedKey = $(loader).find('option:selected').val();
|
||||
runtime.notify('save', {
|
||||
state: 'start',
|
||||
element: element,
|
||||
message: gettext('Updating Tags')
|
||||
});
|
||||
$.post(runtime.handlerUrl(element, 'save_tags'), {
|
||||
'tag': $(loader).attr('name') + ':' + selectedKey
|
||||
}).done(function() {
|
||||
runtime.notify('save', {
|
||||
state: 'end',
|
||||
element: element
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initializeStructuredTags(runtime, element) {
|
||||
return new StructuredTagsView(runtime, element);
|
||||
}
|
||||
|
||||
window.StructuredTagsInit = initializeStructuredTags;
|
||||
})($);
|
||||
Reference in New Issue
Block a user