From 24e9e8530fe5b7ee4a6da37b5da7a1b66eb5b467 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Mon, 9 Dec 2019 18:03:41 -0500 Subject: Add routing to main page after sumbitting --- recipeBuddy/src/app/add-recipe/add-recipe.component.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'recipeBuddy/src') diff --git a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts index 407997c..8f00146 100644 --- a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts +++ b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts @@ -7,6 +7,8 @@ import { FormArray } from '@angular/forms'; import { Validators } from '@angular/forms'; +import { Router } from '@angular/router'; + import { Recipe } from '../DataModels/recipe'; import { Ingredient } from '../DataModels/ingredient' import { Step } from '../DataModels/step'; @@ -43,7 +45,8 @@ export class AddRecipeComponent { }); constructor(private fb: FormBuilder, - private restService: BackendService + private restService: BackendService, + private router: Router, ) { } ngOnInit() { @@ -121,6 +124,7 @@ export class AddRecipeComponent { formData.tags.split(','), //tags formData.photos.split(',') //photos ); - this.restService.createRecipe(recipe).subscribe() + this.restService.createRecipe(recipe).subscribe(); + this.router.navigate(['/']); } } -- cgit v1.1 From e8d327e3783831107400456de84ecd79241b5773 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Mon, 9 Dec 2019 18:03:59 -0500 Subject: Fix array indexing of formData.steps --- recipeBuddy/src/app/add-recipe/add-recipe.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'recipeBuddy/src') diff --git a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts index 8f00146..e6555d4 100644 --- a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts +++ b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts @@ -102,9 +102,9 @@ export class AddRecipeComponent { } var steps = [] - for (i = 0; i < formData.ingredients.length; i++) { - var tmp_timer = parseInt(formData.steps[0].timer) - steps.push(new Step(formData.steps[0].instruct, + for (i = 0; i < formData.steps.length; i++) { + var tmp_timer = parseInt(formData.steps[i].timer) + steps.push(new Step(formData.steps[i].instruct, (isNaN(tmp_timer) ? 0 : tmp_timer) )); } -- cgit v1.1 From e249709c792bb7e819be661a134e3a965d2a0919 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Tue, 10 Dec 2019 15:04:51 -0500 Subject: Fix blank tags/photos not added to Recipe --- recipeBuddy/src/app/add-recipe/add-recipe.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'recipeBuddy/src') diff --git a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts index e6555d4..5109c34 100644 --- a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts +++ b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts @@ -121,8 +121,8 @@ export class AddRecipeComponent { (isNaN(cookTimeTmp) ? 0 :cookTimeTmp), //cookTime 0, //timesCooked 0, //rating - formData.tags.split(','), //tags - formData.photos.split(',') //photos + formData.tags.split(',').filter(word=> !(word==="")), //tags + formData.photos.split(',').filter(word=> !(word==="")) //photos ); this.restService.createRecipe(recipe).subscribe(); this.router.navigate(['/']); -- cgit v1.1