-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Adapt work package show view for semantic identifiers #22704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/73756-adapt-routes-for-project-based-semantic-work-package-identifiers
Are you sure you want to change the base?
Changes from all commits
35f05d5
5815943
6c02cd1
f040a5a
9c757cf
cc6f184
e12be14
61111f0
ce7533b
26f87c6
b29c528
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,6 +125,24 @@ export class WorkPackageBaseResource extends HalResource { | |
|
|
||
| public subject:string; | ||
|
|
||
| /** | ||
| * Returns the user-facing work package identifier. | ||
| * "PROJ-42" in semantic mode, "42" in classic mode. | ||
| */ | ||
| public get displayId():string { | ||
| return this.$source.displayId?.toString() ?? this.id?.toString() ?? ''; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the work package identifier formatted for inline UI display. | ||
| * Classic mode: `#42` (hash-prefixed numeric ID) | ||
| * Semantic mode: `PROJ-42` (no prefix — the identifier is self-describing) | ||
| */ | ||
| public get formattedId():string { | ||
| const wpId = this.displayId; | ||
| return /[A-Za-z]/.test(wpId) ? wpId : `#${wpId}`; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer a more clean way of detecting the semantic mode in the frontend but since we don't have that, the regex is probably fine. However, please add that as a const to the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reckon one way could to check settings on the frontend via the configurations module- but that felt like overkill- and I suppose a small heuristic via regex is sufficient as the case is not too complex? That said, I agree on extracting the function for re-usability 👍🏾
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As it happens, I already moved it in a followup pr: https://github.com/opf/openproject/pull/22733/changes#diff-8c9531ab159b9dd6876e925b03fe7f38c03b1c8fa8511fd074de23552f5360e8
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| } | ||
|
|
||
| public updatedAt:Date; | ||
|
|
||
| public lockVersion:number; | ||
|
|
@@ -170,18 +188,18 @@ export class WorkPackageBaseResource extends HalResource { | |
| } | ||
|
|
||
| /** | ||
| * Return "<type name>: <subject> (#<id>)" if type and id are known. | ||
| * Return "<type name>: <subject> (<formattedId>)" if type and id are known. | ||
| */ | ||
| public subjectWithType(truncateSubject = 40):string { | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
| return `${this.type.name}: ${this.subjectWithId(truncateSubject)}`; | ||
| } | ||
|
|
||
| /** | ||
| * Return "<subject> (#<id>)" if the id is known. | ||
| * Return "<subject> (<formattedId>)" if the id is known. | ||
| */ | ||
| public subjectWithId(truncateSubject = 40):string { | ||
| const id = isNewResource(this) ? '' : ` (#${this.id || ''})`; | ||
| const id = isNewResource(this) ? '' : ` (${this.formattedId})`; | ||
|
|
||
| return `${this.truncatedSubject(truncateSubject)}${id}`; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /** | ||
| * URL-safe pattern that matches work package identifiers: | ||
| * numeric IDs ("123") and semantic identifiers ("PROJ-42"). | ||
| * | ||
| * Used in UI Router route definitions so that both forms are accepted in URLs. | ||
| * The backend equivalent lives in WorkPackage::SemanticIdentifier::ID_ROUTE_CONSTRAINT. | ||
| */ | ||
| export const WP_ID_URL_PATTERN = '\\d+|[A-Za-z][A-Za-z0-9_]*-\\d+'; |
Uh oh!
There was an error while loading. Please reload this page.