Browse Source

Task/migrate tags selector component in holding detail dialog to form control (#5850)

* Migrate tags selector component to form control

* Update changelog
pull/5876/head
Kenrick Tandrian 2 days ago
committed by GitHub
parent
commit
294f1a5f11
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 21
      apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts
  3. 15
      apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html
  4. 6
      libs/ui/src/lib/tags-selector/tags-selector.component.ts

1
CHANGELOG.md

@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved the icon of the holdings tab on the home page - Improved the icon of the holdings tab on the home page
- Improved the icon of the holdings tab on the home page for the _Zen Mode_ - Improved the icon of the holdings tab on the home page for the _Zen Mode_
- Improved the icon of the holdings tab in the account detail dialog - Improved the icon of the holdings tab in the account detail dialog
- Migrated the tags selector component in the holding detail dialog to form control
- Improved the language localization for German (`de`) - Improved the language localization for German (`de`)
## 2.212.0 - 2025-10-29 ## 2.212.0 - 2025-10-29

21
apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts

@ -39,7 +39,7 @@ import {
OnDestroy, OnDestroy,
OnInit OnInit
} from '@angular/core'; } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms'; import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { MatChipsModule } from '@angular/material/chips'; import { MatChipsModule } from '@angular/material/chips';
import { import {
@ -94,6 +94,7 @@ import { HoldingDetailDialogParams } from './interfaces/interfaces';
MatFormFieldModule, MatFormFieldModule,
MatTabsModule, MatTabsModule,
NgxSkeletonLoaderModule, NgxSkeletonLoaderModule,
ReactiveFormsModule,
RouterModule RouterModule
], ],
schemas: [CUSTOM_ELEMENTS_SCHEMA], schemas: [CUSTOM_ELEMENTS_SCHEMA],
@ -103,7 +104,6 @@ import { HoldingDetailDialogParams } from './interfaces/interfaces';
}) })
export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit { export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
public activitiesCount: number; public activitiesCount: number;
public activityForm: FormGroup;
public accounts: Account[]; public accounts: Account[];
public assetClass: string; public assetClass: string;
public assetSubClass: string; public assetSubClass: string;
@ -124,6 +124,7 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
public hasPermissionToCreateOwnTag: boolean; public hasPermissionToCreateOwnTag: boolean;
public hasPermissionToReadMarketDataOfOwnAssetProfile: boolean; public hasPermissionToReadMarketDataOfOwnAssetProfile: boolean;
public historicalDataItems: LineChartItem[]; public historicalDataItems: LineChartItem[];
public holdingForm: FormGroup;
public investmentInBaseCurrencyWithCurrencyEffect: number; public investmentInBaseCurrencyWithCurrencyEffect: number;
public investmentInBaseCurrencyWithCurrencyEffectPrecision = 2; public investmentInBaseCurrencyWithCurrencyEffectPrecision = 2;
public isUUID = isUUID; public isUUID = isUUID;
@ -180,16 +181,16 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
} }
public ngOnInit() { public ngOnInit() {
this.activityForm = this.formBuilder.group({
tags: [] as string[]
});
const filters: Filter[] = [ const filters: Filter[] = [
{ id: this.data.dataSource, type: 'DATA_SOURCE' }, { id: this.data.dataSource, type: 'DATA_SOURCE' },
{ id: this.data.symbol, type: 'SYMBOL' } { id: this.data.symbol, type: 'SYMBOL' }
]; ];
this.activityForm this.holdingForm = this.formBuilder.group({
tags: [] as string[]
});
this.holdingForm
.get('tags') .get('tags')
.valueChanges.pipe(takeUntil(this.unsubscribeSubject)) .valueChanges.pipe(takeUntil(this.unsubscribeSubject))
.subscribe((tags: Tag[]) => { .subscribe((tags: Tag[]) => {
@ -430,7 +431,7 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
}; };
}); });
this.activityForm.setValue({ tags: this.tags }, { emitEvent: false }); this.holdingForm.setValue({ tags: this.tags }, { emitEvent: false });
this.value = value; this.value = value;
@ -617,10 +618,6 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
} }
} }
public onTagsChanged(tags: Tag[]) {
this.activityForm.get('tags').setValue(tags);
}
public onUpdateActivity(aActivity: Activity) { public onUpdateActivity(aActivity: Activity) {
this.router.navigate( this.router.navigate(
internalRoutes.portfolio.subRoutes.activities.routerLink, internalRoutes.portfolio.subRoutes.activities.routerLink,

15
apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html

@ -411,13 +411,14 @@
} }
</mat-tab-group> </mat-tab-group>
<gf-tags-selector <form [formGroup]="holdingForm">
[hasPermissionToCreateTag]="hasPermissionToCreateOwnTag" <gf-tags-selector
[readonly]="!data.hasPermissionToUpdateOrder" formControlName="tags"
[tags]="activityForm.get('tags')?.value" [hasPermissionToCreateTag]="hasPermissionToCreateOwnTag"
[tagsAvailable]="tagsAvailable" [readonly]="!data.hasPermissionToUpdateOrder"
(tagsChanged)="onTagsChanged($event)" [tagsAvailable]="tagsAvailable"
/> />
</form>
@if ( @if (
data.hasPermissionToAccessAdminControl || data.hasPermissionToAccessAdminControl ||

6
libs/ui/src/lib/tags-selector/tags-selector.component.ts

@ -5,12 +5,10 @@ import {
Component, Component,
CUSTOM_ELEMENTS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA,
ElementRef, ElementRef,
EventEmitter,
Input, Input,
OnChanges, OnChanges,
OnDestroy, OnDestroy,
OnInit, OnInit,
Output,
signal, signal,
ViewChild ViewChild
} from '@angular/core'; } from '@angular/core';
@ -66,8 +64,6 @@ export class GfTagsSelectorComponent
@Input() tags: Tag[]; @Input() tags: Tag[];
@Input() tagsAvailable: Tag[]; @Input() tagsAvailable: Tag[];
@Output() tagsChanged = new EventEmitter<Tag[]>();
@ViewChild('tagInput') tagInput: ElementRef<HTMLInputElement>; @ViewChild('tagInput') tagInput: ElementRef<HTMLInputElement>;
public filteredOptions: Subject<Tag[]> = new BehaviorSubject([]); public filteredOptions: Subject<Tag[]> = new BehaviorSubject([]);
@ -115,7 +111,6 @@ export class GfTagsSelectorComponent
}); });
const newTags = this.tagsSelected(); const newTags = this.tagsSelected();
this.tagsChanged.emit(newTags);
this.onChange(newTags); this.onChange(newTags);
this.onTouched(); this.onTouched();
this.tagInput.nativeElement.value = ''; this.tagInput.nativeElement.value = '';
@ -130,7 +125,6 @@ export class GfTagsSelectorComponent
}); });
const newTags = this.tagsSelected(); const newTags = this.tagsSelected();
this.tagsChanged.emit(newTags);
this.onChange(newTags); this.onChange(newTags);
this.onTouched(); this.onTouched();
this.updateFilters(); this.updateFilters();

Loading…
Cancel
Save