From 3b049bc286cb74e6b5cff6ad812451b6346dd46f Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Fri, 4 Dec 2020 23:16:07 +0000 Subject: [PATCH] allow creation of custom layouts, moving layoutId prop to top level of screen --- .../src/builderStore/store/frontend.js | 3 + .../store/screenTemplates/utils/Screen.js | 2 +- .../AppPreview/CurrentItemPreview.svelte | 2 +- .../ScreenDropdownMenu.svelte | 11 - .../userInterface/FrontendNavigatePane.svelte | 8 + .../userInterface/LayoutSelect.svelte | 15 ++ .../userInterface/NewLayoutModal.svelte | 21 ++ .../userInterface/SettingsView.svelte | 7 +- packages/client/src/store/screens.js | 2 +- packages/server/src/api/controllers/layout.js | 10 +- packages/server/src/constants/layouts.js | 40 +++- packages/server/src/constants/screens.js | 4 +- packages/server/src/db/client.js | 2 +- packages/server/yarn.lock | 209 +----------------- 14 files changed, 108 insertions(+), 228 deletions(-) create mode 100644 packages/builder/src/components/userInterface/LayoutSelect.svelte create mode 100644 packages/builder/src/components/userInterface/NewLayoutModal.svelte diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 91ca68f916..0fcf5907b9 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -243,6 +243,9 @@ export const getFrontendStore = () => { ) if (layoutToUpdate) { layoutToUpdate._rev = json.rev + } else { + // TODO: when a new layout is created + state.layouts.push({}) } return state }) diff --git a/packages/builder/src/builderStore/store/screenTemplates/utils/Screen.js b/packages/builder/src/builderStore/store/screenTemplates/utils/Screen.js index aadf5b05eb..00bd43ec2c 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/utils/Screen.js +++ b/packages/builder/src/builderStore/store/screenTemplates/utils/Screen.js @@ -4,8 +4,8 @@ export class Screen extends BaseStructure { constructor() { super(true) this._json = { + layoutId: "layout_private_master", props: { - layoutId: "layout_private_master", _id: "", _component: "", _styles: { diff --git a/packages/builder/src/components/userInterface/AppPreview/CurrentItemPreview.svelte b/packages/builder/src/components/userInterface/AppPreview/CurrentItemPreview.svelte index 674eedfa21..266a5c5816 100644 --- a/packages/builder/src/components/userInterface/AppPreview/CurrentItemPreview.svelte +++ b/packages/builder/src/components/userInterface/AppPreview/CurrentItemPreview.svelte @@ -26,7 +26,7 @@ } else { screen = $currentAsset layout = $store.layouts.find( - layout => layout._id === screen?.props.layoutId + layout => layout._id === screen?.layoutId ) } } diff --git a/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte b/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte index d27bc2bdcd..0f2c30ff88 100644 --- a/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte +++ b/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte @@ -10,7 +10,6 @@ export let screenId let confirmDeleteDialog - let editLayoutDialog let dropdown let anchor @@ -40,10 +39,6 @@ icon="ri-delete-bin-line" title="Delete" on:click={() => confirmDeleteDialog.show()} /> - editLayoutDialog.show()} /> @@ -54,12 +49,6 @@ okText="Delete Screen" onOk={deleteScreen} /> - - - - - -