Difference between revisions of "Widget:DCTList"
From LINKS Community Center
Line 415: | Line 415: | ||
// Passing an empty object (as with applyFilters(true)) should result in an unfiltered table. | // Passing an empty object (as with applyFilters(true)) should result in an unfiltered table. | ||
− | let functionsCheck = true; | + | let functionsCheck = true; // automatically pass functions check if the filter missing |
if (filterState.functions) { | if (filterState.functions) { | ||
// If filterState has a category but subfunctions array is empty, we only care about the category. | // If filterState has a category but subfunctions array is empty, we only care about the category. | ||
Line 506: | Line 506: | ||
`<div class="func-filter-block"> | `<div class="func-filter-block"> | ||
<div> | <div> | ||
− | <input type="checkbox" | + | <input type="checkbox" id="${identifier}" value="${fnCat}" class="func-cat"> |
<label for="${identifier}" title="${fnInfo[DESC_KEY]}"><img src="${fnImages[fnCat]}"> ${fnCat}</label> | <label for="${identifier}" title="${fnInfo[DESC_KEY]}"><img src="${fnImages[fnCat]}"> ${fnCat}</label> | ||
</div>`; | </div>`; | ||
Line 517: | Line 517: | ||
funcFilterHtml += | funcFilterHtml += | ||
`<div> | `<div> | ||
− | <input type="checkbox" | + | <input type="checkbox" id="${subfuncId}" value="${func}"> |
<label for="${subfuncId}">${func}</label> | <label for="${subfuncId}">${func}</label> | ||
</div>`; | </div>`; | ||
Line 547: | Line 547: | ||
return acc + | return acc + | ||
'<div ' + (idx === 0 ? ' class="filter-group-start">' : '>') + | '<div ' + (idx === 0 ? ' class="filter-group-start">' : '>') + | ||
− | '<input type="checkbox" id="filter-' + identifier + '" value="' + curr.name + '" | + | '<input type="checkbox" id="filter-' + identifier + '" value="' + curr.name + '">' + |
'<label for="filter-' + identifier + '"><img src="' + curr.image + '"> ' + curr.name + '</label></div>' | '<label for="filter-' + identifier + '"><img src="' + curr.image + '"> ' + curr.name + '</label></div>' | ||
}, ''); | }, ''); | ||
Line 559: | Line 559: | ||
const identifier = escapeAttr(curr); | const identifier = escapeAttr(curr); | ||
return acc | return acc | ||
− | + '<div><input type="checkbox" | + | + '<div><input type="checkbox" id="bm-filter-' + identifier |
+ '" value="' + curr + '">' | + '" value="' + curr + '">' | ||
+ '<label for="bm-filter-' + identifier + '">' + curr | + '<label for="bm-filter-' + identifier + '">' + curr | ||
Line 570: | Line 570: | ||
// const identifier = escapeAttr(curr); | // const identifier = escapeAttr(curr); | ||
// return acc | // return acc | ||
− | // + '<div><input type="checkbox" | + | // + '<div><input type="checkbox" id="dm-use-filter-' + identifier |
// + '" value="' + curr + '">' | // + '" value="' + curr + '">' | ||
// + '<label for="dm-use-filter-' + identifier + '">' + curr + '</label></div>' | // + '<label for="dm-use-filter-' + identifier + '">' + curr + '</label></div>' | ||
Line 675: | Line 675: | ||
document.getElementById('func-filter-' + escapeAttr(fnCat)) | document.getElementById('func-filter-' + escapeAttr(fnCat)) | ||
.closest('.func-filter-block') | .closest('.func-filter-block') | ||
− | .querySelectorAll('input[type="checkbox"]').forEach(box => box.checked = functions[fnCat]); | + | .querySelectorAll('input[type="checkbox"]').forEach(box => box.checked = !!functions[fnCat]); |
}); | }); | ||
Line 781: | Line 781: | ||
// If no subfunctions are selected, deactivate the category. Activate otherwise. | // If no subfunctions are selected, deactivate the category. Activate otherwise. | ||
const checkedSubs = Array.from(subfunctions).filter(sub => sub.checked).length; | const checkedSubs = Array.from(subfunctions).filter(sub => sub.checked).length; | ||
− | if (checkedSubs > 0) { category.checked = true; } else { category.checked = false; } | + | category.checked = checkedSubs > 0; |
+ | // if (checkedSubs > 0) { category.checked = true; } else { category.checked = false; } | ||
} | } | ||
Revision as of 15:01, 9 March 2023
Current version of the DCT List.
Not ready for production!