File manager - Edit - /home/autoph/.trash/assets/index-eec36940.js
Back
import{B as N}from"./index-e42dff26.js";import"./index-b539cd20.js";import{_ as k,r,o as a,c as n,g as u,b as m,f as p,w as A,e as l,a as B,d as S,J as M,G as V}from"./index-c418b874.js";import{C as j,E as Y,D as Q}from"./DeleteButton-a0fb2217.js";/* empty css */import{I as z}from"./index-c596c165.js";import{L as O}from"./Loading-c4750dda.js";import{P as $}from"./Pagination-4c4030ca.js";import{T as H}from"./index-525f24d4.js";import{s as J,T as K,L as W}from"./index-13d0aaa1.js";import{P}from"./PrfstatusService-1823774a.js";import{F as T,l as X}from"./lodash-1fb77e47.js";import{F as E}from"./index-62ba411c.js";import"./vue-cleave.min-7717683a.js";import{C as G}from"./CloseButton-230b85c8.js";import{S as L,U as I}from"./UpdateButton-33c27ee2.js";import{c as U,b as Z,V as D,a as ee}from"./array-2d279bb5.js";import{R as q}from"./RoleGroupService-c714e7e0.js";import{T as te}from"./index-6faaf3f9.js";import{M as oe}from"./Multiselect-5a14611e.js";import{B as se}from"./index-dad1c552.js";import"./xhebrhsj-8e55735d.js";import"./_commonjsHelpers-de833af9.js";import"./es.string.replace-2e300990.js";const re={components:{Button:N},props:{text:{type:String,default:null},link:[String,Object]},setup(){}};function ae(t,e,s,v,o,i){const f=r("Button");return a(),n(f,{btnClass:"text-pink-500 hover:text-pink-700 py-2 px-1",icon:"carbon:settings",iconClass:"text-xl",text:s.text??null,link:s.link},null,8,["text","link"])}const ie=k(re,[["render",ae]]);const le={components:{FormModal:E,FormGroup:T,SubmitButton:L,UpdateButton:I,CloseButton:G,Loading:O,Multiselect:J},data(){return{roleGroupOptions:[],form:{allowed_to_view:[],allowed_to_action:[]},errors:{},state:{showModal:!1,isSaving:!1,isLoading:!1}}},methods:{async fetchRoleGroups(){await q.fetchRecords().then(t=>{t.status==200&&(this.roleGroupOptions=t.data.data.map(e=>({label:e.name,value:e.id})))}).catch(t=>{console.log(t)})},loadRecord(t){this.resetForm(),this.form=Object.assign({},t),this.form.allowed_to_view=this.form.access.filter(e=>e.pivot.permission=="view").map(e=>e.id),this.form.allowed_to_action=this.form.access.filter(e=>e.pivot.permission=="action").map(e=>e.id)},closeModal(){this.state.showModal=!1},resetForm(){this.form={allowed_to_view:[],allowed_to_act:[]}},reload(){this.$emit("reload")},async saveRecord(){this.state.isSaving=!0;let t=Object.assign({},this.form);this.state.isSaving=!1,await P.saveAccess(this.form.id,t).then(e=>{e.status==201&&(this.$swal.fire({title:"Great!",text:"Record successfully saved.",type:"success",icon:"success",timer:2e3}),this.state.showModal=!1,this.resetForm(),this.reload())}).catch(e=>{console.log(e),this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})})},async submitForm(){try{await U().shape({allowed_to_view:Z().min(1,"Allowed to view field is required")}).validate(this.form,{abortEarly:!1}),this.$swal.fire({title:"Are you sure you want to save this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(e=>{e.value&&this.saveRecord()})}catch(t){if(console.log("validation error"),console.log(t),t instanceof D){const e={};t.inner.forEach(s=>{e[s.path]=s.message}),this.errors=e}this.state.isSaving=!1}}},Validating(t){console.log(t)},mounted(){}},ne={class:"p-2"},ce={class:"flex gap-1 justify-end"};function ue(t,e,s,v,o,i){const f=r("Loading"),g=r("Multiselect"),d=r("FormGroup"),y=r("SubmitButton"),_=r("UpdateButton"),C=r("CloseButton"),x=r("FormModal");return a(),n(x,{title:"Role Group Access",active:o.state.showModal,onSubmit:t.confirmSubmit,onClose:i.closeModal,themeClass:"bg-primary-600",sizeClass:"w-full"},{default:u(()=>[o.state.isLoading?(a(),n(f,{key:0,text:"Fetching record"})):m("",!0),o.state.isSaving?(a(),n(f,{key:1,text:"Saving record"})):m("",!0),p("div",ne,[p("form",{onSubmit:e[2]||(e[2]=A((...h)=>t.confirmSubmit&&t.confirmSubmit(...h),["prevent"])),class:"space-y-4"},[p("div",null,[l(d,{label:"Allowed to View",isRequired:!0},{default:u(()=>[l(g,{modelValue:o.form.allowed_to_view,"onUpdate:modelValue":e[0]||(e[0]=h=>o.form.allowed_to_view=h),mode:"tags","close-on-select":!1,searchable:!0,options:o.roleGroupOptions},null,8,["modelValue","options"])]),_:1}),l(d,{label:"Allowed to Action",isRequired:!0},{default:u(()=>[l(g,{modelValue:o.form.allowed_to_action,"onUpdate:modelValue":e[1]||(e[1]=h=>o.form.allowed_to_action=h),mode:"tags","close-on-select":!1,searchable:!0,options:o.roleGroupOptions},null,8,["modelValue","options"])]),_:1})]),p("div",ce,[o.state.isEdit?(a(),n(_,{key:1,onClick:i.submitForm},null,8,["onClick"])):(a(),n(y,{key:0,onClick:i.submitForm},null,8,["onClick"])),l(C,{onClick:i.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["active","onSubmit","onClose"])}const de=k(le,[["render",ue],["__scopeId","data-v-a0c2b287"]]),R="https://ahg-prf-api.autohub.ph/api/v1/status-tags",me={fetchRecords(t={}){return B.get(`${R}`,{params:t})},fetchRecord(t){return B.get(`${R}/${t}`)},async create(t){return B.post(`${R}`,t)},async update(t,e){return B.put(`${R}/${t}`,e)},async remove(t){return B.delete(`${R}/${t}`)}},pe={components:{FormModal:E,FormGroup:T,TextInput:K,TextArea:te,SubmitButton:L,UpdateButton:I,CloseButton:G,Loading:O,Multiselect:oe},data(){return{roleGroupOptions:[],subProcessOptions:[],tagOptions:[],form:{name:"",description:"",allowed_to_view:[],allowed_to_action:[],notes:"",tag_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1}}},methods:{async fetchRoleGroups(){await q.fetchRecords().then(t=>{t.status==200&&(this.roleGroupOptions=t.data.data.map(e=>({label:e.name,value:e.id})))}).catch(t=>{console.log(t)})},async fetchStatusTags(){await me.fetchRecords().then(t=>{t.status==200&&(this.tagOptions=t.data.data.map(e=>({label:e.name,value:e.id})))}).catch(t=>{console.log(t)})},loadRecord(t){const e=Object.assign({},t);this.resetForm(),this.state.isEdit=!0,this.form={id:e.id,name:e.name,description:e.description,allowed_to_view:e.access.filter(s=>s.permission=="view").map(s=>s.role_group_id),allowed_to_action:e.access.filter(s=>s.permission=="action").map(s=>s.role_group_id),notes:e.notes,tag_id:e.tag_id}},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={name:"",description:"",notes:"",tag_id:""}},reload(){this.$emit("reload")},async saveRecord(){if(this.state.isSaving=!0,!this.state.isEdit)this.state.isSaving=!1,await P.create(this.form).then(t=>{t.status==201&&(this.$swal.fire({title:"Great!",text:"Record successfully saved.",type:"success",icon:"success",timer:2e3}),this.state.showModal=!1,this.resetForm(),this.reload())}).catch(t=>{this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})});else{const t=this.form.id;await P.update(t,this.form).then(e=>{e.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully updated.",icon:"success",timer:2e3}),this.state.showModal=!1,this.reload()):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})}).catch(e=>{console.log(e),e.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:e.response.data.message,type:"error",icon:"error"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})}).finally(()=>{this.state.isSaving=!1})}},async submitForm(){try{await U().shape({name:ee().required("Name field is required")}).validate(this.form,{abortEarly:!1}),this.$swal.fire({title:"Are you sure you want to save this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(e=>{e.value&&this.saveRecord()})}catch(t){if(t instanceof D){const e={};t.inner.forEach(s=>{e[s.path]=s.message}),this.errors=e}this.state.isSaving=!1}}},Validating(t){console.log(t)},mounted(){this.fetchRoleGroups(),this.fetchStatusTags()}},fe={class:"p-2"},he={class:"grid lg:grid-cols-2 gap-8"},ge={class:"flex gap-1 justify-end"};function _e(t,e,s,v,o,i){const f=r("Loading"),g=r("TextInput"),d=r("FormGroup"),y=r("TextArea"),_=r("Multiselect"),C=r("SubmitButton"),x=r("UpdateButton"),h=r("CloseButton"),F=r("FormModal");return a(),n(F,{title:o.state.isEdit?"Edit Record":"Create Record",active:o.state.showModal,onSubmit:t.confirmSubmit,onClose:i.closeModal,themeClass:o.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full"},{default:u(()=>[o.state.isEdit&&o.state.isLoading?(a(),n(f,{key:0,text:"Fetching record"})):m("",!0),p("div",fe,[p("form",{onSubmit:e[6]||(e[6]=A((...c)=>t.confirmSubmit&&t.confirmSubmit(...c),["prevent"])),class:"space-y-4"},[o.state.isEdit&&o.state.isLoading?(a(),n(f,{key:0,text:"Fetching record"})):m("",!0),o.state.isSaving?(a(),n(f,{key:1,text:"Saving record"})):m("",!0),p("div",he,[p("div",null,[l(d,{label:"Name",isRequired:!0},{default:u(()=>[l(g,{type:"text",placeholder:"Input name ",modelValue:o.form.name,"onUpdate:modelValue":e[0]||(e[0]=c=>o.form.name=c),error:o.errors.name,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),l(d,{label:"Description",isRequired:!0},{default:u(()=>[l(g,{type:"text",placeholder:"Input description",modelValue:o.form.description,"onUpdate:modelValue":e[1]||(e[1]=c=>o.form.description=c),error:o.errors.description,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),l(d,{label:"Notes"},{default:u(()=>[l(y,{modelValue:o.form.notes,"onUpdate:modelValue":e[2]||(e[2]=c=>o.form.notes=c),error:o.errors.notes,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1})]),p("div",null,[l(d,{label:"Allowed to View",isRequired:!0},{default:u(()=>[l(_,{modelValue:o.form.allowed_to_view,"onUpdate:modelValue":e[3]||(e[3]=c=>o.form.allowed_to_view=c),mode:"tags","close-on-select":!1,searchable:!0,options:o.roleGroupOptions},null,8,["modelValue","options"])]),_:1}),l(d,{label:"Allowed to Action",isRequired:!0},{default:u(()=>[l(_,{modelValue:o.form.allowed_to_action,"onUpdate:modelValue":e[4]||(e[4]=c=>o.form.allowed_to_action=c),mode:"tags","close-on-select":!1,searchable:!0,options:o.roleGroupOptions},null,8,["modelValue","options"])]),_:1}),l(d,{label:"Tag"},{default:u(()=>[l(_,{modelValue:o.form.tag_id,"onUpdate:modelValue":e[5]||(e[5]=c=>o.form.tag_id=c),"close-on-select":!0,searchable:!0,options:o.tagOptions},null,8,["modelValue","options"])]),_:1})])]),p("div",ge,[o.state.isEdit?(a(),n(x,{key:1,onClick:i.submitForm},null,8,["onClick"])):(a(),n(C,{key:0,onClick:i.submitForm},null,8,["onClick"])),l(h,{onClick:i.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const we=k(pe,[["render",_e]]),be={components:{Layout:W,CreateButton:j,InputGroup:z,Loading:O,EditButton:Y,DeleteButton:Q,SettingsButton:ie,Pagination:$,Form:we,FormAccess:de,Badge:se,Table:H},setup(){},data(){return{title:"PRF Status",breadcrumbs:[{text:"Home",href:"/"},{text:"Settings",href:"/settings/prf-status"},{text:"PRF Status",active:!0}],columns:[{label:"#",field:"#"},{label:"Name",field:"name",sortable:!0},{label:"ID",field:"id",sortable:!0},{label:"Description",field:"description"},{label:"Allowed to View",field:"view_access"},{label:"Allowed to Action",field:"action_access"},{label:"Notes",field:"notes"},{label:"Action",field:"action_buttons"}],perPageOptions:[{value:"10",label:"10"},{value:"50",label:"50"},{value:"100",label:"100"}],items:[],totalItems:0,totalPages:0,searchQuery:null,serverOptions:{page:1,rowsPerPage:10,sortBy:"name",sortType:"asc"},state:{isLoading:!1,isEdit:!1,isDeleting:!1}}},watch:{serverOptions:{handler(){console.log(`perPage: ${this.serverOptions.rowsPerPage}`),this.fetchRecords()},deep:!0},searchQuery:X.debounce(function(){this.fetchRecords()},800)},methods:{async fetchRecords(){this.state.isLoading=!0,await P.fetchRecords({keyword:this.searchQuery,page:this.serverOptions.page,per_page:this.serverOptions.rowsPerPage,sortBy:this.serverOptions.sortBy,sortType:this.serverOptions.sortType}).then(t=>{console.log("response");let e=t.data.data;console.log(e),this.items=e,this.items=e.map((s,v)=>({...s,"#":(this.serverOptions.page-1)*this.serverOptions.rowsPerPage+(v+1),view_access:s.access?s.access.filter(o=>o.permission=="view").map(o=>o.role_group_name):null,action_access:s.access?s.access.filter(o=>o.permission=="action").map(o=>o.role_group_name):null})),this.totalItems=t.data.total,this.totalPages=t.data.last_page}).finally(()=>{this.state.isLoading=!1})},async deleteRecord(t){this.$swal.fire({title:"Are you sure?",text:"You want to delete this record?",icon:"warning",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes, delete it!",background:this.$store.themeSettingsStore.isDark?"#1e293b":"#fff"}).then(e=>{e.value&&(this.state.isDeleting=!0,P.remove(t).then(s=>{s.status==200&&(this.$swal.fire({title:"Yaaay!",text:"Record has been deleted successfully.",type:"success",icon:"success",timer:2e3}),this.fetchRecords())}))}).catch(e=>{e.response&&e.response.status==401&&this.$swal.fire({title:"Ooops! something is wrong.",text:"Error deleting record. Please contact system administrator",type:"error",icon:"error",timer:2e3})}).finally(()=>{this.state.isDeleting=!1})},createRecord(){this.$refs.form.state.showModal=!0,this.$refs.form.resetForm()},editRecord(t){this.$refs.form.resetForm(),this.$refs.form.loadRecord(t),this.$refs.form.state.showModal=!0},closeFormModal(){this.$refs.form.state.showModal=!1},editAccess(t){this.$refs.formAccess.resetForm(),this.$refs.formAccess.fetchRoleGroups(),this.$refs.formAccess.loadRecord(t),this.$refs.formAccess.state.showModal=!0},closeAccessModal(){this.$refs.formAccess.state.showModal=!1},handleSort({field:t,sortOrder:e}){this.serverOptions.sortBy=t,this.serverOptions.sortType=e},handleSearch(t){this.searchQuery=t},changePage(t){this.serverOptions.page=t},updateItemsPerPage(t){this.serverOptions.rowsPerPage=t,this.serverOptions.page=1}},mounted(){this.fetchRecords()}},ve={key:0,class:"badge-group"},ye={key:1,class:"badge-group"},Ce={key:2,class:"flex gap-1"};function xe(t,e,s,v,o,i){const f=r("Loading"),g=r("CreateButton"),d=r("Badge"),y=r("EditButton"),_=r("DeleteButton"),C=r("Pagination"),x=r("Table"),h=r("Form"),F=r("FormAccess"),c=r("Layout");return a(),n(c,{breadcrumbs:o.breadcrumbs},{default:u(()=>[p("div",null,[o.state.isLoading?(a(),n(f,{key:0,text:"Fetching records"})):m("",!0),l(x,{headerTitle:o.title,columns:o.columns,rows:o.items,"default-sort-field":o.serverOptions.sortBy,"default-sort-order":o.serverOptions.sortType,onSort:i.handleSort,onSearch:i.handleSearch,"max-height":"600px",headerClass:"rounded-t bg-[url('@/assets/images/background/shopping-venture.jpg')] bg-cover bg-[center] mih-h-24",headerTitleClass:"ml-4 rounded-lg text-white text-4xl",thClass:"py-6",tdClass:"py-4 px-4"},{action:u(()=>[t.$ability.can("add","module")?(a(),n(g,{key:0,onClick:i.createRecord},null,8,["onClick"])):m("",!0)]),"table-row":u(w=>[w.column.field=="view_access"?(a(),S("div",ve,[(a(!0),S(M,null,V(w.row.view_access,b=>(a(),n(d,{key:b,label:b,badgeClass:"bg-primary-700 text-primary-700 bg-opacity-[0.12] m-1"},null,8,["label"]))),128))])):m("",!0),w.column.field=="action_access"?(a(),S("div",ye,[(a(!0),S(M,null,V(w.row.action_access,b=>(a(),n(d,{key:b,label:b,badgeClass:"bg-primary-700 text-primary-700 bg-opacity-[0.12] m-1"},null,8,["label"]))),128))])):m("",!0),w.column.field=="action_buttons"?(a(),S("div",Ce,[t.$ability.can("edit","prfStatus")?(a(),n(y,{key:0,onClick:b=>i.editRecord(w.row)},null,8,["onClick"])):m("",!0),t.$ability.can("delete","prfStatus")?(a(),n(_,{key:1,onClick:b=>i.deleteRecord(w.row.id)},null,8,["onClick"])):m("",!0)])):m("",!0)]),"pagination-bottom":u(()=>[l(C,{currentPage:o.serverOptions.page,totalItems:o.totalItems,totalPages:o.totalPages,itemsPerPage:o.serverOptions.rowsPerPage,onChangePage:i.changePage,onChangeItemsPerPage:i.updateItemsPerPage,pageOptions:[5,10,20,50,100],pageNumberClass:""},null,8,["currentPage","totalItems","totalPages","itemsPerPage","onChangePage","onChangeItemsPerPage"])]),_:1},8,["headerTitle","columns","rows","default-sort-field","default-sort-order","onSort","onSearch"])]),l(h,{onCloseModal:i.closeFormModal,ref:"form",onReload:i.fetchRecords},null,8,["onCloseModal","onReload"]),l(F,{onCloseModal:i.closeAccessModal,ref:"formAccess",onReload:i.fetchRecords},null,8,["onCloseModal","onReload"])]),_:1},8,["breadcrumbs"])}const He=k(be,[["render",xe]]);export{He as default};
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.03 |
proxy
|
phpinfo
|
Settings