Add a flag to hide instructions in a set card

This commit is contained in:
Gregoo 2025-01-26 09:59:53 +01:00
parent a9bf5e03f8
commit b489cd1ec3
4 changed files with 11 additions and 3 deletions

View File

@ -111,6 +111,10 @@
# Default: false
# BK_HIDE_MISSING_PARTS=true
# Optional: Hide the 'Instructions' entry in a Set card
# Default: false
# BK_HIDE_SET_INSTRUCTIONS=true
# Optional: Hide the 'Wishlist' entry from the menu. Does not disable the route.
# Default: false
# BK_HIDE_WISHES=true

View File

@ -30,6 +30,7 @@ CONFIG: Final[list[dict[str, Any]]] = [
{'n': 'HIDE_ALL_PARTS', 'c': bool},
{'n': 'HIDE_ALL_SETS', 'c': bool},
{'n': 'HIDE_MISSING_PARTS', 'c': bool},
{'n': 'HIDE_SET_INSTRUCTIONS', 'c': bool},
{'n': 'HIDE_WISHES', 'c': bool},
{'n': 'MINIFIGURES_DEFAULT_ORDER', 'd': '"minifigures"."name" ASC'},
{'n': 'MINIFIGURES_FOLDER', 'd': 'minifigs', 's': True},

View File

@ -3,7 +3,7 @@ import traceback
from typing import Any, Self
from uuid import uuid4
from flask import url_for
from flask import current_app, url_for
from .exceptions import DatabaseException, NotFoundException
from .minifigure_list import BrickMinifigureList
@ -179,7 +179,10 @@ class BrickSet(RebrickableSet):
# Compute the url for the set instructions
def url_for_instructions(self, /) -> str:
if len(self.instructions):
if (
not current_app.config['HIDE_SET_INSTRUCTIONS'] and
len(self.instructions)
):
return url_for(
'set.details',
id=self.fields.id,

View File

@ -35,7 +35,7 @@
{% endfor %}
</ul>
{% endif %}
{% if solo %}
{% if solo and not config['HIDE_SET_INSTRUCTIONS'] %}
<div class="accordion accordion-flush border-top" id="set-details">
{% if not delete %}
{{ accordion.header('Instructions', 'instructions', 'set-details', expanded=open_instructions, quantity=item.instructions | length, icon='file-line', class='p-0') }}