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

[#62150] refinement of pattern input

Eric Schubert964a505fa2da
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 0533c3db1a0..b21fe450bb7 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -676,8 +676,8 @@ en:
caption: "Define a pattern using referenced attributes and text to automatically generate work package subjects. Users will not be able to manually edit subjects."
pattern:
label: "Subject pattern"
- caption: "Search for an attribute or add text. To create a space between elements add it as a text."
- insert_as_text: "Add as text: \"%{word}\""
+ caption: "Add text or type / to search for an attribute. You can add spaces to separate them."
+ insert_as_text: "No attributes found. Add as text: \"%{word}\""
export_configuration:
tab: "Generate PDF"
intro: "Select which templates from those that are available you would like to enable for this type. The template determines the design and attributes visible in the exported PDF of a work package using this type. The first template on the list is selected by default."
diff --git a/frontend/src/stimulus/controllers/pattern-input.controller.ts b/frontend/src/stimulus/controllers/pattern-input.controller.ts
index 44777943714..a35053147b6 100644
--- a/frontend/src/stimulus/controllers/pattern-input.controller.ts
+++ b/frontend/src/stimulus/controllers/pattern-input.controller.ts
@@ -133,9 +133,9 @@ export default class PatternInputController extends Controller {
this.tagInvalidTokens();
- // this resets the cursor position without changing it
- // it is necessary because chromium based browsers try to
- // retain styling and adds a unwanted <font> tag,
+ // This resets the cursor position without changing it.
+ // It is necessary because chromium based browsers try to
+ // retain styling and adds an unwanted <font> tag,
// breaking the behaviour of this component
const selection = document.getSelection();
if (selection && selection.rangeCount) {
@@ -338,8 +338,6 @@ export default class PatternInputController extends Controller {
this.clearSuggestionsFilter();
this.suggestionsTarget.classList.remove('d-none');
- this.appendInsertAsTextElement(word);
-
const filtered = this.getFilteredSuggestionsData(word.toLowerCase());
// insert the HTML
@@ -369,6 +367,10 @@ export default class PatternInputController extends Controller {
this.suggestionsTarget.appendChild(groupDivider);
}
});
+
+ if (this.suggestionsTarget.childNodes.length === 0) {
+ this.appendInsertAsTextElement(word);
+ }
}
private appendInsertAsTextElement(word:string):void {