From 2d1683c78510faf9a222f0bd052cbf2b3370d317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Tue, 23 Mar 2021 12:04:01 +0100 Subject: [PATCH] update tables select method --- .../src/builderStore/store/backend/tables.js | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/builderStore/store/backend/tables.js b/packages/builder/src/builderStore/store/backend/tables.js index 29c09839dc..18a29ded32 100644 --- a/packages/builder/src/builderStore/store/backend/tables.js +++ b/packages/builder/src/builderStore/store/backend/tables.js @@ -19,13 +19,21 @@ function createTablesStore() { const tables = await tablesResponse.json() update(state => ({...state, list: tables})) }, - select: table => - update(state => ({ - ...state, - selected: table, - draft: cloneDeep(table), - view: { name: `all_${table._id}` } - })), + select: table => { + if (!table) { + update(state => ({ + ...state, + selected: {} + })) + } else { + update(state => ({ + ...state, + selected: table, + draft: cloneDeep(table), + view: { name: `all_${table._id}` } + })) + } + }, save: async table => { const updatedTable = cloneDeep(table) const oldTable = get(store).list.filter(t => t._id === table._id)[0]