mirror of https://github.com/Lissy93/dashy.git
🔩 Adds updateSection functionality to store
This commit is contained in:
parent
87bf9263db
commit
0a00c9beb2
11
src/store.js
11
src/store.js
|
@ -17,6 +17,7 @@ const {
|
||||||
SET_EDIT_MODE,
|
SET_EDIT_MODE,
|
||||||
UPDATE_PAGE_INFO,
|
UPDATE_PAGE_INFO,
|
||||||
UPDATE_APP_CONFIG,
|
UPDATE_APP_CONFIG,
|
||||||
|
UPDATE_SECTION,
|
||||||
} = Keys;
|
} = Keys;
|
||||||
|
|
||||||
const store = new Vuex.Store({
|
const store = new Vuex.Store({
|
||||||
|
@ -44,6 +45,10 @@ const store = new Vuex.Store({
|
||||||
visibleComponents(state, getters) {
|
visibleComponents(state, getters) {
|
||||||
return componentVisibility(getters.appConfig);
|
return componentVisibility(getters.appConfig);
|
||||||
},
|
},
|
||||||
|
// eslint-disable-next-line arrow-body-style
|
||||||
|
getSectionByIndex: (state, getters) => (index) => {
|
||||||
|
return getters.sections[index];
|
||||||
|
},
|
||||||
getItemById: (state, getters) => (id) => {
|
getItemById: (state, getters) => (id) => {
|
||||||
let item;
|
let item;
|
||||||
getters.sections.forEach(sec => {
|
getters.sections.forEach(sec => {
|
||||||
|
@ -90,6 +95,12 @@ const store = new Vuex.Store({
|
||||||
newConfig.appConfig = newAppConfig;
|
newConfig.appConfig = newAppConfig;
|
||||||
state.config = newConfig;
|
state.config = newConfig;
|
||||||
},
|
},
|
||||||
|
[UPDATE_SECTION](state, payload) {
|
||||||
|
const { sectionIndex, sectionData } = payload;
|
||||||
|
const newConfig = { ...state.config };
|
||||||
|
newConfig.sections[sectionIndex] = sectionData;
|
||||||
|
state.config = newConfig;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
/* Called when app first loaded. Reads config and sets state */
|
/* Called when app first loaded. Reads config and sets state */
|
||||||
|
|
|
@ -8,6 +8,7 @@ const KEY_NAMES = [
|
||||||
'UPDATE_ITEM',
|
'UPDATE_ITEM',
|
||||||
'UPDATE_PAGE_INFO',
|
'UPDATE_PAGE_INFO',
|
||||||
'UPDATE_APP_CONFIG',
|
'UPDATE_APP_CONFIG',
|
||||||
|
'UPDATE_SECTION',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Convert array of key names into an object, and export
|
// Convert array of key names into an object, and export
|
||||||
|
|
Loading…
Reference in New Issue