MDL-68821 course: Add a attr check for the chooser

This commit is contained in:
Mathew May 2020-05-25 14:22:33 +08:00
parent 71965a8572
commit e74bcf19f3
4 changed files with 16 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -91,13 +91,23 @@ const registerListenerEvents = (courseId, chooserConfig) => {
events.forEach((event) => {
document.addEventListener(event, async(e) => {
if (e.target.closest(selectors.elements.sectionmodchooser)) {
let caller;
// 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;
// We always want the sectionDiv caller first as it keeps track of section ID's after DnD changes.
// The button attribute is always just a fallback for us as the section div is not always available.
// A YUI change could be done maybe to only update the button attribute but we are going for minimal change here.
if (sectionDiv !== null && sectionDiv.hasAttribute('data-sectionid')) {
// We check for attributes just in case of outdated contrib course formats.
caller = sectionDiv;
} else {
caller = button;
}
// We want to show the modal instantly but loading whilst waiting for our data.
let bodyPromiseResolver;

View file

@ -15,6 +15,9 @@ Overview of this plugin type at http://docs.moodle.org/dev/Course_formats
preference is set, or when the theme sets $THEME->enablecourseajaxtheme to false. Formats which directly access
the '.section_add_menus' element or its children should be updated accordingly.
* section_header() now needs to include 'data-sectionid' => $section->section in the .section li to ensure correct section
selection for the Activity Chooser.
=== 3.8 ===
* The following functions have been finally deprecated and can not be used anymore: