From 06863c7bec7a63f8aa283922c5f13abd075b1038 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sun, 14 Jun 2026 19:07:16 +0200 Subject: [PATCH] Task/migrate rule settings dialog from ngModel to form control (#7037) * Migrate from ngModel to form control * Update changelog --- CHANGELOG.md | 1 + .../rule-settings-dialog.component.ts | 30 +- .../rule-settings-dialog.html | 262 +++++++++--------- 3 files changed, 159 insertions(+), 134 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c88d9b69c..632ad7330 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.ts index 5c2f3be79..74cc80f26 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 - ) {} + public dialogRef: MatDialogRef, + 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.html index c88a9dc9d..d81a3c1f3 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 @@
{{ data.categoryName }} › {{ data.rule.name }}
-
- @if ( - data.rule.configuration.thresholdMin && data.rule.configuration.thresholdMax - ) { -
-
- Threshold range: - - - - -
-
- - - - - - +
+
+ @if ( + data.rule.configuration.thresholdMin && + data.rule.configuration.thresholdMax + ) { +
+
+ Threshold range: + + - + +
+
+ + + + + + +
-
- } @else { -
-
- Threshold Min: - -
-
- - - - - + } @else { +
+
+ Threshold Min: + +
+
+ + + + + +
-
-
-
- Threshold Max: - -
-
- - - - - +
+
+ Threshold Max: + +
+
+ + + + + +
-
- } -
+ } +
-
- - -
+
+ + +
+