Leaner card dataset
This commit is contained in:
parent
302eafe08c
commit
5ffea66de0
@ -75,11 +75,13 @@ class BrickGridFilter {
|
|||||||
if (select.value.startsWith("-")) {
|
if (select.value.startsWith("-")) {
|
||||||
options.filters.push({
|
options.filters.push({
|
||||||
attribute: select.value.substring(1),
|
attribute: select.value.substring(1),
|
||||||
|
bool: true,
|
||||||
value: "0"
|
value: "0"
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
options.filters.push({
|
options.filters.push({
|
||||||
attribute: select.value,
|
attribute: select.value,
|
||||||
|
bool: true,
|
||||||
value: "1"
|
value: "1"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -93,7 +95,20 @@ class BrickGridFilter {
|
|||||||
cards.forEach(current => {
|
cards.forEach(current => {
|
||||||
// Process all filters
|
// Process all filters
|
||||||
for (const filter of options.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");
|
current.parentElement.classList.add("d-none");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -8,17 +8,25 @@
|
|||||||
data-index="{{ index }}" data-number="{{ item.fields.set }}" data-name="{{ item.fields.name | lower }}" data-parts="{{ item.fields.number_of_parts }}"
|
data-index="{{ index }}" data-number="{{ item.fields.set }}" data-name="{{ item.fields.name | lower }}" data-parts="{{ item.fields.number_of_parts }}"
|
||||||
data-year="{{ item.fields.year }}" data-theme="{{ item.theme.name | lower }}" data-minifigures="{{ item.fields.total_minifigures }}" data-has-minifigures="{{ (item.fields.total_minifigures > 0) | int }}"
|
data-year="{{ item.fields.year }}" data-theme="{{ item.theme.name | lower }}" data-minifigures="{{ item.fields.total_minifigures }}" data-has-minifigures="{{ (item.fields.total_minifigures > 0) | int }}"
|
||||||
data-has-missing="{{ (item.fields.total_missing > 0) | int }}" data-has-missing-instructions="{{ (not (item.instructions | length)) | int }}" data-missing="{{ item.fields.total_missing }}"
|
data-has-missing="{{ (item.fields.total_missing > 0) | int }}" data-has-missing-instructions="{{ (not (item.instructions | length)) | int }}" data-missing="{{ item.fields.total_missing }}"
|
||||||
{% for status in brickset_statuses %}data-{{ status.as_dataset() }}="{{ item.fields[status.as_column()] }}" {% endfor %}
|
{% for status in brickset_statuses %}
|
||||||
|
{% with checked=item.fields[status.as_column()] %}
|
||||||
|
{% if checked %}
|
||||||
|
data-{{ status.as_dataset() }}="{{ checked }}"
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endfor %}
|
||||||
{% for owner in brickset_owners %}
|
{% for owner in brickset_owners %}
|
||||||
{% with checked=item.fields[owner.as_column()] %}
|
{% with checked=item.fields[owner.as_column()] %}
|
||||||
data-{{ owner.as_dataset() }}="{{ checked }}"
|
{% if checked %}
|
||||||
{% if checked %} data-search-owner-{{ loop.index }}="{{ owner.fields.name | lower }}"{% endif %}
|
data-{{ owner.as_dataset() }}="{{ checked }}" data-search-owner-{{ loop.index }}="{{ owner.fields.name | lower }}"
|
||||||
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for tag in brickset_tags %}
|
{% for tag in brickset_tags %}
|
||||||
{% with checked=item.fields[tag.as_column()] %}
|
{% with checked=item.fields[tag.as_column()] %}
|
||||||
data-{{ tag.as_dataset() }}="{{ checked }}"
|
{% if checked %}
|
||||||
{% if checked %} data-search-tag-{{ loop.index }}="{{ tag.fields.name | lower }}"{% endif %}
|
data-{{ tag.as_dataset() }}="{{ checked }}" data-search-tag-{{ loop.index }}="{{ tag.fields.name | lower }}"
|
||||||
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user