-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path590.b7642e3b530c597f.js
1 lines (1 loc) · 9.77 KB
/
590.b7642e3b530c597f.js
1
"use strict";(self.webpackChunkmy_courseProj_basic=self.webpackChunkmy_courseProj_basic||[]).push([[590],{2590:(x,m,s)=>{s.r(m),s.d(m,{RecipesModule:()=>q});var o=s(4719),p=s(2475),Z=s(4466),e=s(6738),R=s(2986),_=s(4850),g=s(5599),l=s(5496),u=s(6895),C=s(8975);function A(i,r){if(1&i&&(e.TgZ(0,"li",10),e._uU(1),e.qZA()),2&i){const t=r.$implicit;e.xp6(1),e.AsE(" ",t.name,"-",t.amount," ")}}let S=(()=>{class i{constructor(t,n,c){this.recipeService=t,this.route=n,this.router=c}ngOnInit(){this.route.params.subscribe(t=>{this.id=t.id;const n=this.recipeService.getRecipe(this.id);n?this.recipe=n:this.router.navigate(["/","recipes"])})}onAddToShoppingList(){console.log(this.recipe.ingredients),this.recipeService.addIngredientsToShoppingList(this.recipe.ingredients)}onEdit(){this.router.navigate(["edit"],{relativeTo:this.route})}onDelete(t){this.recipeService.deleteRecipe(t),this.router.navigate([""],{relativeTo:this.route})}}return i.\u0275fac=function(t){return new(t||i)(e.Y36(l.j),e.Y36(p.gz),e.Y36(p.F0))},i.\u0275cmp=e.Xpm({type:i,selectors:[["app-recipe-detail"]],decls:30,vars:5,consts:[[1,"row"],[1,"col-xs-12"],[1,"img-responsive",2,"max-height","300px",3,"src","alt"],["appDropdown","",1,"btn-group"],["type","button",1,"btn","btn-primary","dropdown-toggle"],[1,"caret"],[1,"dropdown-menu"],[2,"pointer","cursor",3,"click"],[1,"list-group"],["class","list-group-item",4,"ngFor","ngForOf"],[1,"list-group-item"]],template:function(t,n){1&t&&(e.TgZ(0,"div",0)(1,"div",1),e._UZ(2,"img",2),e.qZA()(),e.TgZ(3,"div",0)(4,"div",1)(5,"h2"),e._uU(6),e.qZA(),e._UZ(7,"hr"),e.TgZ(8,"p"),e._uU(9),e.qZA()()(),e.TgZ(10,"div",0)(11,"div",1)(12,"div",3)(13,"button",4),e._uU(14," Manage Recipe "),e._UZ(15,"span",5),e.qZA(),e.TgZ(16,"ul",6)(17,"li")(18,"a",7),e.NdJ("click",function(){return n.onAddToShoppingList()}),e._uU(19,"To shopping List"),e.qZA()(),e.TgZ(20,"li")(21,"a",7),e.NdJ("click",function(){return n.onEdit()}),e._uU(22,"Edit Recipe"),e.qZA()(),e.TgZ(23,"li")(24,"a",7),e.NdJ("click",function(){return n.onDelete(n.id)}),e._uU(25,"Delete Recipe"),e.qZA()()()()()(),e.TgZ(26,"div",0)(27,"div",1)(28,"ul",8),e.YNc(29,A,2,2,"li",9),e.qZA()()()),2&t&&(e.xp6(2),e.s9C("alt",n.recipe.name),e.Q6J("src",n.recipe.imagePath,e.LSH),e.xp6(4),e.Oqu(n.recipe.name),e.xp6(3),e.Oqu(n.recipe.description),e.xp6(20),e.Q6J("ngForOf",n.recipe.ingredients))},dependencies:[u.sg,C.R]}),i})();function b(i,r){if(1&i){const t=e.EpF();e.TgZ(0,"div",17)(1,"div",18),e._UZ(2,"input",19),e.qZA(),e.TgZ(3,"div",20),e._UZ(4,"input",21),e.qZA(),e.TgZ(5,"div",22)(6,"button",23),e.NdJ("click",function(){const a=e.CHM(t).index,d=e.oxw();return e.KtG(d.onDeleteIngredient(a))}),e._uU(7,"X"),e.qZA()()()}2&i&&e.Q6J("formGroupName",r.index)}let v=(()=>{class i{constructor(t,n,c){this.route=t,this.recipeService=n,this.router=c,this.editMode=!1}ngOnInit(){this.route.params.subscribe(t=>{this.id=+t.id,this.editMode=null!=t.id,this.initForm()})}onSubmit(){this.editMode?this.recipeService.updateRecipe(this.id,this.recipeForm.value):this.recipeService.addRecipe(this.recipeForm.value),this.onCancel()}onAddIngredient(){this.recipeForm.get("ingredients").push(new o.cw({name:new o.NI(null,o.kI.required),amount:new o.NI(null,[o.kI.required,o.kI.pattern(/^[1-9]+[0-9]*$/)])}))}onDeleteIngredient(t){this.recipeForm.get("ingredients").removeAt(t)}onCancel(){this.router.navigate(["../"],{relativeTo:this.route})}initForm(){let t="",n="",c="";if(this.recipeIngredients=new o.Oe([]),this.editMode){const a=this.recipeService.getRecipe(this.id);if(t=a.name,n=a.imagePath,c=a.description,a.ingredients)for(let d of a.ingredients)this.recipeIngredients.push(new o.cw({name:new o.NI(d.name,o.kI.required),amount:new o.NI(d.amount,[o.kI.required,o.kI.pattern(/^[1-9]+[0-9]*$/)])}))}this.recipeForm=new o.cw({name:new o.NI(t,o.kI.required),imagePath:new o.NI(n,o.kI.required),description:new o.NI(c,o.kI.required),ingredients:this.recipeIngredients})}}return i.\u0275fac=function(t){return new(t||i)(e.Y36(p.gz),e.Y36(l.j),e.Y36(p.F0))},i.\u0275cmp=e.Xpm({type:i,selectors:[["app-recipe-edit"]],decls:38,vars:4,consts:[[1,"row"],[1,"col-xs-12"],[3,"formGroup","ngSubmit"],["type","submit",1,"btn","btn-success",3,"disabled"],["type","button",1,"btn","btn-danger",3,"click"],[1,"form-group"],["for","name"],["type","text","id","name","formControlName","name",1,"form-control"],["for","imagePath"],["type","text","id","imagePath","formControlName","imagePath",1,"form-control"],["imagePath",""],[1,"img-responsive",2,"max-height","300px",3,"src"],["for","description"],["type","text","id","description","formControlName","description","rows","6",1,"form-control"],["formArrayName","ingredients",1,"col-xs-12"],["class","row","style","margin-top:10px;",3,"formGroupName",4,"ngFor","ngForOf"],["type","button",1,"btn","btn-primary","pull-right",3,"click"],[1,"row",2,"margin-top","10px",3,"formGroupName"],[1,"col-xs-8"],["type","text","formControlName","name",1,"form-control"],[1,"col-xs-3"],["type","number","formControlName","amount",1,"form-control"],[1,"col-xs-1"],[1,"btn","btn-danger",3,"click"]],template:function(t,n){if(1&t&&(e.TgZ(0,"div",0)(1,"div",1)(2,"form",2),e.NdJ("ngSubmit",function(){return n.onSubmit()}),e.TgZ(3,"div",0)(4,"div",1)(5,"button",3),e._uU(6,"Save"),e.qZA(),e.TgZ(7,"button",4),e.NdJ("click",function(){return n.onCancel()}),e._uU(8,"Cancel"),e.qZA()()(),e.TgZ(9,"div",0)(10,"div",1)(11,"div",5)(12,"label",6),e._uU(13,"Name"),e.qZA(),e._UZ(14,"input",7),e.qZA()()(),e.TgZ(15,"div",0)(16,"div",1)(17,"div",5)(18,"label",8),e._uU(19,"Image URL"),e.qZA(),e._UZ(20,"input",9,10),e.qZA()()(),e.TgZ(22,"div",0)(23,"div",1),e._UZ(24,"img",11),e.qZA()(),e.TgZ(25,"div",0)(26,"div",1)(27,"div",5)(28,"label",12),e._uU(29,"Description"),e.qZA(),e._UZ(30,"textarea",13),e.qZA()()(),e.TgZ(31,"div",0)(32,"div",14),e.YNc(33,b,8,1,"div",15),e.qZA()(),e._UZ(34,"hr"),e.TgZ(35,"div",0)(36,"button",16),e.NdJ("click",function(){return n.onAddIngredient()}),e._uU(37,"Add New Ingredient"),e.qZA()()()()()),2&t){const c=e.MAs(21);e.xp6(2),e.Q6J("formGroup",n.recipeForm),e.xp6(3),e.Q6J("disabled",!n.recipeForm.valid),e.xp6(19),e.Q6J("src",c.value,e.LSH),e.xp6(9),e.Q6J("ngForOf",n.recipeIngredients.controls)}},dependencies:[u.sg,o._Y,o.Fj,o.wV,o.JJ,o.JL,o.sg,o.u,o.x0,o.CE]}),i})();var h=s(4110);let f=(()=>{class i{constructor(t,n){this.dataStorageService=t,this.reciepeService=n}resolve(t,n){const c=this.reciepeService.getRecipes();return 0===c.length?this.dataStorageService.fetchRecipes():c}}return i.\u0275fac=function(t){return new(t||i)(e.LFG(h.Z),e.LFG(l.j))},i.\u0275prov=e.Yz7({token:i,factory:i.\u0275fac,providedIn:"root"}),i})(),I=(()=>{class i{}return i.\u0275fac=function(t){return new(t||i)},i.\u0275cmp=e.Xpm({type:i,selectors:[["app-recipe-start"]],decls:2,vars:0,template:function(t,n){1&t&&(e.TgZ(0,"h4"),e._uU(1,"Please Select a Recipe"),e.qZA())}}),i})(),U=(()=>{class i{constructor(t){this.recipeService=t}ngOnInit(){}}return i.\u0275fac=function(t){return new(t||i)(e.Y36(l.j))},i.\u0275cmp=e.Xpm({type:i,selectors:[["app-recipe-item"]],inputs:{recipe:"recipe",index:"index"},decls:8,vars:5,consts:[["routerLinkActive","active",1,"list-group-item","clearfix",2,"cursor","pointer",3,"routerLink"],[1,"pull-left"],[1,"list-group-item-heading"],[1,"list-group-item-text"],[1,"pull-right"],[1,"img-responsive",2,"max-height","50px",3,"src","alt"]],template:function(t,n){1&t&&(e.TgZ(0,"a",0)(1,"div",1)(2,"h4",2),e._uU(3),e.qZA(),e.TgZ(4,"p",3),e._uU(5),e.qZA()(),e.TgZ(6,"span",4),e._UZ(7,"img",5),e.qZA()()),2&t&&(e.Q6J("routerLink","/recipes/"+n.index),e.xp6(3),e.Oqu(n.recipe.name),e.xp6(2),e.Oqu(n.recipe.description),e.xp6(2),e.Q6J("src",n.recipe.imagePath,e.LSH)("alt",n.recipe.name))},dependencies:[p.rH,p.Od]}),i})();function F(i,r){if(1&i&&e._UZ(0,"app-recipe-item",4),2&i){const t=r.$implicit;e.Q6J("index",r.index)("recipe",t)}}let y=(()=>{class i{constructor(t,n,c){this.recipeService=t,this.router=n,this.route=c,this.recipes=[]}ngOnInit(){this.recipes=this.recipeService.getRecipes(),this.subscription=this.recipeService.recipeChanged.subscribe(()=>{this.recipes=this.recipeService.getRecipes()})}ngOnDestroy(){this.subscription.unsubscribe()}onNew(){this.router.navigate(["new"],{relativeTo:this.route})}}return i.\u0275fac=function(t){return new(t||i)(e.Y36(l.j),e.Y36(p.F0),e.Y36(p.gz))},i.\u0275cmp=e.Xpm({type:i,selectors:[["app-recipe-list"]],decls:8,vars:1,consts:[[1,"row"],[1,"col-xs-12"],[1,"btn","btn-success",3,"click"],[3,"index","recipe",4,"ngFor","ngForOf"],[3,"index","recipe"]],template:function(t,n){1&t&&(e.TgZ(0,"div",0)(1,"div",1)(2,"button",2),e.NdJ("click",function(){return n.onNew()}),e._uU(3,"New Recipe"),e.qZA()()(),e._UZ(4,"hr"),e.TgZ(5,"div",0)(6,"div",1),e.YNc(7,F,1,2,"app-recipe-item",3),e.qZA()()),2&t&&(e.xp6(7),e.Q6J("ngForOf",n.recipes))},dependencies:[u.sg,U]}),i})();const N=[{path:"",component:(()=>{class i{constructor(t,n,c,a){this.recipeService=t,this.dataStorageService=n,this.authService=c,this.router=a}ngOnInit(){this.dataStorageService.fetchRecipes().subscribe()}}return i.\u0275fac=function(t){return new(t||i)(e.Y36(l.j),e.Y36(h.Z),e.Y36(g.e),e.Y36(p.F0))},i.\u0275cmp=e.Xpm({type:i,selectors:[["app-recipes"]],decls:5,vars:0,consts:[[1,"row"],[1,"col-md-5"],[1,"col-md-7"]],template:function(t,n){1&t&&(e.TgZ(0,"div",0)(1,"div",1),e._UZ(2,"app-recipe-list"),e.qZA(),e.TgZ(3,"div",2),e._UZ(4,"router-outlet"),e.qZA()())},dependencies:[p.lC,y]}),i})(),canActivate:[(i,r)=>{const t=(0,e.f3M)(p.F0).createUrlTree(["/auth"]);return(0,e.f3M)(g.e).user.pipe((0,R.q)(1),(0,_.U)(n=>!!n||t))}],children:[{path:"",component:I},{path:"new",component:v},{path:":id",component:S,resolve:[f]},{path:":id/edit",component:v,resolve:[f]}]}];let w=(()=>{class i{}return i.\u0275fac=function(t){return new(t||i)},i.\u0275mod=e.oAB({type:i}),i.\u0275inj=e.cJS({imports:[p.Bz.forChild(N),p.Bz]}),i})(),q=(()=>{class i{}return i.\u0275fac=function(t){return new(t||i)},i.\u0275mod=e.oAB({type:i}),i.\u0275inj=e.cJS({imports:[Z.m,o.UX,p.Bz,w]}),i})()}}]);