text: "use strict";(self.webpackChunk=self.webpackChunk||[]).push([[155],{3155:(e,t,n)=>{n.r(t),n.d(t,{default:()=>i});var o=n(7757),a=n.n(o);function r(e,t,n,o,a,r,l){try{var i=e[r](l),s=i.value}catch(e){return void n(e)}i.done?t(s):Promise.resolve(s).then(o,a)}const l={name:"Roles",data:function(){return{loading:!0,dialogDelete:!1,headers:[{text:"#",value:"index"},{text:"Имя",value:"name"},{text:"Code",value:"slug",sortable:!1},{text:"Действия",value:"actions",sortable:!1}],roles:[],role:{},errors:[]}},mounted:function(){this.fetchRoles()},methods:{fetchRoles:function(){var e,t=this;return(e=a().mark((function e(){return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,axios.get("/api/roles").then((function(e){var n;t.roles=null!==(n=e.data)&&void 0!==n?n:[]})).catch((function(e){console.log(e)})).finally((function(){return t.loading=!1}));case 2:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(o,a){var l=e.apply(t,n);function i(e){r(l,o,a,i,s,"next",e)}function s(e){r(l,o,a,i,s,"throw",e)}i(void 0)}))})()},create:function(){this.$router.push("roles/create")},edit:function(e){this.$router.push("/roles/"+e.id+"/edit")},closeDelete:function(){this.dialogDelete=!1},deleteRole:function(e){this.role=Object.assign({},e),this.dialogDelete=!0},deleteItemConfirm:function(){var e=this;axios.delete("/api/roles/"+this.role.id).then((function(t){e.dialogDelete=!1,e.role={},e.$store.dispatch("showAlert",{isVisible:!0,msg:t.data.msg,color:t.data.status?"green":"error",type:t.data.status?"success":"error"}),e.fetchRoles()})).catch((function(e){console.log(e)}))}}};const i=(0,n(1900).Z)(l,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("v-data-table",{staticClass:"elevation-1",attrs:{headers:e.headers,items:e.roles,loading:e.loading,"loading-text":"Loading... Please wait"},scopedSlots:e._u([{key:"item.index",fn:function(t){var n=t.index;return[e._v("\n        "+e._s(n+1)+"\n    ")]}},{key:"top",fn:function(){return[n("v-toolbar",{attrs:{flat:""}},[n("v-toolbar-title",[e._v("Роли")]),e._v(" "),n("v-divider",{staticClass:"mx-4",attrs:{inset:"",vertical:""}}),e._v(" "),n("v-spacer"),e._v(" "),n("v-btn",{staticClass:"mb-2",attrs:{color:"primary",dark:""},on:{click:e.create}},[e._v("\n                Добавить\n            ")]),e._v(" "),n("v-dialog",{attrs:{"max-width":"500px"},model:{value:e.dialogDelete,callback:function(t){e.dialogDelete=t},expression:"dialogDelete"}},[n("v-card",[n("v-card-title",{staticClass:"text-h5"},[e._v("Are you sure you want to delete this item?")]),e._v(" "),n("v-card-actions",[n("v-spacer"),e._v(" "),n("v-btn",{attrs:{color:"blue darken-1",text:""},on:{click:e.closeDelete}},[e._v("Cancel")]),e._v(" "),n("v-btn",{attrs:{color:"blue darken-1",text:""},on:{click:e.deleteItemConfirm}},[e._v("OK")]),e._v(" "),n("v-spacer")],1)],1)],1)],1)]},proxy:!0},{key:"item.actions",fn:function(t){var o=t.item;return[n("v-icon",{staticClass:"mr-2",attrs:{small:""},on:{click:function(t){return e.edit(o)}}},[e._v("\n            mdi-pencil\n        ")]),e._v(" "),n("v-icon",{attrs:{small:""},on:{click:function(t){return e.deleteRole(o)}}},[e._v("\n            mdi-delete\n        ")])]}}])})}),[],!1,null,null,null).exports}}]);