mirror of https://github.com/Lissy93/dashy.git
🚑 HOTFIX, Item save error with widgets
This commit is contained in:
parent
6ddf629c40
commit
35dee3e3b2
|
@ -80,7 +80,7 @@ const store = new Vuex.Store({
|
||||||
getParentSectionOfItem: (state, getters) => (itemId) => {
|
getParentSectionOfItem: (state, getters) => (itemId) => {
|
||||||
let foundSection;
|
let foundSection;
|
||||||
getters.sections.forEach((section) => {
|
getters.sections.forEach((section) => {
|
||||||
section.items.forEach((item) => {
|
(section.items || []).forEach((item) => {
|
||||||
if (item.id === itemId) foundSection = section;
|
if (item.id === itemId) foundSection = section;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -115,7 +115,7 @@ const store = new Vuex.Store({
|
||||||
const { itemId, newItem } = payload;
|
const { itemId, newItem } = payload;
|
||||||
const newConfig = { ...state.config };
|
const newConfig = { ...state.config };
|
||||||
newConfig.sections.forEach((section, secIndex) => {
|
newConfig.sections.forEach((section, secIndex) => {
|
||||||
section.items.forEach((item, itemIndex) => {
|
(section.items || []).forEach((item, itemIndex) => {
|
||||||
if (item.id === itemId) {
|
if (item.id === itemId) {
|
||||||
newConfig.sections[secIndex].items[itemIndex] = newItem;
|
newConfig.sections[secIndex].items[itemIndex] = newItem;
|
||||||
InfoHandler('Item updated', InfoKeys.EDITOR);
|
InfoHandler('Item updated', InfoKeys.EDITOR);
|
||||||
|
@ -170,6 +170,7 @@ const store = new Vuex.Store({
|
||||||
const config = { ...state.config };
|
const config = { ...state.config };
|
||||||
config.sections.forEach((section) => {
|
config.sections.forEach((section) => {
|
||||||
if (section.name === targetSection) {
|
if (section.name === targetSection) {
|
||||||
|
if (!section.items) section.items = [];
|
||||||
section.items.push(newItem);
|
section.items.push(newItem);
|
||||||
InfoHandler('New item added', InfoKeys.EDITOR);
|
InfoHandler('New item added', InfoKeys.EDITOR);
|
||||||
}
|
}
|
||||||
|
@ -183,6 +184,7 @@ const store = new Vuex.Store({
|
||||||
const newItem = { ...item };
|
const newItem = { ...item };
|
||||||
config.sections.forEach((section) => {
|
config.sections.forEach((section) => {
|
||||||
if (section.name === toSection) {
|
if (section.name === toSection) {
|
||||||
|
if (!section.items) section.items = [];
|
||||||
if (appendTo === 'beginning') {
|
if (appendTo === 'beginning') {
|
||||||
section.items.unshift(newItem);
|
section.items.unshift(newItem);
|
||||||
} else {
|
} else {
|
||||||
|
@ -198,7 +200,7 @@ const store = new Vuex.Store({
|
||||||
const { itemId, sectionName } = payload;
|
const { itemId, sectionName } = payload;
|
||||||
const config = { ...state.config };
|
const config = { ...state.config };
|
||||||
config.sections.forEach((section) => {
|
config.sections.forEach((section) => {
|
||||||
if (section.name === sectionName) {
|
if (section.name === sectionName && section.items) {
|
||||||
section.items.forEach((item, index) => {
|
section.items.forEach((item, index) => {
|
||||||
if (item.id === itemId) {
|
if (item.id === itemId) {
|
||||||
section.items.splice(index, 1);
|
section.items.splice(index, 1);
|
||||||
|
|
Loading…
Reference in New Issue