import{u as k,t as V,s as q,r as l,o as p,k as B,l as m,d,e as r,x as h,y as c,b as A,f as i,a as g,F,A as E,L as U}from"./app-44623493.js";const R={class:"grid grid-cols-2 gap-6"},H={class:"col-span-2 sm:col-span-1"},w={class:"col-span-2 sm:col-span-1"},C={class:"col-span-2"},I={class:"col-span-4 sm:col-span-1"},z={key:0},G={class:"col-span-4 sm:col-span-1"},J={name:"LeaveAllocationForm"},K=Object.assign(J,{setup(O){const _=k(),s={employee:"",startDate:"",endDate:"",records:[],description:""},D="leave/allocation/",y=V({leaveTypes:[]}),n=q(D),t=V({...s}),b=V({employee:"",isLoaded:!_.params.uuid}),P=o=>{Object.assign(y,o),y.leaveTypes.forEach(a=>{s.records.push({leaveType:a,allotted:0})}),Object.assign(t,U(s))},j=o=>{var a,f;Object.assign(s,{employee:(a=o.employee)==null?void 0:a.uuid,startDate:o.startDate.value,endDate:o.endDate.value,description:o.description}),s.records.forEach(u=>{let v=o.records.find(T=>T.leaveType.uuid==u.leaveType.uuid);v!==void 0&&(u.leaveType=v.leaveType,u.allotted=v.allotted)}),Object.assign(t,U(s)),b.employee=(f=o.employee)==null?void 0:f.uuid,b.isLoaded=!0};return(o,a)=>{const f=l("BaseSelectSearch"),u=l("DatePicker"),v=l("BaseTextarea"),T=l("BaseLabel"),N=l("BaseInput"),S=l("FormAction");return p(),B(S,{"pre-requisites":!0,onSetPreRequisites:P,"init-url":D,"init-form":s,form:t,"set-form":j,redirect:"LeaveAllocation"},{default:m(()=>[d("div",R,[d("div",H,[b.isLoaded?(p(),B(f,{key:0,name:"employee",label:o.$trans("global.select",{attribute:o.$trans("employee.employee")}),modelValue:t.employee,"onUpdate:modelValue":a[0]||(a[0]=e=>t.employee=e),error:r(n).employee,"onUpdate:error":a[1]||(a[1]=e=>r(n).employee=e),"value-prop":"uuid","init-search":b.employee,"additional-search-query":{self:0},"search-key":"name","search-action":"employee/list"},{selectedOption:m(e=>[h(c(e.value.name)+" ("+c(e.value.codeNumber)+") ",1)]),listOption:m(e=>[h(c(e.option.name)+" ("+c(e.option.codeNumber)+") ",1)]),_:1},8,["label","modelValue","error","init-search"])):A("",!0)]),d("div",w,[i(u,{start:t.startDate,"onUpdate:start":a[2]||(a[2]=e=>t.startDate=e),end:t.endDate,"onUpdate:end":a[3]||(a[3]=e=>t.endDate=e),name:"dateBetween",as:"range",label:o.$trans("general.date_between")},null,8,["start","end","label"])]),d("div",C,[i(v,{modelValue:t.description,"onUpdate:modelValue":a[4]||(a[4]=e=>t.description=e),name:"description",label:o.$trans("leave.allocation.props.description"),error:r(n).description,"onUpdate:error":a[5]||(a[5]=e=>r(n).description=e)},null,8,["modelValue","label","error"])])]),(p(!0),g(F,null,E(t.records,(e,$)=>(p(),g("div",{class:"mt-4 grid grid-cols-4 gap-3",key:e.leaveType.uuid},[d("div",I,[i(T,{class:"mt-4"},{default:m(()=>[h(c(e.leaveType.name)+" ",1),e.leaveType.alias?(p(),g("span",z,"("+c(e.leaveType.alias)+")",1)):A("",!0)]),_:2},1024)]),d("div",G,[i(N,{type:"number",name:`records.${$}.allotted`,modelValue:e.allotted,"onUpdate:modelValue":L=>e.allotted=L,placeholder:o.$trans("leave.allocation.props.allotted"),error:r(n)[`records.${$}.allotted`],"onUpdate:error":L=>r(n)[`records.${$}.allotted`]=L},null,8,["name","modelValue","onUpdate:modelValue","placeholder","error","onUpdate:error"])])]))),128))]),_:1},8,["form"])}}}),M={name:"LeaveAllocationAction"},W=Object.assign(M,{setup(O){const _=k();return(s,D)=>{const y=l("PageHeaderAction"),n=l("PageHeader"),t=l("ParentTransition");return p(),g(F,null,[i(n,{title:s.$trans(r(_).meta.trans,{attribute:s.$trans(r(_).meta.label)}),navs:[{label:s.$trans("leave.leave"),path:"Leave"},{label:s.$trans("leave.allocation.allocation"),path:"LeaveAllocationList"}]},{default:m(()=>[i(y,{name:"LeaveAllocation",title:s.$trans("leave.allocation.allocation"),actions:["list"]},null,8,["title"])]),_:1},8,["title","navs"]),i(t,{appear:"",visibility:!0},{default:m(()=>[i(K)]),_:1})],64)}}});export{W as default};
