firefly-iii/public/v3/js/2324.a7019e47.js
2022-06-09 20:31:44 +02:00

1 line
4.0 KiB
JavaScript
Vendored

"use strict";(self["webpackChunkfirefly_iii"]=self["webpackChunkfirefly_iii"]||[]).push([[2324],{2324:(s,e,t)=>{t.r(e),t.d(e,{default:()=>M});var r=t(9835),i=t(6970);const a={class:"row q-mx-md"},n={class:"col-12"},o={class:"row q-mx-md q-mt-md"},l={class:"col-12"},d=(0,r._)("div",{class:"text-h6"},"Edit piggy bank",-1),u={class:"row"},c={class:"col-12 q-mb-xs"},m={class:"row q-mx-md"},h={class:"col-12"},g={class:"row"},b={class:"col-12 text-right"},p={class:"row"},f={class:"col-12 text-right"};function w(s,e,t,w,k,_){const v=(0,r.up)("q-btn"),y=(0,r.up)("q-banner"),q=(0,r.up)("q-card-section"),E=(0,r.up)("q-input"),x=(0,r.up)("q-card"),B=(0,r.up)("q-checkbox"),C=(0,r.up)("q-page");return(0,r.wg)(),(0,r.j4)(C,null,{default:(0,r.w5)((()=>[(0,r._)("div",a,[(0,r._)("div",n,[""!==k.errorMessage?((0,r.wg)(),(0,r.j4)(y,{key:0,"inline-actions":"",rounded:"",class:"bg-orange text-white"},{action:(0,r.w5)((()=>[(0,r.Wm)(v,{flat:"",onClick:_.dismissBanner,label:"Dismiss"},null,8,["onClick"])])),default:(0,r.w5)((()=>[(0,r.Uk)((0,i.zw)(k.errorMessage)+" ",1)])),_:1})):(0,r.kq)("",!0)])]),(0,r._)("div",o,[(0,r._)("div",l,[(0,r.Wm)(x,{bordered:""},{default:(0,r.w5)((()=>[(0,r.Wm)(q,null,{default:(0,r.w5)((()=>[d])),_:1}),(0,r.Wm)(q,null,{default:(0,r.w5)((()=>[(0,r._)("div",u,[(0,r._)("div",c,[(0,r.Wm)(E,{"error-message":k.submissionErrors.name,error:k.hasSubmissionErrors.name,"bottom-slots":"",disable:_.disabledInput,type:"text",clearable:"",modelValue:k.name,"onUpdate:modelValue":e[0]||(e[0]=s=>k.name=s),label:s.$t("form.name"),outlined:""},null,8,["error-message","error","disable","modelValue","label"])])])])),_:1})])),_:1})])]),(0,r._)("div",m,[(0,r._)("div",h,[(0,r.Wm)(x,{class:"q-mt-xs"},{default:(0,r.w5)((()=>[(0,r.Wm)(q,null,{default:(0,r.w5)((()=>[(0,r._)("div",g,[(0,r._)("div",b,[(0,r.Wm)(v,{disable:_.disabledInput,color:"primary",label:"Update",onClick:_.submitPiggyBank},null,8,["disable","onClick"])])]),(0,r._)("div",p,[(0,r._)("div",f,[(0,r.Wm)(B,{disable:_.disabledInput,modelValue:k.doReturnHere,"onUpdate:modelValue":e[1]||(e[1]=s=>k.doReturnHere=s),"left-label":"",label:"Return here"},null,8,["disable","modelValue"])])])])),_:1})])),_:1})])])])),_:1})}var k=t(670),_=t(1569);class v{post(s,e){let t="/api/v1/piggy_banks/"+s;return _.api.put(t,e)}}var y=t(3555);const q={name:"Edit",data(){return{submissionErrors:{},hasSubmissionErrors:{},submitting:!1,doReturnHere:!1,doResetForm:!1,errorMessage:"",id:0,name:"",store:null}},computed:{disabledInput:function(){return this.submitting}},created(){this.id=parseInt(this.$route.params.id),this.collectPiggyBank(),this.store=(0,y.S)()},methods:{collectPiggyBank:function(){let s=new k.Z;s.get(this.id).then((s=>this.parsePiggyBank(s)))},parsePiggyBank:function(s){this.name=s.data.data.attributes.name},resetErrors:function(){this.submissionErrors={name:""},this.hasSubmissionErrors={name:!1}},submitPiggyBank:function(){this.submitting=!0,this.errorMessage="",this.resetErrors();const s=this.buildPiggyBank();(new v).post(this.id,s).catch(this.processErrors).then(this.processSuccess)},buildPiggyBank:function(){return{name:this.name}},dismissBanner:function(){this.errorMessage=""},processSuccess:function(s){if(this.store.refreshCacheKey(),!s)return;this.submitting=!1;let e={level:"success",text:"Piggy is updated",show:!0,action:{show:!0,text:"Go to piggy",link:{name:"piggy-banks.show",params:{id:parseInt(s.data.data.id)}}}};this.$q.localStorage.set("flash",e),this.doReturnHere&&window.dispatchEvent(new CustomEvent("flash",{detail:{flash:this.$q.localStorage.getItem("flash")}})),this.doReturnHere||this.$router.go(-1)},processErrors:function(s){if(s.response){let e=s.response.data;this.errorMessage=e.message,console.log(e);for(let s in e.errors)e.errors.hasOwnProperty(s)&&(this.submissionErrors[s]=e.errors[s][0],this.hasSubmissionErrors[s]=!0)}this.submitting=!1}}};var E=t(1639),x=t(9885),B=t(7128),C=t(8879),P=t(4458),S=t(3190),W=t(6611),Z=t(1221),I=t(9984),Q=t.n(I);const R=(0,E.Z)(q,[["render",w]]),M=R;Q()(q,"components",{QPage:x.Z,QBanner:B.Z,QBtn:C.Z,QCard:P.Z,QCardSection:S.Z,QInput:W.Z,QCheckbox:Z.Z})}}]);