From b0c7cd7da57abe03c68ba3116e4a083b830b8f8c Mon Sep 17 00:00:00 2001 From: Gregoo <versatile.mailbox@gmail.com> Date: Tue, 4 Feb 2025 09:32:57 +0100 Subject: [PATCH] Enforce hidden features in the card and grid filters/sort --- templates/macro/badge.html | 8 ++++++-- templates/set/card.html | 12 +++++++++--- templates/set/filter.html | 16 ++++++++++++---- templates/set/sort.html | 4 ++++ 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/templates/macro/badge.html b/templates/macro/badge.html index e1f9071..ea2be58 100644 --- a/templates/macro/badge.html +++ b/templates/macro/badge.html @@ -103,7 +103,9 @@ {% endmacro %} {% macro total_damaged(damaged, solo=false, last=false) %} - {{ badge(check=damaged, solo=solo, last=last, color='danger', icon='error-warning-line', collapsible='Damaged:', text=damaged, alt='Damaged') }} + {% if not config['HIDE_TABLE_DAMAGED_PARTS'] %} + {{ badge(check=damaged, solo=solo, last=last, color='danger', icon='error-warning-line', collapsible='Damaged:', text=damaged, alt='Damaged') }} + {% endif %} {% endmacro %} {% macro total_quantity(quantity, solo=false, last=false) %} @@ -115,7 +117,9 @@ {% endmacro %} {% macro total_missing(missing, solo=false, last=false) %} - {{ badge(check=missing, solo=solo, last=last, color='light text-danger-emphasis bg-danger-subtle border border-danger-subtle', icon='question-line', collapsible='Missing:', text=missing, alt='Missing') }} + {% if not config['HIDE_TABLE_MISSING_PARTS'] %} + {{ badge(check=missing, solo=solo, last=last, color='light text-danger-emphasis bg-danger-subtle border border-danger-subtle', icon='question-line', collapsible='Missing:', text=missing, alt='Missing') }} + {% endif %} {% endmacro %} {% macro total_sets(sets, solo=false, last=false) %} diff --git a/templates/set/card.html b/templates/set/card.html index f47a7ca..2064206 100644 --- a/templates/set/card.html +++ b/templates/set/card.html @@ -7,10 +7,16 @@ {% if not solo and not tiny %} 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-has-missing-instructions="{{ (not (item.instructions | length)) | int }}" + {% if not config['HIDE_SET_INSTRUCTIONS'] %} + data-has-missing-instructions="{{ (item.instructions | length == 0) | int }}" + {% endif %} data-has-minifigures="{{ (item.fields.total_minifigures > 0) | int }}" data-minifigures="{{ item.fields.total_minifigures }}" - data-has-missing="{{ (item.fields.total_missing > 0) | int }}" data-missing="{{ item.fields.total_missing }}" - data-has-damaged="{{ (item.fields.total_damaged > 0) | int }}" data-damaged="{{ item.fields.total_damaged }}" + {% if not config['HIDE_TABLE_MISSING_PARTS'] %} + data-has-missing="{{ (item.fields.total_missing > 0) | int }}" data-missing="{{ item.fields.total_missing }}" + {% endif %} + {% if not config['HIDE_TABLE_DAMAGED_PARTS'] %} + data-has-damaged="{{ (item.fields.total_damaged > 0) | int }}" data-damaged="{{ item.fields.total_damaged }}" + {% endif %} data-has-storage="{{ item.fields.storage is not none | int }}" {% if item.fields.storage is not none %} data-storage="{{ item.fields.storage }}" diff --git a/templates/set/filter.html b/templates/set/filter.html index 65c3343..8f3b410 100644 --- a/templates/set/filter.html +++ b/templates/set/filter.html @@ -7,10 +7,18 @@ data-filter="metadata" autocomplete="off"> <option value="" selected>All</option> - <option value="-has-missing">Set is complete</option> - <option value="has-missing">Set has missing pieces</option> - <option value="has-damaged">Set has damaged pieces</option> - <option value="has-missing-instructions">Set has missing instructions</option> + {% if not config['HIDE_TABLE_MISSING_PARTS'] %} + <option value="has-missing">Has missing pieces</option> + <option value="-has-missing">Has NO missing pieces</option> + {% endif %} + {% if not config['HIDE_TABLE_DAMAGED_PARTS'] %} + <option value="has-damaged">Has damaged pieces</option> + <option value="-has-damaged">Has NO damaged pieces</option> + {% endif %} + {% if not config['HIDE_SET_INSTRUCTIONS'] %} + <option value="-has-missing-instructions">Has instructions</option> + <option value="has-missing-instructions">Is MISSING instructions</option> + {% endif %} {% if brickset_storages | length %} <option value="has-storage">Is in storage</option> <option value="-has-storage">Is NOT in storage</option> diff --git a/templates/set/sort.html b/templates/set/sort.html index 09f31f0..3315a1d 100644 --- a/templates/set/sort.html +++ b/templates/set/sort.html @@ -14,10 +14,14 @@ data-sort-attribute="minifigures" data-sort-desc="true"><i class="ri-group-line"></i><span class="d-none d-xl-inline"> Figures</span></button> <button id="sort-parts" type="button" class="btn btn-outline-primary mb-2" data-sort-attribute="parts" data-sort-desc="true"><i class="ri-shapes-line"></i><span class="d-none d-xl-inline"> Parts</span></button> + {% if not config['HIDE_TABLE_MISSING_PARTS'] %} <button id="sort-missing" type="button" class="btn btn-outline-primary mb-2" data-sort-attribute="missing" data-sort-desc="true"><i class="ri-question-line"></i><span class="d-none d-xl-inline"> Missing</span></button> + {% endif %} + {% if not config['HIDE_TABLE_DAMAGED_PARTS'] %} <button id="sort-damaged" type="button" class="btn btn-outline-primary mb-2" data-sort-attribute="damaged" data-sort-desc="true"><i class="ri-error-warning-line"></i><span class="d-none d-xl-inline"> Damaged</span></button> + {% endif %} <button id="sort-clear" type="button" class="btn btn-outline-dark mb-2" data-sort-clear="true"><i class="ri-close-circle-line"></i><span class="d-none d-xl-inline"> Clear</span></button> </div>