Repository navigation
Add configurable tag style rules - #1640
killecaptron wants to merge 1 commit into
Conversation
Tags are a free-form, flat list, and every tag looked the same, so a list of parts with a dozen tags per row gave no visual grouping at all - even though tags are usually used in namespaces like "Risk:High" or "Project:Foo". An administrator can now define an ordered list of rules in the system settings, which map a tag (exactly, or by prefix) to one of the semantic Bootstrap colors. Tags which do not match any rule keep their previous appearance, and only the color of a tag changes - filtering and searching by tags are untouched. At most one rule is applied per tag: an exact rule wins over a prefix rule, the longest matching prefix wins among prefix rules, and the first configured rule wins any remaining tie. The rules are resolved in one place, so tags look the same in the part tables and on the part page. Each rule row previews itself while it is edited. The rules only take effect once the settings are saved, so a row which showed a fixed word in the stored color gave no feedback about what is being typed: the badge now shows the entered tag in the chosen color, a prefix rule marks itself with an ellipsis, and a sentence below the row spells out what the selected match type will match. That sentence is also the answer to "exact or prefix?", which the two words alone do not explain. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
@greptileai Review |
[Medium impact] The PR changes tag badge colors across several part views and adds an administrator settings workflow. Fix the rule-number collision before merging; it can overwrite a remaining rule after saving.
|
| {% endset %} | ||
| {% set _proto_html = __proto|e('html_attr') %} | ||
| {% set _proto_name = form.vars.prototype_name|default('__name__') %} | ||
| {% set _index = form|length %} |
There was a problem hiding this comment.
New rules overwrite existing rules
After removing a middle rule and saving, the page renders the same submitted form, whose remaining child names can be 0 and 2. Using form|length resets the next index to 2. Clicking “Add rule” creates another row with the same field names, so the next save can overwrite the existing rule.
Start above the largest rendered child index, or redirect after saving and handle sparse indexes after invalid submissions.
Prompt To Fix With AI
This is a comment left during a code review.
Path: templates/form/tag_style_rules_collection.html.twig
Line: 43
Comment:
**New rules overwrite existing rules**
After removing a middle rule and saving, the page renders the same submitted form, whose remaining child names can be `0` and `2`. Using `form|length` resets the next index to `2`. Clicking “Add rule” creates another row with the same field names, so the next save can overwrite the existing rule.
Start above the largest rendered child index, or redirect after saving and handle sparse indexes after invalid submissions.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| '<a href="%s" class="badge bg-primary badge-table">%s</a>', | ||
| '<a href="%s" class="%s">%s</a>', | ||
| $this->urlGenerator->generate('part_list_tags', ['tag' => $tag]), | ||
| htmlspecialchars($this->tagStyleResolver->resolve((string) $tag, 'badge bg-primary badge-table')), |
There was a problem hiding this comment.
Selected tags become unreadable
The new text-bg-light, text-bg-warning, and text-bg-info classes need dark text. But tables.css forces white text on every direct link in a selected row with a stronger !important rule. Selecting a part makes these tags hard to read; light becomes almost white on white.
Exclude badges with their own text color from the selected-row override.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/DataTables/Column/TagsColumn.php
Line: 66
Comment:
**Selected tags become unreadable**
The new `text-bg-light`, `text-bg-warning`, and `text-bg-info` classes need dark text. But `tables.css` forces white text on every direct link in a selected row with a stronger `!important` rule. Selecting a part makes these tags hard to read; `light` becomes almost white on white.
Exclude badges with their own text color from the selected-row override.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| //"default" means the rule does not force a colour, which is how an unmatched tag looks | ||
| const badgeClass = color === '' || color === 'default' ? 'bg-secondary' : `text-bg-${color}`; |
There was a problem hiding this comment.
Default preview shows wrong color
Choosing default previews a gray badge, but saved tags do not use gray: TagsColumn keeps bg-primary, and string_to_tags keeps bg-info. Administrators therefore see a color they will not get after saving.
Make the preview explain that default keeps each page’s existing color instead of presenting bg-secondary as the result.
Prompt To Fix With AI
This is a comment left during a code review.
Path: assets/controllers/pages/tag_style_rule_controller.js
Line: 75-76
Comment:
**Default preview shows wrong color**
Choosing `default` previews a gray badge, but saved tags do not use gray: `TagsColumn` keeps `bg-primary`, and `string_to_tags` keeps `bg-info`. Administrators therefore see a color they will not get after saving.
Make the preview explain that `default` keeps each page’s existing color instead of presenting `bg-secondary` as the result.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| ->add('pattern', TextType::class, [ | ||
| 'label' => false, | ||
| 'required' => true, |
There was a problem hiding this comment.
Rule controls lack accessible names
All three rule fields use label: false, but the column headings are plain <strong> elements and are not linked to the controls. The trash button also contains only an unnamed icon. Screen-reader users cannot tell what each field or button does.
Add translated accessible names using visually hidden labels or aria-label.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Form/Settings/TagStyleRuleType.php
Line: 55-57
Comment:
**Rule controls lack accessible names**
All three rule fields use `label: false`, but the column headings are plain `<strong>` elements and are not linked to the controls. The trash button also contains only an unnamed icon. Screen-reader users cannot tell what each field or button does.
Add translated accessible names using visually hidden labels or `aria-label`.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
I am planning to move the tag system to a way, where parts refer to a common global tag entities. |
|
Superseded by #1672, which stores tags as entities of their own (with colors, nesting and the other data structure features), as you suggested above. Closing this one. |
Tags are a free-form, flat list, and every tag looks the same, so a list of parts with a dozen tags per row
gives no visual grouping at all - even though tags are usually used in namespaces like
Risk:HighorProject:Foo.An administrator can now define an ordered list of rules under System settings → Tag styles, which map a tag
(exactly, or by prefix) to one of the semantic Bootstrap colors. Tags which do not match any rule keep their
previous appearance, and only the color of a tag changes - filtering and searching by tags are untouched.
At most one rule is applied per tag: an exact rule wins over a prefix rule, the longest matching prefix wins
among prefix rules, and the first configured rule wins any remaining tie. The rules are resolved in one place,
so tags look the same in the part tables and on the part page.
Each rule row previews itself while it is edited. The rules only take effect once the settings are saved, so a
row which showed a fixed word in the stored color gave no feedback about what is being typed: the badge now
shows the entered tag in the chosen color, a prefix rule marks itself with an ellipsis, and the badge explains
what the selected match type will match. That is also the answer to "exact or prefix?", which the two words
alone do not explain.
Documented in
docs/usage/tag_styles.md.🤖 Generated with Claude Code