mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
2 lines
4.9 KiB
JavaScript
2 lines
4.9 KiB
JavaScript
var F=Object.defineProperty;var M=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var C=(c,o,n)=>o in c?F(c,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):c[o]=n,V=(c,o)=>{for(var n in o||(o={}))O.call(o,n)&&C(c,n,o[n]);if(M)for(var n of M(o))R.call(o,n)&&C(c,n,o[n]);return c};import{u as X,g as H,i as q,j as J,k as h,m as N,n as $,p as K,q as Q,D as W,M as Y,r as m,o as Z,s as ee,w as l,t as _,v as B,x as I,y as e,b as i,z as te,B as ae}from"./vendor.e9042f2c.js";import{g as oe,u as ne,r as se,f as re,o as ie,j as ue}from"./main.50c1f863.js";const le={class:"flex justify-between w-full"},ce=["onSubmit"],de={class:"px-8 py-8 sm:p-6"},me={class:"z-0 flex justify-end px-4 py-4 border-t border-solid border-gray-light"},ye={setup(c){const o=oe(),n=ne(),t=se(),z=re(),E=ie(),j=ue(),d=X(),{t:v}=H();let p=q(!1);const x=J(["Invoice","Estimate","Payment"]);let f=q(["customer","customerCustom"]);const D=h(()=>o.active&&o.componentName==="NoteModal"),P=h(()=>({currentNote:{name:{required:N.withMessage(v("validation.required"),$),minLength:N.withMessage(v("validation.name_min_length",{count:3}),K(3))},notes:{required:N.withMessage(v("validation.required"),$)},type:{required:N.withMessage(v("validation.required"),$)}}})),s=Q(P,h(()=>t));W(()=>t.currentNote.type,a=>{b()}),Y(()=>{d.name==="estimates.create"?t.currentNote.type="Estimate":d.name==="invoices.create"?t.currentNote.type="Invoice":t.currentNote.type="Payment"});function b(){f.value=["customer","customerCustom"],t.currentNote.type=="Invoice"&&f.value.push("invoice","invoiceCustom"),t.currentNote.type=="Estimate"&&f.value.push("estimate","estimateCustom"),t.currentNote.type=="Payment"&&f.value.push("payment","paymentCustom")}async function k(){if(s.value.currentNote.$touch(),s.value.currentNote.$invalid)return!0;if(p.value=!0,t.isEdit){let a=V({id:t.currentNote.id},t.currentNote);await t.updateNote(a).then(r=>{p.value=!1,r.data&&(n.showNotification({type:"success",message:v("settings.customization.notes.note_updated")}),o.refreshData&&o.refreshData(),y())}).catch(r=>{p.value=!1})}else await t.addNote(t.currentNote).then(a=>{p.value=!1,a.data&&(n.showNotification({type:"success",message:v("settings.customization.notes.note_added")}),(d.name==="invoices.create"&&a.data.data.type==="Invoice"||d.name==="invoices.edit"&&a.data.data.type==="Invoice")&&z.selectNote(a.data.data),(d.name==="estimates.create"&&a.data.data.type==="Estimate"||d.name==="estimates.edit"&&a.data.data.type==="Estimate")&&j.selectNote(a.data.data),(d.name==="payments.create"&&a.data.data.type==="Payment"||d.name==="payments.edit"&&a.data.data.type==="Payment")&&E.selectNote(a.data.data)),o.refreshData&&o.refreshData(),y()}).catch(a=>{p.value=!1})}function y(){o.closeModal(),setTimeout(()=>{t.resetCurrentNote(),s.value.$reset()},300)}return(a,r)=>{const w=m("BaseIcon"),G=m("BaseInput"),g=m("BaseInputGroup"),U=m("BaseMultiselect"),L=m("BaseCustomInput"),T=m("BaseInputGrid"),S=m("BaseButton"),A=m("BaseModal");return Z(),ee(A,{show:e(D),onClose:y,onOpen:b},{header:l(()=>[_("div",le,[B(I(e(o).title)+" ",1),i(w,{name:"XIcon",class:"h-6 w-6 text-gray-500 cursor-pointer",onClick:y})])]),default:l(()=>[_("form",{action:"",onSubmit:ae(k,["prevent"])},[_("div",de,[i(T,{layout:"one-column"},{default:l(()=>[i(g,{label:a.$t("settings.customization.notes.name"),variant:"vertical",error:e(s).currentNote.name.$error&&e(s).currentNote.name.$errors[0].$message,required:""},{default:l(()=>[i(G,{modelValue:e(t).currentNote.name,"onUpdate:modelValue":r[0]||(r[0]=u=>e(t).currentNote.name=u),invalid:e(s).currentNote.name.$error,type:"text",onInput:r[1]||(r[1]=u=>e(s).currentNote.name.$touch())},null,8,["modelValue","invalid"])]),_:1},8,["label","error"]),i(g,{label:a.$t("settings.customization.notes.type"),error:e(s).currentNote.type.$error&&e(s).currentNote.type.$errors[0].$message,required:""},{default:l(()=>[i(U,{modelValue:e(t).currentNote.type,"onUpdate:modelValue":r[2]||(r[2]=u=>e(t).currentNote.type=u),options:e(x),"value-prop":"type",class:"mt-2"},null,8,["modelValue","options"])]),_:1},8,["label","error"]),i(g,{label:a.$t("settings.customization.notes.notes"),error:e(s).currentNote.notes.$error&&e(s).currentNote.notes.$errors[0].$message,required:""},{default:l(()=>[i(L,{modelValue:e(t).currentNote.notes,"onUpdate:modelValue":r[3]||(r[3]=u=>e(t).currentNote.notes=u),invalid:e(s).currentNote.notes.$error,fields:e(f),onInput:r[4]||(r[4]=u=>e(s).currentNote.notes.$touch())},null,8,["modelValue","invalid","fields"])]),_:1},8,["label","error"])]),_:1})]),_("div",me,[i(S,{class:"mr-2",variant:"primary-outline",type:"button",onClick:y},{default:l(()=>[B(I(a.$t("general.cancel")),1)]),_:1}),i(S,{loading:e(p),disabled:e(p),variant:"primary",type:"submit"},{left:l(u=>[i(w,{name:"SaveIcon",class:te(u.class)},null,8,["class"])]),default:l(()=>[B(" "+I(e(t).isEdit?a.$t("general.update"):a.$t("general.save")),1)]),_:1},8,["loading","disabled"])])],40,ce)]),_:1},8,["show"])}}};export{ye as _};
|