Browse Source

feat(client): enforce encapsulation

pull/7195/head
KenTandrian 2 weeks ago
parent
commit
39fc567f8f
  1. 80
      apps/client/src/app/pages/accounts/accounts-page.component.ts

80
apps/client/src/app/pages/accounts/accounts-page.component.ts

@ -25,7 +25,7 @@ import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router, RouterModule } from '@angular/router'; import { ActivatedRoute, Router, RouterModule } from '@angular/router';
import { Account as AccountModel } from '@prisma/client'; import { Account as AccountModel } from '@prisma/client';
import { DeviceDetectorService } from 'ngx-device-detector'; import { DeviceDetectorService } from 'ngx-device-detector';
import { EMPTY, Subscription } from 'rxjs'; import { EMPTY } from 'rxjs';
import { catchError } from 'rxjs/operators'; import { catchError } from 'rxjs/operators';
import { GfCreateOrUpdateAccountDialogComponent } from './create-or-update-account-dialog/create-or-update-account-dialog.component'; import { GfCreateOrUpdateAccountDialogComponent } from './create-or-update-account-dialog/create-or-update-account-dialog.component';
@ -41,16 +41,16 @@ import { GfTransferBalanceDialogComponent } from './transfer-balance/transfer-ba
templateUrl: './accounts-page.html' templateUrl: './accounts-page.html'
}) })
export class GfAccountsPageComponent implements OnInit { export class GfAccountsPageComponent implements OnInit {
public accounts: AccountModel[]; protected accounts: AccountModel[];
public activitiesCount = 0; protected activitiesCount = 0;
public deviceType: string; protected hasImpersonationId: boolean;
public hasImpersonationId: boolean; protected hasPermissionToCreateAccount: boolean;
public hasPermissionToCreateAccount: boolean; protected hasPermissionToUpdateAccount: boolean;
public hasPermissionToUpdateAccount: boolean; protected totalBalanceInBaseCurrency = 0;
public routeQueryParams: Subscription; protected totalValueInBaseCurrency = 0;
public totalBalanceInBaseCurrency = 0; protected user: User;
public totalValueInBaseCurrency = 0;
public user: User; private deviceType: string;
public constructor( public constructor(
private changeDetectorRef: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
@ -124,32 +124,7 @@ export class GfAccountsPageComponent implements OnInit {
this.fetchAccounts(); this.fetchAccounts();
} }
public fetchAccounts() { protected onDeleteAccount(aId: string) {
this.dataService
.fetchAccounts()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(
({
accounts,
activitiesCount,
totalBalanceInBaseCurrency,
totalValueInBaseCurrency
}) => {
this.accounts = accounts;
this.activitiesCount = activitiesCount;
this.totalBalanceInBaseCurrency = totalBalanceInBaseCurrency;
this.totalValueInBaseCurrency = totalValueInBaseCurrency;
if (this.accounts?.length <= 0) {
this.router.navigate([], { queryParams: { createDialog: true } });
}
this.changeDetectorRef.markForCheck();
}
);
}
public onDeleteAccount(aId: string) {
this.reset(); this.reset();
this.dataService this.dataService
@ -165,19 +140,44 @@ export class GfAccountsPageComponent implements OnInit {
}); });
} }
public onTransferBalance() { protected onTransferBalance() {
this.router.navigate([], { this.router.navigate([], {
queryParams: { transferBalanceDialog: true } queryParams: { transferBalanceDialog: true }
}); });
} }
public onUpdateAccount(aAccount: AccountModel) { protected onUpdateAccount(aAccount: AccountModel) {
this.router.navigate([], { this.router.navigate([], {
queryParams: { accountId: aAccount.id, editDialog: true } queryParams: { accountId: aAccount.id, editDialog: true }
}); });
} }
public openUpdateAccountDialog({ private fetchAccounts() {
this.dataService
.fetchAccounts()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(
({
accounts,
activitiesCount,
totalBalanceInBaseCurrency,
totalValueInBaseCurrency
}) => {
this.accounts = accounts;
this.activitiesCount = activitiesCount;
this.totalBalanceInBaseCurrency = totalBalanceInBaseCurrency;
this.totalValueInBaseCurrency = totalValueInBaseCurrency;
if (this.accounts?.length <= 0) {
this.router.navigate([], { queryParams: { createDialog: true } });
}
this.changeDetectorRef.markForCheck();
}
);
}
private openUpdateAccountDialog({
balance, balance,
comment, comment,
currency, currency,

Loading…
Cancel
Save