From c3666978e0eef9eeb52d4e383a98d3ef075c37da Mon Sep 17 00:00:00 2001 From: Chris Undercoffer Date: Sat, 7 Dec 2019 16:42:26 -0500 Subject: Add base component for shopping cart --- .../shopping-cart/shopping-cart.component.spec.ts | 25 ++++++++++++++++++++++ .../app/shopping-cart/shopping-cart.component.ts | 18 ++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 recipeBuddy/src/app/shopping-cart/shopping-cart.component.spec.ts create mode 100644 recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts (limited to 'recipeBuddy') diff --git a/recipeBuddy/src/app/shopping-cart/shopping-cart.component.spec.ts b/recipeBuddy/src/app/shopping-cart/shopping-cart.component.spec.ts new file mode 100644 index 0000000..5d77354 --- /dev/null +++ b/recipeBuddy/src/app/shopping-cart/shopping-cart.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ShoppingCartComponent } from './shopping-cart.component'; + +describe('ShoppingCartComponent', () => { + let component: ShoppingCartComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ShoppingCartComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ShoppingCartComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts b/recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts new file mode 100644 index 0000000..4430081 --- /dev/null +++ b/recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts @@ -0,0 +1,18 @@ +import { Component, OnInit } from '@angular/core'; + + + + + +@Component({ + selector: 'shopping-cart.component', + templateUrl: './shopping-cart.component.html', + styleUrls: ['./shopping-cart.component.css'] +}) +export class ShoppingCartComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } +} -- cgit v1.1 From ed1c7d95398c90263db74937a780e71f43475012 Mon Sep 17 00:00:00 2001 From: Chris Undercoffer Date: Wed, 11 Dec 2019 15:23:04 -0500 Subject: add shoppingcart base functionality can add items but not remove, not able to print list yet --- .../app/shopping-cart/shopping-cart.component.css | 13 +++++++ .../app/shopping-cart/shopping-cart.component.html | 28 ++++++++++++++ .../app/shopping-cart/shopping-cart.component.ts | 45 +++++++++++++++++++++- 3 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 recipeBuddy/src/app/shopping-cart/shopping-cart.component.css create mode 100644 recipeBuddy/src/app/shopping-cart/shopping-cart.component.html (limited to 'recipeBuddy') diff --git a/recipeBuddy/src/app/shopping-cart/shopping-cart.component.css b/recipeBuddy/src/app/shopping-cart/shopping-cart.component.css new file mode 100644 index 0000000..4c11ade --- /dev/null +++ b/recipeBuddy/src/app/shopping-cart/shopping-cart.component.css @@ -0,0 +1,13 @@ +.column { + float: left; + width: 33.33%; + +} + + +.row:after { + content: ""; + display: table; + clear: both; + +} \ No newline at end of file diff --git a/recipeBuddy/src/app/shopping-cart/shopping-cart.component.html b/recipeBuddy/src/app/shopping-cart/shopping-cart.component.html new file mode 100644 index 0000000..a4e87ab --- /dev/null +++ b/recipeBuddy/src/app/shopping-cart/shopping-cart.component.html @@ -0,0 +1,28 @@ +
+
+

Recipes

+ + + {{recipe.name}} + + +
+
+

Ingredients

+
+

{{selectedRecipe.value.name}}

+ + + {{ing.name}} {{ing.amount}} {{ing.unit}} + + +
+
+
+

Shopping List

+ + {{cartItem.name}} {{cartItem.amount}} {{cartItem.unit}} + + +
+
\ No newline at end of file diff --git a/recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts b/recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts index 4430081..7c3f6fa 100644 --- a/recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts +++ b/recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts @@ -1,5 +1,8 @@ import { Component, OnInit } from '@angular/core'; - +import { MatSelectModule } from '@angular/material/select'; +import { MatDividerModule } from '@angular/material/divider'; +import { BackendService } from '../REST_service/backend.service'; +import { FormsModule } from '@angular/forms'; @@ -10,9 +13,47 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./shopping-cart.component.css'] }) export class ShoppingCartComponent implements OnInit { + + recipes: Recipe[] = []; + ingredients : Ingredient[] = []; + units: string[] = []; + amounts: number[] = []; + types: string[] = []; + rIDs: number[] = []; + + - constructor() { } + constructor( private restService: BackendService) { + + this.restService.getRecipes().subscribe( + res => { + var i: number; + for(i = 0; i < res.length; i++) { + this.restService.getRecipe(res[i]).subscribe( + res2 => { + this.recipes.push(res2) + }); + } + }); + + } + + ngOnInit() { } + + addAll(): void { + + } + addRecipe(id: number): void { + + } + addIngredient(ing: Ingredient): void { + this.ingredients.push(ing); + + } + printList(): void { + + } } -- cgit v1.1 From 643e4262e8cdd63b546ea7f9b3c8e85883e0215c Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Wed, 11 Dec 2019 16:42:15 -0500 Subject: Fix adding ingredients Ingredients form array is now indexed based on for loop, not just set to 0. --- recipeBuddy/src/app/add-recipe/add-recipe.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'recipeBuddy') diff --git a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts index 5109c34..0366950 100644 --- a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts +++ b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts @@ -93,10 +93,10 @@ export class AddRecipeComponent { var ingredients = [] var i; for (i = 0; i < formData.ingredients.length; i++) { - var tmp_amount = parseFloat(formData.ingredients[0].amount) - ingredients.push(new Ingredient(formData.ingredients[0].ingrName, + var tmp_amount = parseFloat(formData.ingredients[i].amount) + ingredients.push(new Ingredient(formData.ingredients[i].ingrName, (isNaN(tmp_amount) ? 0 : tmp_amount), - formData.ingredients[0].unit, + formData.ingredients[i].unit, "" )); } -- cgit v1.1 From 40e096d8795e0930c99aacbc4116fceacb13ef41 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Wed, 11 Dec 2019 16:53:55 -0500 Subject: Fix units form control name --- recipeBuddy/src/app/add-recipe/add-recipe.component.html | 2 +- recipeBuddy/src/app/add-recipe/add-recipe.component.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'recipeBuddy') diff --git a/recipeBuddy/src/app/add-recipe/add-recipe.component.html b/recipeBuddy/src/app/add-recipe/add-recipe.component.html index 76095f9..11277f9 100644 --- a/recipeBuddy/src/app/add-recipe/add-recipe.component.html +++ b/recipeBuddy/src/app/add-recipe/add-recipe.component.html @@ -59,7 +59,7 @@ + formControlName="unit">