Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#64348] Allow editing and replacing existing tokens within formula

Tobias Dillmannda2ee7154f17
diff --git a/frontend/src/stimulus/controllers/pattern-input.controller.ts b/frontend/src/stimulus/controllers/pattern-input.controller.ts
index f226de6f83c..27d2f31fef0 100644
--- a/frontend/src/stimulus/controllers/pattern-input.controller.ts
+++ b/frontend/src/stimulus/controllers/pattern-input.controller.ts
@@ -39,7 +39,7 @@ type FilteredSuggestions = Array<{
type TokenElement = HTMLElement&{ dataset:{ role:'token', prop:string } };
type ListElement = HTMLElement&{ dataset:{ role:'list_item', prop:string } };
-type AttributeToken = { key:string, label:string, label_with_context:string, insert_as_text?:boolean };
+type AttributeToken = { key:string, label:string, label_with_context?:string, insert_as_text?:boolean };
const COMPLETION_CHARACTER = '/';
const TOKEN_REGEX = /{{([0-9A-Za-z_]+)}}/g;
@@ -349,7 +349,7 @@ export default class PatternInputController extends Controller {
if (this.isToken(parent)) {
const token = this.validTokenMap[parent.dataset.prop];
- const prefix = token.label_with_context.replace(token.label, '');
+ const prefix = token.label_with_context?.replace(token.label, '');
const start = prefix && textContent.startsWith(prefix) ? prefix.length : 0;
return textContent.slice(start, selection.anchorOffset);
@@ -518,8 +518,10 @@ export default class PatternInputController extends Controller {
return key;
}
- if (token.key.startsWith('parent_') || token.key.startsWith('project_')) {
- return token.label_with_context;
+ if (token.label_with_context) {
+ if (token.key.startsWith('parent_') || token.key.startsWith('project_')) {
+ return token.label_with_context;
+ }
}
return token.label;