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

[#62486] searching in tokens removes prefix from word

Eric Schubert0cb7d2b52604
diff --git a/frontend/src/stimulus/controllers/pattern-input.controller.ts b/frontend/src/stimulus/controllers/pattern-input.controller.ts
index ade5b0017e0..871b781637a 100644
--- a/frontend/src/stimulus/controllers/pattern-input.controller.ts
+++ b/frontend/src/stimulus/controllers/pattern-input.controller.ts
@@ -217,7 +217,7 @@ export default class PatternInputController extends Controller {
.reduce((acc, [groupKey, attributes]) => {
if (groupKey !== 'work_package') {
Object.entries(attributes).forEach(([key, value]) => {
- attributes[key] = `${this.headingLocalesValue[groupKey]}: ${value}`;
+ attributes[key] = `${this.tokenPrefix(groupKey)} ${value}`;
});
}
@@ -349,7 +349,11 @@ export default class PatternInputController extends Controller {
if (textContent === null) { return null; }
if (this.isToken(parent)) {
- return textContent.slice(0, selection.anchorOffset);
+ const key = parent.dataset.prop;
+ const prefix = this.tokenPrefix(key.slice(0, key.indexOf('_')));
+ const start = prefix && textContent.startsWith(prefix) ? prefix.length + 2 : 0;
+
+ return textContent.slice(start, selection.anchorOffset);
}
const posKey = textContent.lastIndexOf(COMPLETION_CHARACTER);
@@ -535,6 +539,11 @@ export default class PatternInputController extends Controller {
}, blueprint);
}
+ private tokenPrefix(groupKey:string):string {
+ const locale = this.headingLocalesValue[groupKey];
+ return locale ? `${locale}:` : '';
+ }
+
private toBlueprint():string {
let result = '';
this.contentTarget.childNodes.forEach((node:ChildNode) => {