Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 2x 2x 2x 5x 5x 5x 5x 5x 5x | import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core';
import { Price } from 'ish-core/models/price/price.model';
import { UserBudget } from '../../models/user-budget/user-budget.model';
/**
* displays the user budget and the appropriate budget bar
*/
@Component({
selector: 'ish-user-budget',
templateUrl: './user-budget.component.html',
changeDetection: ChangeDetectionStrategy.Default,
})
export class UserBudgetComponent implements OnChanges {
@Input() budget: UserBudget;
@Input() progressBarClass: string;
usedBudget: Price;
usedBudgetPercentage: number;
remainingBudgetPercentage: number;
ngOnChanges(): void {
if (this.isBudgetDefined()) {
this.calculate();
}
}
private isBudgetDefined(): boolean {
return !!this.budget?.budget && !!this.budget?.remainingBudget;
}
private calculate() {
this.usedBudget = this.budget.spentBudget;
this.usedBudgetPercentage = this.budget.budget.value === 0 ? 0 : this.usedBudget?.value / this.budget.budget.value;
this.remainingBudgetPercentage =
this.budget.budget.value === 0 ? 0 : this.budget.remainingBudget.value / this.budget.budget.value;
}
}
|