diff options
Diffstat (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts')
-rw-r--r-- | ufund-ui/src/app/components/cupboard/cupboard.component.ts | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index c1bf66c..0fec0e0 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { CupboardService } from '../../services/cupboard.service'; import { UsersService } from '../../services/users.service'; import { Need, GoalType } from '../../models/Need'; -import { userType } from '../../models/User'; +import { userType } from '../../models/User'; @Component({ selector: 'app-cupboard', @@ -14,7 +14,7 @@ import { userType } from '../../models/User'; export class CupboardComponent implements OnInit { needs: any; constructor(private cupboardService: CupboardService, private usersService: UsersService) { } - + ngOnInit(): void { this.cupboardService.getNeeds().subscribe(n => this.needs = n); this.close(); @@ -34,7 +34,7 @@ needs: any; type: '' }; selectedNeedId: number | null = null; - + private hideElement(element: any) { if (element){ element.style.visibility = 'hidden'; @@ -53,7 +53,7 @@ needs: any; const menuElement = document.getElementById('menu'); this.showElement(menuElement); } - + opencreate() { this.close(); this.showElement(document.getElementById('create-form')); @@ -68,7 +68,7 @@ needs: any; this.close(); this.openmenu(); } - + close() { this.hideElement(document.getElementById('create-form')); this.hideElement(document.getElementById('destroy-form')); @@ -95,6 +95,7 @@ needs: any; filterAttributes: [], current: 0 }; + console.log("need:", need); console.log(need.id, need, "need updated"); this.cupboardService.updateNeed(need.id, need).subscribe( (result) => { @@ -112,12 +113,13 @@ needs: any; submit(form: any) { const need: Need = { name: form.name, - id: form.id, + id: 0, maxGoal: form.maxGoal, - type: GoalType[form.type as keyof typeof GoalType], + type: form.type, filterAttributes: [], current: 0 }; + console.log("need:", need); console.log("form submitted. creating need: ", need); this.cupboardService.createNeed(need).subscribe( (result) => { @@ -135,4 +137,4 @@ needs: any; destroy() { } - }
\ No newline at end of file + } |