From 760cdd3db96bb7f12cb1447871461349c0c125dc Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 9 Dec 2019 13:17:28 +0300 Subject: [PATCH] Store generated id in mascots state --- src/store/modules/normalizers.js | 17 +++--- src/views/settings/components/Setting.vue | 2 +- .../inputComponents/MascotsInput.vue | 53 +++++++------------ 3 files changed, 31 insertions(+), 41 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index 3822f96f..13be4fd3 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -27,7 +27,7 @@ export const parseTuples = (tuples, key) => { } else if (item.tuple[1] && typeof item.tuple[1] === 'object') { nonAtomsObjects.includes(item.tuple[0]) ? accum[item.tuple[0]] = parseNonAtomObject(item.tuple[1]) - : accum[item.tuple[0]] = parseObject(item.tuple[1]) + : accum[item.tuple[0]] = parseObject(item.tuple) } else { accum[item.tuple[0]] = item.tuple[1] } @@ -49,11 +49,16 @@ const parseNonAtomObject = (object) => { }, {}) } -const parseObject = (object) => { - return Object.keys(object).reduce((acc, item) => { - acc[item] = object[item] - return acc - }, {}) +const parseObject = tuple => { + return tuple[0] === ':mascots' + ? Object.keys(tuple[1]).reduce((acc, item) => { + acc[item] = { ...tuple[1][item], id: `f${(~~(Math.random() * 1e8)).toString(16)}` } + return acc + }, {}) + : Object.keys(tuple[1]).reduce((acc, item) => { + acc[item] = tuple[1][item] + return acc + }, {}) } export const valueHasTuples = (key, value) => { diff --git a/src/views/settings/components/Setting.vue b/src/views/settings/components/Setting.vue index f6641382..9293ec3d 100644 --- a/src/views/settings/components/Setting.vue +++ b/src/views/settings/components/Setting.vue @@ -40,7 +40,7 @@ :nested="true"/>
- +
diff --git a/src/views/settings/components/inputComponents/MascotsInput.vue b/src/views/settings/components/inputComponents/MascotsInput.vue index 8bcc73cb..727fbe64 100644 --- a/src/views/settings/components/inputComponents/MascotsInput.vue +++ b/src/views/settings/components/inputComponents/MascotsInput.vue @@ -1,17 +1,17 @@