diff options
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.ts | 14 |
1 files changed, 12 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..8d23d7b 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,18 +64,24 @@ 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") } |