From a82332117d7b9f0fee2e74437e1072292b131b27 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 30 Jul 2026 15:22:39 +0200 Subject: [PATCH] Migrate account dialogs to dedicated routes --- .../account-dialog-host.component.ts | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/apps/client/src/app/pages/accounts/account-dialog-host/account-dialog-host.component.ts b/apps/client/src/app/pages/accounts/account-dialog-host/account-dialog-host.component.ts index 7d473a106..79f151935 100644 --- a/apps/client/src/app/pages/accounts/account-dialog-host/account-dialog-host.component.ts +++ b/apps/client/src/app/pages/accounts/account-dialog-host/account-dialog-host.component.ts @@ -110,23 +110,16 @@ export class GfAccountDialogHostComponent implements OnDestroy, OnInit { if (mode === 'update') { if ( !account || - !hasPermission(user?.permissions, permissions.updateAccount) + !hasPermission(user?.permissions, permissions.updateAccount) || + this.isReadOnlyMode(user) ) { this.navigateBack(); return; } - const { - balance, - comment, - currency, - id, - isExcluded, - name, - platformId, - tags - } = account; + const { balance, comment, currency, id, name, platformId, tags } = + account; this.openCreateOrUpdateAccountDialog({ user, @@ -135,7 +128,6 @@ export class GfAccountDialogHostComponent implements OnDestroy, OnInit { comment, currency, id, - isExcluded, name, platformId, tags @@ -146,7 +138,10 @@ export class GfAccountDialogHostComponent implements OnDestroy, OnInit { return; } - if (!hasPermission(user?.permissions, permissions.createAccount)) { + if ( + !hasPermission(user?.permissions, permissions.createAccount) || + this.isReadOnlyMode(user) + ) { this.navigateBack(); return; @@ -159,7 +154,6 @@ export class GfAccountDialogHostComponent implements OnDestroy, OnInit { comment: null, currency: user?.settings?.baseCurrency ?? null, id: null, - isExcluded: false, name: null, platformId: null, tags: [] @@ -187,6 +181,15 @@ export class GfAccountDialogHostComponent implements OnDestroy, OnInit { this.dialogRef?.close(); } + private isReadOnlyMode(user: User) { + // Mirrors the conditions under which the accounts page offers the creation + // and the modification of an account + return ( + !!this.impersonationStorageService.getId() || + !!user?.settings?.isRestrictedView + ); + } + private navigateBack() { void this.router.navigate(internalRoutes.accounts.routerLink); } @@ -204,7 +207,7 @@ export class GfAccountDialogHostComponent implements OnDestroy, OnInit { return; } - const hasImpersonationId = !!this.impersonationStorageService.getId(); + const impersonationId = this.impersonationStorageService.getId(); const dialogRef = this.dialog.open< GfAccountDetailDialogComponent, @@ -214,10 +217,10 @@ export class GfAccountDialogHostComponent implements OnDestroy, OnInit { autoFocus: false, data: { accountId, - hasImpersonationId, + impersonationId, deviceType: this.deviceType(), hasPermissionToCreateActivity: - !hasImpersonationId && + !impersonationId && hasPermission(user?.permissions, permissions.createActivity) && !user?.settings?.isRestrictedView },