MDL-68235 core_course: Sections work after drag and drop reordering
authorMathew May <mathewm@hotmail.co.nz>
Tue, 14 Apr 2020 06:16:03 +0000 (14:16 +0800)
committerMathew May <mathewm@hotmail.co.nz>
Wed, 6 May 2020 08:14:48 +0000 (16:14 +0800)
course/amd/build/activitychooser.min.js
course/amd/build/activitychooser.min.js.map
course/amd/src/activitychooser.js
course/renderer.php

index ea7a72e..d9441d4 100644 (file)
Binary files a/course/amd/build/activitychooser.min.js and b/course/amd/build/activitychooser.min.js differ
index f410d70..3348e19 100644 (file)
Binary files a/course/amd/build/activitychooser.min.js.map and b/course/amd/build/activitychooser.min.js.map differ
index 0207281..d3b83d0 100644 (file)
@@ -79,7 +79,13 @@ const registerListenerEvents = (courseId) => {
         document.addEventListener(event, async(e) => {
             if (e.target.closest(selectors.elements.sectionmodchooser)) {
                 const data = await fetchModuleData();
-                const caller = e.target.closest(selectors.elements.sectionmodchooser);
+                // We need to know who called this.
+                // Standard courses use the ID in the main section info.
+                const sectionDiv = e.target.closest(selectors.elements.section);
+                // Front page courses need some special handling.
+                const button = e.target.closest(selectors.elements.sectionmodchooser);
+                // If we don't have a section ID use the fallback ID.
+                const caller = sectionDiv || button;
                 const favouriteFunction = partiallyAppliedFavouriteManager(data, caller.dataset.sectionid);
                 const builtModuleData = sectionIdMapper(data, caller.dataset.sectionid);
                 const sectionModal = await modalBuilder(builtModuleData);
index 784d6ee..cc24507 100644 (file)
@@ -368,11 +368,11 @@ class core_course_renderer extends plugin_renderer_base {
             $ajaxcontrol .= html_writer::start_tag('div', array('class' => 'section-modchooser'));
             $icon = $this->output->pix_icon('t/add', '');
             $span = html_writer::tag('span', $straddeither, array('class' => 'section-modchooser-text'));
-            $ajaxcontrol .= html_writer::tag('button', $icon . $span, array(
+            $ajaxcontrol .= html_writer::tag('button', $icon . $span, [
                     'class' => 'section-modchooser-link btn btn-link',
                     'data-action' => 'open-chooser',
                     'data-sectionid' => $section,
-                )
+                ]
             );
             $ajaxcontrol .= html_writer::end_tag('div');
             $ajaxcontrol .= html_writer::end_tag('div');