Difference between revisions of "Widget:DCTList"
From LINKS Community Center
Line 400: | Line 400: | ||
// TODO: REWORK | // TODO: REWORK | ||
− | // If filterState has a category but subfunctions array is empty, we only care about the category. | + | let functionsCheck = true; |
− | + | if (filterState.functions) { | |
− | + | // If filterState has a category but subfunctions array is empty, we only care about the category. | |
− | + | const emptyCategories = [], nonemptyCategories = []; | |
− | + | Array.from(filterState.functions).forEach(([key, subs]) => { | |
− | + | if (subs.length > 0) { nonemptyCategories.push(key); } else { emptyCategories.push(key); } | |
+ | }); | ||
+ | |||
+ | // Empty categories should only be checked by their name, nonempty - ONLY by subfunctions. | ||
+ | const checkEmpty = emptyCategories.some(cat => dct.functions.has(cat)); | ||
+ | const checkNonempty = nonemptyCategories.some(cat => { | ||
+ | const selectedSubs = filterState.functions.get(cat); | ||
+ | const dctCat = dct.functions.get(cat); | ||
+ | return dctCat && dctCat[FUNC_KEY] && dctCat[FUNC_KEY].some(sub => selectedSubs.includes(func)); | ||
+ | }); | ||
− | + | functionsCheck = checkEmpty || checkNonempty; | |
− | + | } | |
− | const functionsCheck = filterState.functions | + | // const functionsCheck = filterState.functions |
− | + | // ? dctFunctions.some(func => filterState.functions.includes(func)) | |
− | + | // : 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)) | ||
Line 654: | Line 663: | ||
) { summary.textContent = 'No filter. Showing all results.'; } | ) { summary.textContent = 'No filter. Showing all results.'; } | ||
else { | else { | ||
+ | console.log(filter.type.functions) | ||
let summaryHtml = '<table>'; | let summaryHtml = '<table>'; | ||
if (filter.type.functions) { | if (filter.type.functions) { |
Revision as of 16:23, 21 November 2022
Development verstion of the DCT List.
Not ready for production!