mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Merge branch 'MDL-76545-master' of https://github.com/ferranrecio/moodle
This commit is contained in:
commit
0972a5b7a9
4 changed files with 43 additions and 8 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -89,8 +89,14 @@ class GlobalDebugPanel extends BaseComponent {
|
||||||
this.selectors = {
|
this.selectors = {
|
||||||
LOADERS: `[data-for='loaders']`,
|
LOADERS: `[data-for='loaders']`,
|
||||||
SUBPANEL: `[data-for='subpanel']`,
|
SUBPANEL: `[data-for='subpanel']`,
|
||||||
|
NOINSTANCES: `[data-for='noinstances']`,
|
||||||
LOG: `[data-for='log']`,
|
LOG: `[data-for='log']`,
|
||||||
};
|
};
|
||||||
|
this.classes = {
|
||||||
|
HIDE: `d-none`,
|
||||||
|
};
|
||||||
|
// The list of loaded debuggers.
|
||||||
|
this.subPanels = new Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,17 +105,38 @@ class GlobalDebugPanel extends BaseComponent {
|
||||||
* @param {object} state the initial state
|
* @param {object} state the initial state
|
||||||
*/
|
*/
|
||||||
stateReady(state) {
|
stateReady(state) {
|
||||||
if (state.reactives.size > 0) {
|
this._updateReactivesPanels({state});
|
||||||
this.getElement(this.selectors.LOADERS).innerHTML = '';
|
// Remove loading wheel.
|
||||||
}
|
this.getElement(this.selectors.SUBPANEL).innerHTML = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component watchers.
|
||||||
|
*
|
||||||
|
* @returns {Array} of watchers
|
||||||
|
*/
|
||||||
|
getWatchers() {
|
||||||
|
return [
|
||||||
|
{watch: `reactives:created`, handler: this._updateReactivesPanels},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the list of reactive instances.
|
||||||
|
* @param {Object} args
|
||||||
|
* @param {Object} args.state the current state
|
||||||
|
*/
|
||||||
|
_updateReactivesPanels({state}) {
|
||||||
|
this.getElement(this.selectors.NOINSTANCES)?.classList?.toggle(
|
||||||
|
this.classes.HIDE,
|
||||||
|
state.reactives.size > 0
|
||||||
|
);
|
||||||
// Generate loading buttons.
|
// Generate loading buttons.
|
||||||
state.reactives.forEach(
|
state.reactives.forEach(
|
||||||
instance => {
|
instance => {
|
||||||
this._createLoader(instance);
|
this._createLoader(instance);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// Remove loading wheel.
|
|
||||||
this.getElement(this.selectors.SUBPANEL).innerHTML = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,6 +145,10 @@ class GlobalDebugPanel extends BaseComponent {
|
||||||
* @param {object} instance hte instance data
|
* @param {object} instance hte instance data
|
||||||
*/
|
*/
|
||||||
_createLoader(instance) {
|
_createLoader(instance) {
|
||||||
|
if (this.subPanels.has(instance.id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.subPanels.add(instance.id);
|
||||||
const loaders = this.getElement(this.selectors.LOADERS);
|
const loaders = this.getElement(this.selectors.LOADERS);
|
||||||
const btn = document.createElement("button");
|
const btn = document.createElement("button");
|
||||||
btn.innerHTML = instance.id;
|
btn.innerHTML = instance.id;
|
||||||
|
|
|
@ -32,7 +32,11 @@
|
||||||
<div id="{{uniqid}}-reactive-debugpanel" class="py-1">
|
<div id="{{uniqid}}-reactive-debugpanel" class="py-1">
|
||||||
<div>
|
<div>
|
||||||
{{#str}} reactive_instances , core_debug {{/str}}
|
{{#str}} reactive_instances , core_debug {{/str}}
|
||||||
<span data-for="loaders">{{#str}} reactive_noinstances , core_debug {{/str}}</span>
|
<span data-for="loaders">
|
||||||
|
<span data-for="noinstances">
|
||||||
|
{{#str}} reactive_noinstances , core_debug {{/str}}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div data-for="subpanel">
|
<div data-for="subpanel">
|
||||||
{{> core/loading }}
|
{{> core/loading }}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue