1import{v as K,n as L,a as u,s as O,m as j,w as q,x as B,y as A,u as R,z as G,f as J,A as N}from"./index-mGgJqOFQ.js";import{d as Q,y as T,S as H,bo as W,bn as X,br as Y,bu as Z,E as k,bv as y,J as d,i as aa,o as ea,c as oa,b as _,w as D,z as U,u as n,aa as sa,bk as la,bw as $,U as ra,bl as E,_ as ta}from"./core-Cu1dlvv4.js";const ia=Q({__name:"UserEdit",props:{name:{}},async setup(F){let f,b;const i=F,{t:e}=T(),M=H();[f,b]=W(()=>E.fetchAll([{uri:`users/${i.name}`,cachePath:`userDetails.${i.name}`},{uri:"domains",cachePath:"domains"}])),await f,b();const{domainsAsChoices:w,mainDomain:C}=X(),{user:r}=Y(()=>i.name),h=parseInt(r.value["mailbox-quota"].limit)>0?Z(r.value["mailbox-quota"].limit)??0:0,s=k({username:i.name,fullname:r.value.fullname,mail:y(r.value.mail),mailbox_quota:h,mail_aliases:r.value["mail-aliases"].map(m=>y(m)),mail_forward:[...r.value["mail-forward"]],change_password:"",confirmation:""}),v=d({username:{component:"InputItem",label:e("user_username"),cProps:{id:"username",disabled:!0}},fullname:{component:"InputItem",label:e("user_fullname"),rules:{required:u,nameValidator:L},cProps:{id:"fullname",placeholder:e("placeholder.fullname"),spellcheck:"false"}},mail:d({component:"AdressItem",label:e("user_email"),rules:{localPart:{required:u,email:A},domain:{required:u}},cProps:{id:"mail",choices:w}}),mailbox_quota:{append:"M",component:"InputItem",label:e("user_mailbox_quota"),description:e("mailbox_quota_description"),rules:{integer:K,minValue:B(0)},cProps:{id:"mailbox-quota",placeholder:e("mailbox_quota_placeholder"),type:"number"}},mail_aliases:d({component:"AdressItem",label:e("user_emailaliases"),id:"mail_aliases",rules:q(()=>s.value.mail_aliases,{localPart:{required:u,email:A},domain:{required:u}}),cProps:{placeholder:e("placeholder.username"),choices:w}}),mail_forward:d({component:"InputItem",label:e("user_emailforward"),id:"mail_forward",rules:q(()=>s.value.mail_forward,{required:u,emailForward:N}),cProps:{placeholder:e("user_new_forward"),type:"email"}}),change_password:{component:"InputItem",label:e("password"),description:e("good_practices_about_user_password"),descriptionVariant:"warning",rules:{passwordLenght:j(8)},cProps:{id:"change_password",type:"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",autocomplete:"new-password"}},confirmation:d({component:"InputItem",label:e("password_confirmation"),rules:aa(()=>({passwordMatch:O(s.value.change_password)})),cProps:{id:"confirmation",type:"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",autocomplete:"new-password"}})}),{v:p,onSubmit:S}=R(s,v),z=S(async(m,t)=>{const{username:c,confirmation:g,...o}=await la(s,{removeEmpty:!0}),l={};Object.prototype.hasOwnProperty.call(o,"mailbox_quota")||(o.mailbox_quota=0);for(const a of["mail_aliases","mail_forward"]){const x=a.replace("_","-"),I=a.replace("_","").replace("es",""),P=$(o[a],r.value[x]),V=$(r.value[x],o[a]);P.length&&(l[`add_${I}`]=P),V.length&&(l[`remove_${I}`]=V)}if(ra(o).forEach(a=>{a==="mail_aliases"||a==="mail_forward"||(a==="mailbox_quota"?o[a]!==h&&(l[a]=o[a]>0?o[a]+"M":"0"):a==="change_password"?l.change_password=o[a]:o[a]!==r.value[a]&&(l[a]=o[a]))}),Object.keys(l).length===0){t.global=[e("error_modify_something")];return}E.put({uri:`users/${i.name}`,cachePath:`userDetails.${i.name}`,data:l}).then(()=>{M.push({name:"user-info",params:{name:i.name}})}).catch(m)});return(m,t)=>{const c=G,g=J;return ea(),oa("div",null,[_(g,{modelValue:s.value,"onUpdate:modelValue":t[2]||(t[2]=o=>s.value=o),icon:"user",fields:v,title:m.$t("user_username_edit",{name:m.name}),validations:n(p),onSubmit:sa(n(z),["prevent"])},{"field:mail_aliases":D(o=>[_(c,U(o,{modelValue:s.value.mail_aliases,"onUpdate:modelValue":t[0]||(t[0]=l=>s.value.mail_aliases=l),"add-btn-text":n(e)("user_emailaliases_add"),"default-value":()=>({localPart:"",separator:"@",domain:n(C)}),validation:n(p).form.mail_aliases}),null,16,["modelValue","add-btn-text","default-value","validation"])]),"field:mail_forward":D(o=>[_(c,U(o,{modelValue:s.value.mail_forward,"onUpdate:modelValue":t[1]||(t[1]=l=>s.value.mail_forward=l),"add-btn-text":n(e)("user_emailforward_add"),"default-value":()=>"",validation:n(p).form.mail_forward}),null,16,["modelValue","add-btn-text","validation"])]),_:1},8,["modelValue","fields","title","validations","onSubmit"])])}}}),ua=ta(ia,[["__scopeId","data-v-e71b439b"]]);export{ua 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.