summaryrefslogtreecommitdiff
path: root/recipeBuddy/src/app/shopping-cart
diff options
context:
space:
mode:
authorschencej <schencej@clarkson.edu>2019-12-12 10:41:08 -0500
committerschencej <schencej@clarkson.edu>2019-12-12 10:41:08 -0500
commit946512c32a3b94079c9d2aaf48ef16d09fd14e3d (patch)
tree39869562d6defa06096dfdb31148ab45948fd3af /recipeBuddy/src/app/shopping-cart
parent2685a5d6838cf5572998d57eb391f86f4f797199 (diff)
parent09aea62746e50d8284dc234692e7641cca03cc42 (diff)
merged with master
Diffstat (limited to 'recipeBuddy/src/app/shopping-cart')
-rw-r--r--recipeBuddy/src/app/shopping-cart/shopping-cart.component.css13
-rw-r--r--recipeBuddy/src/app/shopping-cart/shopping-cart.component.html28
-rw-r--r--recipeBuddy/src/app/shopping-cart/shopping-cart.component.spec.ts25
-rw-r--r--recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts62
4 files changed, 128 insertions, 0 deletions
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 @@
+<div class="row">
+ <div class="column">
+ <h1> Recipes </h1>
+ <mat-selection-list #rlist>
+ <mat-list-option *ngFor="let recipe of recipes" [value]="recipe">
+ {{recipe.name}}
+ </mat-list-option>
+ </mat-selection-list>
+ </div>
+ <div class="column">
+ <h1> Ingredients </h1>
+ <div *ngFor="let selectedRecipe of rlist.selectedOptions.selected">
+ <h3>{{selectedRecipe.value.name}}</h3>
+ <mat-selection-list #ilist>
+ <mat-list-option *ngFor="let ing of selectedRecipe.value.ingredients" [value]="ing" (click)="addIngredient(ing)">
+ {{ing.name}} {{ing.amount}} {{ing.unit}}
+ </mat-list-option>
+ </mat-selection-list>
+ </div>
+ </div>
+ <div class="column">
+ <h1> Shopping List </h1>
+ <mat-list #clist *ngFor="let cartItem of ingredients">
+ <mat-list-item>{{cartItem.name}} {{cartItem.amount}} {{cartItem.unit}}</mat-list-item>
+ <mat-divider></mat-divider>
+ </mat-list>
+ </div>
+</div> \ No newline at end of file
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<ShoppingCartComponent>;
+
+ 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..26808ee
--- /dev/null
+++ b/recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts
@@ -0,0 +1,62 @@
+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';
+import { Recipe } from '../DataModels/recipe';
+import { Ingredient } from '../DataModels/ingredient';
+
+
+
+
+
+@Component({
+ selector: 'shopping-cart.component',
+ templateUrl: './shopping-cart.component.html',
+ styleUrls: ['./shopping-cart.component.css']
+})
+export class ShoppingCartComponent implements OnInit {
+
+ recipes: Recipe[] = [];
+ ingredients : Ingredient[] = [];
+ units: string[] = [];
+ amounts: number[] = [];
+ types: string[] = [];
+ rIDs: number[] = [];
+
+
+
+ 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 {
+
+ }
+}