Difference between revisions of "Widget:DCTList"
From LINKS Community Center
Line 427: | Line 427: | ||
const filterState = {}; | const filterState = {}; | ||
+ | const functionFilterBlocks = document.querySelectorAll('#functions-filter .func-filter-block'); | ||
+ | const funcOpts = new Map(); | ||
+ | functionFilterBlocks.forEach(block => { | ||
+ | const cat = block.querySelector('input.func-cat'); | ||
+ | if (cat.checked) { | ||
+ | funcOpts.set( | ||
+ | cat.value, | ||
+ | Array.from(block.querySelectorAll('.subfunc-filter-block input[type="checkbox"]:checked')) | ||
+ | .map(box => box.value) | ||
+ | ); | ||
+ | } | ||
+ | }); | ||
+ | console.log(funcOpts) | ||
+ | |||
+ | // If everything is selected, disable functions filter. | ||
const functionOptions = Array.from(document.querySelectorAll('#functions-filter input[type="checkbox"]')); | const functionOptions = Array.from(document.querySelectorAll('#functions-filter input[type="checkbox"]')); | ||
const selectedFunctions = functionOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value); | const selectedFunctions = functionOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value); | ||
+ | |||
filterState.functions = selectedFunctions.length === functionOptions.length ? undefined : selectedFunctions; | filterState.functions = selectedFunctions.length === functionOptions.length ? undefined : selectedFunctions; | ||
Revision as of 17:29, 18 November 2022
Development verstion of the DCT List.
Not ready for production!