diff --git a/libs/ui/src/lib/assistant/assistant.component.ts b/libs/ui/src/lib/assistant/assistant.component.ts index 9fa5df017..566e875c2 100644 --- a/libs/ui/src/lib/assistant/assistant.component.ts +++ b/libs/ui/src/lib/assistant/assistant.component.ts @@ -393,6 +393,13 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { })) as AccountWithValue[]; } + // Handle portfolio filter form disabled state + if (this.hasPermissionToChangeFilters) { + this.portfolioFilterFormControl.enable({ emitEvent: false }); + } else { + this.portfolioFilterFormControl.disable({ emitEvent: false }); + } + this.dateRangeOptions = [ { label: $localize`Today`, diff --git a/libs/ui/src/lib/portfolio-filter-form/portfolio-filter-form.component.ts b/libs/ui/src/lib/portfolio-filter-form/portfolio-filter-form.component.ts index 708581467..259bcf75a 100644 --- a/libs/ui/src/lib/portfolio-filter-form/portfolio-filter-form.component.ts +++ b/libs/ui/src/lib/portfolio-filter-form/portfolio-filter-form.component.ts @@ -20,6 +20,7 @@ import { ControlValueAccessor, FormBuilder, FormControl, + FormGroup, FormsModule, NG_VALUE_ACCESSOR, ReactiveFormsModule @@ -67,12 +68,7 @@ export class GfPortfolioFilterFormComponent @Output() applyFilters = new EventEmitter(); @Output() resetFilters = new EventEmitter(); - public filterForm = this.formBuilder.group({ - account: new FormControl(null), - assetClass: new FormControl(null), - holding: new FormControl(null), - tag: new FormControl(null) - }); + public filterForm: FormGroup; private onChange: (value: PortfolioFilterFormValue) => void = () => { // ControlValueAccessor callback - implemented by parent @@ -85,7 +81,15 @@ export class GfPortfolioFilterFormComponent public constructor( private changeDetectorRef: ChangeDetectorRef, private formBuilder: FormBuilder - ) {} + ) { + // Create form with initial state (will be updated in ngOnChanges) + this.filterForm = this.formBuilder.group({ + account: new FormControl(null), + assetClass: new FormControl(null), + holding: new FormControl(null), + tag: new FormControl(null) + }); + } public ngOnInit() { // Subscribe to form changes to notify parent component @@ -145,7 +149,15 @@ export class GfPortfolioFilterFormComponent public setDisabledState(isDisabled: boolean): void { this.disabled = isDisabled; - this.ngOnChanges(); + + // Update form disabled state manually since this is called by ControlValueAccessor + if (this.disabled) { + this.filterForm.disable({ emitEvent: false }); + } else { + this.filterForm.enable({ emitEvent: false }); + } + + this.changeDetectorRef.markForCheck(); } // Helper methods