From e7b64fb88df6c17f8e7ce4aaf7e4472bdf7dfe0d Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Mon, 16 Mar 2026 10:40:08 +0100 Subject: [PATCH] Move to labels --- backend/i18n/frontend_en.json | 2 +- backend/i18n/source/frontend_en.json | 2 +- frontend/refactor.js | 84 +++++++++---------- .../event-consumer.component.html | 24 ++++-- .../pages/users/user.component.html | 20 +++-- .../pages/graphql/graphql-page.component.html | 4 +- .../assets/pages/asset-tags.component.html | 8 +- .../assets/pages/assets-page.component.html | 11 ++- .../calendar/calendar-page.component.html | 19 +++-- .../comments/comments-page.component.html | 9 +- .../content-history-page.component.html | 3 +- .../pages/content/content-page.component.html | 35 ++++++-- .../contents/contents-page.component.html | 9 +- .../shared/forms/array-editor.component.html | 16 +++- .../shared/forms/array-item.component.html | 50 ++++++++--- .../shared/forms/assets-editor.component.html | 4 +- .../shared/forms/content-field.component.html | 3 +- .../forms/field-copy-button.component.html | 2 +- .../forms/stock-photo-editor.component.html | 11 ++- .../shared/list/content.component.html | 11 ++- .../references/reference-item.component.html | 17 ++-- .../rules/pages/rule/rule-page.component.html | 2 +- .../rules/pages/rules/rule.component.html | 2 +- .../rules/shared/rule-element.component.html | 2 +- .../content-changed-schema.component.html | 2 +- .../content-changed-trigger.component.html | 10 ++- .../schema-preview-urls-form.component.html | 9 +- .../schema-field-rules-form.component.html | 5 +- .../pages/schema/schema-page.component.html | 12 +-- .../pages/clients/client.component.html | 2 +- .../contributors/contributor.component.html | 2 +- .../settings/pages/jobs/job.component.html | 4 +- .../pages/languages/language.component.html | 7 +- .../pages/more/more-page.component.html | 2 +- .../settings/pages/roles/role.component.html | 16 ++-- .../workflows/workflow-step.component.html | 15 +++- .../workflow-transition.component.html | 3 +- .../pages/workflows/workflow.component.html | 2 +- .../teams/pages/auth/auth-page.component.html | 7 +- .../contributors/contributor.component.html | 2 +- .../app/framework/angular/code.component.html | 3 +- .../editors/date-time-editor.component.html | 9 +- .../editors/localized-input.component.html | 3 +- .../framework/angular/layout.component.html | 17 ++-- .../assets/asset-dialog.component.html | 17 ++-- .../assets/asset-selector.component.html | 7 +- .../assets/asset-uploader.component.html | 7 +- .../components/assets/asset.component.html | 30 ++++--- .../assets/image-cropper.component.html | 35 +++++--- .../comments/comment.component.html | 17 ++-- .../contents/content-value.component.html | 3 +- .../forms/geolocation-editor.component.html | 18 +++- .../content-selector.component.html | 4 +- .../components/schema-category.component.html | 7 +- .../search/query-list.component.html | 8 +- .../components/tour-guide.component.html | 3 +- 56 files changed, 416 insertions(+), 222 deletions(-) diff --git a/backend/i18n/frontend_en.json b/backend/i18n/frontend_en.json index 3f3a0b3f5..3e6c63b31 100644 --- a/backend/i18n/frontend_en.json +++ b/backend/i18n/frontend_en.json @@ -201,7 +201,7 @@ "comments.resolve": "Resolve comment", "comments.title": "Comments", "comments.unresolve": "Unresolve comment", - "comments.unresolved": "Comments", + "comments.unresolved": "Open Comments", "common.actions": "Actions", "common.add": "Add", "common.administration": "Administration", diff --git a/backend/i18n/source/frontend_en.json b/backend/i18n/source/frontend_en.json index 3f3a0b3f5..3e6c63b31 100644 --- a/backend/i18n/source/frontend_en.json +++ b/backend/i18n/source/frontend_en.json @@ -201,7 +201,7 @@ "comments.resolve": "Resolve comment", "comments.title": "Comments", "comments.unresolve": "Unresolve comment", - "comments.unresolved": "Comments", + "comments.unresolved": "Open Comments", "common.actions": "Actions", "common.add": "Add", "common.administration": "Administration", diff --git a/frontend/refactor.js b/frontend/refactor.js index ce5423700..0d69dfbab 100644 --- a/frontend/refactor.js +++ b/frontend/refactor.js @@ -1,5 +1,3 @@ -#!/usr/bin/env node - const fs = require("fs"); const path = require("path"); @@ -18,20 +16,9 @@ class AddButtonTypesStrategy { class FixIconOnlyInteractivesStrategy { #interactiveTagPattern = /<(a|button)(\s[^>]*)?>/gi; - #iconPattern = /${this.#resolveTitle(title)}`; - } + #visuallyHiddenSpanPattern = /\s*([\s\S]*?)<\/span>/i; + #nestedInteractiveOpenPattern = /<(a|button)[\s>]/gi; + #nestedInteractiveClosePattern = /<\/(a|button)\s*>/gi; #findClosingTag(html, from, tag) { const openingTagPattern = new RegExp(`<${tag}[\\s>]`, "gi"); @@ -60,21 +47,34 @@ class FixIconOnlyInteractivesStrategy { return position; } - #lineAndColumn(html, index) { - const before = html.slice(0, index); - const line = (before.match(/\n/g) || []).length + 1; - const column = index - before.lastIndexOf("\n"); - return { line, column }; - } + #isDirectChild(inner, spanIndex) { + let depth = 0; + let position = 0; + + while (position < spanIndex) { + this.#nestedInteractiveOpenPattern.lastIndex = position; + this.#nestedInteractiveClosePattern.lastIndex = position; + const nextOpening = this.#nestedInteractiveOpenPattern.exec(inner); + const nextClosing = this.#nestedInteractiveClosePattern.exec(inner); + + const openingBeforeSpan = nextOpening && nextOpening.index < spanIndex; + const closingBeforeSpan = nextClosing && nextClosing.index < spanIndex; + + if (openingBeforeSpan && (!closingBeforeSpan || nextOpening.index < nextClosing.index)) { + depth++; + position = nextOpening.index + 1; + } else if (closingBeforeSpan) { + depth--; + position = nextClosing.index + 1; + } else { + break; + } + } - #hasOnlyIcons(inner) { - this.#iconPattern.lastIndex = 0; - const withoutIcons = inner.replace(this.#iconPattern, "").replace(/<[^>]+>/g, "").trim(); - this.#iconPattern.lastIndex = 0; - return withoutIcons.length === 0 && this.#iconPattern.test(inner); + return depth === 0; } - fix(html, filePath) { + fix(html) { const fixes = []; let match; @@ -86,29 +86,27 @@ class FixIconOnlyInteractivesStrategy { const openEnd = match.index + match[0].length; const closeEnd = this.#findClosingTag(html, openEnd, tag); const inner = html.slice(openEnd, closeEnd - ``.length); + const spanMatch = this.#visuallyHiddenSpanPattern.exec(inner); - if (!this.#hasOnlyIcons(inner) || this.#screenReaderPattern.test(inner) || this.#screenReaderPattern.test(attributes)) { + if (!spanMatch || !this.#isDirectChild(inner, spanMatch.index)) { continue; } - const titleMatch = this.#titleAttributePattern.exec(attributes); - - const { line, column } = this.#lineAndColumn(html, match.index); + const ariaLabel = spanMatch[1].trim().replace(/"/g, "'"); + const innerWithout = inner.slice(0, spanMatch.index) + inner.slice(spanMatch.index + spanMatch[0].length); + const newOpenTag = `<${tag}${attributes} attr.aria-label="${ariaLabel}">`; - if (titleMatch) { - fixes.push({ insertAt: openEnd + inner.length, title: titleMatch[1] }); - } else { - fixes.push({ insertAt: openEnd + inner.length, title: null }); - console.log(`${filePath}:${line}:${column}`); - } + fixes.push({ + from: match.index, + to: openEnd + inner.length, + newOpenTag, + newInner: innerWithout, + }); } let result = html; - for (const fix of fixes.sort((a, b) => b.insertAt - a.insertAt)) { - const span = fix.title !== null - ? this.#visuallyHiddenSpan(fix.title) - : this.#visuallyHiddenSpan("{{ 'i18n:TODO' | sqxTranslate }}"); - result = result.slice(0, fix.insertAt) + span + result.slice(fix.insertAt); + for (const fix of fixes.sort((a, b) => b.from - a.from)) { + result = result.slice(0, fix.from) + fix.newOpenTag + fix.newInner + result.slice(fix.to); } return result; diff --git a/frontend/src/app/features/administration/pages/event-consumers/event-consumer.component.html b/frontend/src/app/features/administration/pages/event-consumers/event-consumer.component.html index bacd398e4..cb334e2a8 100644 --- a/frontend/src/app/features/administration/pages/event-consumers/event-consumer.component.html +++ b/frontend/src/app/features/administration/pages/event-consumers/event-consumer.component.html @@ -16,23 +16,35 @@ @if (eventConsumer.canReset) { - } @if (eventConsumer.canStart) { - } @if (eventConsumer.canStop) { - } diff --git a/frontend/src/app/features/administration/pages/users/user.component.html b/frontend/src/app/features/administration/pages/users/user.component.html index 52f3f18ab..e4d49c1da 100644 --- a/frontend/src/app/features/administration/pages/users/user.component.html +++ b/frontend/src/app/features/administration/pages/users/user.component.html @@ -11,20 +11,31 @@ @if (user.canLock) { - } @if (user.canUnlock) { - } diff --git a/frontend/src/app/features/api/pages/graphql/graphql-page.component.html b/frontend/src/app/features/api/pages/graphql/graphql-page.component.html index e70321d84..0e0f2b261 100644 --- a/frontend/src/app/features/api/pages/graphql/graphql-page.component.html +++ b/frontend/src/app/features/api/pages/graphql/graphql-page.component.html @@ -3,8 +3,8 @@
@if (clientsReadable) { - } diff --git a/frontend/src/app/features/assets/pages/asset-tags.component.html b/frontend/src/app/features/assets/pages/asset-tags.component.html index 84f34510e..2d082ce7a 100644 --- a/frontend/src/app/features/assets/pages/asset-tags.component.html +++ b/frontend/src/app/features/assets/pages/asset-tags.component.html @@ -15,9 +15,13 @@
{{ tag.count }}
@if (canRename) { - } diff --git a/frontend/src/app/features/assets/pages/assets-page.component.html b/frontend/src/app/features/assets/pages/assets-page.component.html index 839ff1ded..67b98b3e3 100644 --- a/frontend/src/app/features/assets/pages/assets-page.component.html +++ b/frontend/src/app/features/assets/pages/assets-page.component.html @@ -37,18 +37,23 @@
-
diff --git a/frontend/src/app/features/content/pages/calendar/calendar-page.component.html b/frontend/src/app/features/content/pages/calendar/calendar-page.component.html index 477b722ee..549017f39 100644 --- a/frontend/src/app/features/content/pages/calendar/calendar-page.component.html +++ b/frontend/src/app/features/content/pages/calendar/calendar-page.component.html @@ -9,13 +9,21 @@ - - @@ -30,9 +38,8 @@
-
diff --git a/frontend/src/app/features/content/pages/comments/comments-page.component.html b/frontend/src/app/features/content/pages/comments/comments-page.component.html index 432f0886b..5f9e9394f 100644 --- a/frontend/src/app/features/content/pages/comments/comments-page.component.html +++ b/frontend/src/app/features/content/pages/comments/comments-page.component.html @@ -3,12 +3,17 @@