mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 10:56:56 +02:00
Merge branch 'MDL-83327_main' of https://github.com/marxjohnson/moodle
This commit is contained in:
commit
13fdeab15e
3 changed files with 3 additions and 12 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -243,8 +243,6 @@ export default class extends BaseComponent {
|
||||||
* @return {Promise<void>}
|
* @return {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async updatePosition({element}) {
|
async updatePosition({element}) {
|
||||||
window.console.log('updating', this.getElement());
|
|
||||||
window.console.log('new state', element);
|
|
||||||
// Move to a new parent category.
|
// Move to a new parent category.
|
||||||
let newParent;
|
let newParent;
|
||||||
const originParent = document.querySelector(this.selectors.CHILD_LIST(this.getElement().dataset.parent));
|
const originParent = document.querySelector(this.selectors.CHILD_LIST(this.getElement().dataset.parent));
|
||||||
|
@ -258,7 +256,6 @@ export default class extends BaseComponent {
|
||||||
} else {
|
} else {
|
||||||
newParent = this.getElement().parentElement;
|
newParent = this.getElement().parentElement;
|
||||||
}
|
}
|
||||||
window.console.log('newParent', newParent);
|
|
||||||
|
|
||||||
// Move to a new position within the parent.
|
// Move to a new position within the parent.
|
||||||
let previousSibling;
|
let previousSibling;
|
||||||
|
@ -271,21 +268,15 @@ export default class extends BaseComponent {
|
||||||
previousSibling = newParent.querySelector(this.selectors.PREVIOUS_SIBLING(element.sortorder - 1));
|
previousSibling = newParent.querySelector(this.selectors.PREVIOUS_SIBLING(element.sortorder - 1));
|
||||||
nextSibling = previousSibling?.nextElementSibling;
|
nextSibling = previousSibling?.nextElementSibling;
|
||||||
}
|
}
|
||||||
window.console.log('previousSibling', previousSibling);
|
|
||||||
window.console.log('nextSibling', nextSibling);
|
|
||||||
|
|
||||||
// Check if this has actually moved, or if it's just having its sortorder updated due to another element moving.
|
// Check if this has actually moved, or if it's just having its sortorder updated due to another element moving.
|
||||||
const moved = (newParent !== this.getElement().parentElement || nextSibling !== this.getElement());
|
const moved = (newParent !== this.getElement().parentElement || nextSibling !== this.getElement());
|
||||||
|
|
||||||
window.console.log('moved', moved);
|
|
||||||
|
|
||||||
if (moved) {
|
if (moved) {
|
||||||
if (nextSibling) {
|
if (nextSibling) {
|
||||||
window.console.log('insertBefore');
|
|
||||||
// Move to the specified position in the list.
|
// Move to the specified position in the list.
|
||||||
newParent.insertBefore(this.getElement(), nextSibling);
|
newParent.insertBefore(this.getElement(), nextSibling);
|
||||||
} else {
|
} else {
|
||||||
window.console.log('appendChild');
|
|
||||||
// Move to the end of the list (may also be the top of the list is empty).
|
// Move to the end of the list (may also be the top of the list is empty).
|
||||||
newParent.appendChild(this.getElement());
|
newParent.appendChild(this.getElement());
|
||||||
}
|
}
|
||||||
|
@ -397,7 +388,7 @@ export default class extends BaseComponent {
|
||||||
*/
|
*/
|
||||||
async showMoveModal(e) {
|
async showMoveModal(e) {
|
||||||
// Return if it is not menu item.
|
// Return if it is not menu item.
|
||||||
const item = e.target;
|
const item = e.target.closest(this.selectors.MOVE_BUTTON);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue