Use formatted_id in user-facing WP identifier rendering#23200
Merged
akabiru merged 4 commits intoMay 14, 2026
Conversation
…antic ids
The autocomplete dropdown in CKEditor renders each result with
`item.name = wp.to_s`, and `to_s` hardcoded `##{id}` — so a semantic-mode
search for `#KSTP-2` resolved correctly but the dropdown row showed
`Task #10244: Subject` instead of `Task KSTP-2: Subject`.
Switch to `formatted_id`, which already produces the user-facing form in
both modes (`PROJ-7` semantic, `#42` classic). The other caller — the
delete-dialog component — benefits from the same mode awareness.
The activity feed renders an automatic entry whenever a parent / child /
predecessor / related work package change cascades dates onto the
current WP. Both render paths spoke numeric ids:
- The plain-text branch (used for the API JSON) hardcoded `##{id}`.
- The HTML branch went through `link_to_work_package`, which built the
visible link label as `Type ##{id}: subject`.
Both now use `formatted_id`, which produces `PROJ-7` in semantic mode
and `#42` in classic — same shape, mode-aware. The link href was
already mode-correct via `to_param`; only the visible label needed the
swap.
- Pin literal "MACROPROJ-42" in helper spec so a regression where the helper accidentally returns `#N` shape still trips the assertion. Previously the expected string was built from the same accessor under test. - Drop framework-mechanics narration from the cause spec comment. The assertion already conveys intent.
Deploying openproject with ⚡ PullPreview
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates user-facing work package identifier rendering to consistently use WorkPackage#formatted_id, ensuring semantic identifiers (e.g., PROJ-7) are shown in semantic mode while preserving classic #42 formatting in classic mode.
Changes:
- Update
WorkPackage#to_sto useformatted_idinstead of the raw numericid. - Update
link_to_work_packageandJournalFormatter::Causeto renderformatted_idin visible labels / raw text variants. - Add/extend specs to cover classic vs semantic mode output for the affected render paths.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| app/models/work_package.rb | Switch to_s to use formatted_id for mode-correct user-visible IDs. |
| app/helpers/work_packages_helper.rb | Render formatted_id in work package link labels. |
| lib/open_project/journal_formatter/cause.rb | Use formatted_id for raw text cause rendering when a related WP is present. |
| spec/models/work_package_spec.rb | Add coverage for to_s output in classic vs semantic modes. |
| spec/helpers/work_packages_helper_spec.rb | Add coverage for link_to_work_package label in semantic mode. |
| spec/lib/open_project/journal_formatter/cause_spec.rb | Add coverage ensuring cause formatter uses formatted_id in semantic mode (HTML + raw). |
The hardcoded `#6` in the examples was misleading once the rendered label became mode-dependent. Use `<id>` placeholder so the docstring stays accurate across both modes without re-describing the modes.
Member
Author
|
→ https://pr-23200-use-formatted-id-i-ip-178-105-9-66.my.opf.run/projects/DP/work_packages/12/activity Note WorkPackage links are not yet converted to semantic IDs- this PR only addresses the search menu and journal formatter. The former will be addressed in #23203
|
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.


Ticket
https://community.openproject.org/wp/74945
Split out of #22976; ships independently.
What are you trying to accomplish?
Three WP render paths spoke numeric ids —
WorkPackage#to_s(autocomplete dropdown rows and the delete-confirmation dialog),link_to_work_package(the visible link label in activity-feed entries), andJournalFormatter::Cause(the automatic entry emitted when a parent / child / predecessor date cascade fires).All three switch to
formatted_id, which producesPROJ-7in semantic mode and#42in classic. The href usesto_paramand is mode-correct without changes; this updates only the visible label.Screenshots
Merge checklist