Browse Source

Make the loading general for rules

pull/3537/head
Sonlis 1 year ago
committed by Thomas Kaul
parent
commit
47d2636cc9
  1. 10
      apps/client/src/app/components/rule/rule.component.html
  2. 4
      apps/client/src/app/components/rules/rules.component.html
  3. 3
      apps/client/src/app/components/rules/rules.component.ts
  4. 3
      apps/client/src/app/pages/portfolio/fire/fire-page.component.ts
  5. 73
      apps/client/src/app/pages/portfolio/fire/fire-page.html

10
apps/client/src/app/components/rule/rule.component.html

@ -47,22 +47,18 @@
} @else { } @else {
<div class="flex-grow-1"> <div class="flex-grow-1">
<div class="h6 my-1">{{ rule?.name }}</div> <div class="h6 my-1">{{ rule?.name }}</div>
<div class="evaluation"> <div class="evaluation">{{ rule?.evaluation }}</div>
@if (rule?.evaluation) {
{{ rule?.evaluation }}
}
</div>
</div> </div>
<div> <div>
<button <button
class="mx-1 no-min-width px-2" class="mx-1 no-min-width px-2"
mat-button mat-button
[matMenuTriggerFor]="accountMenu" [matMenuTriggerFor]="rulesMenu"
(click)="$event.stopPropagation()" (click)="$event.stopPropagation()"
> >
<ion-icon name="ellipsis-horizontal" /> <ion-icon name="ellipsis-horizontal" />
</button> </button>
<mat-menu #accountMenu="matMenu" xPosition="before"> <mat-menu #rulesMenu="matMenu" xPosition="before">
<button mat-menu-item (click)="onUpdateRule(rule)"> <button mat-menu-item (click)="onUpdateRule(rule)">
@if (rule?.isActive) { @if (rule?.isActive) {
<ng-container i18n>Deactivate</ng-container> <ng-container i18n>Deactivate</ng-container>

4
apps/client/src/app/components/rules/rules.component.html

@ -9,13 +9,13 @@
</mat-card> </mat-card>
} }
@if (rules?.length === 0) { @if (isLoading) {
<gf-rule [isLoading]="true" /> <gf-rule [isLoading]="true" />
} }
@if (rules !== null && rules !== undefined) { @if (rules !== null && rules !== undefined) {
@for (rule of rules; track rule.key) { @for (rule of rules; track rule.key) {
<gf-rule [rule]="rule" (ruleUpdated)="onRulesUpdated($event)" /> <gf-rule [rule]="rule" (ruleUpdated)="onRuleUpdated($event)" />
} }
} }
</div> </div>

3
apps/client/src/app/components/rules/rules.component.ts

@ -17,13 +17,14 @@ import {
}) })
export class RulesComponent { export class RulesComponent {
@Input() hasPermissionToCreateOrder: boolean; @Input() hasPermissionToCreateOrder: boolean;
@Input() isLoading: boolean;
@Input() rules: PortfolioReportRule[]; @Input() rules: PortfolioReportRule[];
@Output() rulesUpdated = new EventEmitter<UpdateUserSettingDto>(); @Output() rulesUpdated = new EventEmitter<UpdateUserSettingDto>();
public constructor() {} public constructor() {}
public onRulesUpdated(event: UpdateUserSettingDto) { public onRuleUpdated(event: UpdateUserSettingDto) {
this.rulesUpdated.emit(event); this.rulesUpdated.emit(event);
} }
} }

3
apps/client/src/app/pages/portfolio/fire/fire-page.component.ts

@ -105,6 +105,7 @@ export class FirePageComponent implements OnDestroy, OnInit {
public initializePortfolioReport() { public initializePortfolioReport() {
this.isLoadingPortfolioReport = true; this.isLoadingPortfolioReport = true;
this.dataService this.dataService
.fetchPortfolioReport() .fetchPortfolioReport()
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
@ -125,6 +126,7 @@ export class FirePageComponent implements OnDestroy, OnInit {
this.feeRules = this.feeRules =
portfolioReport.rules['fees'].filter((rule) => rule.isActive) || null; portfolioReport.rules['fees'].filter((rule) => rule.isActive) || null;
this.isLoadingPortfolioReport = false; this.isLoadingPortfolioReport = false;
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
}); });
} }
@ -170,6 +172,7 @@ export class FirePageComponent implements OnDestroy, OnInit {
public onRulesUpdated(event: UpdateUserSettingDto) { public onRulesUpdated(event: UpdateUserSettingDto) {
this.isLoading = true; this.isLoading = true;
this.dataService this.dataService
.putUserSetting(event) .putUserSetting(event)
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))

73
apps/client/src/app/pages/portfolio/fire/fire-page.html

@ -124,13 +124,12 @@
<gf-premium-indicator class="ml-1" /> <gf-premium-indicator class="ml-1" />
} }
</h4> </h4>
@if (!isLoadingPortfolioReport) { <gf-rules
<gf-rules [hasPermissionToCreateOrder]="hasPermissionToCreateOrder"
[hasPermissionToCreateOrder]="hasPermissionToCreateOrder" [isLoading]="isLoadingPortfolioReport"
[rules]="emergencyFundRules" [rules]="emergencyFundRules"
(rulesUpdated)="onRulesUpdated($event)" (rulesUpdated)="onRulesUpdated($event)"
/> />
}
</div> </div>
<div class="mb-4"> <div class="mb-4">
<h4 class="align-items-center d-flex m-0"> <h4 class="align-items-center d-flex m-0">
@ -139,13 +138,12 @@
<gf-premium-indicator class="ml-1" /> <gf-premium-indicator class="ml-1" />
} }
</h4> </h4>
@if (!isLoadingPortfolioReport) { <gf-rules
<gf-rules [hasPermissionToCreateOrder]="hasPermissionToCreateOrder"
[hasPermissionToCreateOrder]="hasPermissionToCreateOrder" [isLoading]="isLoadingPortfolioReport"
[rules]="currencyClusterRiskRules" [rules]="currencyClusterRiskRules"
(rulesUpdated)="onRulesUpdated($event)" (rulesUpdated)="onRulesUpdated($event)"
/> />
}
</div> </div>
<div class="mb-4"> <div class="mb-4">
<h4 class="align-items-center d-flex m-0"> <h4 class="align-items-center d-flex m-0">
@ -154,13 +152,12 @@
<gf-premium-indicator class="ml-1" /> <gf-premium-indicator class="ml-1" />
} }
</h4> </h4>
@if (!isLoadingPortfolioReport) { <gf-rules
<gf-rules [hasPermissionToCreateOrder]="hasPermissionToCreateOrder"
[hasPermissionToCreateOrder]="hasPermissionToCreateOrder" [isLoading]="isLoadingPortfolioReport"
[rules]="accountClusterRiskRules" [rules]="accountClusterRiskRules"
(rulesUpdated)="onRulesUpdated($event)" (rulesUpdated)="onRulesUpdated($event)"
/> />
}
</div> </div>
<div> <div>
<h4 class="align-items-center d-flex m-0"> <h4 class="align-items-center d-flex m-0">
@ -169,29 +166,29 @@
<gf-premium-indicator class="ml-1" /> <gf-premium-indicator class="ml-1" />
} }
</h4> </h4>
@if (!isLoadingPortfolioReport) { <gf-rules
<gf-rules [hasPermissionToCreateOrder]="hasPermissionToCreateOrder"
[hasPermissionToCreateOrder]="hasPermissionToCreateOrder" [isLoading]="isLoadingPortfolioReport"
[rules]="feeRules" [rules]="feeRules"
(rulesUpdated)="onRulesUpdated($event)" (rulesUpdated)="onRulesUpdated($event)"
/> />
}
</div> </div>
<div> @if (inactiveRules?.length > 0) {
<h4 class="align-items-center d-flex m-0"> <div>
<span i18n>Inactive</span> <h4 class="align-items-center d-flex m-0">
@if (user?.subscription?.type === 'Basic') { <span i18n>Inactive</span>
<gf-premium-indicator class="ml-1" /> @if (user?.subscription?.type === 'Basic') {
} <gf-premium-indicator class="ml-1" />
</h4> }
@if (!isLoadingPortfolioReport) { </h4>
<gf-rules <gf-rules
[hasPermissionToCreateOrder]="hasPermissionToCreateOrder" [hasPermissionToCreateOrder]="hasPermissionToCreateOrder"
[isLoading]="isLoadingPortfolioReport"
[rules]="inactiveRules" [rules]="inactiveRules"
(rulesUpdated)="onRulesUpdated($event)" (rulesUpdated)="onRulesUpdated($event)"
/> />
} </div>
</div> }
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save