From 7e65edfc5a9c0ed7f860c0a92f4dee89053598b9 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 24 Nov 2021 19:10:10 +0000 Subject: [PATCH] refactor screen templates to include table name --- .../store/screenTemplates/newRowScreen.js | 1 + .../store/screenTemplates/rowDetailScreen.js | 1 + .../store/screenTemplates/rowListScreen.js | 1 + .../design/NavigationPanel/NewScreenModal.svelte | 12 +++++------- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/builderStore/store/screenTemplates/newRowScreen.js b/packages/builder/src/builderStore/store/screenTemplates/newRowScreen.js index c2dffef4b6..7370ee6c6a 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/newRowScreen.js +++ b/packages/builder/src/builderStore/store/screenTemplates/newRowScreen.js @@ -15,6 +15,7 @@ export default function (tables) { name: `${table.name} - New`, create: () => createScreen(table), id: NEW_ROW_TEMPLATE, + table: table.name } }) } diff --git a/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js b/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js index 3ba8be10b5..1b20e33b64 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js +++ b/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js @@ -17,6 +17,7 @@ export default function (tables) { name: `${table.name} - Detail`, create: () => createScreen(table), id: ROW_DETAIL_TEMPLATE, + table: table.name } }) } diff --git a/packages/builder/src/builderStore/store/screenTemplates/rowListScreen.js b/packages/builder/src/builderStore/store/screenTemplates/rowListScreen.js index 188682ed3f..e26e81ec45 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/rowListScreen.js +++ b/packages/builder/src/builderStore/store/screenTemplates/rowListScreen.js @@ -10,6 +10,7 @@ export default function (tables) { name: `${table.name} - List`, create: () => createScreen(table), id: ROW_LIST_TEMPLATE, + table: table.name } }) } diff --git a/packages/builder/src/components/design/NavigationPanel/NewScreenModal.svelte b/packages/builder/src/components/design/NavigationPanel/NewScreenModal.svelte index 1483517c20..57a40b9081 100644 --- a/packages/builder/src/components/design/NavigationPanel/NewScreenModal.svelte +++ b/packages/builder/src/components/design/NavigationPanel/NewScreenModal.svelte @@ -21,13 +21,13 @@ $: autoSelected = selectedScreens?.length > 0 && !blankSelected let templates = getTemplates($store, $tables.list) const toggleScreenSelection = table => { - if (selectedScreens.find(s => s.name.includes(table.name))) { + if (selectedScreens.find(s => s.table === table.name)) { selectedScreens = selectedScreens.filter( - screen => !screen.name.includes(table.name) + screen => screen.table !== table.name ) } else { let partialTemplates = getTemplates($store, $tables.list).filter( - template => template.name.includes(table.name) + template => template.table === table.name ) selectedScreens = [...partialTemplates, ...selectedScreens] } @@ -75,9 +75,7 @@ {#each $tables.list.filter(table => table._id !== "ta_users") as table}
- x.name.includes(table.name) - )} + class:selected={selectedScreens.find(x => x.table === table.name)} on:click={() => toggleScreenSelection(table)} class="item" > @@ -87,7 +85,7 @@
- {#if selectedScreens.find(x => x.name.includes(table.name))} + {#if selectedScreens.find(x => x.table === table.name)}