import{_ as x,m as a,T as y,d as n,o as c,e as u,w as l,g as m,h as r,j as k,t as v,O as V}from"./index.cf09daef.js";import{Q as C}from"./QPage.17eab31b.js";import{S as N}from"./SkeletonSinglePage.c6d95753.js";import{u as D}from"./location.b02c5e7e.js";import"./QSkeleton.b65f9727.js";const p={is_active:!0},L={components:{SkeletonSinglePage:N},data(){return{default:a.exports.cloneDeep(p),location:a.exports.cloneDeep(p),loaded:!1,submited:!1}},methods:{...y(D,["store","show","update"]),onSubmit(e){console.func("pages/admins/locations/LocationPage:methods.onSubmit()",arguments),this.submited=!0,(this.creating?this.store:this.update)(this.location).then(({data:t,message:h})=>{this.submited=!1,this.$q.notify(h),this.location=t,this.default=a.exports.cloneDeep(t),this.$router.push({name:"Location",params:{id:t.id},query:{action:"edit"}})}).catch(t=>{this.submited=!1,this.$core.error(t,{title:this.$t("dialog.title.error")})})},onReset(e){console.func("pages/admins/locations/LocationPage:methods.onReset()",arguments),this.loaded=!1,this.$nextTick(()=>{this.location=a.exports.cloneDeep(this.default),this.loaded=!0})},onCancel(e){console.func("pages/admins/locations/LocationPage:methods.onCancel()",arguments),this.$router.go(-1)}},async mounted(){this.creating?this.loaded=!0:this.show(this.id).then(e=>{this.location=e,this.default=a.exports.cloneDeep(e),this.loaded=!0}).catch(e=>{this.$emit("error",e)})},computed:{edit(){return["add","edit"].includes(this.action)||this.id==="add"},creating(){return this.id==="add"},id(){return this.$route.params.id},action(){return this.$route.query.action},disable(){return this.default&&JSON.stringify(this.location)===JSON.stringify(this.default)},resetable(){return this.default&&JSON.stringify(this.location)!==JSON.stringify(this.default)}}},P={class:"q-gutter-md"},q={class:"col-xs-12 col-sm-12"},O={class:"col-xs-12"};function R(e,s,t,h,o,i){const b=n("base-label"),f=n("base-input"),g=n("base-section"),_=n("base-form"),S=n("skeleton-single-page");return c(),u(C,{padding:""},{default:l(()=>[o.loaded?(c(),u(_,{key:0,onSubmit:i.onSubmit,onCancel:i.onCancel,onReset:i.onReset,resetable:i.resetable,disable:i.disable,submited:o.submited},{default:l(()=>[m("div",P,[r(g,{flat:"",bordered:"",title:e.$t("generalInformation")},{default:l(()=>[m("div",q,[r(b,{required:""},{default:l(()=>[k(v(e.$t("label.label")),1)]),_:1}),r(f,{modelValue:o.location.label,"onUpdate:modelValue":s[0]||(s[0]=d=>o.location.label=d),name:"label",type:"text"},null,8,["modelValue"])]),m("div",O,[r(V,{dense:"",modelValue:o.location.is_active,"onUpdate:modelValue":s[1]||(s[1]=d=>o.location.is_active=d),label:e.$t("active"),color:"green"},null,8,["modelValue","label"])])]),_:1},8,["title"])])]),_:1},8,["onSubmit","onCancel","onReset","resetable","disable","submited"])):(c(),u(S,{key:1}))]),_:1})}var T=x(L,[["render",R]]);export{T as default};
