Skip to content

Add an optional color to the custom part states - #1537

Open
killecaptron wants to merge 2 commits into
Part-DB:masterfrom
killecaptron:part-custom-state-colors
Open

Add an optional color to the custom part states#1537
killecaptron wants to merge 2 commits into
Part-DB:masterfrom
killecaptron:part-custom-state-colors

Conversation

@killecaptron

Copy link
Copy Markdown
Contributor

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.

killecaptron and others added 2 commits September 7, 2026 17:29
…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

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.24390% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.40%. Comparing base (0f0ee60) to head (c06c358).

Files with missing lines Patch % Lines
src/DataTables/Helpers/PartDataTableHelper.php 50.00% 3 Missing ⚠️
src/Form/AdminPages/PartCustomStateAdminForm.php 91.66% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant