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