diff options
Diffstat (limited to 'ufund-ui/src/app/components/cupboard')
| -rw-r--r-- | ufund-ui/src/app/components/cupboard/cupboard.component.html | 36 | ||||
| -rw-r--r-- | ufund-ui/src/app/components/cupboard/cupboard.component.ts | 108 | 
2 files changed, 5 insertions, 139 deletions
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html index 5e88582..3873719 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.html +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html @@ -1,7 +1,10 @@  <div id="box">      <div id="header">          <h1> Cupboard </h1> -        <button *ngIf="isManager()" class="button2" (click)="this.selectForm('create')"><span class="icon">add</span>Create Need</button> +        <ng-template #create> +            <app-need-edit [mode]="'Create'" (refreshNeedList)="refresh()"></app-need-edit> +        </ng-template> +        <button *ngIf="isManager()" class="button2" (click)="modalService.showModal(create)"><span class="icon">add</span>Create Need</button>      </div>      <div id="header2"> @@ -34,7 +37,7 @@              <span class="icon">{{inBasket(usersService.getBasket() | async, need)? "check": "add" }}</span>Add To Basket          </button>          <ng-template #edit> -            <app-need-edit *ngIf="need" [selectedNeed]="need" (refreshNeedList)="refresh()"></app-need-edit> +            <app-need-edit *ngIf="need" [mode]="'Edit'" [need]="need" (refreshNeedList)="refresh()"></app-need-edit>          </ng-template>          <button *ngIf="isManager()" (click)="modalService.showModal(edit)">              <span class="icon">edit</span>Edit Need @@ -45,32 +48,3 @@      </ng-template>      <app-need-list [actionArea]="NLActions" *ngIf="searchResults.length > 0" [needs]="searchResults" [itemsPerPage]="itemsPerPage" #needList/>  </div> - -<!--<div>--> -<!--    <div>--> -<!--        <div id="create-form" *ngIf="selectedForm === 'create'">--> -<!--            <h1> Create Need </h1>--> -<!--            <form #cupboardForm="ngForm" (ngSubmit)="submit(cupboardForm.value)">--> -<!--                <label>Name:</label><br>--> -<!--                <input type="text" name="name" ngModel><br>--> -<!--                <label>Image:</label><br>--> -<!--                <input type="text" name="image" ngModel><br>--> -<!--                <label>Location:</label><br>--> -<!--                <input type="text" name="location" ngModel><br>--> -<!--                <label>Max Goal:</label><br>--> -<!--                <input type="number" name="maxGoal" ngModel><br>--> -<!--                <label>Type</label><br>--> -<!--                <input type="radio" name="type" value="MONETARY" ngModel>--> -<!--                <label>Monetary</label><br>--> -<!--                <input type="radio" name="type" value="PHYSICAL" ngModel>--> -<!--                <label>Physical</label><br>--> -<!--                <input type="checkbox" name="urgent" value="false" ngModel>--> -<!--                <label>Urgent</label><br>--> -<!--                <label>Description</label><br>--> -<!--                <textarea name="description"></textarea><br>--> -<!--                <input type="submit" value="Submit">--> - -<!--            </form>--> -<!--        </div>--> -<!--    </div>--> -<!--</div>--> diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index f5e4c00..56fdd70 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -152,114 +152,6 @@ export class CupboardComponent implements OnInit {          return basket?.map(r => r.id).includes(need.id);      } -    // editNeed(need : Need) { -    //     this.activeEdit = need -    // } - -    // --------------- FORM STUFF NOT IMPLEMENTED YET --------------- // - -    // async updateSearchResults() { -    //     if (this.needList) { -    //         while (this.selectedForm == 'update') { -    //             // this.searchResults = this.needList.searchResults -    //             await new Promise(resolve => setTimeout(resolve, 100)); -    //         } -    //     } -    // } - -    selectForm(name: string) { -        // //get search results from the need list -        // if (this.needList) { -        //     // this.searchResults = this.needList.searchResults; -        // } -        // console.log(this.searchResults) -        // this.selectedForm = name; -        // if (name == 'update') { -        //     if (this.searchResults) { -        //         this.searchResults.forEach((element: any) => { -        //             console.log(element) -        //         }); -        //     } -        // -        // } -    } - -    // populateForm(need: any): void { -    //     this.selectForm('update'); -    //     this.selectedNeed = { ...need }; -    // } -    // -    // select(need : Need) { -        // //emit value -        // // this.currentNeed.emit(need); -        // if (this.selectedNeed) { -        //     //revert already selected need to previous style -        //     console.log(need.id); -        //     let button = document.getElementById('need-button-' + this.selectedNeed.id); -        //     if (button) { -        //         console.log(button) -        //         button.style.background = 'lightgray'; -        //         button.style.marginLeft = '0%'; -        //         button.style.width = '98%'; -        //     } -        //     button = document.getElementById('need-edit-button-' + this.selectedNeed.id); -        //     if (button) { -        //         button.style.visibility = 'visible'; -        //     } -        // } -        // //change selected need to selected style -        // this.selectedNeed = need; -        // let button = document.getElementById('need-button-' + need.id); -        // if (button) { -        //     button.style.background = 'white'; -        //     button.style.marginLeft = '4%'; -        //     button.style.width = '100%'; -        // } -        // button = document.getElementById('need-edit-button-' + need.id); -        // if (button) { -        //     button.style.visibility = 'hidden'; -        // } -    // } - -    // submit(form: any) { -    //     const need: Need = { -    //         name: form.name, -    //         image: form.image, -    //         location: form.location, -    //         id: 0, -    //         maxGoal: form.maxGoal, -    //         type: form.type, -    //         urgent: !!form.urgent, -    //         filterAttributes: [], -    //         current: 0, -    //         description: form.description -    //     }; -    //     console.log("need:", need); -    //     console.log("form submitted. creating need: ", need); -    //     this.cupboardService.createNeed(need) -    //         .pipe(catchError((ex, _) => { -    //             if (ex.status == 500) { -    //                 this.toastService.sendToast(ToastType.ERROR, "Fields cannot be blank"); -    //             } else if (ex.status == 400) { -    //                 this.toastService.sendToast(ToastType.ERROR, ex.error); -    //             } else { -    //                 this.toastService.sendToast(ToastType.ERROR, "Error on creating need"); -    //             } -    //             return of() -    //         })) -    //         .subscribe( -    //             (result) => { -    //                 if (result) { -    //                     console.log("need created successfully"); -    //                     // this.needList?.refresh() -    //                 } else { -    //                     console.log("need creation failed"); -    //                 } -    //             } -    // -    //         ); -    // } -      protected readonly SortingAlgorithms = SortingAlgoArrays;      protected readonly Object = Object;  }  | 
