mirror of
https://github.com/BrenBroZAYT/dashy.git
synced 2026-06-14 16:20:03 +00:00
🚧 You can now save items to VueX store, neat!
This commit is contained in:
+18
-1
@@ -8,7 +8,12 @@ import filterUserSections from '@/utils/CheckSectionVisibility';
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
const { UPDATE_CONFIG, SET_MODAL_OPEN, SET_LANGUAGE } = Keys;
|
||||
const {
|
||||
UPDATE_CONFIG,
|
||||
SET_MODAL_OPEN,
|
||||
SET_LANGUAGE,
|
||||
UPDATE_ITEM,
|
||||
} = Keys;
|
||||
|
||||
const store = new Vuex.Store({
|
||||
state: {
|
||||
@@ -54,6 +59,18 @@ const store = new Vuex.Store({
|
||||
[SET_MODAL_OPEN](state, modalOpen) {
|
||||
state.modalOpen = modalOpen;
|
||||
},
|
||||
[UPDATE_ITEM](state, payload) {
|
||||
const { itemId, newItem } = payload;
|
||||
const newConfig = state.config;
|
||||
newConfig.sections.forEach((section, secIndex) => {
|
||||
section.items.forEach((item, itemIndex) => {
|
||||
if (item.id === itemId) {
|
||||
newConfig.sections[secIndex].items[itemIndex] = newItem;
|
||||
}
|
||||
});
|
||||
});
|
||||
state.config = newConfig;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
/* Called when app first loaded. Reads config and sets state */
|
||||
|
||||
Reference in New Issue
Block a user