File manager - Edit - /home/autoph/.trash/assets/index-564c846f.js
Back
import{P as y}from"./PermissionService-eb0257af.js";import{T as R,L as S}from"./index-7e6e3e0e.js";import{C as E,E as F,D as M}from"./DeleteButton-4b4c3fe2.js";import{P as I}from"./index-0bdf7fad.js";import{I as V}from"./index-bb890bdf.js";import{L as B}from"./Loading-72cea012.js";import{F as L}from"./index-7aca01a0.js";import{F as D,l as T}from"./lodash-c1fc8ad0.js";import"./index-03c97535.js";import{_ as O,r as o,o as i,c as l,g as m,b as u,f as h,w as G,e as a,d as U}from"./index-742713c5.js";import{T as q}from"./index-3db24310.js";import"./index-0e0b03a7.js";import{C as N}from"./CloseButton-8c964a52.js";import{S as A,U as Q}from"./UpdateButton-f1ff0bbe.js";/* empty css */import{c as Y,a as x,V as j}from"./array-2d279bb5.js";import"./vue-cleave.min-672a27a8.js";import"./_commonjsHelpers-de833af9.js";import"./xhebrhsj-c0ad78fc.js";import"./es.string.replace-2e300990.js";const z={components:{FormModal:L,FormGroup:D,TextInput:R,TextArea:q,SubmitButton:A,UpdateButton:Q,CloseButton:N,Loading:B},data(){return{menuOptions:null,form:{code:"",name:"",description:""},errors:{},state:{isEdit:null,isSaving:!1,isLoading:!1}}},methods:{loadRecord(e){this.resetForm(),this.state.isEdit=!0,this.form=e},resetForm(){this.state.isEdit=!1,this.form={code:null,name:null,description:null}},async submitForm(){try{await Y().shape({code:x().nullable().required("Code is required"),name:x().nullable().required("Name 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(t=>{t.value?this.saveRecord():this.state.showModal=!1})}catch(e){if(e instanceof j){const t={};e.inner.forEach(n=>{t[n.path]=n.message}),this.errors=t}this.state.isSaving=!1}},async saveRecord(){if(this.state.isSaving=!0,!this.state.isEdit)await y.create(this.form).then(e=>{e.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully saved.",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,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})}).finally(()=>{this.state.isSaving=!1});else{const e=this.form.id;await y.update(e,this.form).then(t=>{t.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully updated.",type:"success",icon:"success",timer:2e3}),this.state.showModal=!1):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})}).catch(t=>{console.log(t),t.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:t.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,this.reload()})}},closeModal(){this.state.showModal=!1},reload(){this.$emit("reload")}},mounted(){this.state.isEdit=!1}},H={class:"lg:p-2"},J={class:"flex gap-1 justify-end"};function K(e,t,n,w,s,r){const f=o("Loading"),g=o("TextInput"),p=o("FormGroup"),v=o("TextArea"),C=o("SubmitButton"),b=o("UpdateButton"),_=o("CloseButton"),P=o("FormModal");return i(),l(P,{title:s.state.isEdit?"Edit Record":"Create Record",active:s.state.showModal,onSubmit:e.confirmSubmit,onClose:r.closeModal,themeClass:s.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"lg:w-1/2"},{default:m(()=>[s.state.isEdit&&s.state.isLoading?(i(),l(f,{key:0,text:"Fetching record"})):u("",!0),s.state.isSaving?(i(),l(f,{key:1,text:"Saving record"})):u("",!0),h("div",H,[h("form",{onSubmit:t[3]||(t[3]=G((...c)=>r.submitForm&&r.submitForm(...c),["prevent"])),class:"space-y-4"},[a(p,{label:"Code",isRequired:!0},{default:m(()=>[a(g,{type:"text",placeholder:"Input code ",modelValue:s.form.code,"onUpdate:modelValue":t[0]||(t[0]=c=>s.form.code=c),error:s.errors.code,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),a(p,{label:"Name",isRequired:!0},{default:m(()=>[a(g,{type:"text",placeholder:"Input name ",modelValue:s.form.name,"onUpdate:modelValue":t[1]||(t[1]=c=>s.form.name=c),error:s.errors.name,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),a(p,{label:"Description"},{default:m(()=>[a(v,{placeholder:"Input description",modelValue:s.form.description,"onUpdate:modelValue":t[2]||(t[2]=c=>s.form.description=c)},null,8,["modelValue"])]),_:1}),h("div",J,[s.state.isEdit?(i(),l(b,{key:1,onClick:r.submitForm},null,8,["onClick"])):(i(),l(C,{key:0,onClick:r.submitForm},null,8,["onClick"])),a(_,{onClick:r.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const W=O(z,[["render",K]]);const X={components:{Layout:S,Loading:B,Pagination:I,InputGroup:V,CreateButton:E,EditButton:F,DeleteButton:M,Form:W},data(){return{title:"Permissions",breadcrumbs:[{text:"Home",href:"/"},{text:"Masterfile",href:"/settings/permissions"},{text:"Permissions",active:!0}],state:{isEdit:!1,isLoading:!1,isMounted:!1,isResetError:!1,isSubmitted:!1,showModal:!1,isDeleting:!1},items:[],error:[],totalItems:0,columns:[{label:"#",field:"#",tdClass:"text-center w-[20px]",sortable:!1},{label:"Code",field:"code"},{label:"Name",field:"name"},{label:"Description",field:"description"},{label:"Action",field:"action",tdClass:"self-center w-[100px]",sortable:!1}],perPageOptions:[{value:"10",label:"10"},{value:"50",label:"50"},{value:"100",label:"100"}],searchQuery:"",serverOptions:{page:1,rowsPerPage:10,sortBy:"name",sortType:"asc"}}},watch:{serverOptions:{handler(){console.log(`perPage: ${this.serverOptions.rowsPerPage}`),this.fetchRecords()},deep:!0},searchQuery:T.debounce(function(){this.fetchRecords()},800)},computed:{perPage:function(){return this.serverOptions.rowsPerPage}},methods:{async fetchRecords(){this.state.isLoading=!0,this.state.isMounted=!1,await y.fetchRecords({keyword:this.searchQuery,page:this.serverOptions.page,per_page:this.serverOptions.rowsPerPage,sortBy:this.serverOptions.sortBy,sortType:this.serverOptions.sortType}).then(e=>{console.log(e);let t=e.data.data;this.items=t.map((n,w)=>({...n,"#":(this.serverOptions.page-1)*this.serverOptions.rowsPerPage+(w+1)})),this.totalItems=e.data.total??0}).finally(()=>{this.state.isLoading=!1,this.state.isMounted=!0})},handlePageChange(e){console.log(e),console.log(this.serverOptions.page),this.serverOptions.page!=e&&(this.serverOptions.page=e)},handlePerPageChange(e){this.serverOptions.rowsPerPage=e},onSortChange(e){console.log(e),e[0].type!="none"&&(this.serverOptions.sortBy=e[0].field,this.serverOptions.sortType=e[0].type)},createRecord(){this.$refs.form.state.showModal=!0,this.$refs.form.resetForm()},editRecord(e){this.$refs.form.resetForm(),this.$refs.form.loadRecord(e),this.$refs.form.state.showModal=!0},async deleteRecord(e){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(t=>{t.value&&(this.state.isDeleting=!0,y.remove(e).then(n=>{n.status==200&&(this.$swal.fire({title:"Yaaay!",text:"Record has been deleted successfully.",type:"success",icon:"success",timer:2e3}),this.fetchRecords())}).catch(n=>{n.response&&n.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}))})}},mounted(){this.fetchRecords()}},Z={key:0,class:"flex gap-1"},$={class:"py-4 px-3 flex justify-end"};function ee(e,t,n,w,s,r){const f=o("InputGroup"),g=o("CreateButton"),p=o("Loading"),v=o("EditButton"),C=o("DeleteButton"),b=o("Pagination"),_=o("vue-good-table"),P=o("Form"),c=o("Layout");return i(),l(c,{header:s.title,headerIcon:"mdi:file-cabinet",breadcrumbs:s.breadcrumbs},{search:m(()=>[a(f,{modelValue:s.searchQuery,"onUpdate:modelValue":t[0]||(t[0]=d=>s.searchQuery=d),class:"w-full border focus:border-cyan-500",placeholder:"Search",type:"text",prependIcon:"heroicons-outline:search",merged:""},null,8,["modelValue"])]),action:m(()=>[e.$ability.can("add","permission")?(i(),l(g,{key:0,onClick:r.createRecord},null,8,["onClick"])):u("",!0)]),default:m(()=>[h("div",null,[s.state.isLoading?(i(),l(p,{key:0,searching:!0,text:"Fetching records"})):u("",!0),s.state.isDeleting?(i(),l(p,{key:1,text:"Deleting record"})):u("",!0),a(_,{columns:s.columns,styleClass:"vgt-table lesspadding v-middle",mode:"remote",rows:s.items,search:!0,"sort-options":{enabled:!0},"pagination-options":{enabled:!0},onSortChange:r.onSortChange,"max-height":"600px"},{"table-row":m(d=>[d.column.field=="action"?(i(),U("div",Z,[e.$ability.can("edit","permission")?(i(),l(v,{key:0,onClick:k=>r.editRecord(d.row)},null,8,["onClick"])):u("",!0),e.$ability.can("delete","permission")?(i(),l(C,{key:1,onClick:k=>r.deleteRecord(d.row.id)},null,8,["onClick"])):u("",!0)])):u("",!0)]),"pagination-bottom":m(d=>[h("div",$,[a(b,{total:s.totalItems,current:s.serverOptions.page,"per-page":s.serverOptions.rowsPerPage,onPageChanged:r.handlePageChange,pageChanged:d.pageChanged,perPageChanged:s.serverOptions.rowsPerPage,enableSelect:"",perPageOptions:s.perPageOptions,onChangePerPage:r.handlePerPageChange},null,8,["total","current","per-page","onPageChanged","pageChanged","perPageChanged","perPageOptions","onChangePerPage"])])]),_:1},8,["columns","rows","onSortChange"])]),a(P,{editData:e.editData,onCloseModal:t[1]||(t[1]=d=>s.state.showModal=!1),ref:"form",onReload:t[2]||(t[2]=d=>r.fetchRecords())},null,8,["editData"])]),_:1},8,["header","breadcrumbs"])}const be=O(X,[["render",ee],["__scopeId","data-v-5388d258"]]);export{be as default};
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings