summaryrefslogtreecommitdiff
path: root/recipeBuddy
diff options
context:
space:
mode:
Diffstat (limited to 'recipeBuddy')
-rw-r--r--recipeBuddy/src/app/edit-recipe/edit-recipe.component.ts16
-rw-r--r--recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts16
2 files changed, 17 insertions, 15 deletions
diff --git a/recipeBuddy/src/app/edit-recipe/edit-recipe.component.ts b/recipeBuddy/src/app/edit-recipe/edit-recipe.component.ts
index 203f733..e7966b3 100644
--- a/recipeBuddy/src/app/edit-recipe/edit-recipe.component.ts
+++ b/recipeBuddy/src/app/edit-recipe/edit-recipe.component.ts
@@ -13,6 +13,7 @@ import { Recipe } from '../DataModels/recipe';
import { Ingredient } from '../DataModels/ingredient'
import { Step } from '../DataModels/step';
import { BackendService } from '../REST_service/backend.service';
+import { RecipePassService } from '../recipePass/recipe-pass.service';
@Component({
selector: 'app-edit-recipe',
@@ -21,18 +22,7 @@ import { BackendService } from '../REST_service/backend.service';
})
export class EditRecipeComponent implements OnInit {
- baseRecipe: Recipe = new Recipe (15, //id
- '', //name
- '', //description
- [], //ingredients
- [], //steps
- 0, //servingSize
- 0, //cookTime
- 0, //timesCooked
- 0, //rating
- [], //tags
- [] //photos
- );
+ baseRecipe: Recipe = this.passService.getRecipe();
recipeForm = this.fb.group({
recipeName: ['', Validators.required],
@@ -59,7 +49,7 @@ export class EditRecipeComponent implements OnInit {
constructor(private fb: FormBuilder,
private restService: BackendService,
private router: Router,
- /*private passService: PassService,*/
+ private passService: RecipePassService,
)
{
restService.getRecipe(this.baseRecipe.id).subscribe(
diff --git a/recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts b/recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts
index 26808ee..b60a63c 100644
--- a/recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts
+++ b/recipeBuddy/src/app/shopping-cart/shopping-cart.component.ts
@@ -34,6 +34,10 @@ export class ShoppingCartComponent implements OnInit {
for(i = 0; i < res.length; i++) {
this.restService.getRecipe(res[i]).subscribe(
res2 => {
+ for (var j = 0; j < res2.ingredients.length; j++) {
+ res2.ingredients[j]["checked"] = false;
+ res2.ingredients[j]["cart_index"] = -1;
+ }
this.recipes.push(res2)
});
}
@@ -53,10 +57,18 @@ export class ShoppingCartComponent implements OnInit {
}
addIngredient(ing: Ingredient): void {
- this.ingredients.push(ing);
+ ing.checked = !ing.checked;
+ if (ing.checked){
+ this.ingredients.push(ing);
+ ing.cart_index = this.ingredients.length - 1;
+ } else {
+ this.ingredients.splice(ing.cart_index, 1);
+ for(var i = 0; i < this.ingredients.length; i++) {
+ this.ingredients[i].cart_index = i;
+ }
+ }
}
printList(): void {
-
}
}