Skip to content

Commit

Permalink
Merge branch 'MDL-72776-master' of https://github.com/ferranrecio/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies committed Nov 23, 2021
2 parents eab5f3c + 675f8e2 commit 46e6502
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 49 deletions.
2 changes: 1 addition & 1 deletion course/amd/build/actions.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion course/amd/build/actions.min.js.map

Large diffs are not rendered by default.

27 changes: 18 additions & 9 deletions course/amd/src/actions.js
Expand Up @@ -201,7 +201,13 @@ define(
* @returns {Node}
*/
var addSectionLightbox = function(sectionelement) {
var lightbox = M.util.add_lightbox(Y, Y.Node(sectionelement.get(0)));
const item = sectionelement.get(0);
var lightbox = M.util.add_lightbox(Y, Y.Node(item));
if (item.dataset.for == 'section' && item.dataset.id) {
courseeditor.dispatch('sectionLock', [item.dataset.id], true);
lightbox.setAttribute('data-state', 'section');
lightbox.setAttribute('data-state-id', item.dataset.id);
}
lightbox.show();
return lightbox;
};
Expand Down Expand Up @@ -237,6 +243,14 @@ define(
if (lightbox) {
window.setTimeout(function() {
lightbox.hide();
// Unlock state if necessary.
if (lightbox.getAttribute('data-state')) {
courseeditor.dispatch(
`${lightbox.getAttribute('data-state')}Lock`,
[lightbox.getAttribute('data-state-id')],
false
);
}
}, delay);
}
};
Expand Down Expand Up @@ -776,18 +790,13 @@ define(
return;
}

// Send the element is locked. Reactive events are only triggered when the state
// read only mode is restored. We want to notify the interface the element is
// locked so we need to do a quick lock operation before performing the rest
// of the mutation.
statemanager.setReadOnly(false);
cm.locked = true;
statemanager.setReadOnly(true);
// Send the element is locked.
courseeditor.dispatch('cmLock', [cm.id], true);

// Now we do the real mutation.
statemanager.setReadOnly(false);

// This locked will take effect when the read only is restored.
// This unlocked will take effect when the read only is restored.
cm.locked = false;

switch (action) {
Expand Down
2 changes: 1 addition & 1 deletion course/format/amd/build/local/content/section.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions course/format/amd/src/local/content/section.js
Expand Up @@ -82,12 +82,12 @@ export default class extends DndSection {
}

/**
* Validate if the drop data can be dropped over the component.
*
* @param {Object} dropdata the exported drop data.
* @returns {boolean}
*/
validateDropData(dropdata) {
* Validate if the drop data can be dropped over the component.
*
* @param {Object} dropdata the exported drop data.
* @returns {boolean}
*/
validateDropData(dropdata) {
// If the format uses one section per page sections dropping in the content is ignored.
if (dropdata?.type === 'section' && this.reactive.sectionReturn != 0) {
return false;
Expand Down

0 comments on commit 46e6502

Please sign in to comment.