From d08b7bb063d9df455d02c7494668ff1df41de117 Mon Sep 17 00:00:00 2001 From: Gregoo Date: Wed, 29 Jan 2025 10:36:43 +0100 Subject: [PATCH] Display RGB color, transparency and prints for parts --- bricktracker/rebrickable_part.py | 8 ++++++++ bricktracker/sql/part/base/base.sql | 2 +- static/styles.css | 6 ++++++ templates/macro/card.html | 13 +++++++++++-- templates/part/card.html | 2 +- templates/part/table.html | 5 ++++- 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/bricktracker/rebrickable_part.py b/bricktracker/rebrickable_part.py index b0282be..8224d98 100644 --- a/bricktracker/rebrickable_part.py +++ b/bricktracker/rebrickable_part.py @@ -134,6 +134,14 @@ class RebrickablePart(BrickRecord): spare=self.fields.spare, ) + # Compute the url for the original of the printed part + def url_for_print(self, /) -> str: + return url_for( + 'part.details', + part=self.fields.print, + color=self.fields.color, + ) + # Compute the url for the rebrickable page def url_for_rebrickable(self, /) -> str: if current_app.config['REBRICKABLE_LINKS']: diff --git a/bricktracker/sql/part/base/base.sql b/bricktracker/sql/part/base/base.sql index d9226b3..7849d4c 100644 --- a/bricktracker/sql/part/base/base.sql +++ b/bricktracker/sql/part/base/base.sql @@ -19,7 +19,7 @@ SELECT "rebrickable_parts"."image", "rebrickable_parts"."image_id", "rebrickable_parts"."url", - --"rebrickable_parts"."print", + "rebrickable_parts"."print", {% block total_missing %} NULL AS "total_missing", -- dummy for order: total_missing {% endblock %} diff --git a/static/styles.css b/static/styles.css index 9ac95de..af00525 100644 --- a/static/styles.css +++ b/static/styles.css @@ -59,3 +59,9 @@ .sortable thead th { font-weight: bold !important; } + +.color-rgb { + display: inline-block; + width: 15px; + height: 15px; +} \ No newline at end of file diff --git a/templates/macro/card.html b/templates/macro/card.html index 1cc92ac..7f2924f 100644 --- a/templates/macro/card.html +++ b/templates/macro/card.html @@ -1,11 +1,20 @@ -{% macro header(item, name, solo=false, identifier=none, color=none, icon='hashtag') %} +{% macro header(item, name, solo=false, identifier=none, icon='hashtag') %}
{% if not solo %} {% endif %}
{% if identifier %}{{ identifier }}{% endif %} - {% if color %} {{ color }}{% endif %} + {% if item.fields.color_name %} + + {% if item.fields.color_rgb %} + + {% endif %} + {{ item.fields.color_name }} + + {% endif %} + {% if item.fields.color_transparent %} Transparent{% endif %} + {% if item.fields.print %} Print{% endif %} {{ name }}
{% if not solo %} diff --git a/templates/part/card.html b/templates/part/card.html index 8c23b59..9a14f4a 100644 --- a/templates/part/card.html +++ b/templates/part/card.html @@ -3,7 +3,7 @@ {% import 'macro/card.html' as card %}
- {{ card.header(item, item.fields.name, solo=solo, identifier=item.fields.part, color=item.fields.color, icon='shapes-line') }} + {{ card.header(item, item.fields.name, solo=solo, identifier=item.fields.part, icon='shapes-line') }} {{ card.image(item, solo=solo, last=last, caption=item.fields.name, alt=item.fields.image_id, medium=true) }}
{{ badge.total_sets(sets_using | length, solo=solo, last=last) }} diff --git a/templates/part/table.html b/templates/part/table.html index 78d0efe..f9f8c34 100644 --- a/templates/part/table.html +++ b/templates/part/table.html @@ -15,7 +15,10 @@ {{ table.bricklink(item) }} {% endif %} - {{ item.fields.color_name }} + + {% if item.fields.color_rgb %}{% endif %} + {{ item.fields.color_name }} + {% if not no_quantity %} {% if all %} {{ item.fields.total_quantity }}