mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-82341 core_courseformat: migrate events for inplace editable
This commit is contained in:
parent
074645571b
commit
f081373156
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
import {BaseComponent} from 'core/reactive';
|
||||
import {eventTypes} from 'core/local/inplace_editable/events';
|
||||
import Modal from 'core/modal';
|
||||
import ModalSaveCancel from 'core/modal_save_cancel';
|
||||
import ModalDeleteCancel from 'core/modal_delete_cancel';
|
||||
@ -131,6 +132,12 @@ export default class extends BaseComponent {
|
||||
CourseEvents.sectionRefreshed,
|
||||
() => this._checkSectionlist({state})
|
||||
);
|
||||
// Any inplace editable update needs state refresh.
|
||||
this.addEventListener(
|
||||
this.element,
|
||||
eventTypes.elementUpdated,
|
||||
this._inplaceEditableHandler
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,6 +198,30 @@ export default class extends BaseComponent {
|
||||
this._setAddSectionLocked(state.course.sectionlist.length > state.course.maxsections);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle inplace editable updates.
|
||||
*
|
||||
* @param {Event} event the triggered event
|
||||
* @private
|
||||
*/
|
||||
_inplaceEditableHandler(event) {
|
||||
const itemtype = event.detail?.ajaxreturn?.itemtype;
|
||||
const itemid = parseInt(event.detail?.ajaxreturn?.itemid);
|
||||
if (!Number.isFinite(itemid) || !itemtype) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemtype === 'activityname') {
|
||||
this.reactive.dispatch('cmState', [itemid]);
|
||||
return;
|
||||
}
|
||||
// Sections uses sectionname for normal sections and sectionnamenl for the no link sections.
|
||||
if (itemtype === 'sectionname' || itemtype === 'sectionnamenl') {
|
||||
this.reactive.dispatch('sectionState', [itemid]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ids represented by this element.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user