text: (self.webpackChunkfusioncms=self.webpackChunkfusioncms||[]).push([[1629],{1629:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>o,getNavigation:()=>a});var i=n(6072);function a(t,e){axios.all([axios.get("/api/navigation/"+t)]).then(axios.spread((function(t){t=t.data.data;var n={name:"",url:"",new_window:0,parent_id:0,order:null,status:1};_.forEach(t.blueprint.sections,(function(t){_.forEach(t.fields,(function(t){n[t.handle]=t.default}))})),e(null,t,n)})))}const r={auth:function(){return{permission:"links.update"}},components:{"shared-form":n(4635).Z},data:function(){return{navigation:{},links:[],form:new i.Z({name:"",url:"",new_window:!1,parent_id:0,order:0,status:!1},!0)}},methods:{submit:function(){var t=this;this.form.post("/api/navigation/"+this.navigation.id+"/links").then((function(e){toast("Link saved successfully","success"),t.$router.push("/navigation/"+t.navigation.id+"/links")})).catch((function(t){toast(t.response.data.message,"failed")}))}},beforeRouteEnter:function(t,e,n){a(t.params.navigation,(function(t,e,a){n(t?function(e){e.$router.push("/navigation"),toast(t.toString(),"danger")}:function(t){t.navigation=e,t.form=new i.Z(a,!0),t.links=_.map(e.links,(function(t){return{label:t.name,value:t.id}})),t.links.unshift({label:"None",value:0}),t.$emit("updateHead")})}))}};const o=(0,n(1900).Z)(r,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[n("portal",{attrs:{to:"title"}},[n("page-title",{attrs:{icon:"anchor"}},[t._v("Create Link")])],1),t._v(" "),n("shared-form",{attrs:{form:t.form,submit:t.submit,navigation:t.navigation,links:t.links}})],1)}),[],!1,null,null,null).exports},4635:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});const i={props:{link:{type:Object,default:function(){return{}}},links:{type:Array,required:!0},navigation:{type:Object,required:!0},form:{type:Object,required:!0},submit:{required:!0}},computed:{sections:function(){var t=[],e=[];return this.navigation.blueprint&&(t=_.filter(this.navigation.blueprint.sections,(function(t){return"body"==t.placement})),e=_.filter(this.navigation.blueprint.sections,(function(t){return"sidebar"==t.placement}))),{body:t,sidebar:e}},fields:function(){var t=[],e=[];return this.navigation.blueprint&&(t=_.filter(this.navigation.blueprint.sections,(function(t){return"body"==t.placement})),t=_.flatMap(t,(function(t){return t.fields})),e=_.filter(this.navigation.blueprint.sections,(function(t){return"sidebar"==t.placement})),e=_.flatMap(e,(function(t){return t.fields}))),{body:t,sidebar:e}}}};const a=(0,n(1900).Z)(i,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[n("portal",{attrs:{to:"actions"}},[n("div",{staticClass:"buttons"},[t.navigation.id&&"sm"!=t.$mq?n("ui-button",{attrs:{to:{name:"links",params:{navigation:t.navigation.id}},variant:"secondary"}},[t._v("Go Back")]):t._e(),t._v(" "),n("ui-button",{attrs:{type:"submit",variant:"primary",disabled:!t.form.hasChanges},on:{click:function(e){return e.preventDefault(),t.submit(e)}}},[t._v("Save")])],1)]),t._v(" "),n("portal",{attrs:{to:"sidebar-right"}},[n("sidebar",{attrs:{id:"link-sidebar"}},[n("sidebar-section",{attrs:{id:"link_panel_status",tabindex:"-1"}},[n("ui-toggle",{attrs:{name:"status",label:"Status",help:t.form.status?"Toggle to disable this link.":"Toggle to enable this link.","true-value":1,"false-value":0},model:{value:t.form.status,callback:function(e){t.$set(t.form,"status",e)},expression:"form.status"}}),t._v(" "),n("ui-select-group",{attrs:{name:"new_window",label:"Open link where",help:"Determine where the link should open.",options:[{label:"New Window",value:1},{label:"Same Window",value:0}]},model:{value:t.form.new_window,callback:function(e){t.$set(t.form,"new_window",e)},expression:"form.new_window"}})],1)],1)],1),t._v(" "),n("ui-card",{attrs:{id:"link_panel",tabindex:"-1"}},[n("ui-card-body",[n("ui-title-group",{attrs:{name:"name",label:"Name",autocomplete:"off",autofocus:"",required:"","has-error":t.form.errors.has("name"),"error-message":t.form.errors.get("name")},model:{value:t.form.name,callback:function(e){t.$set(t.form,"name",e)},expression:"form.name"}}),t._v(" "),n("ui-input-group",{attrs:{name:"url",label:"URL",help:"The URL of the link.",autocomplete:"off","has-error":t.form.errors.has("url"),"error-message":t.form.errors.get("url")},model:{value:t.form.url,callback:function(e){t.$set(t.form,"url",e)},expression:"form.url"}})],1)],1),t._v(" "),t._l(t.sections.body,(function(e){return n("section-card",{key:e.handle,attrs:{id:"collection_panel_"+e.handle,title:e.name,description:e.description,tabindex:"-1"}},[e.fields.length>0?n("div",t._l(e.fields,(function(e){return n(e.type.id+"-fieldtype",{key:e.handle,tag:"component",attrs:{field:e,errors:t.form.errors},model:{value:t.form[e.handle],callback:function(n){t.$set(t.form,e.handle,n)},expression:"form[field.handle]"}})})),1):t._e()])}))],2)}),[],!1,null,null,null).exports}}]);