Browse Source

Refactoring

pull/3636/head
Thomas Kaul 1 year ago
parent
commit
ec68ba69d3
  1. 19
      apps/client/src/app/pages/portfolio/activities/import-activities-dialog/import-activities-dialog.component.ts
  2. 8
      apps/client/src/app/pages/portfolio/activities/import-activities-dialog/import-activities-dialog.html

19
apps/client/src/app/pages/portfolio/activities/import-activities-dialog/import-activities-dialog.component.ts

@ -38,6 +38,7 @@ import { ImportActivitiesDialogParams } from './interfaces/interfaces';
export class ImportActivitiesDialog implements OnDestroy { export class ImportActivitiesDialog implements OnDestroy {
public accounts: CreateAccountDto[] = []; public accounts: CreateAccountDto[] = [];
public activities: Activity[] = []; public activities: Activity[] = [];
public assetProfileForm: FormGroup;
public dataSource: MatTableDataSource<Activity>; public dataSource: MatTableDataSource<Activity>;
public details: any[] = []; public details: any[] = [];
public deviceType: string; public deviceType: string;
@ -53,7 +54,6 @@ export class ImportActivitiesDialog implements OnDestroy {
public sortDirection: SortDirection = 'desc'; public sortDirection: SortDirection = 'desc';
public stepperOrientation: StepperOrientation; public stepperOrientation: StepperOrientation;
public totalItems: number; public totalItems: number;
public uniqueAssetForm: FormGroup;
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
@ -73,8 +73,8 @@ export class ImportActivitiesDialog implements OnDestroy {
this.stepperOrientation = this.stepperOrientation =
this.deviceType === 'mobile' ? 'vertical' : 'horizontal'; this.deviceType === 'mobile' ? 'vertical' : 'horizontal';
this.uniqueAssetForm = this.formBuilder.group({ this.assetProfileForm = this.formBuilder.group({
uniqueAsset: [undefined, Validators.required] assetProfileIdentifier: [undefined, Validators.required]
}); });
if ( if (
@ -85,7 +85,7 @@ export class ImportActivitiesDialog implements OnDestroy {
this.dialogTitle = $localize`Import Dividends`; this.dialogTitle = $localize`Import Dividends`;
this.mode = 'DIVIDEND'; this.mode = 'DIVIDEND';
this.uniqueAssetForm.get('uniqueAsset').disable(); this.assetProfileForm.get('assetProfileIdentifier').disable();
this.dataService this.dataService
.fetchPortfolioHoldings({ .fetchPortfolioHoldings({
@ -102,7 +102,7 @@ export class ImportActivitiesDialog implements OnDestroy {
this.holdings = sortBy(holdings, ({ name }) => { this.holdings = sortBy(holdings, ({ name }) => {
return name.toLowerCase(); return name.toLowerCase();
}); });
this.uniqueAssetForm.get('uniqueAsset').enable(); this.assetProfileForm.get('assetProfileIdentifier').enable();
this.isLoading = false; this.isLoading = false;
@ -167,10 +167,11 @@ export class ImportActivitiesDialog implements OnDestroy {
} }
public onLoadDividends(aStepper: MatStepper) { public onLoadDividends(aStepper: MatStepper) {
this.uniqueAssetForm.get('uniqueAsset').disable(); this.assetProfileForm.get('assetProfileIdentifier').disable();
const { dataSource, symbol } = const { dataSource, symbol } = this.assetProfileForm.get(
this.uniqueAssetForm.get('uniqueAsset').value; 'assetProfileIdentifier'
).value;
this.dataService this.dataService
.fetchDividendsImport({ .fetchDividendsImport({
@ -193,7 +194,7 @@ export class ImportActivitiesDialog implements OnDestroy {
this.details = []; this.details = [];
this.errorMessages = []; this.errorMessages = [];
this.importStep = ImportStep.SELECT_ACTIVITIES; this.importStep = ImportStep.SELECT_ACTIVITIES;
this.uniqueAssetForm.get('uniqueAsset').enable(); this.assetProfileForm.get('assetProfileIdentifier').enable();
aStepper.reset(); aStepper.reset();
} }

8
apps/client/src/app/pages/portfolio/activities/import-activities-dialog/import-activities-dialog.html

@ -25,14 +25,14 @@
<div class="pt-3"> <div class="pt-3">
@if (mode === 'DIVIDEND') { @if (mode === 'DIVIDEND') {
<form <form
[formGroup]="uniqueAssetForm" [formGroup]="assetProfileForm"
(ngSubmit)="onLoadDividends(stepper)" (ngSubmit)="onLoadDividends(stepper)"
> >
<mat-form-field appearance="outline" class="w-100"> <mat-form-field appearance="outline" class="w-100">
<mat-label i18n>Holding</mat-label> <mat-label i18n>Holding</mat-label>
<mat-select formControlName="uniqueAsset"> <mat-select formControlName="assetProfileIdentifier">
<mat-select-trigger>{{ <mat-select-trigger>{{
uniqueAssetForm.get('uniqueAsset')?.value?.name assetProfileForm.get('assetProfileIdentifier')?.value?.name
}}</mat-select-trigger> }}</mat-select-trigger>
@for (holding of holdings; track holding) { @for (holding of holdings; track holding) {
<mat-option <mat-option
@ -63,7 +63,7 @@
color="primary" color="primary"
mat-flat-button mat-flat-button
type="submit" type="submit"
[disabled]="!uniqueAssetForm.valid" [disabled]="!assetProfileForm.valid"
> >
<span i18n>Load Dividends</span> <span i18n>Load Dividends</span>
</button> </button>

Loading…
Cancel
Save