fix: remove macrogroup panel from dashboard when delete macrogroup
Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
1 parent
bb9d10e00c
commit
5495d53cd3
2 files changed
+23
-1
No files matched your search
@@ -52,8 +52,24 @@ export const actions: ActionTree<GuiMacrogroupsState, RootState> = {
|
||||
dispatch('upload', payload.id)
|
||||
},
|
||||
|
||||
delete({ commit }, id) {
|
||||
delete({ commit, dispatch, rootState }, id) {
|
||||
commit('delete', id)
|
||||
Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail_macrogroups', key: id })
|
||||
|
||||
const layouts = ['mobileLayout', 'tabletLayout1', 'tabletLayout2', 'desktopLayout1', 'desktopLayout2',
|
||||
'widescreenLayout1', 'widescreenLayout2', 'widescreenLayout3']
|
||||
|
||||
layouts.forEach((layoutname: string) => {
|
||||
const layoutArray = [...rootState.gui?.dashboard[layoutname]]
|
||||
|
||||
const index = layoutArray.findIndex((layoutPos: any) => layoutPos.name === 'macrogroup_'+id)
|
||||
if (index !== -1) {
|
||||
commit('gui/deleteFromDashboardLayout', { layoutname, index }, { root: true })
|
||||
dispatch('gui/updateSettings', {
|
||||
keyName: 'dashboard.'+layoutname,
|
||||
newVal: rootState.gui?.dashboard[layoutname]
|
||||
}, { root: true })
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
@@ -96,4 +96,10 @@ export const mutations: MutationTree<GuiState> = {
|
||||
Vue.set(state.dashboard, 'nonExpandPanels', nonExpandPanels)
|
||||
}
|
||||
},
|
||||
|
||||
deleteFromDashboardLayout(state, payload) {
|
||||
const layoutArray = [...state.dashboard[payload.layoutname]]
|
||||
layoutArray.splice(payload.index, 1)
|
||||
Vue.set(state.dashboard, payload.layoutname, layoutArray)
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user