Add an optional color to the custom part states - #1537
Open
killecaptron wants to merge 2 commits into
Open
Conversation
…lass SkippableItemNormalizer resolves IRI strings itself, to work around an API Platform issue with abstract resource classes which have a discriminator map (see Part-DB#1370). That check only looked at the shape of the data, not at what was being denormalized, so it also caught plain values nested inside a resource - a backed enum for example, whose scalar value is a string, but certainly not an IRI. Such a value was silently swallowed instead of being handed to the normalizer which is actually responsible for it. Only resolve IRIs if the target type really is an API resource class. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Custom part states are shown as a badge on the part page and in the part tables, but every state looked the same, so a state like "defective" could not be told apart from "in testing" at a glance. A state can now optionally be given one of the eight semantic Bootstrap colors. The choice is a closed list, so no free-form CSS class or color can end up in the templates, and the mapping from a color to its badge class exists exactly once. States without a color keep exactly the appearance they had before. The custom state is also available as an (optional) column in the project BOM table, where the color is what makes the column useful in the first place. Rendering the badge lives in the part table helper and in the entity itself, so the part table, the BOM table and the part page can not drift apart. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1537 +/- ##
=========================================
Coverage 62.39% 62.40%
- Complexity 9879 9889 +10
=========================================
Files 736 738 +2
Lines 31779 31813 +34
=========================================
+ Hits 19829 19853 +24
- Misses 11950 11960 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A custom part state is shown as a badge on the part page and as plain text in the part tables, and
every state looks the same. States are typically used for things which differ in urgency though -
"needs review" and "do not use" should not look alike at a glance.
A state can now carry an optional semantic color, chosen from a fixed list of the Bootstrap
colors. The list is a closed whitelist: no free-form CSS or hex value ends up in the database, and
the mapping to a class happens in exactly one place. A state without a color keeps its previous
appearance, so nothing changes for existing installations until someone picks one.
The badge markup lives in PartDataTableHelper rather than being repeated in the part table, the
BOM table and the sidebar template, and the same helper renders the custom state column which the
project BOM table gained here (hidden by default).
The first commit is unrelated to the feature but needed by it: SkippableItemNormalizer treated any
string as an IRI, including the scalar value of a backed enum nested inside a resource, which
swallowed the value instead of letting the enum normalizer handle it. It now only does so for
types which really are API resources.