Widget: DCTList: Difference between revisions

From LINKS Community Center
Jump to: navigation, search
Eschmidt (talk | contribs)
No edit summary
Eschmidt (talk | contribs)
No edit summary
Line 251: Line 251:
     */
     */
     function dctFilter(dct, filterState) {
     function dctFilter(dct, filterState) {
         // If the property is empty, don't apply the filter (return true)
         // If filtering property is empty, don't apply the filter (set the check to true).
        // Passing an empty object (as with applyFilters(true)) should result in an unfiltered table.
         const sourcesCheck = filterState.dataSources
         const sourcesCheck = filterState.dataSources
             ? dct.dataSources.some(source => filterState.dataSources.includes(source))
             ? dct.dataSources.some(source => filterState.dataSources.includes(source))
Line 261: Line 262:
     }
     }


     function applyFilters() {
     function applyFilters(clear) {
         if (!table) return;
         if (!table) return;
        // If clear=true, pass empty object to the filter to disable it.
        if (clear) {
            table.setFilter(dctFilter, {});
            return;
        }


         /** @type {Partial<DCT>} */
         /** @type {Partial<DCT>} */
Line 418: Line 425:
     function clearFilters() {
     function clearFilters() {
         document.querySelectorAll('#dct-filters input[type="checkbox').forEach(checkbox => checkbox.checked = checkbox.defaultChecked);
         document.querySelectorAll('#dct-filters input[type="checkbox').forEach(checkbox => checkbox.checked = checkbox.defaultChecked);
         applyFilters();
         applyFilters(true);
     }
     }
     </script>
     </script>

Revision as of 12:09, 20 June 2022

Development verstion of the DCT List.
Not ready for production!