summaryrefslogblamecommitdiffstats
path: root/webapp/src/store/permissions.js
blob: 5f16045140483755bc73f84fbc04f4b7f911a048 (plain) (tree)
1
2
3
4
5
6
7
8
9





                         
                        
                      
                                                 

              






                                                                    


            
                         
                                                


                                                 
                               



                                                       


                                         


     
import axios from 'axios'

export default {
  namespaced: true,
  state: {
    roles: [],
    permissionsList: [],
    selectedUsers: [],
    dialog: { show: false, type: null, info: {} }
  },
  mutations: {
    setRoles (state, value) { state.roles = value },
    setSelectedUsers (state, value) { state.selectedUsers = value },
    setPermissions (state, value) { state.permissionsList = value },
    setDialog (state, { show, type, info }) {
      if (show !== undefined) state.dialog.show = show
      if (type !== undefined) state.dialog.type = type
      if (info !== undefined) state.dialog.info = info
    }
  },
  actions: {
    loadRoles (context) {
      axios.get('/api/roles').then(response => {
        context.commit('setRoles', response.data)
      })
    },
    loadPermissions (context) {
      axios.get('/api/permissions').then(response => {
        context.commit('setPermissions', response.data)
      })
    },
    loadLists (context) {
      context.dispatch('loadRoles')
      context.dispatch('loadPermissions')
    }
  }
}