From 931a8021e046f43faf066c9b5563481eef76c7dc Mon Sep 17 00:00:00 2001 From: Roland Sams Date: Mon, 22 Jan 2024 13:40:06 +0100 Subject: [PATCH] cleanup --- .../anschriften-edit.component.ts | 4 +- .../anschriften-overview.component.ts | 6 +- .../instrumente-editor.component.ts | 4 +- .../instrumente-overview.component.ts | 8 +- .../noten-editor/noten-editor.component.ts | 4 +- .../noten-overview.component.ts | 10 +- .../notenmappe-edit.component.ts | 10 +- .../notenmappe-noten-list.component.ts | 8 +- .../notenmappen-overview.component.ts | 6 +- .../ui-naming-config.component.ts | 6 +- .../rollen-edit/rollen-edit.component.ts | 4 +- .../kassabuch-details.component.ts | 4 +- .../kassabuch-edit.component.ts | 4 +- .../kassabuchung-edit.component.ts | 4 +- .../kassabuecher-overview.component.ts | 4 +- .../gruppe-edit/gruppe-edit.component.ts | 4 +- .../gruppe-mitglieder-list.component.ts | 2 +- .../gruppen-overview.component.ts | 6 +- .../mitglieder-overview.component.ts | 10 +- .../mitglieder-edit.component.ts | 6 +- .../termin-details.component.ts | 4 +- .../termin-edit/termin-edit.component.ts | 8 +- .../termine-overview.component.ts | 20 +-- .../visible-for-permission.directive.ts | 4 +- src/app/guards/route.guard.ts | 6 +- src/app/models/User.ts | 2 +- src/app/services/app-config.service.ts | 23 ++-- .../services/authentication/user.service.ts | 10 +- src/app/services/menu.service.ts | 48 +++---- .../instrumente-list-config.class.ts | 2 +- .../mkj-date-input.component.ts | 125 +++++------------- .../mkj-toolbar/mkj-toolbar.component.html | 13 -- .../mkj-toolbar/mkj-toolbar.component.scss | 11 -- .../mkj-toolbar/mkj-toolbar.service.ts | 8 +- 34 files changed, 159 insertions(+), 239 deletions(-) diff --git a/src/app/components/anschriften/anschriften-edit/anschriften-edit.component.ts b/src/app/components/anschriften/anschriften-edit/anschriften-edit.component.ts index 740a17b1..03057598 100644 --- a/src/app/components/anschriften/anschriften-edit/anschriften-edit.component.ts +++ b/src/app/components/anschriften/anschriften-edit/anschriften-edit.component.ts @@ -2,7 +2,7 @@ import { Component } from "@angular/core"; import { FormControl, FormGroup } from "@angular/forms"; import { ActivatedRoute, Router } from "@angular/router"; import { Anschrift } from "src/app/models/Anschrift"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { AnschriftenApiService } from "src/app/services/api/anschriften-api.service"; import { InfoService } from "src/app/services/info.service"; import { AbstractFormComponent } from "src/app/utilities/form-components/_abstract-form-component.class"; @@ -36,7 +36,7 @@ export class AnschriftEditComponent extends AbstractFormComponent { label: "Adresse Löschen", icon: "pi pi-trash", click: () => this.delete(), - permissions: [PermissionMap.ANSCHRIFTEN_DELETE], + permissions: [PermissionKey.ANSCHRIFTEN_DELETE], }, ]; } else { diff --git a/src/app/components/anschriften/anschriften-overview/anschriften-overview.component.ts b/src/app/components/anschriften/anschriften-overview/anschriften-overview.component.ts index 12a501bb..3347b76e 100644 --- a/src/app/components/anschriften/anschriften-overview/anschriften-overview.component.ts +++ b/src/app/components/anschriften/anschriften-overview/anschriften-overview.component.ts @@ -1,7 +1,7 @@ import { Component } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; import { Anschrift } from "src/app/models/Anschrift"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { UserService } from "src/app/services/authentication/user.service"; import { AnschriftenListConfig } from "src/app/utilities/_list-configurations/anschriften-list-config.class"; import { AnschriftenListDatasource } from "src/app/utilities/_list-datasources/anschriften-list-datasource.class"; @@ -31,13 +31,13 @@ export class AnschriftenOverviewComponent { this.router.navigate(["new"], { relativeTo: this.route, }), - permissions: [PermissionMap.ANSCHRIFTEN_SAVE], + permissions: [PermissionKey.ANSCHRIFTEN_SAVE], }, ]; } public navigateToEdit(item: Anschrift): void { - if (this.userServie.hasPermission(PermissionMap.ANSCHRIFTEN_SAVE)) { + if (this.userServie.hasPermission(PermissionKey.ANSCHRIFTEN_SAVE)) { this.router.navigate([item.id], { relativeTo: this.route, }); diff --git a/src/app/components/archiv/instrumente/instrumente-editor/instrumente-editor.component.ts b/src/app/components/archiv/instrumente/instrumente-editor/instrumente-editor.component.ts index bd59504a..543f8e69 100644 --- a/src/app/components/archiv/instrumente/instrumente-editor/instrumente-editor.component.ts +++ b/src/app/components/archiv/instrumente/instrumente-editor/instrumente-editor.component.ts @@ -4,7 +4,7 @@ import { ActivatedRoute, Router } from "@angular/router"; import { UiDropdownOption } from "src/app/interfaces/UiConfigurations"; import { Instrument } from "src/app/models/Instrument"; import { Mitglied } from "src/app/models/Mitglied"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { GruppenApiService } from "src/app/services/api/gruppen-api.service"; import { InstrumenteApiService } from "src/app/services/api/instrumente-api.service"; import { InfoService } from "src/app/services/info.service"; @@ -67,7 +67,7 @@ export class InstrumenteEditorComponent label: "Instrument Löschen", icon: "pi pi-trash", click: () => this.delete(), - permissions: [PermissionMap.INSTRUMENTE_DELETE], + permissions: [PermissionKey.INSTRUMENTE_DELETE], }, ]; } else { diff --git a/src/app/components/archiv/instrumente/instrumente-overview/instrumente-overview.component.ts b/src/app/components/archiv/instrumente/instrumente-overview/instrumente-overview.component.ts index c9000ce3..bd29679a 100644 --- a/src/app/components/archiv/instrumente/instrumente-overview/instrumente-overview.component.ts +++ b/src/app/components/archiv/instrumente/instrumente-overview/instrumente-overview.component.ts @@ -1,7 +1,7 @@ import { Component } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; import { Instrument } from "src/app/models/Instrument"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { AppConfigService } from "src/app/services/app-config.service"; import { UserService } from "src/app/services/authentication/user.service"; import { InstrumenteListConfig } from "src/app/utilities/_list-configurations/instrumente-list-config.class"; @@ -24,19 +24,19 @@ export class InstrumenteOverviewComponent { toolbarService: MkjToolbarService, configService: AppConfigService ) { - toolbarService.header = configService.appNaming.Instrumente; + toolbarService.header = configService.uiNaming.Instrumente; toolbarService.buttons = [ { icon: "pi pi-plus", label: "Neu", - permissions: [PermissionMap.INSTRUMENTE_SAVE], + permissions: [PermissionKey.INSTRUMENTE_SAVE], click: () => this.navigateEditor(), }, ]; } public navigateEditor(instrument?: Instrument): void { - if (!this.userService.hasPermission(PermissionMap.INSTRUMENTE_SAVE)) + if (!this.userService.hasPermission(PermissionKey.INSTRUMENTE_SAVE)) return; this.router.navigate([instrument?.id ?? "new"], { relativeTo: this.route, diff --git a/src/app/components/archiv/noten/noten-editor/noten-editor.component.ts b/src/app/components/archiv/noten/noten-editor/noten-editor.component.ts index 5dc36670..5ed7abc0 100644 --- a/src/app/components/archiv/noten/noten-editor/noten-editor.component.ts +++ b/src/app/components/archiv/noten/noten-editor/noten-editor.component.ts @@ -2,7 +2,7 @@ import { Component } from "@angular/core"; import { FormControl, FormGroup, Validators } from "@angular/forms"; import { ActivatedRoute, Router } from "@angular/router"; import { Noten, NotenGattungMap } from "src/app/models/Noten"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { NotenApiService } from "src/app/services/api/noten-api.service"; import { InfoService } from "src/app/services/info.service"; import { AbstractFormComponent } from "src/app/utilities/form-components/_abstract-form-component.class"; @@ -40,7 +40,7 @@ export class NotenEditorComponent extends AbstractFormComponent { label: "Mappe Löschen", icon: "pi pi-trash", click: () => this.delete(), - permissions: [PermissionMap.NOTEN_DELETE], + permissions: [PermissionKey.NOTEN_DELETE], }, ]; } else { diff --git a/src/app/components/archiv/noten/noten-overview/noten-overview.component.ts b/src/app/components/archiv/noten/noten-overview/noten-overview.component.ts index b0e7898d..ccaf21df 100644 --- a/src/app/components/archiv/noten/noten-overview/noten-overview.component.ts +++ b/src/app/components/archiv/noten/noten-overview/noten-overview.component.ts @@ -1,7 +1,7 @@ import { Component } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; import { Noten } from "src/app/models/Noten"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { AppConfigService } from "src/app/services/app-config.service"; import { UserService } from "src/app/services/authentication/user.service"; import { NotenListConfig } from "src/app/utilities/_list-configurations/noten-list-config.class"; @@ -15,7 +15,7 @@ import { MkjToolbarService } from "src/app/utilities/mkj-toolbar/mkj-toolbar.ser providers: [NotenListDatasource, NotenListConfig], }) export class NotenOverviewComponent { - public readonly PermissionMap = PermissionMap; + public readonly PermissionMap = PermissionKey; constructor( public datasource: NotenListDatasource, @@ -26,19 +26,19 @@ export class NotenOverviewComponent { private namingService: AppConfigService, private userService: UserService ) { - this.toolbarService.header = this.namingService.appNaming.Noten; + this.toolbarService.header = this.namingService.uiNaming.Noten; this.toolbarService.buttons = [ { icon: "pi pi-plus", label: "Neu", - permissions: [PermissionMap.NOTEN_SAVE], + permissions: [PermissionKey.NOTEN_SAVE], click: () => this.navigateToEditView(), }, ]; } public navigateToEditView(noten?: Noten) { - if (!this.userService.hasPermission(PermissionMap.NOTEN_SAVE)) { + if (!this.userService.hasPermission(PermissionKey.NOTEN_SAVE)) { return; } this.router.navigate([noten?.id ?? "new"], { relativeTo: this.route }); diff --git a/src/app/components/archiv/notenmappen/notenmappe-edit/notenmappe-edit.component.ts b/src/app/components/archiv/notenmappen/notenmappe-edit/notenmappe-edit.component.ts index 009f003c..fe8c0575 100644 --- a/src/app/components/archiv/notenmappen/notenmappe-edit/notenmappe-edit.component.ts +++ b/src/app/components/archiv/notenmappen/notenmappe-edit/notenmappe-edit.component.ts @@ -2,7 +2,7 @@ import { Component } from "@angular/core"; import { FormControl, FormGroup, Validators } from "@angular/forms"; import { ActivatedRoute, Router } from "@angular/router"; import { Notenmappe } from "src/app/models/Noten"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { NotenmappenApiService } from "src/app/services/api/notenmappen-api.service"; import { InfoService } from "src/app/services/info.service"; import { AbstractFormComponent } from "src/app/utilities/form-components/_abstract-form-component.class"; @@ -13,7 +13,7 @@ import { MkjToolbarService } from "src/app/utilities/mkj-toolbar/mkj-toolbar.ser templateUrl: "./notenmappe-edit.component.html", }) export class NotenmappeEditComponent extends AbstractFormComponent { - public readonly Permission = PermissionMap; + public readonly Permission = PermissionKey; public editMode: boolean = false; constructor( @@ -54,8 +54,8 @@ export class NotenmappeEditComponent extends AbstractFormComponent { this.toolbarService.buttons[0].highlighted = this.editMode; }, permissions: [ - PermissionMap.NOTENMAPPE_SAVE, - PermissionMap.NOTENMAPPE_ASSIGN, + PermissionKey.NOTENMAPPE_SAVE, + PermissionKey.NOTENMAPPE_ASSIGN, ], }, { @@ -63,7 +63,7 @@ export class NotenmappeEditComponent extends AbstractFormComponent { icon: "pi pi-trash", hidden: this.getId() === "new", click: () => this.delete(), - permissions: [PermissionMap.NOTENMAPPE_DELETE], + permissions: [PermissionKey.NOTENMAPPE_DELETE], }, ]; } diff --git a/src/app/components/archiv/notenmappen/notenmappe-noten-list/notenmappe-noten-list.component.ts b/src/app/components/archiv/notenmappen/notenmappe-noten-list/notenmappe-noten-list.component.ts index 5115a2ea..bd5e8138 100644 --- a/src/app/components/archiv/notenmappen/notenmappe-noten-list/notenmappe-noten-list.component.ts +++ b/src/app/components/archiv/notenmappen/notenmappe-noten-list/notenmappe-noten-list.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnChanges, SimpleChanges } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; import { Noten } from "src/app/models/Noten"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { NotenmappenApiService } from "src/app/services/api/notenmappen-api.service"; import { AppConfigService } from "src/app/services/app-config.service"; import { UserService } from "src/app/services/authentication/user.service"; @@ -31,7 +31,7 @@ export class NotenmappeNotenListComponent implements OnChanges { public readonly hasAssignPermission: boolean = false; public readonly hasSavePermission: boolean = false; - public readonly PermissionMap = PermissionMap; + public readonly PermissionMap = PermissionKey; public selectedNoten: Noten; public listDatasource: MappeNotenListDatasource; @@ -49,10 +49,10 @@ export class NotenmappeNotenListComponent implements OnChanges { private route: ActivatedRoute ) { this.hasAssignPermission = this.userService.hasPermission( - PermissionMap.NOTENMAPPE_ASSIGN + PermissionKey.NOTENMAPPE_ASSIGN ); this.hasSavePermission = this.userService.hasPermission( - PermissionMap.NOTEN_SAVE + PermissionKey.NOTEN_SAVE ); } diff --git a/src/app/components/archiv/notenmappen/notenmappen-overview/notenmappen-overview.component.ts b/src/app/components/archiv/notenmappen/notenmappen-overview/notenmappen-overview.component.ts index af9321e8..8dfaa6a3 100644 --- a/src/app/components/archiv/notenmappen/notenmappen-overview/notenmappen-overview.component.ts +++ b/src/app/components/archiv/notenmappen/notenmappen-overview/notenmappen-overview.component.ts @@ -1,7 +1,7 @@ import { Component } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; import { Notenmappe } from "src/app/models/Noten"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { AppConfigService } from "src/app/services/app-config.service"; import { NotenmappeListDatasource } from "src/app/utilities/_list-datasources/notenmappe-list-datasource.class"; import { MkjToolbarService } from "src/app/utilities/mkj-toolbar/mkj-toolbar.service"; @@ -19,13 +19,13 @@ export class NotenmappenOverviewComponent { private toolbarService: MkjToolbarService, configService: AppConfigService ) { - this.toolbarService.header = configService.appNaming.Notenmappen; + this.toolbarService.header = configService.uiNaming.Notenmappen; this.toolbarService.buttons = [ { icon: "pi pi-plus", click: () => this.navigateToNotenmappe(), label: "Neue Mappe", - permissions: [PermissionMap.NOTENMAPPE_SAVE], + permissions: [PermissionKey.NOTENMAPPE_SAVE], }, ]; } diff --git a/src/app/components/einstellungen/globale-einstellungen/ui-naming-config/ui-naming-config.component.ts b/src/app/components/einstellungen/globale-einstellungen/ui-naming-config/ui-naming-config.component.ts index 76636627..2f67f551 100644 --- a/src/app/components/einstellungen/globale-einstellungen/ui-naming-config/ui-naming-config.component.ts +++ b/src/app/components/einstellungen/globale-einstellungen/ui-naming-config/ui-naming-config.component.ts @@ -8,12 +8,12 @@ import { AppConfigService } from "src/app/services/app-config.service"; styleUrls: ["./ui-naming-config.component.scss"], }) export class UiNamingConfigComponent { - public readonly appNaming = _.cloneDeep(this.configService.appNaming); - public readonly editNaming = _.cloneDeep(this.configService.appNaming); + public readonly appNaming = _.cloneDeep(this.configService.uiNaming); + public readonly editNaming = _.cloneDeep(this.configService.uiNaming); constructor(private configService: AppConfigService) {} public updateNaming(): void { - this.configService.updateAppNamingConfig(this.editNaming); + this.configService.saveUiNamingConfig(this.editNaming); } } diff --git a/src/app/components/einstellungen/rollen-edit/rollen-edit.component.ts b/src/app/components/einstellungen/rollen-edit/rollen-edit.component.ts index e378bb6b..2f09f210 100644 --- a/src/app/components/einstellungen/rollen-edit/rollen-edit.component.ts +++ b/src/app/components/einstellungen/rollen-edit/rollen-edit.component.ts @@ -1,5 +1,5 @@ import { ConfirmationService } from "primeng/api"; -import { Permission, PermissionMap, Role } from "../../../models/User"; +import { Permission, PermissionKey, Role } from "../../../models/User"; import { RolesApiService } from "../../../services/api/roles-api.service"; import { Component, OnInit } from "@angular/core"; import { UserService } from "src/app/services/authentication/user.service"; @@ -42,7 +42,7 @@ export class RollenEditComponent implements OnInit { this.addDialogVisible = true; }, icon: "pi pi-plus", - permissions: [PermissionMap.ROLE_SAVE], + permissions: [PermissionKey.ROLE_SAVE], }, ]; } diff --git a/src/app/components/finanzen/kassabuch-details/kassabuch-details.component.ts b/src/app/components/finanzen/kassabuch-details/kassabuch-details.component.ts index 6e0fe801..614876d7 100644 --- a/src/app/components/finanzen/kassabuch-details/kassabuch-details.component.ts +++ b/src/app/components/finanzen/kassabuch-details/kassabuch-details.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; import { BehaviorSubject } from "rxjs"; import { Kassabuch } from "src/app/models/Kassabuch"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { KassabuchApiService } from "src/app/services/api/kassabuch-api.service"; import { MkjToolbarService } from "src/app/utilities/mkj-toolbar/mkj-toolbar.service"; @@ -37,7 +37,7 @@ export class KassabuchDetailsComponent implements OnInit { ], { relativeTo: this.route } ), - permissions: [PermissionMap.KASSABUCH_SAVE], + permissions: [PermissionKey.KASSABUCH_SAVE], }, ]; } diff --git a/src/app/components/finanzen/kassabuch-edit/kassabuch-edit.component.ts b/src/app/components/finanzen/kassabuch-edit/kassabuch-edit.component.ts index 140e1253..969fbb77 100644 --- a/src/app/components/finanzen/kassabuch-edit/kassabuch-edit.component.ts +++ b/src/app/components/finanzen/kassabuch-edit/kassabuch-edit.component.ts @@ -3,7 +3,7 @@ import { FormControl, FormGroup } from "@angular/forms"; import { ActivatedRoute, Router } from "@angular/router"; import { UiDropdownOption } from "src/app/interfaces/UiConfigurations"; import { Kassabuch } from "src/app/models/Kassabuch"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { GruppenApiService } from "src/app/services/api/gruppen-api.service"; import { KassabuchApiService } from "src/app/services/api/kassabuch-api.service"; import { InfoService } from "src/app/services/info.service"; @@ -49,7 +49,7 @@ export class KassabuchEditComponent extends AbstractFormComponent { click: () => { this.delete(); }, - permissions: [PermissionMap.KASSABUCH_DELETE], + permissions: [PermissionKey.KASSABUCH_DELETE], }, ]; } diff --git a/src/app/components/finanzen/kassabuchung-edit/kassabuchung-edit.component.ts b/src/app/components/finanzen/kassabuchung-edit/kassabuchung-edit.component.ts index 753e43c2..087c60a4 100644 --- a/src/app/components/finanzen/kassabuchung-edit/kassabuchung-edit.component.ts +++ b/src/app/components/finanzen/kassabuchung-edit/kassabuchung-edit.component.ts @@ -8,7 +8,7 @@ import { import { ActivatedRoute, Router } from "@angular/router"; import { UtilFunctions } from "src/app/helpers/util-functions"; import { Kassabuchung, KassabuchungTyp } from "src/app/models/Kassabuch"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { KassabuchungenApiService } from "src/app/services/api/kassabuchungen-api.service"; import { InfoService } from "src/app/services/info.service"; import { AbstractFormComponent } from "src/app/utilities/form-components/_abstract-form-component.class"; @@ -58,7 +58,7 @@ export class KassabuchungEditComponent extends AbstractFormComponent { this.delete(); }, - permissions: [PermissionMap.KASSABUCHUNG_DELETE], + permissions: [PermissionKey.KASSABUCHUNG_DELETE], }, ]; } diff --git a/src/app/components/finanzen/kassabuecher-overview/kassabuecher-overview.component.ts b/src/app/components/finanzen/kassabuecher-overview/kassabuecher-overview.component.ts index 950e2efd..c8a8eb95 100644 --- a/src/app/components/finanzen/kassabuecher-overview/kassabuecher-overview.component.ts +++ b/src/app/components/finanzen/kassabuecher-overview/kassabuecher-overview.component.ts @@ -1,7 +1,7 @@ import { Component } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; import { Kassabuch } from "src/app/models/Kassabuch"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { KassabuchListDatasource } from "src/app/utilities/_list-datasources/kassabuch-list-datasource"; import { MkjToolbarService } from "src/app/utilities/mkj-toolbar/mkj-toolbar.service"; @@ -27,7 +27,7 @@ export class KassabuecherComponent { relativeTo: this.route, }); }, - permissions: [PermissionMap.KASSABUCH_SAVE], + permissions: [PermissionKey.KASSABUCH_SAVE], }, ]; } diff --git a/src/app/components/gruppen/gruppe-edit/gruppe-edit.component.ts b/src/app/components/gruppen/gruppe-edit/gruppe-edit.component.ts index 44dba7f9..1c4c4b8e 100644 --- a/src/app/components/gruppen/gruppe-edit/gruppe-edit.component.ts +++ b/src/app/components/gruppen/gruppe-edit/gruppe-edit.component.ts @@ -2,7 +2,7 @@ import { Component } from "@angular/core"; import { FormControl, FormGroup, Validators } from "@angular/forms"; import { ActivatedRoute, Router } from "@angular/router"; import { Gruppe } from "src/app/models/Gruppe"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { GruppenApiService } from "src/app/services/api/gruppen-api.service"; import { InfoService } from "src/app/services/info.service"; import { MitgliedAutoCompleteConfigiguration } from "src/app/utilities/_autocomplete-configurations/mitglied-autocomplete-config.class"; @@ -52,7 +52,7 @@ export class GruppeEditComponent extends AbstractFormComponent { icon: "pi pi-trash", hidden: this.getId() === "new", click: () => this.delete(), - permissions: [PermissionMap.GRUPPEN_DELETE], + permissions: [PermissionKey.GRUPPEN_DELETE], }, ]; } diff --git a/src/app/components/gruppen/gruppe-mitglieder-list/gruppe-mitglieder-list.component.ts b/src/app/components/gruppen/gruppe-mitglieder-list/gruppe-mitglieder-list.component.ts index a66a013c..3e35236e 100644 --- a/src/app/components/gruppen/gruppe-mitglieder-list/gruppe-mitglieder-list.component.ts +++ b/src/app/components/gruppen/gruppe-mitglieder-list/gruppe-mitglieder-list.component.ts @@ -19,7 +19,7 @@ export class GruppeMitgliederListComponent implements OnChanges { public gruppeId: string; public listDatasource: GruppeMitgliederListDatasource; - public listConfig = new GruppeMitgliederListConfig(); + public readonly listConfig = new GruppeMitgliederListConfig(); public selectedMitglied: Mitglied; public tableLocked: boolean = false; diff --git a/src/app/components/gruppen/gruppen-overview/gruppen-overview.component.ts b/src/app/components/gruppen/gruppen-overview/gruppen-overview.component.ts index 456b6dcb..1d7a1983 100644 --- a/src/app/components/gruppen/gruppen-overview/gruppen-overview.component.ts +++ b/src/app/components/gruppen/gruppen-overview/gruppen-overview.component.ts @@ -1,7 +1,7 @@ import { Component } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; import { Gruppe } from "src/app/models/Gruppe"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { AppConfigService } from "src/app/services/app-config.service"; import { GruppeListDatasource } from "src/app/utilities/_list-datasources/gruppe-list-datasource.class"; import { MkjToolbarService } from "src/app/utilities/mkj-toolbar/mkj-toolbar.service"; @@ -20,12 +20,12 @@ export class GruppenOverviewComponent { private route: ActivatedRoute, configService: AppConfigService ) { - this.toolbarService.header = configService.appNaming.Gruppen; + this.toolbarService.header = configService.uiNaming.Gruppen; this.toolbarService.buttons = [ { label: "Neue Gruppe", icon: "pi pi-plus", - permissions: [PermissionMap.GRUPPEN_SAVE], + permissions: [PermissionKey.GRUPPEN_SAVE], click: () => this.navigateDetails(), }, ]; diff --git a/src/app/components/mitglieder/mitglied-overview/mitglieder-overview.component.ts b/src/app/components/mitglieder/mitglied-overview/mitglieder-overview.component.ts index c71a33b5..8757bb74 100644 --- a/src/app/components/mitglieder/mitglied-overview/mitglieder-overview.component.ts +++ b/src/app/components/mitglieder/mitglied-overview/mitglieder-overview.component.ts @@ -1,7 +1,7 @@ import { Component } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; import { Mitglied } from "src/app/models/Mitglied"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { AppConfigService } from "src/app/services/app-config.service"; import { UserService } from "src/app/services/authentication/user.service"; import { MitgliederListConfig } from "src/app/utilities/_list-configurations/mitglieder-list-config.class"; @@ -15,7 +15,7 @@ import { MkjToolbarService } from "src/app/utilities/mkj-toolbar/mkj-toolbar.ser providers: [MitgliederListDatasource, MitgliederListConfig], }) export class MitgliederOverviewComponent { - public readonly PermissionMap = PermissionMap; + public readonly PermissionMap = PermissionKey; constructor( public datasource: MitgliederListDatasource, @@ -26,19 +26,19 @@ export class MitgliederOverviewComponent { private userService: UserService, appconfig: AppConfigService ) { - this.toolbarService.header = appconfig.appNaming.Mitglieder; + this.toolbarService.header = appconfig.uiNaming.Mitglieder; this.toolbarService.buttons = [ { icon: "pi pi-plus", click: () => this.navigateSingleMitglied(), label: "Neu", - permissions: [PermissionMap.MITGLIEDER_SAVE], + permissions: [PermissionKey.MITGLIEDER_SAVE], }, ]; } public navigateSingleMitglied(mitglied?: Mitglied) { - if (this.userService.hasPermissionNot(PermissionMap.MITGLIEDER_SAVE)) + if (this.userService.hasPermissionNot(PermissionKey.MITGLIEDER_SAVE)) return; this.router.navigate(["../" + (mitglied?.id ?? "new")], { relativeTo: this.route, diff --git a/src/app/components/mitglieder/mitglieder-edit/mitglieder-edit.component.ts b/src/app/components/mitglieder/mitglieder-edit/mitglieder-edit.component.ts index 516a66fe..e6f8bc1b 100644 --- a/src/app/components/mitglieder/mitglieder-edit/mitglieder-edit.component.ts +++ b/src/app/components/mitglieder/mitglieder-edit/mitglieder-edit.component.ts @@ -3,7 +3,7 @@ import { FormControl, FormGroup, Validators } from "@angular/forms"; import { ActivatedRoute, Router } from "@angular/router"; import { ConfirmationService } from "primeng/api"; import { Mitglied, MitgliedGeschlechtMap } from "src/app/models/Mitglied"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { UserService } from "src/app/services/authentication/user.service"; import { InfoService } from "src/app/services/info.service"; import { AbstractFormComponent } from "src/app/utilities/form-components/_abstract-form-component.class"; @@ -36,7 +36,7 @@ export class MitgliederEditComponent extends AbstractFormComponent { super(toolbarService, apiService, infoService, route, router); this.canAssignRoles = this.userService.hasPermission( - PermissionMap.ROLE_ASSIGN + PermissionKey.ROLE_ASSIGN ); } @@ -51,7 +51,7 @@ export class MitgliederEditComponent extends AbstractFormComponent { { icon: "pi pi-trash", click: () => this.deleteMitglied(), - permissions: [PermissionMap.MITGLIEDER_DELETE], + permissions: [PermissionKey.MITGLIEDER_DELETE], label: "Löschen", }, ]; diff --git a/src/app/components/termine/termin-details/termin-details.component.ts b/src/app/components/termine/termin-details/termin-details.component.ts index 5623f99c..73e58549 100644 --- a/src/app/components/termine/termin-details/termin-details.component.ts +++ b/src/app/components/termine/termin-details/termin-details.component.ts @@ -13,7 +13,7 @@ import { ExportService } from "../../../services/export.service"; import { NotenListDatasource } from "src/app/utilities/_list-datasources/noten-list-datasource.class"; import { NotenAutoCompleteConfigiguration } from "src/app/utilities/_autocomplete-configurations/noten-autocomplete-config.class"; import { AppConfigService } from "src/app/services/app-config.service"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; @Component({ selector: "app-termin-details", @@ -82,7 +82,7 @@ export class TerminDetailsComponent implements OnInit { { icon: "pi pi-pencil", label: "Bearbeiten", - permissions: [PermissionMap.TERMIN_SAVE], + permissions: [PermissionKey.TERMIN_SAVE], click: () => this.router.navigate(["../../", this.termin.id], { relativeTo: this.route, diff --git a/src/app/components/termine/termin-edit/termin-edit.component.ts b/src/app/components/termine/termin-edit/termin-edit.component.ts index c6732841..48708fce 100644 --- a/src/app/components/termine/termin-edit/termin-edit.component.ts +++ b/src/app/components/termine/termin-edit/termin-edit.component.ts @@ -3,7 +3,7 @@ import { FormControl, FormGroup, Validators } from "@angular/forms"; import { ActivatedRoute, Router } from "@angular/router"; import moment from "moment"; import { Termin, TerminStatusMap } from "src/app/models/Termin"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { GruppenApiService } from "src/app/services/api/gruppen-api.service"; import { TermineApiService } from "src/app/services/api/termine-api.service"; import { AppConfigService } from "src/app/services/app-config.service"; @@ -63,7 +63,7 @@ export class TerminEditComponent extends AbstractFormComponent { icon: "pi pi-trash", hidden: this.getId() === "new", click: () => this.delete(), - permissions: [PermissionMap.TERMIN_DELETE], + permissions: [PermissionKey.TERMIN_DELETE], }, ]; } @@ -145,9 +145,9 @@ export class TerminEditComponent extends AbstractFormComponent { let gruppenleiterMitgliedId = null; if ( this.userService.hasPermission( - PermissionMap.TERMIN_GRUPPENLEITER_SAVE + PermissionKey.TERMIN_GRUPPENLEITER_SAVE ) && - this.userService.hasPermissionNot(PermissionMap.TERMIN_SAVE) + this.userService.hasPermissionNot(PermissionKey.TERMIN_SAVE) ) { gruppenleiterMitgliedId = this.userService.currentMitglied.getValue().id; diff --git a/src/app/components/termine/termine-overview/termine-overview.component.ts b/src/app/components/termine/termine-overview/termine-overview.component.ts index 1d636813..cdac1bba 100644 --- a/src/app/components/termine/termine-overview/termine-overview.component.ts +++ b/src/app/components/termine/termine-overview/termine-overview.component.ts @@ -6,7 +6,7 @@ import { MenuItem } from "primeng/api"; import { Menu } from "primeng/menu"; import { GetListInput } from "src/app/interfaces/api-middleware"; import { Termin } from "src/app/models/Termin"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { MkjDatePipe } from "src/app/pipes/mkj-date.pipe"; import { TermineApiService } from "src/app/services/api/termine-api.service"; import { AppConfigService } from "src/app/services/app-config.service"; @@ -41,7 +41,7 @@ export class TermineOverviewComponent { label: "Duplizieren", icon: "pi pi-copy", visible: this.userService.hasOneOfPermissions([ - PermissionMap.TERMIN_SAVE, + PermissionKey.TERMIN_SAVE, ]), command: () => this.duplicateAusrueckung(this.selectedRow), }, @@ -49,8 +49,8 @@ export class TermineOverviewComponent { label: "Bearbeiten", icon: "pi pi-pencil", visible: this.userService.hasOneOfPermissions([ - PermissionMap.TERMIN_SAVE, - PermissionMap.TERMIN_GRUPPENLEITER_SAVE, + PermissionKey.TERMIN_SAVE, + PermissionKey.TERMIN_GRUPPENLEITER_SAVE, ]), command: () => this.navigateEditor(this.selectedRow), }, @@ -88,19 +88,19 @@ export class TermineOverviewComponent { public toolbarService: MkjToolbarService ) { this.hasAktionenPermissions = this.userService.hasOneOfPermissions([ - PermissionMap.TERMIN_SAVE, - PermissionMap.TERMIN_GRUPPENLEITER_SAVE, - PermissionMap.TERMIN_DELETE, + PermissionKey.TERMIN_SAVE, + PermissionKey.TERMIN_GRUPPENLEITER_SAVE, + PermissionKey.TERMIN_DELETE, ]); - this.toolbarService.header = this.namingService.appNaming.Termine; + this.toolbarService.header = this.namingService.uiNaming.Termine; this.toolbarService.buttons = [ { icon: "pi pi-plus", click: () => this.navigateEditor(), label: "Neu", permissions: [ - PermissionMap.TERMIN_SAVE, - PermissionMap.TERMIN_GRUPPENLEITER_SAVE, + PermissionKey.TERMIN_SAVE, + PermissionKey.TERMIN_GRUPPENLEITER_SAVE, ], }, // { diff --git a/src/app/directives/visible-for-permission.directive.ts b/src/app/directives/visible-for-permission.directive.ts index 95912de3..11374481 100644 --- a/src/app/directives/visible-for-permission.directive.ts +++ b/src/app/directives/visible-for-permission.directive.ts @@ -7,6 +7,7 @@ import { ViewContainerRef, } from "@angular/core"; import { UserService } from "../services/authentication/user.service"; +import { PermissionKey } from "../models/User"; @Directive({ selector: "[visibleFor]", @@ -28,7 +29,8 @@ export class VisibleForPermissionDirective implements OnDestroy { .subscribe({ next: () => { permissions.forEach((r) => { - if (this.userService.hasPermission(r)) isVisible = true; + if (this.userService.hasPermission(r as PermissionKey)) + isVisible = true; }); if (isVisible) { this.viewContainer.createEmbeddedView(this.templateRef); diff --git a/src/app/guards/route.guard.ts b/src/app/guards/route.guard.ts index bb2279a8..3b44d0e6 100644 --- a/src/app/guards/route.guard.ts +++ b/src/app/guards/route.guard.ts @@ -4,6 +4,7 @@ import { Observable } from "rxjs"; import { MenuService } from "../services/menu.service"; import { environment } from "src/environments/environment"; import { UserService } from "../services/authentication/user.service"; +import { PermissionKey } from "../models/User"; @Injectable() export class RouteGuard { @@ -23,7 +24,10 @@ export class RouteGuard { const permission = item?.permission; - if (!permission || this.userService.hasPermission(permission)) { + if ( + !permission || + this.userService.hasPermission(permission as PermissionKey) + ) { return true; } else { return this.router.parseUrl(environment.prefix + "/noaccess"); diff --git a/src/app/models/User.ts b/src/app/models/User.ts index 616c7478..e1855b73 100644 --- a/src/app/models/User.ts +++ b/src/app/models/User.ts @@ -31,7 +31,7 @@ export interface Permission { updated_at?: string; } -export enum PermissionMap { +export enum PermissionKey { ANSCHRIFTEN_READ = "anschriften_read", ANSCHRIFTEN_SAVE = "anschriften_save", ANSCHRIFTEN_DELETE = "anschriften_delete", diff --git a/src/app/services/app-config.service.ts b/src/app/services/app-config.service.ts index 7763af29..775e428d 100644 --- a/src/app/services/app-config.service.ts +++ b/src/app/services/app-config.service.ts @@ -12,14 +12,14 @@ import { InfoService } from "./info.service"; providedIn: "root", }) export class AppConfigService { - private _appNaming = new BehaviorSubject(null); - public get appNaming(): UiNamingConfig { - return this._appNaming.value; + private readonly _uiConfig = new BehaviorSubject(null); + + public get uiNaming(): UiNamingConfig { + return this._uiConfig.value?.uiNaming; } - private _terminConfig = new BehaviorSubject(null); public get terminConfig(): UiTerminConfig { - return this._terminConfig.value; + return this._uiConfig.value?.terminConfig; } constructor( @@ -29,12 +29,14 @@ export class AppConfigService { public initAppNamingConfig(): Observable { return this.configService.getConfigs().pipe( - tap((config) => this.setInternalConfigs(config)), + tap((config) => this._uiConfig.next(config)), map((config) => null) ); } - public updateAppNamingConfig(naming: UiNamingConfig) { + public saveUiNamingConfig(naming: UiNamingConfig) { + if (!this._uiConfig.value) return; + const configurations: UiConfigurations = { uiNaming: naming, terminConfig: this.terminConfig, @@ -49,14 +51,9 @@ export class AppConfigService { private permitConfigs(configurations: UiConfigurations): Observable { return this.configService.saveConfigs(configurations).pipe( tap((res) => { - this.setInternalConfigs(res); + this._uiConfig.next(res); }), map((_) => null) ); } - - private setInternalConfigs(config: UiConfigurations): void { - this._appNaming.next(config.uiNaming); - this._terminConfig.next(config.terminConfig); - } } diff --git a/src/app/services/authentication/user.service.ts b/src/app/services/authentication/user.service.ts index c6a80e8f..37b98e3b 100644 --- a/src/app/services/authentication/user.service.ts +++ b/src/app/services/authentication/user.service.ts @@ -3,7 +3,7 @@ import { Observable, Subject } from "rxjs"; import { BehaviorSubject } from "rxjs/internal/BehaviorSubject"; import { Gruppe } from "src/app/models/Gruppe"; import { Mitglied } from "../../models/Mitglied"; -import { Permission, Role, User } from "../../models/User"; +import { Permission, PermissionKey, Role, User } from "../../models/User"; import { AuthAPIService } from "../api/auth-api.service"; import { TokenService } from "./token.service"; @@ -82,7 +82,7 @@ export class UserService { this.currentMitgliedGruppen.next(gruppen); } - public hasPermission(permission: string): boolean { + public hasPermission(permission: PermissionKey): boolean { if (!this.currentPermissions.getValue() || permission === null) return false; let bool = false; @@ -92,13 +92,13 @@ export class UserService { return bool; } - public hasPermissionNot(permission: any): boolean { + public hasPermissionNot(permission: PermissionKey): boolean { return !this.currentPermissions .getValue() .find((e) => e.name === permission); } - public hasOneOfPermissions(permissions: string[]): boolean { + public hasOneOfPermissions(permissions: PermissionKey[]): boolean { if (!this.currentPermissions.getValue() || !permissions) return false; let bool = false; permissions.forEach((e) => { @@ -109,7 +109,7 @@ export class UserService { return bool; } - public hasAllOfPermissions(permissions: string[]): boolean { + public hasAllOfPermissions(permissions: PermissionKey[]): boolean { if (!this.currentPermissions.getValue() || !permissions) return false; let bool = true; permissions.forEach((e) => { diff --git a/src/app/services/menu.service.ts b/src/app/services/menu.service.ts index b0fc7097..f5fda853 100644 --- a/src/app/services/menu.service.ts +++ b/src/app/services/menu.service.ts @@ -2,7 +2,7 @@ import { Injectable, OnDestroy } from "@angular/core"; import { ConfirmationService, MenuItem } from "primeng/api"; import { Subject } from "rxjs"; import { SubSink } from "subsink"; -import { Permission, PermissionMap } from "../models/User"; +import { Permission, PermissionKey } from "../models/User"; import { AuthStateService } from "./authentication/auth-state.service"; import { UserService } from "./authentication/user.service"; import { AppConfigService } from "./app-config.service"; @@ -18,7 +18,7 @@ export class MenuService implements OnDestroy { visible: false, }, { - label: this.namingService.appNaming.Termine, + label: this.namingService.uiNaming.Termine, icon: "pi pi-fw pi-calendar", enumLabel: MenuLabels.TERMINE, visible: false, @@ -36,81 +36,81 @@ export class MenuService implements OnDestroy { ], }, { - label: this.namingService.appNaming.Mitglieder, + label: this.namingService.uiNaming.Mitglieder, icon: "pi pi-fw pi-users", enumLabel: MenuLabels.MITGLIEDER, - permission: PermissionMap.MITGLIEDER_READ, + permission: PermissionKey.MITGLIEDER_READ, children: [ { - label: this.namingService.appNaming.Mitglieder, + label: this.namingService.uiNaming.Mitglieder, icon: "pi pi-users", routerLink: "mitglieder/liste", - permission: PermissionMap.MITGLIEDER_READ, + permission: PermissionKey.MITGLIEDER_READ, }, { - label: this.namingService.appNaming.Gruppen, + label: this.namingService.uiNaming.Gruppen, icon: "pi pi-folder-open", routerLink: "mitglieder/gruppen", - permission: PermissionMap.GRUPPEN_READ, + permission: PermissionKey.GRUPPEN_READ, }, ], }, { - label: this.namingService.appNaming.Archiv, + label: this.namingService.uiNaming.Archiv, icon: "mdi mdi-archive-music-outline", enumLabel: MenuLabels.ARCHIV, visible: false, - permission: PermissionMap.NOTEN_READ, + permission: PermissionKey.NOTEN_READ, children: [ { - label: this.namingService.appNaming.Noten, + label: this.namingService.uiNaming.Noten, icon: "mdi mdi-music", routerLink: "archiv/noten", visible: false, - permission: PermissionMap.NOTEN_READ, + permission: PermissionKey.NOTEN_READ, }, { - label: this.namingService.appNaming.Notenmappen, + label: this.namingService.uiNaming.Notenmappen, icon: "mdi mdi-book-music-outline", routerLink: "archiv/mappen", visible: false, - permission: PermissionMap.NOTENMAPPE_READ, + permission: PermissionKey.NOTENMAPPE_READ, }, { - label: this.namingService.appNaming.Instrumente, + label: this.namingService.uiNaming.Instrumente, icon: "mdi mdi-trumpet", routerLink: "archiv/instrumente", visible: false, - permission: PermissionMap.INSTRUMENTE_READ, + permission: PermissionKey.INSTRUMENTE_READ, }, ], }, { - label: this.namingService.appNaming.Statistiken, + label: this.namingService.uiNaming.Statistiken, icon: "pi pi-chart-line", enumLabel: MenuLabels.STATISTIK, visible: false, routerLink: "statistik", }, { - label: this.namingService.appNaming.Finanzen, + label: this.namingService.uiNaming.Finanzen, icon: "mdi mdi-currency-eur", enumLabel: MenuLabels.FINANZEN, visible: false, - permission: PermissionMap.KASSABUCH_READ, + permission: PermissionKey.KASSABUCH_READ, children: [ { label: "Kassabücher", icon: "mdi mdi-currency-eur", routerLink: "finanzen/list", - permission: PermissionMap.KASSABUCH_READ, + permission: PermissionKey.KASSABUCH_READ, visible: false, }, { label: "Adressen", icon: "pi pi-fw pi-users", routerLink: "finanzen/adressen", - permission: PermissionMap.ANSCHRIFTEN_READ, + permission: PermissionKey.ANSCHRIFTEN_READ, }, ], }, @@ -131,7 +131,7 @@ export class MenuService implements OnDestroy { icon: "mdi mdi-account-lock-open-outline", routerLink: "einstellungen/rollen", visible: false, - permission: PermissionMap.ROLE_READ, + permission: PermissionKey.ROLE_READ, }, { label: "Lokale Einstellungen", @@ -143,7 +143,7 @@ export class MenuService implements OnDestroy { label: "Globale Einstellungen", icon: "mdi mdi-cog", routerLink: "einstellungen/global", - permission: PermissionMap.USER_DELETE, + permission: PermissionKey.USER_DELETE, visible: false, }, { @@ -175,7 +175,7 @@ export class MenuService implements OnDestroy { routerLink: "test", enumLabel: MenuLabels.TEST, visible: false, - permission: PermissionMap.ROLE_ASSIGN, + permission: PermissionKey.ROLE_ASSIGN, }, ]; diff --git a/src/app/utilities/_list-configurations/instrumente-list-config.class.ts b/src/app/utilities/_list-configurations/instrumente-list-config.class.ts index cd40ab46..c62b3168 100644 --- a/src/app/utilities/_list-configurations/instrumente-list-config.class.ts +++ b/src/app/utilities/_list-configurations/instrumente-list-config.class.ts @@ -37,7 +37,7 @@ export class InstrumenteListConfig implements ListConfiguration { sortable: true, }, { - header: this.appNaming.appNaming.Gruppen, + header: this.appNaming.uiNaming.Gruppen, field: null, templateName: "gruppen", type: "value", diff --git a/src/app/utilities/form-input-components/mkj-date-input/mkj-date-input.component.ts b/src/app/utilities/form-input-components/mkj-date-input/mkj-date-input.component.ts index 38003eae..2f74830d 100644 --- a/src/app/utilities/form-input-components/mkj-date-input/mkj-date-input.component.ts +++ b/src/app/utilities/form-input-components/mkj-date-input/mkj-date-input.component.ts @@ -1,15 +1,9 @@ -import { - AfterViewInit, - Component, - EventEmitter, - Injector, - Input, - Output, -} from "@angular/core"; -import { controlValueAccessor } from "src/app/providers/control-value-accessor"; +import { AfterViewInit, Component, Injector, Input } from "@angular/core"; +import { ControlValueAccessor } from "@angular/forms"; import moment from "moment"; -import { ControlValueAccessor, FormControl, NgControl } from "@angular/forms"; import { UtilFunctions } from "src/app/helpers/util-functions"; +import { controlValueAccessor } from "src/app/providers/control-value-accessor"; +import { AbstractControlAccessor } from "../abstract-control-accessor"; export enum MkjDateType { DATE = "date", @@ -24,6 +18,7 @@ export enum MkjDateType { providers: [controlValueAccessor(MkjDateInputComponent)], }) export class MkjDateInputComponent + extends AbstractControlAccessor implements ControlValueAccessor, AfterViewInit { @Input() @@ -32,124 +27,74 @@ export class MkjDateInputComponent @Input() public label: string; - @Input() public internModel: Date | string; - - @Output() - public valueChanged = new EventEmitter(); - - public MkjDateType = MkjDateType; - - public _registerOnChange: (_: any) => void; - public _registerOnTouched: () => void; public isDisabled: boolean = false; public isDesktop: boolean = UtilFunctions.isDesktop(); public nativeModel: string; - - private _value: string | Date; - @Input() - public get value(): string | Date { - return this._value; - } - public set value(value: string | Date) { - this._value = value; - if (!value) { - this.internModel = null; - } else if (this.type === MkjDateType.TIME) { - this.internModel = value; - } else { - this.internModel = new Date(value); - } - } - - formControl: FormControl; - - constructor(private inj: Injector) {} - - ngAfterViewInit() { - this.formControl = this.inj.get(NgControl, null) - ?.control as FormControl; - } - - writeValue(obj: any): void { - if (obj) { - this.nativeModel = obj; - switch (this.type) { - case MkjDateType.DATE: - this.internModel = new Date(obj); - break; - case MkjDateType.TIME: - this.internModel = obj; - break; - case MkjDateType.COMBINED: - this.internModel = new Date(obj); - break; + public readonly MkjDateType = MkjDateType; + + constructor(inj: Injector) { + super(inj); + this.subs.sink = this.value$.subscribe((value) => { + if (value) { + this.nativeModel = value as string; + switch (this.type) { + case MkjDateType.DATE: + this.internModel = new Date(value); + break; + case MkjDateType.TIME: + this.internModel = value; + break; + case MkjDateType.COMBINED: + this.internModel = new Date(value); + break; + } + } else { + this.internModel = null; + this.nativeModel = null; } - } else { - this.internModel = null; - this.nativeModel = null; - } - } - - registerOnChange(fn: any): void { - this._registerOnChange = fn; - } - - registerOnTouched(fn: any): void { - this._registerOnTouched = fn; - } - - setDisabledState(isDisabled: boolean): void { - this.isDisabled = isDisabled; + }); } public onModelChange(newDate: Date | string) { if (!newDate) { - this.valueChanged.emit(null); - this._registerOnChange?.(null); + this.change?.(null); return; } switch (this.type) { case MkjDateType.DATE: const date = moment(newDate).format("YYYY-MM-DD"); - this.valueChanged.emit(date); - this._registerOnChange?.(date); + this.change(date); break; case MkjDateType.TIME: const time = moment(newDate).format("HH:mm"); - this.valueChanged.emit(time); - this._registerOnChange?.(time); + this.change(time); break; case MkjDateType.COMBINED: const combined = moment(newDate).format("YYYY-MM-DD HH:mm:ss"); - this.valueChanged.emit(date); - this._registerOnChange?.(combined); + this.change(combined); break; } } public onNativeModelChange(newDate: string) { if (!newDate) { - this.valueChanged.emit(null); - this._registerOnChange?.(null); + this.change(null); return; } switch (this.type) { case MkjDateType.DATE: const date = moment(newDate).format("YYYY-MM-DD"); - this.valueChanged.emit(date); - this._registerOnChange?.(date); + this.change(date); break; case MkjDateType.TIME: - this.valueChanged.emit(newDate); - this._registerOnChange?.(newDate); + this.change(newDate); break; case MkjDateType.COMBINED: const combined = moment(newDate).format("YYYY-MM-DD hh:mm:ss"); - this.valueChanged.emit(date); - this._registerOnChange?.(combined); + this.change(combined); break; } } diff --git a/src/app/utilities/mkj-toolbar/mkj-toolbar.component.html b/src/app/utilities/mkj-toolbar/mkj-toolbar.component.html index cdbf586f..590a7876 100644 --- a/src/app/utilities/mkj-toolbar/mkj-toolbar.component.html +++ b/src/app/utilities/mkj-toolbar/mkj-toolbar.component.html @@ -45,16 +45,3 @@ - -
-
- -
-
diff --git a/src/app/utilities/mkj-toolbar/mkj-toolbar.component.scss b/src/app/utilities/mkj-toolbar/mkj-toolbar.component.scss index 40e0f043..6b9760fe 100644 --- a/src/app/utilities/mkj-toolbar/mkj-toolbar.component.scss +++ b/src/app/utilities/mkj-toolbar/mkj-toolbar.component.scss @@ -21,14 +21,3 @@ color: var(--primary-color); } } - -.mkj-toolbar-content { - display: none; - -webkit-animation-duration: 0.5s; - -moz-animation-duration: 0.5s; - animation-duration: 0.5s; - - &-visible { - display: block; - } -} diff --git a/src/app/utilities/mkj-toolbar/mkj-toolbar.service.ts b/src/app/utilities/mkj-toolbar/mkj-toolbar.service.ts index 38f0dad5..0ba86aef 100644 --- a/src/app/utilities/mkj-toolbar/mkj-toolbar.service.ts +++ b/src/app/utilities/mkj-toolbar/mkj-toolbar.service.ts @@ -6,14 +6,14 @@ import { NavigationEnd, Router, } from "@angular/router"; -import { PermissionMap } from "src/app/models/User"; +import { PermissionKey } from "src/app/models/User"; import { UserService } from "src/app/services/authentication/user.service"; import { SubSink } from "subsink"; export interface MkjToolbarButton { icon: string; label?: string; - permissions?: PermissionMap[]; + permissions?: PermissionKey[]; routerLink?: string; click?: (event: MouseEvent) => void; visible?: boolean; @@ -27,8 +27,6 @@ export interface MkjToolbarButton { export class MkjToolbarService implements OnInit, OnDestroy { public backButton: boolean; public header: string; - public contentSectionExpanded: boolean; - public contentSectionTemplate: TemplateRef; public temporaryBackRoute: { backRoute: string; route: ActivatedRoute }; private _buttons: MkjToolbarButton[]; @@ -92,8 +90,6 @@ export class MkjToolbarService implements OnInit, OnDestroy { public resetToolbar(): void { this.backButton = null; this.header = null; - this.contentSectionTemplate = null; - this.contentSectionExpanded = false; this.buttons = null; }