Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Task/add value components to rule settings dialog (#5653)

Malay Kumard71514329935
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9ad8f22675..4a58a725c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
+- Localized the number formatting in the settings dialog to customize the rule thresholds of the _X-ray_ page
- Improved the usability of the _Cancel_ / _Close_ buttons in the create watchlist item dialog
- Refactored the `fireWealth` from `number` type to a structured object in the summary of the portfolio details endpoint
- Refactored the _Open Startup_ (`/open`) page to standalone
diff --git a/apps/client/src/app/components/rule/rule-settings-dialog/interfaces/interfaces.ts b/apps/client/src/app/components/rule/rule-settings-dialog/interfaces/interfaces.ts
index 9811a65643..51c2b89514 100644
--- a/apps/client/src/app/components/rule/rule-settings-dialog/interfaces/interfaces.ts
+++ b/apps/client/src/app/components/rule/rule-settings-dialog/interfaces/interfaces.ts
@@ -5,6 +5,7 @@ import {
export interface IRuleSettingsDialogParams {
categoryName: string;
+ locale: string;
rule: PortfolioReportRule;
settings: XRayRulesSettings['AccountClusterRiskCurrentInvestment'];
}
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 7ee9c66cf4..f8ce13e0d9 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,4 +1,5 @@
import { XRayRulesSettings } from '@ghostfolio/common/interfaces';
+import { GfValueComponent } from '@ghostfolio/ui/value';
import { CommonModule } from '@angular/common';
import { Component, Inject } from '@angular/core';
@@ -17,6 +18,7 @@ import { IRuleSettingsDialogParams } from './interfaces/interfaces';
imports: [
CommonModule,
FormsModule,
+ GfValueComponent,
MatButtonModule,
MatDialogModule,
MatSliderModule
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 9fdc0cd57c..83d4e2d19c 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
@@ -5,28 +5,30 @@
data.rule.configuration.thresholdMin && data.rule.configuration.thresholdMax
) {
<div class="w-100">
- <h6 class="mb-0">
+ <h6 class="d-flex mb-0">
<ng-container i18n>Threshold range</ng-container>:
- @if (data.rule.configuration.threshold.unit === '%') {
- {{ data.settings.thresholdMin | percent: '1.2-2' }}
- } @else {
- {{ data.settings.thresholdMin }}
- }
- -
- @if (data.rule.configuration.threshold.unit === '%') {
- {{ data.settings.thresholdMax | percent: '1.2-2' }}
- } @else {
- {{ data.settings.thresholdMax }}
- }
+ <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">
- @if (data.rule.configuration.threshold.unit === '%') {
- <label>{{
- data.rule.configuration.threshold.min | percent: '1.2-2'
- }}</label>
- } @else {
- <label>{{ data.rule.configuration.threshold.min }}</label>
- }
+ <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"
@@ -36,13 +38,12 @@
<input matSliderStartThumb [(ngModel)]="data.settings.thresholdMin" />
<input matSliderEndThumb [(ngModel)]="data.settings.thresholdMax" />
</mat-slider>
- @if (data.rule.configuration.threshold.unit === '%') {
- <label>{{
- data.rule.configuration.threshold.max | percent: '1.2-2'
- }}</label>
- } @else {
- <label>{{ data.rule.configuration.threshold.max }}</label>
- }
+ <gf-value
+ [isPercent]="data.rule.configuration.threshold.unit === '%'"
+ [locale]="data.locale"
+ [precision]="2"
+ [value]="data.rule.configuration.threshold.max"
+ />
</div>
</div>
} @else {
@@ -50,22 +51,23 @@
class="w-100"
[ngClass]="{ 'd-none': !data.rule.configuration.thresholdMin }"
>
- <h6 class="mb-0">
+ <h6 class="d-flex mb-0">
<ng-container i18n>Threshold Min</ng-container>:
- @if (data.rule.configuration.threshold.unit === '%') {
- {{ data.settings.thresholdMin | percent: '1.2-2' }}
- } @else {
- {{ data.settings.thresholdMin }}
- }
+ <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">
- @if (data.rule.configuration.threshold.unit === '%') {
- <label>{{
- data.rule.configuration.threshold.min | percent: '1.2-2'
- }}</label>
- } @else {
- <label>{{ data.rule.configuration.threshold.min }}</label>
- }
+ <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"
@@ -75,35 +77,35 @@
>
<input matSliderThumb [(ngModel)]="data.settings.thresholdMin" />
</mat-slider>
- @if (data.rule.configuration.threshold.unit === '%') {
- <label>{{
- data.rule.configuration.threshold.max | percent: '1.2-2'
- }}</label>
- } @else {
- <label>{{ data.rule.configuration.threshold.max }}</label>
- }
+ <gf-value
+ [isPercent]="data.rule.configuration.threshold.unit === '%'"
+ [locale]="data.locale"
+ [precision]="2"
+ [value]="data.rule.configuration.threshold.max"
+ />
</div>
</div>
<div
class="w-100"
[ngClass]="{ 'd-none': !data.rule.configuration.thresholdMax }"
>
- <h6 class="mb-0">
+ <h6 class="d-flex mb-0">
<ng-container i18n>Threshold Max</ng-container>:
- @if (data.rule.configuration.threshold.unit === '%') {
- {{ data.settings.thresholdMax | percent: '1.2-2' }}
- } @else {
- {{ data.settings.thresholdMax }}
- }
+ <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">
- @if (data.rule.configuration.threshold.unit === '%') {
- <label>{{
- data.rule.configuration.threshold.min | percent: '1.2-2'
- }}</label>
- } @else {
- <label>{{ data.rule.configuration.threshold.min }}</label>
- }
+ <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"
@@ -113,13 +115,12 @@
>
<input matSliderThumb [(ngModel)]="data.settings.thresholdMax" />
</mat-slider>
- @if (data.rule.configuration.threshold.unit === '%') {
- <label>{{
- data.rule.configuration.threshold.max | percent: '1.2-2'
- }}</label>
- } @else {
- <label>{{ data.rule.configuration.threshold.max }}</label>
- }
+ <gf-value
+ [isPercent]="data.rule.configuration.threshold.unit === '%'"
+ [locale]="data.locale"
+ [precision]="2"
+ [value]="data.rule.configuration.threshold.max"
+ />
</div>
</div>
}