1import{_ as q,c as B,v as M}from"./index-rpK2Mxmx.js";import{C as V,c as z}from"./ckeditorConfig-B2828DRV.js";import{h as w}from"./moment-lgN9U01c.js";import{a2 as f,k as o,a6 as l,ah as H,ai as Y,a5 as s,v as A,W as d,F as g,ag as S,X as x,G as c,ae as b,q as L,a3 as _}from"./vue-E3d3mecD.js";import{f as N}from"./formMixins-C1VyZE4Z.js";import{f as W,a as G}from"./getQueryData-BXVrGk7m.js";import{I as O,P as j}from"./antd-C9qusGDu.js";import"./ckeditor-C5RZI2Xj.js";import"./lodash-BLIbnOd4.js";const X={mixins:[N],components:{PlusOutlined:j,InboxOutlined:O},data(){return{formState:{title:"",content:"",employment_type:null,role_ids:[],position_ids:[],expiry_date:null,expiry_time:null,images:[]},editor:V,editorConfig:z({placeholder:"Type here..."}),employmentType:this.$constants.employment_types,roles:[],employeePositions:[],options:[],infoText:"If no Employment Type, Role or Position is selected, the announcement will be displayed to all employees.",rules:{title:[{required:!0,message:"A title is required!",transform(t){return typeof t=="string"?t.trim():t}}],content:[{required:!0,message:"Content is required!",transform(t){return typeof t=="string"?t.trim():t}}],expiry_date:[{required:!0,message:"Invalid date.",type:"date"}],expiry_time:[{required:!0,message:"This field is required!"},{message:"Invalid time.",validator:M.timeWithSecFormat}]}}},computed:{...Y("drawer",["record"]),submitButtonText(){return this.record.id?"Update":"Create"}},async mounted(){this.getFormState(),this.roles=await W(),this.employeePositions=await G()},created(){},methods:{...H("drawer",["loadingStart","loadingStop","close"]),getFormState(){var t,i,p,r;this.formState={title:this.record.title??"",content:this.record.content??"",employment_type:((t=this.record)==null?void 0:t.employment_type)??null,role_ids:((i=this.record.roles)==null?void 0:i.map(e=>e.id))??[],position_ids:((r=(p=this.record)==null?void 0:p.employee_positions)==null?void 0:r.map(e=>e.id))??[],expiry_date:this.record.expiry_datetime?w(this.record.expiry_datetime):null,expiry_time:this.record.expiry_datetime?w(this.record.expiry_datetime).format("HH:mm:ss"):null,images:this.record.id?this.record.images.map(e=>({id:e.id,status:"Done",url:e.full_file_path,thumbUrl:e.full_file_path,name:e.file_name_with_ext})):[]}},onSubmit(){const t=new FormData;this.record.id&&t.append("id",this.record.id),t.append("title",this.formState.title),t.append("content",this.formState.content),t.append("employment_type",this.formState.employment_type??""),this.formState.position_ids.forEach((r,e)=>{t.append(`position_ids[${e}]`,r)}),this.formState.role_ids.forEach((r,e)=>{t.append(`role_ids[${e}]`,r)}),t.append("expiry_date",this.formState.expiry_date.format("YYYY-MM-DD")),t.append("expiry_time",this.formState.expiry_time);const i=[],p=[];this.formState.images.forEach((r,e)=>{r.id?i.push(r.id):p.push(r)}),i.forEach((r,e)=>{t.append(`old_images[${e}]`,r)}),p.forEach((r,e)=>{t.append(`images[${e}]`,r)}),this.loadingStart(),B.store(this.$constants.adminAnnouncementStoreUrl,t).then(r=>{this.$message.success(r.message),this.close(),this.$emit("callback")}).catch(r=>{this.$message.error(r.message)}).finally(()=>{this.loadingStop()})},handleRemoveReceipt(t){console.log({file:t}),this.formState.images=this.formState.images.filter(i=>i.id!==t.id)},beforeUploadReceipt(t){return t.size<10*1024*1024?this.formState.images.push(t):this.$message.error(`${t.name} size is more then 10MB`),!1}}},J={class:"ant-upload-drag-icon"};function K(t,i,p,r,e,u){const k=s("a-textarea"),m=s("a-form-item"),n=s("a-col"),E=s("ckeditor"),v=s("a-alert"),y=s("a-select-option"),h=s("a-select"),P=s("a-date-picker"),T=s("a-input"),C=s("inbox-outlined"),F=s("a-upload-dragger"),U=s("a-row"),D=s("side-drawer-buttons"),R=s("a-form"),I=A("maska");return d(),f("div",null,[o(R,{onFinish:u.onSubmit,ref:"announcement_form",model:e.formState,rules:e.rules,layout:"vertical",name:"announcement_form"},{default:l(()=>[o(U,{gutter:[20,0]},{default:l(()=>[o(n,{span:24},{default:l(()=>[o(m,{ref:"title",class:"announcement-title-item",label:"Title",name:"title"},{default:l(()=>[o(k,{value:e.formState.title,"onUpdate:value":i[0]||(i[0]=a=>e.formState.title=a),maxlength:200,autoSize:"",placeholder:"Enter title here",showCount:""},null,8,["value"])]),_:1},512)]),_:1}),o(n,{span:24},{default:l(()=>[o(m,{label:"Content",name:"content"},{default:l(()=>[o(E,{modelValue:e.formState.content,"onUpdate:modelValue":i[1]||(i[1]=a=>e.formState.content=a),config:e.editorConfig,editor:e.editor},null,8,["modelValue","config","editor"])]),_:1})]),_:1}),o(n,{span:24},{default:l(()=>[o(v,{message:e.infoText,class:"mb-sm-1",type:"info"},null,8,["message"])]),_:1}),o(n,{span:24},{default:l(()=>[o(m,{label:"Employment Type",name:"employment_type"},{default:l(()=>[o(h,{value:e.formState.employment_type,"onUpdate:value":i[2]||(i[2]=a=>e.formState.employment_type=a),"allow-clear":"",optionFilterProp:"label",placeholder:"Select Employment Type",style:{width:"100%"}},{default:l(()=>[(d(!0),f(g,null,S(e.employmentType,a=>(d(),x(y,{key:a,label:a.text,value:a.value},{default:l(()=>[c(b(a.text),1)]),_:2},1032,["label","value"]))),128))]),_:1},8,["value"])]),_:1})]),_:1}),o(n,{span:24},{default:l(()=>[o(m,{label:"Roles",name:"role_ids"},{default:l(()=>[o(h,{value:e.formState.role_ids,"onUpdate:value":i[3]||(i[3]=a=>e.formState.role_ids=a),"allow-clear":"",mode:"multiple",optionFilterProp:"label",placeholder:"Select Roles",style:{width:"100%"}},{default:l(()=>[(d(!0),f(g,null,S(e.roles,a=>(d(),x(y,{key:a,label:a.name,value:a.id},{default:l(()=>[c(b(a.name),1)]),_:2},1032,["label","value"]))),128))]),_:1},8,["value"])]),_:1})]),_:1}),o(n,{span:24},{default:l(()=>[o(m,{label:"Position",name:"position_ids"},{default:l(()=>[o(h,{value:e.formState.position_ids,"onUpdate:value":i[4]||(i[4]=a=>e.formState.position_ids=a),"allow-clear":"",mode:"multiple",optionFilterProp:"label",placeholder:"Position",style:{width:"100%"}},{default:l(()=>[(d(!0),f(g,null,S(e.employeePositions,a=>(d(),x(y,{key:a,label:a.name,value:a.id},{default:l(()=>[c(b(a.name),1)]),_:2},1032,["label","value"]))),128))]),_:1},8,["value"])]),_:1})]),_:1}),o(n,{span:12},{default:l(()=>[o(m,{label:"Expiry Date",name:"expiry_date"},{default:l(()=>[o(P,{value:e.formState.expiry_date,"onUpdate:value":i[5]||(i[5]=a=>e.formState.expiry_date=a),allowClear:!1,"disabled-date":t.$comman.disabledPastDate,format:t.$constants.datepickerFormat,placeholder:t.$constants.datePickerPlaceholder},null,8,["value","disabled-date","format","placeholder"])]),_:1})]),_:1}),o(n,{span:12},{default:l(()=>[o(m,{label:"Expiry Time",name:"expiry_time"},{default:l(()=>[L(o(T,{value:e.formState.expiry_time,"onUpdate:value":i[6]||(i[6]=a=>e.formState.expiry_time=a),placeholder:"HH:mm:ss"},null,8,["value"]),[[I,t.$constants.timeWithSecMaska]])]),_:1})]),_:1}),o(n,{span:24},{default:l(()=>[o(v,{message:"Images uploaded in ratio of 16/4 are ideal.",class:"mb-sm-1",type:"info"})]),_:1}),o(n,{span:24},{default:l(()=>[o(m,{ref:"images",label:"Images",name:"images"},{default:l(()=>[o(F,{"before-upload":u.beforeUploadReceipt,fileList:e.formState.images,remove:u.handleRemoveReceipt,accept:"image/jpeg,image/png",multiple:""},{default:l(()=>[_("p",J,[o(C)]),i[7]||(i[7]=_("p",{class:"ant-upload-text"}," Click or drag file to this area to upload ",-1)),i[8]||(i[8]=_("p",{class:"ant-upload-hint"},[c("Max file size: 10MB"),_("br")],-1))]),_:1},8,["before-upload","fileList","remove"])]),_:1},512)]),_:1})]),_:1}),o(D,{name:u.submitButtonText},null,8,["name"])]),_:1},8,["onFinish","model","rules"])])}const re=q(X,[["render",K],["__scopeId","data-v-f9203afb"]]);export{re 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.