Feature/support permissions in fire calculator (#891)
* Support hasPermissionToUpdateUserSettings * Update changelog
This commit is contained in:
parent
eb9cece4e4
commit
b3e07c8446
@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Migrated the asset profile data gathering to the queue design pattern
|
- Migrated the asset profile data gathering to the queue design pattern
|
||||||
- Improved the allocations page with no filtering
|
- Improved the allocations page with no filtering
|
||||||
- Harmonized the _No data available_ label in the portfolio proportion chart component
|
- Harmonized the _No data available_ label in the portfolio proportion chart component
|
||||||
|
- Improved the _FIRE_ calculator for the _Live Demo_
|
||||||
- Upgraded `angular` from version `13.2.2` to `13.3.6`
|
- Upgraded `angular` from version `13.2.2` to `13.3.6`
|
||||||
- Upgraded `Nx` from version `13.8.5` to `14.1.4`
|
- Upgraded `Nx` from version `13.8.5` to `14.1.4`
|
||||||
- Upgraded `storybook` from version `6.4.18` to `6.4.22`
|
- Upgraded `storybook` from version `6.4.18` to `6.4.22`
|
||||||
|
@ -2,6 +2,7 @@ import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
|||||||
import { DataService } from '@ghostfolio/client/services/data.service';
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
||||||
import { User } from '@ghostfolio/common/interfaces';
|
import { User } from '@ghostfolio/common/interfaces';
|
||||||
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
||||||
import Big from 'big.js';
|
import Big from 'big.js';
|
||||||
import { DeviceDetectorService } from 'ngx-device-detector';
|
import { DeviceDetectorService } from 'ngx-device-detector';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
@ -16,6 +17,7 @@ import { takeUntil } from 'rxjs/operators';
|
|||||||
export class FirePageComponent implements OnDestroy, OnInit {
|
export class FirePageComponent implements OnDestroy, OnInit {
|
||||||
public deviceType: string;
|
public deviceType: string;
|
||||||
public fireWealth: Big;
|
public fireWealth: Big;
|
||||||
|
public hasPermissionToUpdateUserSettings: boolean;
|
||||||
public isLoading = false;
|
public isLoading = false;
|
||||||
public user: User;
|
public user: User;
|
||||||
public withdrawalRatePerMonth: Big;
|
public withdrawalRatePerMonth: Big;
|
||||||
@ -63,6 +65,11 @@ export class FirePageComponent implements OnDestroy, OnInit {
|
|||||||
if (state?.user) {
|
if (state?.user) {
|
||||||
this.user = state.user;
|
this.user = state.user;
|
||||||
|
|
||||||
|
this.hasPermissionToUpdateUserSettings = hasPermission(
|
||||||
|
this.user.permissions,
|
||||||
|
permissions.updateUserSettings
|
||||||
|
);
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
this.changeDetectorRef.markForCheck();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
[currency]="user?.settings?.baseCurrency"
|
[currency]="user?.settings?.baseCurrency"
|
||||||
[deviceType]="deviceType"
|
[deviceType]="deviceType"
|
||||||
[fireWealth]="fireWealth?.toNumber()"
|
[fireWealth]="fireWealth?.toNumber()"
|
||||||
|
[hasPermissionToUpdateUserSettings]="hasPermissionToUpdateUserSettings"
|
||||||
[locale]="user?.settings?.locale"
|
[locale]="user?.settings?.locale"
|
||||||
[savingsRate]="user?.settings?.savingsRate"
|
[savingsRate]="user?.settings?.savingsRate"
|
||||||
(savingsRateChanged)="onSavingsRateChange($event)"
|
(savingsRateChanged)="onSavingsRateChange($event)"
|
||||||
|
@ -41,6 +41,7 @@ export class FireCalculatorComponent
|
|||||||
@Input() currency: string;
|
@Input() currency: string;
|
||||||
@Input() deviceType: string;
|
@Input() deviceType: string;
|
||||||
@Input() fireWealth: number;
|
@Input() fireWealth: number;
|
||||||
|
@Input() hasPermissionToUpdateUserSettings: boolean;
|
||||||
@Input() locale: string;
|
@Input() locale: string;
|
||||||
@Input() savingsRate = 0;
|
@Input() savingsRate = 0;
|
||||||
|
|
||||||
@ -76,12 +77,17 @@ export class FireCalculatorComponent
|
|||||||
Tooltip
|
Tooltip
|
||||||
);
|
);
|
||||||
|
|
||||||
this.calculatorForm.setValue({
|
this.calculatorForm.setValue(
|
||||||
annualInterestRate: 5,
|
{
|
||||||
paymentPerPeriod: this.savingsRate,
|
annualInterestRate: 5,
|
||||||
principalInvestmentAmount: 0,
|
paymentPerPeriod: this.savingsRate,
|
||||||
time: 10
|
principalInvestmentAmount: 0,
|
||||||
});
|
time: 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
emitEvent: false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
this.calculatorForm.valueChanges
|
this.calculatorForm.valueChanges
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
@ -115,6 +121,12 @@ export class FireCalculatorComponent
|
|||||||
this.changeDetectorRef.markForCheck();
|
this.changeDetectorRef.markForCheck();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.hasPermissionToUpdateUserSettings === true) {
|
||||||
|
this.calculatorForm.get('paymentPerPeriod').enable({ emitEvent: false });
|
||||||
|
} else {
|
||||||
|
this.calculatorForm.get('paymentPerPeriod').disable({ emitEvent: false });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnChanges() {
|
public ngOnChanges() {
|
||||||
@ -135,6 +147,12 @@ export class FireCalculatorComponent
|
|||||||
this.changeDetectorRef.markForCheck();
|
this.changeDetectorRef.markForCheck();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.hasPermissionToUpdateUserSettings === true) {
|
||||||
|
this.calculatorForm.get('paymentPerPeriod').enable({ emitEvent: false });
|
||||||
|
} else {
|
||||||
|
this.calculatorForm.get('paymentPerPeriod').disable({ emitEvent: false });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnDestroy() {
|
public ngOnDestroy() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user