Browse Source

fix(client): modernize home holdings component

pull/7302/head
KenTandrian 4 days ago
parent
commit
92585495f9
  1. 43
      apps/client/src/app/components/home-holdings/home-holdings.component.ts

43
apps/client/src/app/components/home-holdings/home-holdings.component.ts

@ -20,6 +20,7 @@ import {
Component, Component,
CUSTOM_ELEMENTS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA,
DestroyRef, DestroyRef,
inject,
OnInit OnInit
} from '@angular/core'; } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
@ -53,32 +54,32 @@ import { DeviceDetectorService } from 'ngx-device-detector';
export class GfHomeHoldingsComponent implements OnInit { export class GfHomeHoldingsComponent implements OnInit {
public static DEFAULT_HOLDINGS_VIEW_MODE: HoldingsViewMode = 'TABLE'; public static DEFAULT_HOLDINGS_VIEW_MODE: HoldingsViewMode = 'TABLE';
public deviceType: string; protected deviceType: string;
public hasImpersonationId: boolean; protected hasImpersonationId: boolean;
public hasPermissionToAccessHoldingsChart: boolean; protected hasPermissionToAccessHoldingsChart: boolean;
public hasPermissionToCreateActivity: boolean; protected hasPermissionToCreateActivity: boolean;
public holdings: PortfolioPosition[]; protected holdings: PortfolioPosition[];
public holdingType: HoldingType = 'ACTIVE'; protected holdingType: HoldingType = 'ACTIVE';
public holdingTypeOptions: ToggleOption[] = [ protected readonly holdingTypeOptions: ToggleOption[] = [
{ label: $localize`Active`, value: 'ACTIVE' }, { label: $localize`Active`, value: 'ACTIVE' },
{ label: $localize`Closed`, value: 'CLOSED' } { label: $localize`Closed`, value: 'CLOSED' }
]; ];
public routerLinkPortfolioActivities = protected readonly routerLinkPortfolioActivities =
internalRoutes.portfolio.subRoutes.activities.routerLink; internalRoutes.portfolio.subRoutes.activities.routerLink;
public user: User; protected user: User;
public viewModeFormControl = new FormControl<HoldingsViewMode>( protected readonly viewModeFormControl = new FormControl<HoldingsViewMode>(
GfHomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE GfHomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE
); );
public constructor( private readonly changeDetectorRef = inject(ChangeDetectorRef);
private changeDetectorRef: ChangeDetectorRef, private readonly dataService = inject(DataService);
private dataService: DataService, private readonly destroyRef = inject(DestroyRef);
private destroyRef: DestroyRef, private readonly deviceDetectorService = inject(DeviceDetectorService);
private deviceDetectorService: DeviceDetectorService, private readonly impersonationStorageService = inject(ImpersonationStorageService);
private impersonationStorageService: ImpersonationStorageService, private readonly router = inject(Router);
private router: Router, private readonly userService = inject(UserService);
private userService: UserService
) { public constructor() {
addIcons({ gridOutline, reorderFourOutline }); addIcons({ gridOutline, reorderFourOutline });
} }
@ -139,13 +140,13 @@ export class GfHomeHoldingsComponent implements OnInit {
}); });
} }
public onChangeHoldingType(aHoldingType: HoldingType) { protected onChangeHoldingType(aHoldingType: HoldingType) {
this.holdingType = aHoldingType; this.holdingType = aHoldingType;
this.initialize(); this.initialize();
} }
public onHoldingClicked({ dataSource, symbol }: AssetProfileIdentifier) { protected onHoldingClicked({ dataSource, symbol }: AssetProfileIdentifier) {
if (dataSource && symbol) { if (dataSource && symbol) {
this.router.navigate([], { this.router.navigate([], {
queryParams: { dataSource, symbol, holdingDetailDialog: true } queryParams: { dataSource, symbol, holdingDetailDialog: true }

Loading…
Cancel
Save