diff --git a/CHANGELOG.md b/CHANGELOG.md index 63bb46822..da0437cd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## UNRELEASED + +### Fixed + +- Fixed unable to Add 'Item' and 'Liability' Activities + ## 1.285.0 - 2023-07-01 ### Added diff --git a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts index 6962d4d40..ce772f5c5 100644 --- a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts +++ b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts @@ -241,7 +241,11 @@ export class CreateOrUpdateActivityDialog implements OnDestroy { this.activityForm.controls['searchSymbol'].valueChanges.subscribe(() => { if (this.activityForm.controls['searchSymbol'].invalid) { this.data.activity.SymbolProfile = null; - } else { + } else if ( + !['ITEM', 'LIABILITY'].includes( + this.activityForm.controls['type'].value + ) + ) { this.activityForm.controls['dataSource'].setValue( this.activityForm.controls['searchSymbol'].value.dataSource ); diff --git a/libs/ui/src/lib/symbol-autocomplete/abstract-mat-form-field.ts b/libs/ui/src/lib/symbol-autocomplete/abstract-mat-form-field.ts index b0ce3dc9b..38198daea 100644 --- a/libs/ui/src/lib/symbol-autocomplete/abstract-mat-form-field.ts +++ b/libs/ui/src/lib/symbol-autocomplete/abstract-mat-form-field.ts @@ -9,7 +9,7 @@ import { Input, OnDestroy } from '@angular/core'; -import { ControlValueAccessor, NgControl } from '@angular/forms'; +import { ControlValueAccessor, NgControl, Validators } from '@angular/forms'; import { MatFormFieldControl } from '@angular/material/form-field'; import { Subject } from 'rxjs'; @@ -96,7 +96,10 @@ export abstract class AbstractMatFormField public _required: boolean = false; public get required() { - return this._required; + return ( + this._required || + this.ngControl.control?.hasValidator(Validators.required) + ); } @Input() diff --git a/libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts b/libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts index ea99ab0e5..3f59f8e03 100644 --- a/libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts +++ b/libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts @@ -76,12 +76,16 @@ export class SymbolAutocompleteComponent } public ngOnInit() { - super.required = this.ngControl.control?.hasValidator(Validators.required); - if (this.disabled) { this.control.disable(); } + this.control.valueChanges.subscribe((_) => { + if (super.value) { + super.value.dataSource = null; + } + }); + this.control.valueChanges .pipe( debounceTime(400), @@ -136,11 +140,6 @@ export class SymbolAutocompleteComponent public ngDoCheck() { if (this.ngControl) { this.validateRequired(); - - if (this.control.touched) { - this.validateSelection(); - } - this.errorState = this.ngControl.invalid && this.ngControl.touched; this.stateChanges.next(); } @@ -173,13 +172,4 @@ export class SymbolAutocompleteComponent this.ngControl.control.setErrors({ invalidData: true }); } } - - private validateSelection() { - const error = - !this.isValueInOptions(this.input?.value) || - this.input?.value !== super.value?.symbol; - if (error) { - this.ngControl.control.setErrors({ invalidData: true }); - } - } }