diff --git a/src/store/gui/macrogroups/actions.ts b/src/store/gui/macrogroups/actions.ts index 30d4a8a5..b4895c66 100644 --- a/src/store/gui/macrogroups/actions.ts +++ b/src/store/gui/macrogroups/actions.ts @@ -52,8 +52,24 @@ export const actions: ActionTree = { 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 }) + } + }) }, } \ No newline at end of file diff --git a/src/store/gui/mutations.ts b/src/store/gui/mutations.ts index 1676ee84..d57f681c 100644 --- a/src/store/gui/mutations.ts +++ b/src/store/gui/mutations.ts @@ -96,4 +96,10 @@ export const mutations: MutationTree = { 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) + }, }