From be1394e50b38f229260e267828cd880299b99393 Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Fri, 20 Jul 2018 03:49:54 +0000 Subject: [webapp/settings] added switch to enable colored tab panels --- webapp/src/store/global.js | 27 ++++++++++----------------- webapp/src/store/groups.js | 44 +++++++++++++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 30 deletions(-) (limited to 'webapp/src/store') diff --git a/webapp/src/store/global.js b/webapp/src/store/global.js index 366b0fb..0b52b12 100644 --- a/webapp/src/store/global.js +++ b/webapp/src/store/global.js @@ -2,33 +2,26 @@ export default { state: { locale: localStorage.getItem('locale') || 'en', dark: localStorage.getItem('dark') !== 'false', + coloredTabs: localStorage.getItem('coloredTabs') === 'true', clipped: localStorage.getItem('clipped') !== 'false', mini: localStorage.getItem('mini') !== 'false', snackbars: [] }, getters: { + tabsDark: state => state.dark || state.coloredTabs, + tabsColor: state => state.coloredTabs ? 'primary' : '', + tabsSliderColor: state => state.coloredTabs ? 'white' : 'primary', nextSnackbar (state) { if (state.snackbars) return state.snackbars[0] else return '' - } + }, }, mutations: { - setLocale (state, value) { - state.locale = value - localStorage.setItem('locale', value) - }, - setDark (state, value) { - state.dark = value - localStorage.setItem('dark', value) - }, - setClipped (state, value) { - state.clipped = value - localStorage.setItem('clipped', value) - }, - setMini (state, value) { - state.mini = value - localStorage.setItem('mini', value) - }, + setLocale: (state, value) => { state.locale = value; localStorage.setItem('locale', value) }, + setDark: (state, value) => { state.dark = value; localStorage.setItem('dark', value) }, + setColoredTabs: (state, value) => { state.coloredTabs = value; localStorage.setItem('coloredTabs', value) }, + setClipped: (state, value) => { state.clipped = value; localStorage.setItem('clipped', value) }, + setMini: (state, value) => { state.mini = value; localStorage.setItem('mini', value) }, shiftSnackbars (state) { state.snackbars.shift() }, diff --git a/webapp/src/store/groups.js b/webapp/src/store/groups.js index fca5358..c5ecce4 100644 --- a/webapp/src/store/groups.js +++ b/webapp/src/store/groups.js @@ -4,30 +4,48 @@ export default { namespaced: true, state: { groupChain: [], - activeTab: 0 + activeTab: 0, + editGroupDialog: false, + editGroup: null, }, mutations: { updateActiveTab (state, tabIndex) { state.activeTab = tabIndex }, - addGroup (state, data) { - if (state.groupChain.length <= data.tabIndex || state.groupChain[data.tabIndex].id !== data.group.id) { - state.groupChain = state.groupChain.slice(0, data.tabIndex) - state.groupChain.push(data.group) + setGroupInChain (state, { tabIndex, group }) { + if (state.groupChain.length <= tabIndex || state.groupChain[tabIndex].id !== group.id) { + state.groupChain = state.groupChain.slice(0, tabIndex) + state.groupChain.push(group) } - state.activeTab = data.tabIndex + }, + openEditGroupDialog (state, group) { + state.editGroupDialog = true + state.editGroup = group + }, + closeEditGroupDialog (state) { + state.editGroupDialog = false + state.editGroup = null } }, actions: { - loadGroup (context, data) { - var getSubGroups = axios('/api/groups?action=getSubGroups&id=' + data.id) - var getClients = axios('/api/groups?action=getClients&id=' + data.id) + loadGroupInChain (context, { id, name, tabIndex, switchTab }) { + var getSubGroups = axios.get('/api/groups?action=getSubGroups&id=' + id) + var getClients = axios.get('/api/groups?action=getClients&id=' + id) axios.all([getSubGroups, getClients]).then(axios.spread((groupRespsonse, clientResponse) => { - var group = { id: data.id, name: data.name } - group.subGroups = groupRespsonse.data - group.clients = clientResponse.data - context.commit('addGroup', { group: group, tabIndex: data.tabIndex }) + var group = { id: id, name: name, subGroups: groupRespsonse.data, clients: clientResponse.data } + context.commit('setGroupInChain', { group: group, tabIndex: tabIndex }) + if (switchTab) context.commit('updateActiveTab', tabIndex) })) + }, + editGroup (context, { id, name }) { + axios.get('/api/groups?action=getParents&id=' + id).then(res => { + context.commit('openEditGroupDialog', { id: id, name: name, parents: res.data }) + }) + }, + saveGroup (context) { + axios.post('/api/groups?action=update&id=' + context.state.editGroup.id).then(res => { + context.commit('closeEditGroupDialog') + }) } } } -- cgit v1.2.3-55-g7522