aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src')
-rw-r--r--ufund-ui/src/app/components/cupboard/cupboard.component.html11
-rw-r--r--ufund-ui/src/app/components/cupboard/cupboard.component.ts28
2 files changed, 28 insertions, 11 deletions
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html
index 9b74b2a..3ed06fb 100644
--- a/ufund-ui/src/app/components/cupboard/cupboard.component.html
+++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html
@@ -9,7 +9,7 @@
<button [ngClass]="selectedForm === 'update' ? 'selected-tab' : 'tab'" (click)="selectForm('update')">Update existing Need</button>
</div>
<div id="create-form" *ngIf="selectedForm === 'create'">
- <h1> Create a new need </h1>
+ <h1> Create Need </h1>
<form #cupboardForm="ngForm" (ngSubmit)="submit(cupboardForm.value)">
<label>Name:</label><br>
<input type="text" name="name" ngModel><br>
@@ -26,15 +26,10 @@
</div>
<div id="update-form" *ngIf="selectedForm === 'update'">
- <h1> Update a need </h1>
+ <h1> Update Need </h1>
<label>Needs:</label><br>
<form #updateForm="ngForm" (ngSubmit)="update(updateForm.value)">
- <div *ngFor="let need of needs">
-
- <input type="radio" name="id" [value]=need.id [(ngModel)]="selectedNeedId" (change)="populateForm(need)">
- <label name="template">{{need.name}}</label><br>
- </div>
- <label>Name:</label><br>
+ <label>Currently Editing : need.name</label><br>
<input type="text" name="name" [(ngModel)]="selectedNeed.name"><br>
<label>Max Goal:</label><br>
<input type="number" name="maxGoal" [(ngModel)]="selectedNeed.maxGoal"><br>
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
index 646c4ff..e38f8c0 100644
--- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts
+++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
@@ -16,10 +16,9 @@ import { NeedListComponent } from '../need-list/need-list.component';
export class CupboardComponent implements OnInit {
protected statusText = new BehaviorSubject("")
- selectedForm = "create"
+ selectedForm = "create";
needs: any;
- @ViewChild("needList") needList?: NeedListComponent
-
+ @ViewChild("needList") needList?: NeedListComponent;
constructor(private cupboardService: CupboardService, private usersService: UsersService) { }
ngOnInit(): void {
@@ -38,9 +37,32 @@ export class CupboardComponent implements OnInit {
type: ''
};
selectedNeedId: number | null = null;
+ searchResults: any[] = [];
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)
+ });
+ }
+
+ }
+ }
+
+ async updateSearchResults() {
+ if (this.needList) {
+ while (this.selectedForm == 'update') {
+ this.searchResults = this.needList.searchResults
+ await new Promise(resolve => setTimeout(resolve, 100));
+ }
+ }
}
populateForm(need: any): void {