aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src/app/components/funding-basket/funding-basket.component.ts')
-rw-r--r--ufund-ui/src/app/components/funding-basket/funding-basket.component.ts15
1 files changed, 13 insertions, 2 deletions
diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts
index 78ce958..920a7ef 100644
--- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts
+++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts
@@ -24,7 +24,8 @@ export class FundingBasketComponent implements OnInit {
private toastService: ToastsService
) {}
- public runningTotal = new BehaviorSubject(0)
+ protected runningTotal = new BehaviorSubject(0)
+ protected physicalTotal: string[] = []
@ViewChild("contribution") contribution?: Input;
ngOnInit(): void {
@@ -36,6 +37,9 @@ export class FundingBasketComponent implements OnInit {
let order: { needID: number, quantity: number }[] = []
let isNotValid = false
+ this.runningTotal.next(0);
+ this.physicalTotal = []
+
for (let contribution of document.querySelectorAll<HTMLInputElement>('.contribution')!) {
if (contribution.value == '' || contribution.valueAsNumber <= 0) {
isNotValid = true
@@ -60,21 +64,28 @@ export class FundingBasketComponent implements OnInit {
this.toastService.sendToast(ToastType.INFO, "Checkout successful");
}
- resetColor(ev: any) {
+ onInput(ev: any) {
let total = 0
this.runningTotal.next(total);
+ this.physicalTotal = []
for (let contribution of document.querySelectorAll<HTMLInputElement>('.contribution')!) {
this.cupboardService.getNeed(+contribution.id).subscribe(need => {
if (contribution.value != '' && need.type != GoalType.PHYSICAL) {
total += contribution.valueAsNumber
+ } else if (contribution.value != '' && need.type == GoalType.PHYSICAL) {
+ this.physicalTotal.push(need.name + ": " + contribution.value)
}
this.runningTotal.next(total);
+
})
}
+ this.physicalTotal.sort((a, b) => a < b ? -1 : 1);
+
(ev.target as HTMLInputElement).setAttribute("style", "border-color: unset")
}
protected readonly of = of;
protected readonly userType = userType;
+ protected readonly Infinity = Infinity;
}