diff options
Diffstat (limited to 'ufund-ui')
| -rw-r--r-- | ufund-ui/src/app/components/cupboard/cupboard.component.ts | 18 | ||||
| -rw-r--r-- | ufund-ui/src/app/models/User.ts | 6 | 
2 files changed, 13 insertions, 11 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 +  } diff --git a/ufund-ui/src/app/models/User.ts b/ufund-ui/src/app/models/User.ts index 5ed3a3f..b640e04 100644 --- a/ufund-ui/src/app/models/User.ts +++ b/ufund-ui/src/app/models/User.ts @@ -6,7 +6,7 @@ export enum userType {  }  export interface User { -  username: string; -  basket: Need[]; -  type: userType +    username: string; +    basket: Need[]; +    type: userType  }  | 
