|
|
@ -8,12 +8,14 @@ import { |
|
|
ChangeDetectionStrategy, |
|
|
ChangeDetectionStrategy, |
|
|
ChangeDetectorRef, |
|
|
ChangeDetectorRef, |
|
|
Component, |
|
|
Component, |
|
|
|
|
|
DestroyRef, |
|
|
Input, |
|
|
Input, |
|
|
OnChanges, |
|
|
OnChanges, |
|
|
OnDestroy, |
|
|
|
|
|
OnInit, |
|
|
OnInit, |
|
|
forwardRef |
|
|
forwardRef, |
|
|
|
|
|
inject |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
|
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; |
|
|
import { |
|
|
import { |
|
|
ControlValueAccessor, |
|
|
ControlValueAccessor, |
|
|
FormBuilder, |
|
|
FormBuilder, |
|
|
@ -25,7 +27,6 @@ import { |
|
|
} from '@angular/forms'; |
|
|
} from '@angular/forms'; |
|
|
import { MatFormFieldModule } from '@angular/material/form-field'; |
|
|
import { MatFormFieldModule } from '@angular/material/form-field'; |
|
|
import { MatSelectModule } from '@angular/material/select'; |
|
|
import { MatSelectModule } from '@angular/material/select'; |
|
|
import { Subject, takeUntil } from 'rxjs'; |
|
|
|
|
|
|
|
|
|
|
|
import { GfEntityLogoComponent } from '../entity-logo/entity-logo.component'; |
|
|
import { GfEntityLogoComponent } from '../entity-logo/entity-logo.component'; |
|
|
import { PortfolioFilterFormValue } from './interfaces'; |
|
|
import { PortfolioFilterFormValue } from './interfaces'; |
|
|
@ -53,7 +54,7 @@ import { PortfolioFilterFormValue } from './interfaces'; |
|
|
templateUrl: './portfolio-filter-form.component.html' |
|
|
templateUrl: './portfolio-filter-form.component.html' |
|
|
}) |
|
|
}) |
|
|
export class GfPortfolioFilterFormComponent |
|
|
export class GfPortfolioFilterFormComponent |
|
|
implements ControlValueAccessor, OnInit, OnChanges, OnDestroy |
|
|
implements ControlValueAccessor, OnInit, OnChanges |
|
|
{ |
|
|
{ |
|
|
@Input() accounts: AccountWithPlatform[] = []; |
|
|
@Input() accounts: AccountWithPlatform[] = []; |
|
|
@Input() assetClasses: Filter[] = []; |
|
|
@Input() assetClasses: Filter[] = []; |
|
|
@ -68,7 +69,7 @@ export class GfPortfolioFilterFormComponent |
|
|
tag: FormControl<string | null>; |
|
|
tag: FormControl<string | null>; |
|
|
}>; |
|
|
}>; |
|
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
private readonly destroyRef = inject(DestroyRef); |
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
@ -84,7 +85,7 @@ export class GfPortfolioFilterFormComponent |
|
|
|
|
|
|
|
|
public ngOnInit() { |
|
|
public ngOnInit() { |
|
|
this.filterForm.valueChanges |
|
|
this.filterForm.valueChanges |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((value) => { |
|
|
.subscribe((value) => { |
|
|
this.onChange(value as PortfolioFilterFormValue); |
|
|
this.onChange(value as PortfolioFilterFormValue); |
|
|
this.onTouched(); |
|
|
this.onTouched(); |
|
|
@ -166,11 +167,6 @@ export class GfPortfolioFilterFormComponent |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
|
|
|
this.unsubscribeSubject.next(); |
|
|
|
|
|
this.unsubscribeSubject.complete(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
private onChange = (_value: PortfolioFilterFormValue): void => { |
|
|
private onChange = (_value: PortfolioFilterFormValue): void => { |
|
|
// ControlValueAccessor onChange callback
|
|
|
// ControlValueAccessor onChange callback
|
|
|
|