From 5c484fb2742b34e411558e6f3f7cf6507e12c389 Mon Sep 17 00:00:00 2001
From: Florent Poittevin <florent.poittevin@unige.ch>
Date: Thu, 24 Oct 2019 17:00:25 +0200
Subject: [PATCH] fix: add button to go back to menu admin

---
 .../admin-funding-agencies-list.routable.ts               | 2 ++
 .../admin-institution-list.routable.ts                    | 1 +
 .../admin-license-list/admin-license-list.routable.ts     | 1 +
 .../admin-oauth2-client-list.routable.ts                  | 1 +
 .../admin-orgunit-list/admin-orgunit-list.routable.ts     | 1 +
 .../admin-person-list/admin-person-list.routable.ts       | 1 +
 .../admin-preservation-policy-list.routable.ts            | 1 +
 .../routables/admin-role-list/admin-role-list.routable.ts | 1 +
 .../admin-submission-policy-list.routable.ts              | 1 +
 .../routables/admin-user-list/admin-user-list.routable.ts | 1 +
 .../routables/deposit-list/deposit-list.routable.ts       | 1 +
 .../routables/orgunit-list/orgunit-list.routable.ts       | 1 +
 .../shared-abstract-list.routable.html                    | 8 ++++++++
 .../shared-abstract-list/shared-abstract-list.routable.ts | 6 ++++++
 src/assets/i18n/de.json                                   | 3 +++
 src/assets/i18n/en.json                                   | 3 +++
 src/assets/i18n/fr.json                                   | 3 +++
 17 files changed, 36 insertions(+)

diff --git a/src/app/features/admin/funding-agencies/components/routables/admin-funding-agencies-list/admin-funding-agencies-list.routable.ts b/src/app/features/admin/funding-agencies/components/routables/admin-funding-agencies-list/admin-funding-agencies-list.routable.ts
index 702dc390a..f47f82be5 100644
--- a/src/app/features/admin/funding-agencies/components/routables/admin-funding-agencies-list/admin-funding-agencies-list.routable.ts
+++ b/src/app/features/admin/funding-agencies/components/routables/admin-funding-agencies-list/admin-funding-agencies-list.routable.ts
@@ -21,6 +21,7 @@ import {TRANSLATE} from "solidify-frontend";
 export class AdminFundingAgenciesListRoutable extends SharedAbstractListRoutable<FundingAgency, AdminFundingAgenciesStateModel> {
   readonly KEY_CREATE_BUTTON: string = TRANSLATE("admin.funding-agencies.button.new");
   readonly KEY_REFRESH_BUTTON: string = TRANSLATE("admin.funding-agencies.button.refresh");
+  readonly KEY_BACK_BUTTON: string | undefined = TRANSLATE("admin.button.goBackToAdminHome");
 
   constructor(protected store: Store,
               protected _changeDetector: ChangeDetectorRef) {
@@ -47,4 +48,5 @@ export class AdminFundingAgenciesListRoutable extends SharedAbstractListRoutable
       },
     ];
   }
+
 }
diff --git a/src/app/features/admin/institution/components/routables/admin-institution-list/admin-institution-list.routable.ts b/src/app/features/admin/institution/components/routables/admin-institution-list/admin-institution-list.routable.ts
index 8b4cccaf3..518380ade 100644
--- a/src/app/features/admin/institution/components/routables/admin-institution-list/admin-institution-list.routable.ts
+++ b/src/app/features/admin/institution/components/routables/admin-institution-list/admin-institution-list.routable.ts
@@ -21,6 +21,7 @@ import {TRANSLATE} from "solidify-frontend";
 export class AdminInstitutionListRoutable extends SharedAbstractListRoutable<Institution, AdminInstitutionStateModel> {
   readonly KEY_CREATE_BUTTON: string = TRANSLATE("admin.institution.button.new");
   readonly KEY_REFRESH_BUTTON: string = TRANSLATE("admin.institution.button.refresh");
+  readonly KEY_BACK_BUTTON: string | undefined = TRANSLATE("admin.button.goBackToAdminHome");
 
   constructor(protected store: Store,
               protected _changeDetector: ChangeDetectorRef) {
diff --git a/src/app/features/admin/license/components/routables/admin-license-list/admin-license-list.routable.ts b/src/app/features/admin/license/components/routables/admin-license-list/admin-license-list.routable.ts
index b07c904d2..590a1c739 100644
--- a/src/app/features/admin/license/components/routables/admin-license-list/admin-license-list.routable.ts
+++ b/src/app/features/admin/license/components/routables/admin-license-list/admin-license-list.routable.ts
@@ -21,6 +21,7 @@ import {TRANSLATE} from "solidify-frontend";
 export class AdminLicenseListRoutable extends SharedAbstractListRoutable<License, AdminLicenseStateModel> {
   readonly KEY_CREATE_BUTTON: string = TRANSLATE("admin.license.button.new");
   readonly KEY_REFRESH_BUTTON: string = TRANSLATE("admin.license.button.refresh");
+  readonly KEY_BACK_BUTTON: string | undefined = TRANSLATE("admin.button.goBackToAdminHome");
 
   constructor(protected store: Store,
               protected _changeDetector: ChangeDetectorRef) {
diff --git a/src/app/features/admin/oauth2-client/components/routables/admin-oauth2-client-list/admin-oauth2-client-list.routable.ts b/src/app/features/admin/oauth2-client/components/routables/admin-oauth2-client-list/admin-oauth2-client-list.routable.ts
index 8508966ad..41fb267d0 100644
--- a/src/app/features/admin/oauth2-client/components/routables/admin-oauth2-client-list/admin-oauth2-client-list.routable.ts
+++ b/src/app/features/admin/oauth2-client/components/routables/admin-oauth2-client-list/admin-oauth2-client-list.routable.ts
@@ -21,6 +21,7 @@ import {TRANSLATE} from "solidify-frontend";
 export class AdminOAuth2ClientListRoutable extends SharedAbstractListRoutable<Oauth2Client, AdminOAuth2ClientStateModel> {
   readonly KEY_CREATE_BUTTON: string = TRANSLATE("admin.oauth2.button.new");
   readonly KEY_REFRESH_BUTTON: string = TRANSLATE("admin.oauth2.button.refresh");
+  readonly KEY_BACK_BUTTON: string | undefined = TRANSLATE("admin.button.goBackToAdminHome");
 
   constructor(protected store: Store,
               protected _changeDetector: ChangeDetectorRef) {
diff --git a/src/app/features/admin/orgunit/components/routables/admin-orgunit-list/admin-orgunit-list.routable.ts b/src/app/features/admin/orgunit/components/routables/admin-orgunit-list/admin-orgunit-list.routable.ts
index b35563b59..fb87013fd 100644
--- a/src/app/features/admin/orgunit/components/routables/admin-orgunit-list/admin-orgunit-list.routable.ts
+++ b/src/app/features/admin/orgunit/components/routables/admin-orgunit-list/admin-orgunit-list.routable.ts
@@ -21,6 +21,7 @@ import {TRANSLATE} from "solidify-frontend";
 export class AdminOrgunitListRoutable extends SharedAbstractListRoutable<OrganizationalUnitExtended, AdminOrganizationalUnitStateModel> {
   readonly KEY_CREATE_BUTTON: string = TRANSLATE("admin.organizationalUnit.new");
   readonly KEY_REFRESH_BUTTON: string = TRANSLATE("admin.organizationalUnit.refresh");
+  readonly KEY_BACK_BUTTON: string | undefined = TRANSLATE("admin.button.goBackToAdminHome");
 
   constructor(protected store: Store,
               protected _changeDetector: ChangeDetectorRef) {
diff --git a/src/app/features/admin/person/components/routables/admin-person-list/admin-person-list.routable.ts b/src/app/features/admin/person/components/routables/admin-person-list/admin-person-list.routable.ts
index f2947643a..63420cdeb 100644
--- a/src/app/features/admin/person/components/routables/admin-person-list/admin-person-list.routable.ts
+++ b/src/app/features/admin/person/components/routables/admin-person-list/admin-person-list.routable.ts
@@ -21,6 +21,7 @@ import {TRANSLATE} from "solidify-frontend";
 export class AdminPersonListRoutable extends SharedAbstractListRoutable<PersonExtended, AdminPersonStateModel> {
   readonly KEY_CREATE_BUTTON: string = TRANSLATE("admin.person.button.new");
   readonly KEY_REFRESH_BUTTON: string = TRANSLATE("admin.person.button.refresh");
+  readonly KEY_BACK_BUTTON: string | undefined = TRANSLATE("admin.button.goBackToAdminHome");
 
   constructor(protected store: Store,
               protected _changeDetector: ChangeDetectorRef) {
diff --git a/src/app/features/admin/preservation-policy/components/routables/admin-preservation-policy-list/admin-preservation-policy-list.routable.ts b/src/app/features/admin/preservation-policy/components/routables/admin-preservation-policy-list/admin-preservation-policy-list.routable.ts
index a43a26209..52498b7fe 100644
--- a/src/app/features/admin/preservation-policy/components/routables/admin-preservation-policy-list/admin-preservation-policy-list.routable.ts
+++ b/src/app/features/admin/preservation-policy/components/routables/admin-preservation-policy-list/admin-preservation-policy-list.routable.ts
@@ -21,6 +21,7 @@ import {TRANSLATE} from "solidify-frontend";
 export class AdminPreservationPolicyListRoutable extends SharedAbstractListRoutable<PreservationPolicy, AdminPreservationPolicyStateModel> {
   readonly KEY_CREATE_BUTTON: string = TRANSLATE("admin.preservationPolicy.button.new");
   readonly KEY_REFRESH_BUTTON: string = TRANSLATE("admin.preservationPolicy.button.refresh");
+  readonly KEY_BACK_BUTTON: string | undefined = TRANSLATE("admin.button.goBackToAdminHome");
 
   constructor(protected store: Store,
               protected _changeDetector: ChangeDetectorRef) {
diff --git a/src/app/features/admin/role/components/routables/admin-role-list/admin-role-list.routable.ts b/src/app/features/admin/role/components/routables/admin-role-list/admin-role-list.routable.ts
index beef91d3f..12360c54b 100644
--- a/src/app/features/admin/role/components/routables/admin-role-list/admin-role-list.routable.ts
+++ b/src/app/features/admin/role/components/routables/admin-role-list/admin-role-list.routable.ts
@@ -21,6 +21,7 @@ import {TRANSLATE} from "solidify-frontend";
 export class AdminRoleListRoutable extends SharedAbstractListRoutable<Role, AdminRoleStateModel> {
   readonly KEY_CREATE_BUTTON: string = TRANSLATE("admin.roles.button.new");
   readonly KEY_REFRESH_BUTTON: string = TRANSLATE("admin.roles.button.refresh");
+  readonly KEY_BACK_BUTTON: string | undefined = TRANSLATE("admin.button.goBackToAdminHome");
 
   constructor(protected store: Store,
               protected _changeDetector: ChangeDetectorRef) {
diff --git a/src/app/features/admin/submission-policy/components/routables/admin-submission-policy-list/admin-submission-policy-list.routable.ts b/src/app/features/admin/submission-policy/components/routables/admin-submission-policy-list/admin-submission-policy-list.routable.ts
index 339b35fa6..3bfdc9aac 100644
--- a/src/app/features/admin/submission-policy/components/routables/admin-submission-policy-list/admin-submission-policy-list.routable.ts
+++ b/src/app/features/admin/submission-policy/components/routables/admin-submission-policy-list/admin-submission-policy-list.routable.ts
@@ -21,6 +21,7 @@ import {TRANSLATE} from "solidify-frontend";
 export class AdminSubmissionPolicyListRoutable extends SharedAbstractListRoutable<SubmissionPolicy, AdminSubmissionPolicyStateModel> {
   readonly KEY_CREATE_BUTTON: string = TRANSLATE("admin.submissionPolicy.button.new");
   readonly KEY_REFRESH_BUTTON: string = TRANSLATE("admin.submissionPolicy.button.refresh");
+  readonly KEY_BACK_BUTTON: string | undefined = TRANSLATE("admin.button.goBackToAdminHome");
 
   constructor(protected store: Store,
               protected _changeDetector: ChangeDetectorRef) {
diff --git a/src/app/features/admin/user/components/routables/admin-user-list/admin-user-list.routable.ts b/src/app/features/admin/user/components/routables/admin-user-list/admin-user-list.routable.ts
index 108795b29..678de02c0 100644
--- a/src/app/features/admin/user/components/routables/admin-user-list/admin-user-list.routable.ts
+++ b/src/app/features/admin/user/components/routables/admin-user-list/admin-user-list.routable.ts
@@ -21,6 +21,7 @@ import {TRANSLATE} from "solidify-frontend";
 export class AdminUserListRoutable extends SharedAbstractListRoutable<UserExtended, AdminUserStateModel> {
   readonly KEY_CREATE_BUTTON: string = TRANSLATE("admin.user.button.new");
   readonly KEY_REFRESH_BUTTON: string = TRANSLATE("admin.user.button.refresh");
+  readonly KEY_BACK_BUTTON: string | undefined = TRANSLATE("admin.button.goBackToAdminHome");
 
   constructor(protected store: Store,
               protected _changeDetector: ChangeDetectorRef) {
diff --git a/src/app/features/deposit/components/routables/deposit-list/deposit-list.routable.ts b/src/app/features/deposit/components/routables/deposit-list/deposit-list.routable.ts
index 5a632c994..4dc4f8975 100644
--- a/src/app/features/deposit/components/routables/deposit-list/deposit-list.routable.ts
+++ b/src/app/features/deposit/components/routables/deposit-list/deposit-list.routable.ts
@@ -26,6 +26,7 @@ import {
 export class DepositListRoutable extends SharedAbstractListRoutable<DepositExtended, DepositStateModel> implements OnInit {
   readonly KEY_CREATE_BUTTON: string = TRANSLATE("deposit.new");
   readonly KEY_REFRESH_BUTTON: string = TRANSLATE("deposit.refresh");
+  readonly KEY_BACK_BUTTON: string | undefined = undefined;
 
   constructor(protected store: Store,
               protected _changeDetector: ChangeDetectorRef,
diff --git a/src/app/features/organizational-unit/components/routables/orgunit-list/orgunit-list.routable.ts b/src/app/features/organizational-unit/components/routables/orgunit-list/orgunit-list.routable.ts
index 2d5ac2c16..d6f2a4ae8 100644
--- a/src/app/features/organizational-unit/components/routables/orgunit-list/orgunit-list.routable.ts
+++ b/src/app/features/organizational-unit/components/routables/orgunit-list/orgunit-list.routable.ts
@@ -21,6 +21,7 @@ import {TRANSLATE} from "solidify-frontend";
 export class OrgunitListRoutable extends SharedAbstractListRoutable<OrganizationalUnitExtended, OrganizationalUnitStateModel> {
   readonly KEY_CREATE_BUTTON: string = TRANSLATE("organizationalUnit.new");
   readonly KEY_REFRESH_BUTTON: string = TRANSLATE("organizationalUnit.refresh");
+  readonly KEY_BACK_BUTTON: string | undefined = undefined;
 
   constructor(protected store: Store,
               protected _changeDetector: ChangeDetectorRef) {
diff --git a/src/app/shared/components/routables/shared-abstract-list/shared-abstract-list.routable.html b/src/app/shared/components/routables/shared-abstract-list/shared-abstract-list.routable.html
index 6d0d1bb45..d6a5ae0c7 100644
--- a/src/app/shared/components/routables/shared-abstract-list/shared-abstract-list.routable.html
+++ b/src/app/shared/components/routables/shared-abstract-list/shared-abstract-list.routable.html
@@ -1,5 +1,13 @@
 <div class="host">
   <div class="button-toolbar">
+    <button *ngIf="KEY_BACK_BUTTON"
+            mat-button
+            color="accent"
+            (click)="back()"
+    >
+      <mat-icon>navigate_before</mat-icon>
+      {{KEY_BACK_BUTTON | translate}}
+    </button>
     <button mat-flat-button
             color="primary"
             *ngIf="options.canCreate"
diff --git a/src/app/shared/components/routables/shared-abstract-list/shared-abstract-list.routable.ts b/src/app/shared/components/routables/shared-abstract-list/shared-abstract-list.routable.ts
index 4f2b59cf5..923aa4e34 100644
--- a/src/app/shared/components/routables/shared-abstract-list/shared-abstract-list.routable.ts
+++ b/src/app/shared/components/routables/shared-abstract-list/shared-abstract-list.routable.ts
@@ -8,6 +8,7 @@ import {DataTableColumns} from "@app/shared/models/data-table-columns.model";
 import {StoreRouteLocalUtil} from "@app/shared/utils/store-route-local.util";
 import {Navigate} from "@ngxs/router-plugin";
 import {Store} from "@ngxs/store";
+import {RoutesEnum} from "@shared/enums/routes.enum";
 import {Observable} from "rxjs";
 import {
   QueryParameters,
@@ -26,6 +27,7 @@ export abstract class SharedAbstractListRoutable<TResourceModel, UResourceStateM
   columns: DataTableColumns<TResourceModel>[];
   abstract readonly KEY_CREATE_BUTTON: string;
   abstract readonly KEY_REFRESH_BUTTON: string;
+  abstract readonly KEY_BACK_BUTTON: string | undefined;
 
   protected constructor(protected store: Store,
                         protected _changeDetector: ChangeDetectorRef,
@@ -69,6 +71,10 @@ export abstract class SharedAbstractListRoutable<TResourceModel, UResourceStateM
     this.store.dispatch(ResourceActionHelper.changeQueryParameters(this.resourceNameSpace, queryParameters, true));
     this._changeDetector.detectChanges(); // Allow to display spinner the first time
   }
+
+  back(): void {
+    this.store.dispatch(new Navigate([RoutesEnum.admin]));
+  }
 }
 
 export interface SharedAbstractListRoutableOption {
diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json
index e40e8b7c3..81a0d07fc 100644
--- a/src/assets/i18n/de.json
+++ b/src/assets/i18n/de.json
@@ -21,6 +21,9 @@
     }
   },
   "admin": {
+    "button": {
+      "goBackToAdminHome": "Back"
+    },
     "funding-agencies": {
       "button": {
         "delete": "Delete",
diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json
index e40e8b7c3..81a0d07fc 100644
--- a/src/assets/i18n/en.json
+++ b/src/assets/i18n/en.json
@@ -21,6 +21,9 @@
     }
   },
   "admin": {
+    "button": {
+      "goBackToAdminHome": "Back"
+    },
     "funding-agencies": {
       "button": {
         "delete": "Delete",
diff --git a/src/assets/i18n/fr.json b/src/assets/i18n/fr.json
index 429336da0..1c8a69633 100644
--- a/src/assets/i18n/fr.json
+++ b/src/assets/i18n/fr.json
@@ -21,6 +21,9 @@
     }
   },
   "admin": {
+    "button": {
+      "goBackToAdminHome": "Retour"
+    },
     "funding-agencies": {
       "button": {
         "delete": "Supprimer",
-- 
GitLab