From 033f766ab81ffa92745f97c3c3e3b72344ff4b25 Mon Sep 17 00:00:00 2001 From: Alicia de Dios Fuente <Alicia.DeDiosFuente@unige.ch> Date: Thu, 7 May 2020 13:00:51 +0200 Subject: [PATCH] fix: mutualise toolbar and menu titles --- src/app/app-routing.module.ts | 11 +++--- src/app/app.component.html | 2 +- src/app/app.helper.ts | 20 ++++++++++ .../avatar/avatar.presentational.html | 6 +-- .../language-selector.presentational.html | 2 +- .../abstract-main-toolbar.presentational.ts | 13 ++++--- ...bar-desktop-horizontal.presentational.html | 2 +- ...olbar-desktop-vertical.presentational.html | 2 +- .../main-toolbar-mobile.presentational.html | 4 +- .../theme-selector.presentational.html | 2 +- .../admin-home/admin-home.routable.html | 2 +- .../admin-home/admin-home.routable.ts | 2 + .../order-home/order-home.routable.html | 2 +- .../preservation-space-home.routable.html | 2 +- .../preservation-space-home.routable.ts | 2 +- .../preservation-home.routable.html | 2 +- src/assets/i18n/de.json | 38 +++++++++--------- src/assets/i18n/en.json | 39 ++++++++++--------- src/assets/i18n/fr.json | 36 ++++++++--------- 19 files changed, 107 insertions(+), 82 deletions(-) create mode 100644 src/app/app.helper.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 8ee826c36..816f9296d 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -12,6 +12,7 @@ import { StringUtil, TRANSLATE, } from "solidify-frontend"; +import {AppHelper} from "@app/app.helper"; function getQueryParam(): string { // NEED FOR OAUTH 2 CODE QUERY PARAM @@ -37,7 +38,7 @@ const routes: DlcmRoutes = [ // @ts-ignore Dynamic import loadChildren: () => import("./features/deposit/deposit.module").then(m => m.DepositModule), data: { - breadcrumb: TRANSLATE("breadcrumb.deposit.root"), + breadcrumb: AppHelper.deposit, permission: ApplicationRolePermissionEnum.userPermission, }, canActivate: [ApplicationRoleGuardService], @@ -47,7 +48,7 @@ const routes: DlcmRoutes = [ // @ts-ignore Dynamic import loadChildren: () => import("./features/preservation-space/preservation-space.module").then(m => m.PreservationSpaceModule), data: { - breadcrumb: TRANSLATE("breadcrumb.preservation-space.root"), + breadcrumb: AppHelper.preservationSpace, permission: ApplicationRolePermissionEnum.userPermission, }, canActivate: [ApplicationRoleGuardService], @@ -57,7 +58,7 @@ const routes: DlcmRoutes = [ // @ts-ignore Dynamic import loadChildren: () => import("./features/admin/admin.module").then(m => m.AdminModule), data: { - breadcrumb: TRANSLATE("breadcrumb.admin.root"), + breadcrumb: AppHelper.admin, permission: ApplicationRolePermissionEnum.adminPermission, }, canActivate: [ApplicationRoleGuardService], @@ -67,7 +68,7 @@ const routes: DlcmRoutes = [ // @ts-ignore Dynamic import loadChildren: () => import("./features/preservation/preservation.module").then(m => m.PreservationModule), data: { - breadcrumb: TRANSLATE("breadcrumb.preservation.root"), + breadcrumb: AppHelper.preservationPlanning, permission: ApplicationRolePermissionEnum.adminPermission, }, canActivate: [ApplicationRoleGuardService], @@ -77,7 +78,7 @@ const routes: DlcmRoutes = [ // @ts-ignore Dynamic import loadChildren: () => import("./features/order/order.module").then(m => m.OrderModule), data: { - breadcrumb: TRANSLATE("breadcrumb.order.root"), + breadcrumb: AppHelper.order, }, canActivate: [ApplicationRoleGuardService], }, diff --git a/src/app/app.component.html b/src/app/app.component.html index 322bf7b6c..687f34754 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -48,7 +48,7 @@ mat-icon-button mat-button aria-label="Open cart" - [matTooltip]="'app.toolbar.cart' | translate" + [matTooltip]="'app.module.cart' | translate" class="cart" > <dlcm-shared-icon class="icon" diff --git a/src/app/app.helper.ts b/src/app/app.helper.ts new file mode 100644 index 000000000..a96862f98 --- /dev/null +++ b/src/app/app.helper.ts @@ -0,0 +1,20 @@ +import {TRANSLATE} from "solidify-frontend"; + +export class AppHelper { + + static home: string = TRANSLATE("app.module.home"); + static deposit: string = TRANSLATE("app.module.deposit"); + static order: string = TRANSLATE("app.module.order"); + static preservationSpace: string = TRANSLATE("app.module.preservation-space"); + static admin: string = TRANSLATE("app.module.admin"); + static preservationPlanning: string = TRANSLATE("app.module.preservation"); + static cart: string = TRANSLATE("app.module.cart"); + static languageSelector: string = TRANSLATE("app.module.languageSelector"); + static login: string = TRANSLATE("app.module.login"); + static logout: string = TRANSLATE("app.module.logout"); + static profileInfo: string = TRANSLATE("app.module.profileInfo"); + static themeSelector: string = TRANSLATE("app.module.themeSelector"); + static token: string = TRANSLATE("app.module.token"); +} + + diff --git a/src/app/components/presentationals/avatar/avatar.presentational.html b/src/app/components/presentationals/avatar/avatar.presentational.html index cbefda02a..903ea48ad 100644 --- a/src/app/components/presentationals/avatar/avatar.presentational.html +++ b/src/app/components/presentationals/avatar/avatar.presentational.html @@ -12,7 +12,7 @@ (click)="profileInfo()" > <dlcm-shared-icon [iconName]="iconNameEnum.profile"></dlcm-shared-icon> - <span>{{'app.toolbar.profileInfo' | translate}}</span> + <span>{{'app.module.profileInfo' | translate}}</span> </button> <button mat-menu-item solidifyShortCuts @@ -20,12 +20,12 @@ (click)="displayToken()" > <dlcm-shared-icon [iconName]="iconNameEnum.token"></dlcm-shared-icon> - <span>{{'app.toolbar.token' | translate}}</span> + <span>{{'app.module.token' | translate}}</span> </button> <button mat-menu-item (click)="logout()" > <dlcm-shared-icon [iconName]="iconNameEnum.logout"></dlcm-shared-icon> - <span>{{'app.toolbar.logout' | translate}}</span> + <span>{{'app.module.logout' | translate}}</span> </button> </mat-menu> diff --git a/src/app/components/presentationals/language-selector/language-selector.presentational.html b/src/app/components/presentationals/language-selector/language-selector.presentational.html index 472718bc0..6ba6d21a4 100644 --- a/src/app/components/presentationals/language-selector/language-selector.presentational.html +++ b/src/app/components/presentationals/language-selector/language-selector.presentational.html @@ -1,5 +1,5 @@ <img class="selected-language-img" - [matTooltip]="'app.toolbar.languageSelector' | translate" + [matTooltip]="'app.module.languageSelector' | translate" [matTooltipPosition]="'left'" [src]="getPathToImage(currentLanguage)" (click)="matSelect.open()" diff --git a/src/app/components/presentationals/main-toolbar/abstract-main-toolbar/abstract-main-toolbar.presentational.ts b/src/app/components/presentationals/main-toolbar/abstract-main-toolbar/abstract-main-toolbar.presentational.ts index 3f2d31ccd..7a7867bc8 100644 --- a/src/app/components/presentationals/main-toolbar/abstract-main-toolbar/abstract-main-toolbar.presentational.ts +++ b/src/app/components/presentationals/main-toolbar/abstract-main-toolbar/abstract-main-toolbar.presentational.ts @@ -27,6 +27,7 @@ import { TRANSLATE, urlSeparator, } from "solidify-frontend"; +import {AppHelper} from "@app/app.helper"; @Directive() export abstract class AbstractMainToolbarPresentational extends SharedAbstractPresentational { @@ -107,14 +108,14 @@ export abstract class AbstractMainToolbarPresentational extends SharedAbstractPr { click: (menu) => this.navigate(menu.path), path: RoutesEnum.homePage, - labelToTranslate: TRANSLATE("app.toolbar.home"), + labelToTranslate: AppHelper.home, isVisible: () => true, icon: IconNameEnum.home, }, { click: (menu) => this.openOrder(), path: RoutesEnum.order, - labelToTranslate: TRANSLATE("app.toolbar.order"), + labelToTranslate: AppHelper.order, isVisible: () => PermissionUtil.isUserHavePermission(this.logged, ApplicationRolePermissionEnum.userPermission, this.userRoles), icon: IconNameEnum.order, // badgeCounter: () => "" + this.numberMyOrderReadyNew, @@ -124,14 +125,14 @@ export abstract class AbstractMainToolbarPresentational extends SharedAbstractPr { click: (menu) => this.navigate(menu.path), path: RoutesEnum.deposit, - labelToTranslate: TRANSLATE("app.toolbar.deposit"), + labelToTranslate: AppHelper.deposit, isVisible: () => PermissionUtil.isUserHavePermission(this.logged, ApplicationRolePermissionEnum.userPermission, this.userRoles), icon: IconNameEnum.deposit, }, { click: (menu) => this.navigate(menu.path), path: RoutesEnum.preservationSpace, - labelToTranslate: TRANSLATE("app.toolbar.preservation-space"), + labelToTranslate: AppHelper.preservationSpace, isVisible: () => PermissionUtil.isUserHavePermission(this.logged, ApplicationRolePermissionEnum.userPermission, this.userRoles), icon: IconNameEnum.preservationSpace, badgeCounter: () => "" + this.numberPendingRequestNotificationInbox, @@ -141,14 +142,14 @@ export abstract class AbstractMainToolbarPresentational extends SharedAbstractPr { click: (menu) => this.navigate(menu.path), path: RoutesEnum.preservationPlanning, - labelToTranslate: TRANSLATE("app.toolbar.preservation"), + labelToTranslate: AppHelper.preservationPlanning, isVisible: () => PermissionUtil.isUserHavePermission(this.logged, ApplicationRolePermissionEnum.adminPermission, this.userRoles), icon: IconNameEnum.preservationPlanning, }, { click: (menu) => this.navigate(menu.path), path: RoutesEnum.admin, - labelToTranslate: TRANSLATE("app.toolbar.admin"), + labelToTranslate: AppHelper.admin, isVisible: () => PermissionUtil.isUserHavePermission(this.logged, ApplicationRolePermissionEnum.adminPermission, this.userRoles), icon: IconNameEnum.administration, }, diff --git a/src/app/components/presentationals/main-toolbar/main-toolbar-desktop-horizontal/main-toolbar-desktop-horizontal.presentational.html b/src/app/components/presentationals/main-toolbar/main-toolbar-desktop-horizontal/main-toolbar-desktop-horizontal.presentational.html index 5e65df698..f547ed017 100644 --- a/src/app/components/presentationals/main-toolbar/main-toolbar-desktop-horizontal/main-toolbar-desktop-horizontal.presentational.html +++ b/src/app/components/presentationals/main-toolbar/main-toolbar-desktop-horizontal/main-toolbar-desktop-horizontal.presentational.html @@ -51,7 +51,7 @@ <div class="login"> <a data-test="login-horizontal-input" (click)="login()" - >{{'app.toolbar.login' | translate }}</a> + >{{'app.module.login' | translate }}</a> </div> </ng-template> diff --git a/src/app/components/presentationals/main-toolbar/main-toolbar-desktop-vertical/main-toolbar-desktop-vertical.presentational.html b/src/app/components/presentationals/main-toolbar/main-toolbar-desktop-vertical/main-toolbar-desktop-vertical.presentational.html index 3aa02cbc7..5d7c50869 100644 --- a/src/app/components/presentationals/main-toolbar/main-toolbar-desktop-vertical/main-toolbar-desktop-vertical.presentational.html +++ b/src/app/components/presentationals/main-toolbar/main-toolbar-desktop-vertical/main-toolbar-desktop-vertical.presentational.html @@ -57,7 +57,7 @@ > <li data-test="login-vertical-input" class="login" - [matTooltip]="'app.toolbar.login' | translate" + [matTooltip]="'app.module.login' | translate" [matTooltipPosition]="'right'" (click)="login()" > diff --git a/src/app/components/presentationals/main-toolbar/main-toolbar-mobile/main-toolbar-mobile.presentational.html b/src/app/components/presentationals/main-toolbar/main-toolbar-mobile/main-toolbar-mobile.presentational.html index 037dcc26e..4d5b148d5 100644 --- a/src/app/components/presentationals/main-toolbar/main-toolbar-mobile/main-toolbar-mobile.presentational.html +++ b/src/app/components/presentationals/main-toolbar/main-toolbar-mobile/main-toolbar-mobile.presentational.html @@ -50,13 +50,13 @@ [ngIfElse]="loggedOut" > <li class="login"> - <a data-test="login-mobile-input" (click)="login()">{{'app.toolbar.login' | translate }}</a> + <a data-test="login-mobile-input" (click)="login()">{{'app.module.login' | translate }}</a> </li> </ng-template> <ng-template #loggedOut> <li class="logout"> - <a data-test="logout-mobile-input" (click)="logout()">{{'app.toolbar.logout' | translate }}</a> + <a data-test="logout-mobile-input" (click)="logout()">{{'app.module.logout' | translate }}</a> </li> </ng-template> diff --git a/src/app/components/presentationals/theme-selector/theme-selector.presentational.html b/src/app/components/presentationals/theme-selector/theme-selector.presentational.html index 909466a6b..fc04d19e5 100644 --- a/src/app/components/presentationals/theme-selector/theme-selector.presentational.html +++ b/src/app/components/presentationals/theme-selector/theme-selector.presentational.html @@ -1,5 +1,5 @@ <img class="selected-theme-img" - [matTooltip]="'app.toolbar.themeSelector' | translate" + [matTooltip]="'app.module.themeSelector' | translate" [matTooltipPosition]="'right'" [src]="getPathToImage(matSelect.value)" (click)="matSelect.open()"> diff --git a/src/app/features/admin/components/routables/admin-home/admin-home.routable.html b/src/app/features/admin/components/routables/admin-home/admin-home.routable.html index a964ceb97..c71b68644 100644 --- a/src/app/features/admin/components/routables/admin-home/admin-home.routable.html +++ b/src/app/features/admin/components/routables/admin-home/admin-home.routable.html @@ -1,4 +1,4 @@ -<h1 id="admin-home-title">{{'admin.home.title' | translate}}</h1> +<h1 id="admin-home-title">{{'app.module.admin' | translate}}</h1> <div class="toolbar" cdkTrapFocus [solidifyFocusFirstElement]="true" diff --git a/src/app/features/admin/components/routables/admin-home/admin-home.routable.ts b/src/app/features/admin/components/routables/admin-home/admin-home.routable.ts index fabb99973..e651739a4 100644 --- a/src/app/features/admin/components/routables/admin-home/admin-home.routable.ts +++ b/src/app/features/admin/components/routables/admin-home/admin-home.routable.ts @@ -12,6 +12,8 @@ import { } from "@shared/components/routables/shared-abstract-home/shared-abstract-home.routable"; import {IconNameEnum} from "@shared/enums/icon-name.enum"; import {TRANSLATE} from "solidify-frontend"; +import {AppHelper} from "@app/app.helper"; + @Component({ selector: "dlcm-admin-home-routable", diff --git a/src/app/features/order/components/routables/order-home/order-home.routable.html b/src/app/features/order/components/routables/order-home/order-home.routable.html index bc80633c1..68049886b 100644 --- a/src/app/features/order/components/routables/order-home/order-home.routable.html +++ b/src/app/features/order/components/routables/order-home/order-home.routable.html @@ -1,4 +1,4 @@ -<h1>{{'order.home.title' | translate}}</h1> +<h1>{{'app.module.order' | translate}}</h1> <div class="cards-container" [solidifyFocusFirstElement]="true" diff --git a/src/app/features/preservation-space/components/routables/preservation-space-home/preservation-space-home.routable.html b/src/app/features/preservation-space/components/routables/preservation-space-home/preservation-space-home.routable.html index 247b0beba..9cf9c586c 100644 --- a/src/app/features/preservation-space/components/routables/preservation-space-home/preservation-space-home.routable.html +++ b/src/app/features/preservation-space/components/routables/preservation-space-home/preservation-space-home.routable.html @@ -1,4 +1,4 @@ -<h1>{{'preservation.space.home.title' | translate}}</h1> +<h1>{{'app.module.preservation-space' | translate}}</h1> <dlcm-shared-tabs-container [tabs]="preservationSpaceTabs" [isLoading]="isLoadingObs | async" diff --git a/src/app/features/preservation-space/components/routables/preservation-space-home/preservation-space-home.routable.ts b/src/app/features/preservation-space/components/routables/preservation-space-home/preservation-space-home.routable.ts index 35a3fb393..5036d8998 100644 --- a/src/app/features/preservation-space/components/routables/preservation-space-home/preservation-space-home.routable.ts +++ b/src/app/features/preservation-space/components/routables/preservation-space-home/preservation-space-home.routable.ts @@ -50,7 +50,7 @@ export class PreservationSpaceHomeRoutable extends SharedAbstractPresentational { id: "CONTRIBUTOR", icon: IconNameEnum.contributor, - titleToTranslate: TRANSLATE("admin.contributor.home.title"), + titleToTranslate: TRANSLATE("preservationSpace.contributor.home.title"), suffixUrl: PreservationSpaceRoutesEnum.contributor, route: () => [...this.rootUrl, PreservationSpaceRoutesEnum.contributor], }, diff --git a/src/app/features/preservation/components/routables/preservation-home/preservation-home.routable.html b/src/app/features/preservation/components/routables/preservation-home/preservation-home.routable.html index 32bcf47ec..6fe3fbaf2 100644 --- a/src/app/features/preservation/components/routables/preservation-home/preservation-home.routable.html +++ b/src/app/features/preservation/components/routables/preservation-home/preservation-home.routable.html @@ -1,4 +1,4 @@ -<h1>{{'preservation.home.title' | translate}}</h1> +<h1>{{'app.module.preservation' | translate}}</h1> <div class="toolbar" cdkTrapFocus diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json index 2a5856e1d..6cf0d40b9 100644 --- a/src/assets/i18n/de.json +++ b/src/assets/i18n/de.json @@ -62,9 +62,6 @@ "lastName": "Last name", "orcid": "ORCID" }, - "home": { - "title": "Contributors" - }, "table": { "header": { "creation": { @@ -928,6 +925,21 @@ }, "title": "{{name}}: Status history" }, + "module": { + "admin": "Administration", + "cart": "Cart", + "deposit": "Deposits", + "home": "Home", + "languageSelector": "Select a language", + "login": "Log in", + "logout": "Log out", + "order": "Orders", + "preservation": "Preservation Planning", + "preservation-space": "Preservation Space", + "profileInfo": "Profile", + "themeSelector": "Application theme", + "token": "Token" + }, "navigation": { "button": { "back": "Back", @@ -987,21 +999,6 @@ "copyToClipboard": "Copy to the clipboard", "title": "Token" }, - "toolbar": { - "admin": "Administration", - "cart": "Cart", - "deposit": "Deposits", - "home": "Home", - "languageSelector": "Select a language", - "login": "Log in", - "logout": "Log out", - "order": "Archives", - "preservation": "Preservation Planning", - "preservation-space": "Preservation Space", - "profileInfo": "Profile", - "themeSelector": "Application theme", - "token": "Token" - }, "tootlip": { "copyToClipboard": "Copy ID to clipboard" }, @@ -1945,7 +1942,7 @@ "status": "Status" }, "home": { - "subtitle": " ", + "subtitle": "All orders requests", "title": "All orders" }, "notification": { @@ -2450,6 +2447,9 @@ }, "preservationSpace": { "contributor": { + "home": { + "title": "Contributor" + }, "button": { "refresh": "Refresh" }, diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 78cfa75e7..3c53d3caa 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -62,9 +62,6 @@ "lastName": "Last name", "orcid": "ORCID" }, - "home": { - "title": "Contributors" - }, "table": { "header": { "creation": { @@ -928,6 +925,21 @@ }, "title": "{{name}}: Status history" }, + "module": { + "admin": "Administration", + "cart": "Cart", + "deposit": "Deposits", + "home": "Home", + "languageSelector": "Select a language", + "login": "Log in", + "logout": "Log out", + "order": "Orders", + "preservation": "Preservation Planning", + "preservation-space": "Preservation Space", + "profileInfo": "Profile", + "themeSelector": "Application theme", + "token": "Token" + }, "navigation": { "button": { "back": "Back", @@ -987,21 +999,6 @@ "copyToClipboard": "Copy to the clipboard", "title": "Token" }, - "toolbar": { - "admin": "Administration", - "cart": "Cart", - "deposit": "Deposits", - "home": "Home", - "languageSelector": "Select a language", - "login": "Log in", - "logout": "Log out", - "order": "Archives", - "preservation": "Preservation Planning", - "preservation-space": "Preservation Space", - "profileInfo": "Profile", - "themeSelector": "Application theme", - "token": "Token" - }, "tootlip": { "copyToClipboard": "Copy ID to clipboard" }, @@ -1988,7 +1985,8 @@ } }, "home": { - "title": "Orders" + "title": "Orders", + "subtitle": "All order requests" }, "myOrder": { "accessLevel": "Access level", @@ -2450,6 +2448,9 @@ }, "preservationSpace": { "contributor": { + "home": { + "title": "Contributor" + }, "button": { "refresh": "Refresh" }, diff --git a/src/assets/i18n/fr.json b/src/assets/i18n/fr.json index c271aa538..42626f2ad 100644 --- a/src/assets/i18n/fr.json +++ b/src/assets/i18n/fr.json @@ -62,9 +62,6 @@ "lastName": "Nom", "orcid": "ORCID" }, - "home": { - "title": "Contributeur-rice-s" - }, "table": { "header": { "creation": { @@ -928,6 +925,21 @@ }, "title": "{{name}} : Historique des statuts" }, + "module": { + "admin": "Administration", + "cart": "Panier", + "deposit": "Dépôts", + "home": "Accueil", + "languageSelector": "Sélectionner une langue", + "login": "Connexion", + "logout": "Déconnexion", + "order": "Orders", + "preservation": "Planification de préservation", + "preservation-space": "Espace de préservation", + "profileInfo": "Profil", + "themeSelector": "Thème d'application", + "token": "Token" + }, "navigation": { "button": { "back": "Retour", @@ -987,21 +999,6 @@ "copyToClipboard": "Copier dans le presse-papiers", "title": "Token" }, - "toolbar": { - "admin": "Administration", - "cart": "Panier", - "deposit": "Dépôts", - "home": "Accueil", - "languageSelector": "Sélectionner une langue", - "login": "Connexion", - "logout": "Déconnexion", - "order": "Archives", - "preservation": "Planification de préservation", - "preservation-space": "Espace de préservation", - "profileInfo": "Profil", - "themeSelector": "Thème d'application", - "token": "Token" - }, "tootlip": { "copyToClipboard": "Copier l'identifiant dans le presse-papiers" }, @@ -2450,6 +2447,9 @@ }, "preservationSpace": { "contributor": { + "home": { + "title": "Contributeur-rice" + }, "button": { "refresh": "Rafraichir" }, -- GitLab