Leaner card dataset

This commit is contained in:
2025-01-31 18:38:03 +01:00
parent 302eafe08c
commit 5ffea66de0
2 changed files with 29 additions and 6 deletions

View File

@@ -75,11 +75,13 @@ class BrickGridFilter {
if (select.value.startsWith("-")) {
options.filters.push({
attribute: select.value.substring(1),
bool: true,
value: "0"
})
} else {
options.filters.push({
attribute: select.value,
bool: true,
value: "1"
})
}
@@ -93,7 +95,20 @@ class BrickGridFilter {
cards.forEach(current => {
// Process all filters
for (const filter of options.filters) {
if (current.getAttribute(`data-${filter.attribute}`) != filter.value) {
const attribute = current.getAttribute(`data-${filter.attribute}`);
// Bool check
// Attribute not equal value, or undefined and value is truthy
if (filter.bool) {
if ((attribute != null && attribute != filter.value) || (attribute == null && filter.value == "1")) {
current.parentElement.classList.add("d-none");
return;
}
}
// Value check
// Attribute not equal value, or attribute undefined
else if ((attribute != null && attribute != filter.value) || attribute == null) {
current.parentElement.classList.add("d-none");
return;
}