Difference between revisions of "Widget:DCTList"

From LINKS Community Center
Jump to: navigation, search
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 13:09, 20 June 2022

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