Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 61... Línea 61...
61
                this.addFilterRow();
61
                this.addFilterRow();
62
            }
62
            }
Línea 63... Línea 63...
63
 
63
 
64
            if (e.target.closest(Selectors.filterset.actions.applyFilters)) {
64
            if (e.target.closest(Selectors.filterset.actions.applyFilters)) {
65
                e.preventDefault();
-
 
66
 
65
                e.preventDefault();
67
                this.updateTableFromFilter();
66
                this.updateTableFromFilter();
Línea 68... Línea 67...
68
            }
67
            }
69
 
68
 
Línea 190... Línea 189...
190
        const filterDataNode = this.getFilterDataSource(filterType);
189
        const filterDataNode = this.getFilterDataSource(filterType);
Línea 191... Línea 190...
191
 
190
 
192
        // Instantiate the Filter class.
191
        // Instantiate the Filter class.
193
        let Filter = GenericFilter;
192
        let Filter = GenericFilter;
-
 
193
        if (filterDataNode.dataset.filterTypeClass) {
-
 
194
 
-
 
195
            // Ensure the filter class passed through exists, otherwise the filtering will break.
194
        if (filterDataNode.dataset.filterTypeClass) {
196
            try {
-
 
197
                Filter = await import(filterDataNode.dataset.filterTypeClass);
-
 
198
            } catch (error) {
-
 
199
                Notification.exception(error);
-
 
200
            }
195
            Filter = await import(filterDataNode.dataset.filterTypeClass);
201
 
196
        }
202
        }
Línea 197... Línea 203...
197
        this.activeFilters[filterType] = new Filter(filterType, this.filterSet, initialFilterValues, filterOptions);
203
        this.activeFilters[filterType] = new Filter(filterType, this.filterSet, initialFilterValues, filterOptions);
198
 
204
 
Línea 411... Línea 417...
411
        }
417
        }
412
    }
418
    }
Línea 413... Línea 419...
413
 
419
 
414
    /**
420
    /**
-
 
421
     * Update the Dynamic table based upon the current filter.
-
 
422
     *
-
 
423
     * @param {bool} validate Should we validate the filters? We might want to skip this if the filters won't have changed,
415
     * Update the Dynamic table based upon the current filter.
424
     *     for example for pagination/sorting.
416
     */
425
     */
417
    updateTableFromFilter() {
426
    updateTableFromFilter(validate = true) {
Línea 418... Línea 427...
418
        const pendingPromise = new Pending('core/datafilter:updateTableFromFilter');
427
        const pendingPromise = new Pending('core/datafilter:updateTableFromFilter');
-
 
428
 
419
 
429
        const filters = {};
-
 
430
        let valid = true;
-
 
431
        Object.values(this.activeFilters).forEach(filter => {
-
 
432
            if (validate) {
420
        const filters = {};
433
                valid = valid && filter.validate();
421
        Object.values(this.activeFilters).forEach(filter => {
434
            }
-
 
435
            filters[filter.filterValue.name] = filter.filterValue;
-
 
436
        });
422
            filters[filter.filterValue.name] = filter.filterValue;
437
        if (validate) {
423
        });
438
            valid = valid && document.querySelector(Selectors.filter.region).closest('form').reportValidity();
424
 
439
        }
-
 
440
        if (this.applyCallback && valid) {
-
 
441
            this.applyCallback(filters, pendingPromise);
425
        if (this.applyCallback) {
442
        } else {
426
            this.applyCallback(filters, pendingPromise);
443
            pendingPromise.resolve();
Línea 427... Línea 444...
427
        }
444
        }
428
    }
445
    }