MDL-68231 core_formats: conditionally swap controls on section drop

When using section drag and drop, the topics and weeks formats expected
the '.section_add_menus' element to be present so it could update it on
section drop. Due to MDL-68056, this control is only sometimes present.
This has been updated to conditionally swap to address this.
This commit is contained in:
Jake Dallimore 2020-03-24 08:45:23 +08:00
parent f2fc4a9fa1
commit b3f19d3547
3 changed files with 11 additions and 4 deletions

View File

@ -40,8 +40,10 @@ M.course.format.swap_sections = function(Y, node1, node2) {
};
var sectionlist = Y.Node.all('.'+CSS.COURSECONTENT+' '+M.course.format.get_section_selector(Y));
// Swap menus.
sectionlist.item(node1).one('.'+CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one('.'+CSS.SECTIONADDMENUS));
// Swap the non-ajax menus, noting these are not always present (depends on theme and user prefs).
if (sectionlist.item(node1).one('.'+CSS.SECTIONADDMENUS)) {
sectionlist.item(node1).one('.'+CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one('.'+CSS.SECTIONADDMENUS));
}
}
/**

View File

@ -11,6 +11,9 @@ Overview of this plugin type at http://docs.moodle.org/dev/Course_formats
- format_weeks_upgrade_remove_numsections()
- format_weeks_upgrade_hide_extra_sections()
- format_weeks_upgrade_add_empty_sections()
* The non-ajax controls to add resources and activities are now rendered only when needed, such as when the user
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.
=== 3.8 ===

View File

@ -40,8 +40,10 @@ M.course.format.swap_sections = function(Y, node1, node2) {
};
var sectionlist = Y.Node.all('.'+CSS.COURSECONTENT+' '+M.course.format.get_section_selector(Y));
// Swap menus.
sectionlist.item(node1).one('.'+CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one('.'+CSS.SECTIONADDMENUS));
// Swap the non-ajax menus, noting these are not always present (depends on theme and user prefs).
if (sectionlist.item(node1).one('.'+CSS.SECTIONADDMENUS)) {
sectionlist.item(node1).one('.' + CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one('.' + CSS.SECTIONADDMENUS));
}
}
/**