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 200: Line 200:
     */
     */
     function dctFilter(dct, filterState) {
     function dctFilter(dct, filterState) {
         // if the property is empty, don't apply the filter (return true)
         // If the property is empty, don't apply the filter (return true)
         const sourcesCheck = filterState.dataSources
         const sourcesCheck = filterState.dataSources
             ? dct.dataSources.some(source => filterState.dataSources.includes(source))
             ? dct.dataSources.some(source => filterState.dataSources.includes(source))
             : true;
             : true;
         return sourcesCheck;
        const functionsCheck = filterState.functions
            ? dct.functions.some(func => filterState.functions.includes(func))
            : true;
         return sourcesCheck && functionsCheck;
     }
     }


Line 213: Line 216:
         const filterState = {};
         const filterState = {};


         // Build filter from the current filter form state
         const selectedFunctions = Array.from(document.querySelectorAll('#functions-filter input[type="checkbox"]:checked')).map(checkbox => checkbox.value);
         // Alternative: keep a copy and update
         filterState.functions = selectedFunctions;


         const selectedSources = Array.from(document.querySelectorAll('#data-source-filter input[type="checkbox"]:checked')).map(checkbox => checkbox.value);
         const selectedSources = Array.from(document.querySelectorAll('#data-source-filter input[type="checkbox"]:checked')).map(checkbox => checkbox.value);

Revision as of 16:05, 13 June 2022

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