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 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;
            // Empty categories should only be checked by their name, nonempty - ONLY by subfunctions.
            if (filterState.functions) {
            const emptyCategories = [], nonemptyCategories = [];
                // If filterState has a category but subfunctions array is empty, we only care about the category.
            Array.from(filterState.functions).forEach(([key, subs]) => {
                const emptyCategories = [], nonemptyCategories = [];
                if (subs.length > 0) { nonemptyCategories.push(key); } else { emptyCategories.push(key); }
                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));
                });


            console.log(emptyCategories, nonemptyCategories)
                functionsCheck = checkEmpty || checkNonempty;
             // return true
             }


             const functionsCheck = filterState.functions
             // const functionsCheck = filterState.functions
                ? dctFunctions.some(func => filterState.functions.includes(func))
            //    ? dctFunctions.some(func => filterState.functions.includes(func))
                : true;
            //    : 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 15:23, 21 November 2022

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