1import{G as _,S as C,Tt as s,_t as n,ft as d,k as g}from"./Sy73EA5S.js";import{m as P}from"./C5DEmlk8.js";import{t as S}from"./jp6zKvM7.js";import{t as E}from"./BAoCsJed.js";import{t as w}from"./5szJIr4Q.js";import{t as b}from"./Dj2hRMOS.js";import{t as x}from"./CJvjscdV.js";import{t as M}from"./BQoOBjNj2.js";import{t as B}from"./D3IbRSzO.js";var L=g({__name:"create",setup(R){M({layout:"admin",requiredAuthority:w.CHECKLIST_TEMPLATE_CREATE});const{checklistTemplateApi:m,checklistTemplateActivityApi:v,checklistTemplateActivityContactApi:f}=E(),u=b(),T=P(),y=S(),h=x(),a=n({title:"",periodType:"",municipalityId:null,description:""}),i=n([]),c=n(!1);async function A(){c.value=!0;const r={title:a.value.title.trim()??"",description:a.value.description??"",periodType:a.value.periodType??"",active:!0,municipalityId:a.value.municipalityId},t=(await m.create({checklistTemplatePost:r}))?.data;if(!t){u.showErrorToast("Toast.genericError");return}for(let e=0;e<i.value.length;e++){const o=i.value[e],k={title:o?.title?.trim()??"",description:o?.description?.trim()??"",index:e},l=(await v.create({checklistTemplateId:t,checklistTemplateActivityPost:k}))?.data;if(l&&o?.contactIds&&o.contactIds.length>0)for(const p of o.contactIds){if(!p)continue;const I={checklistTemplateActivityId:l,contactId:p};await f.create({activityId:l,checklistTemplateActivityContactPost:I})}}u.showSuccessToast("Toast.changesSaved"),await T.replace({path:y("admin-checklist-template-update"),query:{id:t}}),c.value=!1}return(r,t)=>(_(),C(B,{"model-value":s(a),"onUpdate:modelValue":t[0]||(t[0]=e=>d(a)?a.value=e:null),activities:s(i),"onUpdate:activities":t[1]||(t[1]=e=>d(i)?i.value=e:null),"is-update-mode":!1,"save-button-text":r.$t("generic.save"),disabled:s(c),onSave:A,onCancel:t[2]||(t[2]=e=>s(h).routerBackAdmin())},null,8,["model-value","activities","save-button-text","disabled"]))}}),z=L;export{z as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.