From 8775c594a138470f3735046d72c325153234693b Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Fri, 4 Dec 2020 23:42:22 +0000 Subject: [PATCH] deletion and error handling of layouts --- .../src/builderStore/store/frontend.js | 17 +++++++ .../EditScreenLayoutModal.svelte | 15 ------ .../LayoutDropdownMenu.svelte | 51 +++++++++++++++++++ .../ScreenDropdownMenu.svelte | 9 ---- .../components/userInterface/Layout.svelte | 5 +- .../[application]/design/layouts/index.svelte | 4 +- 6 files changed, 75 insertions(+), 26 deletions(-) delete mode 100644 packages/builder/src/components/userInterface/ComponentNavigationTree/EditScreenLayoutModal.svelte create mode 100644 packages/builder/src/components/userInterface/ComponentNavigationTree/LayoutDropdownMenu.svelte diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 0fcf5907b9..8d432ae5d2 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -257,6 +257,23 @@ export const getFrontendStore = () => { const storeContents = get(store) return storeContents.layouts.find(layout => layout._id === layoutId) }, + delete: async layoutToDelete => { + const response = await api.delete( + `/api/layouts/${layoutToDelete._id}/${layoutToDelete._rev}` + ) + + if (response.status !== 200) { + const json = await response.json() + throw new Error(json.message) + } + + store.update(state => { + state.layouts = state.layouts.filter( + layout => layout._id !== layoutToDelete._id + ) + return state + }) + }, }, components: { select: component => { diff --git a/packages/builder/src/components/userInterface/ComponentNavigationTree/EditScreenLayoutModal.svelte b/packages/builder/src/components/userInterface/ComponentNavigationTree/EditScreenLayoutModal.svelte deleted file mode 100644 index 55ff074f6d..0000000000 --- a/packages/builder/src/components/userInterface/ComponentNavigationTree/EditScreenLayoutModal.svelte +++ /dev/null @@ -1,15 +0,0 @@ - - -
- -
diff --git a/packages/builder/src/components/userInterface/ComponentNavigationTree/LayoutDropdownMenu.svelte b/packages/builder/src/components/userInterface/ComponentNavigationTree/LayoutDropdownMenu.svelte new file mode 100644 index 0000000000..d5a0d411a9 --- /dev/null +++ b/packages/builder/src/components/userInterface/ComponentNavigationTree/LayoutDropdownMenu.svelte @@ -0,0 +1,51 @@ + + +
+
dropdown.show()}> + +
+ + + confirmDeleteDialog.show()} /> + + +
+ + + diff --git a/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte b/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte index 0f2c30ff88..0b0cb44fa7 100644 --- a/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte +++ b/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte @@ -3,7 +3,6 @@ import { store, allScreens } from "builderStore" import { notifier } from "builderStore/store/notifications" import ConfirmDialog from "components/common/ConfirmDialog.svelte" - import EditScreenLayoutModal from "./EditScreenLayoutModal.svelte" import { DropdownMenu, Modal, ModalContent } from "@budibase/bbui" import { DropdownContainer, DropdownItem } from "components/common/Dropdowns" @@ -19,14 +18,6 @@ store.actions.screens.delete(screen) store.actions.routing.fetch() } - - async function saveScreen() { - try { - await store.actions.screens.save(screen) - } catch (err) { - notifier.danger("Error saving page.") - } - }
diff --git a/packages/builder/src/components/userInterface/Layout.svelte b/packages/builder/src/components/userInterface/Layout.svelte index 7222ffd36a..7473e0bfec 100644 --- a/packages/builder/src/components/userInterface/Layout.svelte +++ b/packages/builder/src/components/userInterface/Layout.svelte @@ -2,6 +2,7 @@ import { goto } from "@sveltech/routify" import { FrontendTypes } from "constants" import ComponentTree from "./ComponentNavigationTree/ComponentTree.svelte" + import LayoutDropdownMenu from "./ComponentNavigationTree/LayoutDropdownMenu.svelte" import initDragDropStore from "./ComponentNavigationTree/dragDropStore" import NavItem from "components/common/NavItem.svelte" import { last } from "lodash/fp" @@ -28,7 +29,9 @@ withArrow selected={$store.currentComponentInfo?._id === layout.props._id} opened={$store.currentAssetId === layout._id} - on:click={selectLayout} /> + on:click={selectLayout}> + + {#if $store.currentAssetId === layout._id && layout.props._children} + + \ No newline at end of file