aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ufund-api/package-lock.json6
-rw-r--r--ufund-api/src/test/java/com/ufund/api/ufundapi/model/NeedTest.java78
-rw-r--r--ufund-ui/src/app/components/cupboard/cupboard.component.html17
-rw-r--r--ufund-ui/src/app/components/cupboard/cupboard.component.ts26
-rw-r--r--ufund-ui/src/app/models/Need.ts2
5 files changed, 124 insertions, 5 deletions
diff --git a/ufund-api/package-lock.json b/ufund-api/package-lock.json
new file mode 100644
index 0000000..b005fc2
--- /dev/null
+++ b/ufund-api/package-lock.json
@@ -0,0 +1,6 @@
+{
+ "name": "ufund-api",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {}
+}
diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/model/NeedTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/model/NeedTest.java
new file mode 100644
index 0000000..50b5cf2
--- /dev/null
+++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/model/NeedTest.java
@@ -0,0 +1,78 @@
+package com.ufund.api.ufundapi.model;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+import com.ufund.api.ufundapi.model.Need.GoalType;
+
+@Tag("Model-tier")
+public class NeedTest {
+
+ @Test
+ public void createNeed() {
+
+ String name = "Jellyfish";
+ int id = 0;
+ double maxGoal = 100.00;
+ GoalType type = GoalType.MONETARY;
+ Need need = new Need(name, id, maxGoal, type);
+
+ assertNotNull(need);
+
+ }
+
+ @Test
+ public void testFields() {
+ String name = "Jellyfish";
+ int id = 0;
+ double maxGoal = 100.00;
+ GoalType type = GoalType.MONETARY;
+ Need need = new Need(name, id, maxGoal, type);
+
+
+ assertEquals(name, need.getName());
+ assertEquals(id, need.getId());
+ assertEquals(maxGoal, need.getMaxGoal());
+ assertEquals(type, need.getType());
+ }
+
+ @Test
+ public void testCurrentGoal() {
+ String name = "Jellyfish";
+ int id = 0;
+ double maxGoal = 100.00;
+ GoalType type = GoalType.MONETARY;
+ Need need = new Need(name, id, maxGoal, type);
+
+ double current = 0.00;
+ need.setCurrent(current);
+ assertEquals(need.getCurrent(), current);
+
+ current = 100.00;
+ need.setCurrent(current);
+ assertEquals(need.getCurrent(), current);
+
+ current = -100.00;
+ need.setCurrent(current);
+ assertEquals(need.getCurrent(), current);
+
+ }
+ @Test
+ public void testFilterAttributes() {
+
+ String name = "Jellyfish";
+ int id = 0;
+ double maxGoal = 100.00;
+ GoalType type = GoalType.MONETARY;
+ Need need = new Need(name, id, maxGoal, type);
+
+ String[] filterAttributes = {"seaweed", "divers", "pacific", "plankton"};
+
+ need.setFilterAttributes(filterAttributes);
+
+ assertEquals(need.getFilterAttributes(), filterAttributes);
+ }
+
+}
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html
index 056c167..ad8e60c 100644
--- a/ufund-ui/src/app/components/cupboard/cupboard.component.html
+++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html
@@ -1,2 +1,17 @@
-<p>cupboard works!</p>
+<h1> Cupboard </h1>
+<form>
+ <label for="name">Name:</label><br>
+ <input #name type="text" name="name"><br>
+ <label for="id">Id:</label><br>
+ <input #id type="number" name="id"><br>
+ <label for="max-goal">Max Goal:</label><br>
+ <input #maxgoal type="number" name="max-goal"><br>
+ <label>Type</label><br>
+ <input id="monetary" type="radio" name="type" value="MONETARY">
+ <label for="monetary">Monetary</label><br>
+ <input #physical type="radio" name="type" value="PHYSICAL">
+ <label for="physical">Physical</label><br>
+</form>
+<button (click)="submit(name.value, id.valueAsNumber, maxgoal.valueAsNumber, physical.value)">Submit</button>
+
<app-need-list></app-need-list>
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
index c78434e..53dad8a 100644
--- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts
+++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
@@ -1,4 +1,8 @@
-import { Component } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
+import { CupboardService } from '../../services/cupboard.service';
+import { NeedListComponent } from '../need-list/need-list.component';
+
+import { Need, GoalType } from '../../models/Need';
@Component({
selector: 'app-cupboard',
@@ -6,6 +10,22 @@ import { Component } from '@angular/core';
templateUrl: './cupboard.component.html',
styleUrl: './cupboard.component.css'
})
-export class CupboardComponent {
+export class CupboardComponent implements
+ OnInit {
+
+ constructor(private cupboardService: CupboardService){}
+ ngOnInit() {
-}
+
+ }
+ need!: Need;
+ submit(name: string, id: number, maxGoal: number, type: string) {
+ if (this.need) {
+ this.need.name = name;
+ this.need.id = id;
+ this.need.maxGoal = maxGoal;
+ console.log(type);
+ this.cupboardService.createNeed(this.need);
+ }
+ }
+ }
diff --git a/ufund-ui/src/app/models/Need.ts b/ufund-ui/src/app/models/Need.ts
index 607a6a7..c0425ec 100644
--- a/ufund-ui/src/app/models/Need.ts
+++ b/ufund-ui/src/app/models/Need.ts
@@ -7,7 +7,7 @@ export interface Need {
current: number;
}
-enum GoalType {
+export enum GoalType {
MONETARY,
PHYSICAL
}