mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
MDL-71779 core_courseformat: reactive add and delete sections
This commit is contained in:
parent
a9d44b0f75
commit
3d2a6eacae
57 changed files with 883 additions and 140 deletions
|
@ -96,13 +96,38 @@ M.course_dndupload = {
|
|||
this.add_status_div();
|
||||
}
|
||||
|
||||
// Any change to the course must be applied also to the course state via the courseeditor module.
|
||||
var self = this;
|
||||
require(['core_courseformat/courseeditor'], function(editor) {
|
||||
self.courseeditor = editor.getCurrentCourseEditor();
|
||||
require([
|
||||
'core_courseformat/courseeditor',
|
||||
'core_course/events'
|
||||
], function(
|
||||
Editor,
|
||||
CourseEvents
|
||||
) {
|
||||
// Any change to the course must be applied also to the course state via the courseeditor module.
|
||||
self.courseeditor = Editor.getCurrentCourseEditor();
|
||||
|
||||
// Some formats can add sections without reloading the page.
|
||||
document.querySelector('#' + self.pagecontentid).addEventListener(
|
||||
CourseEvents.sectionRefreshed,
|
||||
self.sectionRefreshed.bind(self)
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Setup Drag and Drop in a section.
|
||||
* @param {CustomEvent} event The custom event
|
||||
*/
|
||||
sectionRefreshed: function(event) {
|
||||
if (event.detail.newSectionElement === undefined) {
|
||||
return;
|
||||
}
|
||||
var element = this.Y.one(event.detail.newSectionElement);
|
||||
this.add_preview_element(element);
|
||||
this.init_events(element);
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a div element to tell the user that drag and drop upload
|
||||
* is available (or to explain why it is not available)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue