Merge branch 'MDL-84529' of https://github.com/cwarwicker/moodle
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -191,7 +191,14 @@ export default class {
|
||||
// Instantiate the Filter class.
|
||||
let Filter = GenericFilter;
|
||||
if (filterDataNode.dataset.filterTypeClass) {
|
||||
Filter = await import(filterDataNode.dataset.filterTypeClass);
|
||||
|
||||
// Ensure the filter class passed through exists, otherwise the filtering will break.
|
||||
try {
|
||||
Filter = await import(filterDataNode.dataset.filterTypeClass);
|
||||
} catch (error) {
|
||||
Notification.exception(error);
|
||||
}
|
||||
|
||||
}
|
||||
this.activeFilters[filterType] = new Filter(filterType, this.filterSet, initialFilterValues, filterOptions);
|
||||
|
||||
|
||||
@@ -50,9 +50,14 @@ export default class extends Filter {
|
||||
this.addModeSelector(filterOptions.mode);
|
||||
}
|
||||
|
||||
async addValueSelector(initialValues = []) {
|
||||
// We specify a specific filterset in case there are multiple filtering condition - avoiding glitches.
|
||||
const specificFilterSet = this.rootNode.querySelector(Selectors.filter.byName(this.filterType));
|
||||
/**
|
||||
* Get the context object to be sent through to the mustache template.
|
||||
* This can be overridden by any filters which inherit from datetime to add/exclude data.
|
||||
*
|
||||
* @param {array} initialValues
|
||||
* @returns {Promise<{filtertype: *, afterlabel: *, beforelabel: *, required, aftervalue: *, beforevalue: *}>}
|
||||
*/
|
||||
async getContext(initialValues) {
|
||||
const sourceDataNode = this.getSourceDataForFilter();
|
||||
const defaultBefore = sourceDataNode.getElementsByTagName('option')[0].value;
|
||||
const defaultAfter = sourceDataNode.getElementsByTagName('option')[1].value;
|
||||
@@ -69,15 +74,20 @@ export default class extends Filter {
|
||||
param: {title},
|
||||
},
|
||||
]);
|
||||
const context = {
|
||||
return {
|
||||
filtertype: this.filterType,
|
||||
afterlabel: labels[0],
|
||||
beforelabel: labels[1],
|
||||
required: sourceDataNode.dataset.required,
|
||||
aftervalue: initialValues[0] ?? defaultAfter,
|
||||
beforevalue: initialValues[1] ?? defaultBefore,
|
||||
now: defaultBefore,
|
||||
};
|
||||
}
|
||||
|
||||
async addValueSelector(initialValues = []) {
|
||||
// We specify a specific filterset in case there are multiple filtering condition - avoiding glitches.
|
||||
const specificFilterSet = this.rootNode.querySelector(Selectors.filter.byName(this.filterType));
|
||||
const context = await this.getContext(initialValues);
|
||||
const datetimeUi = await Templates.renderForPromise('core/datafilter/filtertypes/datetime_selector', context);
|
||||
return Templates.replaceNodeContents(
|
||||
specificFilterSet.querySelector(Selectors.filter.regions.values),
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
value="{{aftervalue}}"
|
||||
data-filterfield="{{filtertype}}1"
|
||||
data-field-title="{{afterlabel}}"
|
||||
max="{{now}}"
|
||||
{{#max}}max="{{max}}"{{/max}}
|
||||
>
|
||||
</span>
|
||||
<span class="{{filtertype}}-betweenwrapper ms-2 me-2">
|
||||
@@ -66,7 +66,7 @@
|
||||
value="{{beforevalue}}"
|
||||
data-filterfield="{{filtertype}}2"
|
||||
data-field-title="{{beforelabel}}"
|
||||
max="{{now}}"
|
||||
{{#max}}max="{{max}}"{{/max}}
|
||||
>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user