import{t as U}from"./Cryk7dx_.js";import{E as S}from"./AM6NDti1.js";import{_ as T,m as I,s as N,i as q,q as O,$ as b,r as n,j as R,o as r,c as p,b as s,w as l,k as m,f as A,d as h,h as H,a,F as v,x as y,t as z}from"./D5hhbjwO.js";/* empty css        */import{E as w}from"./DBk-nsxg.js";const P={setup(){const t=I(null),{loggedInUser:e,accessToken:u}=N(q());return{incidentForm:t,user:e,accessToken:u}},components:{SuccessFilled:O,Editor:S},mixins:[U],props:{show:Boolean,screenshotBlob:{type:[String,Object],default:null}},watch:{show:{immediate:!0,deep:!0,handler(t,e){this.incidentModel.created_on_url=window.location.href,setTimeout(()=>{this.screenshotBlob!=null&&(this.fileList.push({name:"screenshot.png",raw:this.screenshotBlob}),this.incidentModel.attachments=this.fileList)},100)}}},data(){return{categories:[],priorities:["1. Critical","2. High","3. Medium","4. Low"],incidentModel:{id:0,subject:"",priority:"4. Low",description:"",category_ids:[],created_on_url:"",attachments:[]},formLoading:!1,processing:!1,errors:"",fileList:[],rules:{subject:[{required:!0,message:"The subject is required!",trigger:"blur"}],category_ids:[{required:!0,message:"Select at least one category!",trigger:"blur"}]}}},mounted(){this.getData()},methods:{async getData(){this.formLoading=!0;const t=await b().get("/incidentCategories");this.categories=t.data.categories,this.formLoading=!1},submitForm(){this.errors="",this.incidentForm.validate(t=>{if(t)this.processing=!0,this.store();else return console.log("error submit!!"),!1})},store(){let t=new FormData;t.append("subject",this.incidentModel.subject),t.append("priority",this.incidentModel.priority),t.append("description",this.incidentModel.description),t.append("category_ids",this.incidentModel.category_ids),t.append("created_on_url",this.incidentModel.created_on_url);for(let e=0;e<this.incidentModel.attachments.length;e++)t.append(`attachments[${e}]`,this.incidentModel.attachments[e].raw);b().post("/incidents",t).then(e=>{w({title:"Success",message:"The incident has been created successfully!",type:"success"}),this.processing=!1,this.$emit("add",e.data.incident),this.$emit("update:show",!1),this.incidentCommentModel.subject="",this.incidentCommentModel.description="",this.incidentCommentModel.attachments="",this.fileList=[]}).catch(e=>{e.response.status==422?this.errors=response.data:w({message:"There were some errors when saving this incident.",position:"bottom-right",duration:5e3}),this.processing=!1})},dialogClosed(){this.incidentForm.resetFields(),this.incidentModel.id=0,this.incidentModel={id:0,subject:"",priority:"4. Low",description:"",category_ids:[],created_on_url:"",attachments:[]}},handleFileChange(t,e){this.fileList=e,this.incidentModel.attachments=e},handleFileRemove(t,e){this.fileList=e,this.incidentModel.attachments=e}}},G={class:"row"},J={class:"col-md-12"},K={class:"col-md-12"},Q={class:"col-md-12"},W={class:"col-md-12"},X={class:"col-md-12"},Y={class:"col-md-12"};function Z(t,e,u,M,i,c){const k=n("success-filled"),C=n("el-icon"),_=n("el-button"),V=n("ErrorValidation"),F=n("el-input"),d=n("el-form-item"),f=n("el-option"),g=n("el-select"),j=n("editor"),D=n("font-awesome-icon"),L=n("el-upload"),x=n("el-form"),E=n("CustomElDialog"),B=R("loading");return r(),p("div",null,[s(E,{modal:!1,title:"Report Incident","close-on-click-modal":!1,visible:u.show,"onUpdate:visible":e[4]||(e[4]=o=>t.$emit("update:show",o)),onClosed:c.dialogClosed},{title:l(()=>[s(_,{type:"primary",onClick:c.submitForm,loading:i.processing,size:"large"},{default:l(()=>[i.processing?A("",!0):(r(),m(C,{key:0,class:"mr-1"},{default:l(()=>[s(k)]),_:1})),h(" Submit ")]),_:1},8,["onClick","loading"])]),default:l(()=>[s(V,{errors:i.errors},null,8,["errors"]),H((r(),m(x,{"label-position":"top",ref:"incidentForm",model:i.incidentModel,"status-icon":"",rules:i.rules,"label-width":"180px"},{default:l(()=>[a("div",G,[a("div",J,[s(d,{label:"Subject",prop:"subject"},{default:l(()=>[s(F,{modelValue:i.incidentModel.subject,"onUpdate:modelValue":e[0]||(e[0]=o=>i.incidentModel.subject=o)},null,8,["modelValue"])]),_:1})]),a("div",K,[s(d,{label:"Priority",prop:"priority"},{default:l(()=>[s(g,{modelValue:i.incidentModel.priority,"onUpdate:modelValue":e[1]||(e[1]=o=>i.incidentModel.priority=o),filterable:"",placeholder:"Priority"},{default:l(()=>[(r(!0),p(v,null,y(i.priorities,o=>(r(),m(f,{key:o,label:o,value:o},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),a("div",Q,[s(d,{label:"Categories",prop:"category_ids"},{default:l(()=>[s(g,{modelValue:i.incidentModel.category_ids,"onUpdate:modelValue":e[2]||(e[2]=o=>i.incidentModel.category_ids=o),filterable:"",multiple:"",placeholder:"Categories"},{default:l(()=>[(r(!0),p(v,null,y(i.categories,o=>(r(),m(f,{key:o.id,label:o.name,value:o.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),a("div",W,[s(d,{label:"Description",prop:"description"},{default:l(()=>[s(j,{"tinymce-script-src":"/vendor/tinymce/tinymce.min.js",onOnDrop:t.editorHandleDrop,modelValue:i.incidentModel.description,"onUpdate:modelValue":e[3]||(e[3]=o=>i.incidentModel.description=o),init:{browser_spellcheck:!0,plugins:"preview code searchreplace autolink directionality visualblocks visualchars fullscreen image link template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists wordcount imagetools textpattern help",height:300,toolbar:"formatselect | bold italic strikethrough forecolor backcolor permanentpen formatpainter | link image media pageembed | alignleft aligncenter alignright alignjustify  | numlist bullist outdent indent | removeformat | addcomment",link_assume_external_targets:!0,relative_urls:!1,convert_urls:!1,remove_script_host:!0,automatic_uploads:!0,file_picker_types:"image",images_upload_handler:t.editorImageUploadHandler,document_base_url:"https://titlesearch.afxllc.com/"}},null,8,["onOnDrop","modelValue","init"])]),_:1})]),a("div",X,[s(d,null,{default:l(()=>[s(L,{ref:"fileUploader","auto-upload":!1,class:"avatar-uploader","show-file-list":!0,name:"attachments",action:"","on-change":c.handleFileChange,"on-remove":c.handleFileRemove,"file-list":i.fileList},{default:l(()=>[s(_,{size:"small"},{default:l(()=>[s(D,{icon:"paperclip"}),h(" Attachment(s) ")]),_:1})]),_:1},8,["on-change","on-remove","file-list"])]),_:1})]),a("div",Y,[s(d,{label:"Created On",prop:"created_on_url"},{default:l(()=>[h(z(i.incidentModel.created_on_url),1)]),_:1})])])]),_:1},8,["model","rules"])),[[B,i.formLoading]])]),_:1},8,["visible","onClosed"])])}const se=T(P,[["render",Z]]);export{se as A};
