Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Task/migrate rule settings dialog from ngModel to form control (#7037)
Thomas Kaul06863c7bec7a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c88d9b69c8..632ad73305 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Improved the styling of the tabs across various dialogs- Improved the styling of the page tabs component on desktop- Enabled the _Bull Dashboard_ tab in the admin control panel (experimental)+- Migrated the settings dialog to customize the rule thresholds of the _X-ray_ page from `ngModel` to form control- Improved the language localization for Spanish (`es`)- Upgraded `bull-board` from version `7.1.5` to `7.2.1`- Upgraded `date-fns` from version `4.1.0` to `4.4.0`diff --git a/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.component.ts b/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.component.tsindex 5c2f3be790..74cc80f269 100644--- a/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.component.ts+++ b/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.component.ts@@ -1,8 +1,7 @@-import { XRayRulesSettings } from '@ghostfolio/common/interfaces';import { GfValueComponent } from '@ghostfolio/ui/value';-import { Component, Inject } from '@angular/core';-import { FormsModule } from '@angular/forms';+import { ChangeDetectionStrategy, Component, Inject } from '@angular/core';+import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms';import { MatButtonModule } from '@angular/material/button';import {MAT_DIALOG_DATA,@@ -14,22 +13,37 @@ import { MatSliderModule } from '@angular/material/slider';import { RuleSettingsDialogParams } from './interfaces/interfaces';@Component({+ changeDetection: ChangeDetectionStrategy.OnPush,imports: [- FormsModule,GfValueComponent,MatButtonModule,MatDialogModule,- MatSliderModule+ MatSliderModule,+ ReactiveFormsModule],selector: 'gf-rule-settings-dialog',styleUrls: ['./rule-settings-dialog.scss'],templateUrl: './rule-settings-dialog.html'})export class GfRuleSettingsDialogComponent {- public settings: XRayRulesSettings['AccountClusterRiskCurrentInvestment'];+ public settingsForm: FormGroup;public constructor(@Inject(MAT_DIALOG_DATA) public data: RuleSettingsDialogParams,- public dialogRef: MatDialogRef<GfRuleSettingsDialogComponent>- ) {}+ public dialogRef: MatDialogRef<GfRuleSettingsDialogComponent>,+ private formBuilder: FormBuilder+ ) {+ this.settingsForm = this.formBuilder.group({+ thresholdMax: [this.data.settings.thresholdMax],+ thresholdMin: [this.data.settings.thresholdMin]+ });+ }++ public onSubmit() {+ this.dialogRef.close({+ ...this.data.settings,+ thresholdMax: this.settingsForm.get('thresholdMax')?.value,+ thresholdMin: this.settingsForm.get('thresholdMin')?.value+ });+ }}diff --git a/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.html b/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.htmlindex c88a9dc9d9..d81a3c1f39 100644--- a/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.html+++ b/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.html@@ -1,132 +1,142 @@<div mat-dialog-title>{{ data.categoryName }} › {{ data.rule.name }}</div>-<div class="py-3" mat-dialog-content>- @if (- data.rule.configuration.thresholdMin && data.rule.configuration.thresholdMax- ) {- <div class="w-100">- <h6 class="d-flex mb-0">- <ng-container i18n>Threshold range</ng-container>:- <gf-value- class="ml-1"- [isPercent]="data.rule.configuration.threshold.unit === '%'"- [locale]="data.locale"- [precision]="2"- [value]="data.settings.thresholdMin"- />- <span class="mx-1">-</span>- <gf-value- [isPercent]="data.rule.configuration.threshold.unit === '%'"- [locale]="data.locale"- [precision]="2"- [value]="data.settings.thresholdMax"- />- </h6>- <div class="align-items-center d-flex w-100">- <gf-value- [isPercent]="data.rule.configuration.threshold.unit === '%'"- [locale]="data.locale"- [precision]="2"- [value]="data.rule.configuration.threshold.min"- />- <mat-slider- class="flex-grow-1"- [max]="data.rule.configuration.threshold.max"- [min]="data.rule.configuration.threshold.min"- [step]="data.rule.configuration.threshold.step"- >- <input matSliderStartThumb [(ngModel)]="data.settings.thresholdMin" />- <input matSliderEndThumb [(ngModel)]="data.settings.thresholdMax" />- </mat-slider>- <gf-value- [isPercent]="data.rule.configuration.threshold.unit === '%'"- [locale]="data.locale"- [precision]="2"- [value]="data.rule.configuration.threshold.max"- />+<form+ class="d-flex flex-column h-100"+ [formGroup]="settingsForm"+ (ngSubmit)="onSubmit()"+>+ <div class="py-3" mat-dialog-content>+ @if (+ data.rule.configuration.thresholdMin &&+ data.rule.configuration.thresholdMax+ ) {+ <div class="w-100">+ <h6 class="d-flex mb-0">+ <ng-container i18n>Threshold range</ng-container>:+ <gf-value+ class="ml-1"+ [isPercent]="data.rule.configuration.threshold.unit === '%'"+ [locale]="data.locale"+ [precision]="2"+ [value]="settingsForm.get('thresholdMin').value"+ />+ <span class="mx-1">-</span>+ <gf-value+ [isPercent]="data.rule.configuration.threshold.unit === '%'"+ [locale]="data.locale"+ [precision]="2"+ [value]="settingsForm.get('thresholdMax').value"+ />+ </h6>+ <div class="align-items-center d-flex w-100">+ <gf-value+ [isPercent]="data.rule.configuration.threshold.unit === '%'"+ [locale]="data.locale"+ [precision]="2"+ [value]="data.rule.configuration.threshold.min"+ />+ <mat-slider+ class="flex-grow-1"+ [max]="data.rule.configuration.threshold.max"+ [min]="data.rule.configuration.threshold.min"+ [step]="data.rule.configuration.threshold.step"+ >+ <input formControlName="thresholdMin" matSliderStartThumb />+ <input formControlName="thresholdMax" matSliderEndThumb />+ </mat-slider>+ <gf-value+ [isPercent]="data.rule.configuration.threshold.unit === '%'"+ [locale]="data.locale"+ [precision]="2"+ [value]="data.rule.configuration.threshold.max"+ />+ </div></div>- </div>- } @else {- <div class="w-100" [class.d-none]="!data.rule.configuration.thresholdMin">- <h6 class="d-flex mb-0">- <ng-container i18n>Threshold Min</ng-container>:- <gf-value- class="ml-1"- [isPercent]="data.rule.configuration.threshold.unit === '%'"- [locale]="data.locale"- [precision]="2"- [value]="data.settings.thresholdMin"- />- </h6>- <div class="align-items-center d-flex w-100">- <gf-value- [isPercent]="data.rule.configuration.threshold.unit === '%'"- [locale]="data.locale"- [precision]="2"- [value]="data.rule.configuration.threshold.min"- />- <mat-slider- class="flex-grow-1"- name="thresholdMin"- [max]="data.rule.configuration.threshold.max"- [min]="data.rule.configuration.threshold.min"- [step]="data.rule.configuration.threshold.step"- >- <input matSliderThumb [(ngModel)]="data.settings.thresholdMin" />- </mat-slider>- <gf-value- [isPercent]="data.rule.configuration.threshold.unit === '%'"- [locale]="data.locale"- [precision]="2"- [value]="data.rule.configuration.threshold.max"- />+ } @else {+ <div class="w-100" [class.d-none]="!data.rule.configuration.thresholdMin">+ <h6 class="d-flex mb-0">+ <ng-container i18n>Threshold Min</ng-container>:+ <gf-value+ class="ml-1"+ [isPercent]="data.rule.configuration.threshold.unit === '%'"+ [locale]="data.locale"+ [precision]="2"+ [value]="settingsForm.get('thresholdMin').value"+ />+ </h6>+ <div class="align-items-center d-flex w-100">+ <gf-value+ [isPercent]="data.rule.configuration.threshold.unit === '%'"+ [locale]="data.locale"+ [precision]="2"+ [value]="data.rule.configuration.threshold.min"+ />+ <mat-slider+ class="flex-grow-1"+ name="thresholdMin"+ [max]="data.rule.configuration.threshold.max"+ [min]="data.rule.configuration.threshold.min"+ [step]="data.rule.configuration.threshold.step"+ >+ <input formControlName="thresholdMin" matSliderThumb />+ </mat-slider>+ <gf-value+ [isPercent]="data.rule.configuration.threshold.unit === '%'"+ [locale]="data.locale"+ [precision]="2"+ [value]="data.rule.configuration.threshold.max"+ />+ </div></div>- </div>- <div class="w-100" [class.d-none]="!data.rule.configuration.thresholdMax">- <h6 class="d-flex mb-0">- <ng-container i18n>Threshold Max</ng-container>:- <gf-value- class="ml-1"- [isPercent]="data.rule.configuration.threshold.unit === '%'"- [locale]="data.locale"- [precision]="2"- [value]="data.settings.thresholdMax"- />- </h6>- <div class="align-items-center d-flex w-100">- <gf-value- [isPercent]="data.rule.configuration.threshold.unit === '%'"- [locale]="data.locale"- [precision]="2"- [value]="data.rule.configuration.threshold.min"- />- <mat-slider- class="flex-grow-1"- name="thresholdMax"- [max]="data.rule.configuration.threshold.max"- [min]="data.rule.configuration.threshold.min"- [step]="data.rule.configuration.threshold.step"- >- <input matSliderThumb [(ngModel)]="data.settings.thresholdMax" />- </mat-slider>- <gf-value- [isPercent]="data.rule.configuration.threshold.unit === '%'"- [locale]="data.locale"- [precision]="2"- [value]="data.rule.configuration.threshold.max"- />+ <div class="w-100" [class.d-none]="!data.rule.configuration.thresholdMax">+ <h6 class="d-flex mb-0">+ <ng-container i18n>Threshold Max</ng-container>:+ <gf-value+ class="ml-1"+ [isPercent]="data.rule.configuration.threshold.unit === '%'"+ [locale]="data.locale"+ [precision]="2"+ [value]="settingsForm.get('thresholdMax').value"+ />+ </h6>+ <div class="align-items-center d-flex w-100">+ <gf-value+ [isPercent]="data.rule.configuration.threshold.unit === '%'"+ [locale]="data.locale"+ [precision]="2"+ [value]="data.rule.configuration.threshold.min"+ />+ <mat-slider+ class="flex-grow-1"+ name="thresholdMax"+ [max]="data.rule.configuration.threshold.max"+ [min]="data.rule.configuration.threshold.min"+ [step]="data.rule.configuration.threshold.step"+ >+ <input formControlName="thresholdMax" matSliderThumb />+ </mat-slider>+ <gf-value+ [isPercent]="data.rule.configuration.threshold.unit === '%'"+ [locale]="data.locale"+ [precision]="2"+ [value]="data.rule.configuration.threshold.max"+ />+ </div></div>- </div>- }-</div>+ }+ </div>-<div align="end" mat-dialog-actions>- <button i18n mat-button (click)="dialogRef.close()">Close</button>- <button- color="primary"- mat-flat-button- (click)="dialogRef.close(data.settings)"- >- <ng-container i18n>Save</ng-container>- </button>-</div>+ <div align="end" mat-dialog-actions>+ <button mat-button type="button" (click)="dialogRef.close()">+ <ng-container i18n>Close</ng-container>+ </button>+ <button+ color="primary"+ mat-flat-button+ type="submit"+ [disabled]="!settingsForm.dirty"+ >+ <ng-container i18n>Save</ng-container>+ </button>+ </div>+</form>