Bugfix/fix adding 'Item' and 'Liability' activities (#2119)

* Fix adding activities of type item and liability

* Update changelog
pull/2120/head
Arghya Ghosh 11 months ago committed by GitHub
parent f5180ce88f
commit 0d421e7181
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 the creation of (wealth) items and liabilities
## 1.285.0 - 2023-07-01
### Added

@ -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 (
['BUY', 'DIVIDEND', 'SELL'].includes(
this.activityForm.controls['type'].value
)
) {
this.activityForm.controls['dataSource'].setValue(
this.activityForm.controls['searchSymbol'].value.dataSource
);
@ -408,8 +412,9 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
fee: this.activityForm.controls['fee'].value,
quantity: this.activityForm.controls['quantity'].value,
symbol:
this.activityForm.controls['searchSymbol'].value.symbol === undefined ||
isUUID(this.activityForm.controls['searchSymbol'].value.symbol)
this.activityForm.controls['searchSymbol'].value?.symbol ===
undefined ||
isUUID(this.activityForm.controls['searchSymbol'].value?.symbol)
? this.activityForm.controls['name'].value
: this.activityForm.controls['searchSymbol'].value.symbol,
tags: this.activityForm.controls['tags'].value,

@ -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<T>
public _required: boolean = false;
public get required() {
return this._required;
return (
this._required ||
this.ngControl.control?.hasValidator(Validators.required)
);
}
@Input()

@ -9,7 +9,7 @@ import {
OnInit,
ViewChild
} from '@angular/core';
import { FormControl, NgControl, Validators } from '@angular/forms';
import { FormControl, NgControl } from '@angular/forms';
import {
MatAutocomplete,
MatAutocompleteSelectedEvent
@ -25,7 +25,8 @@ import {
debounceTime,
distinctUntilChanged,
filter,
switchMap
switchMap,
takeUntil
} from 'rxjs/operators';
import { AbstractMatFormField } from './abstract-mat-form-field';
@ -76,12 +77,18 @@ export class SymbolAutocompleteComponent
}
public ngOnInit() {
super.required = this.ngControl.control?.hasValidator(Validators.required);
if (this.disabled) {
this.control.disable();
}
this.control.valueChanges
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(() => {
if (super.value) {
super.value.dataSource = null;
}
});
this.control.valueChanges
.pipe(
debounceTime(400),
@ -89,6 +96,7 @@ export class SymbolAutocompleteComponent
filter((query) => {
return isString(query) && query.length > 1;
}),
takeUntil(this.unsubscribeSubject),
tap(() => {
this.isLoading = true;
@ -136,11 +144,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 +176,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 });
}
}
}

Loading…
Cancel
Save