From 063cb0f41f2001659a658e32a32a025e34ddc95f Mon Sep 17 00:00:00 2001 From: pngwn Date: Tue, 18 Feb 2020 15:53:22 +0000 Subject: [PATCH] Add screenslot to current preview. --- packages/builder/src/builderStore/store.js | 8 +++- .../src/userInterface/ComponentPanel.svelte | 43 +++++++++---------- .../userInterface/CurrentItemPreview.svelte | 34 ++++++++++++++- .../EventsEditor/EventsEditor.svelte | 7 +-- packages/client/src/render/screenRouter.js | 7 ++- .../standard-components/src/button.svelte | 5 ++- 6 files changed, 72 insertions(+), 32 deletions(-) diff --git a/packages/builder/src/builderStore/store.js b/packages/builder/src/builderStore/store.js index 8b163649f9..4e145f3643 100644 --- a/packages/builder/src/builderStore/store.js +++ b/packages/builder/src/builderStore/store.js @@ -182,6 +182,7 @@ const initialise = (store, initial) => async () => { } store.set(initial) + console.log(initial) return initial } @@ -743,6 +744,7 @@ const setCurrentPage = store => pageName => { }) } + const getContainerComponent = components => components.find(c => c.name === "@budibase/standard-components/container") @@ -758,14 +760,16 @@ const addChildComponent = store => componentName => { ) _savePage(s) - + //console.log(JSON.stringify(s.screens[0].props._children)) return s }) } const selectComponent = store => component => { store.update(s => { - const componentDef = s.components.find(c => c.name === component._component) + const componentDef = component._component.startsWith("##") + ? component + : s.components.find(c => c.name === component._component) s.currentComponentInfo = makePropsSafe(componentDef, component) return s }) diff --git a/packages/builder/src/userInterface/ComponentPanel.svelte b/packages/builder/src/userInterface/ComponentPanel.svelte index 0f7aae4be5..4b6f7b0631 100644 --- a/packages/builder/src/userInterface/ComponentPanel.svelte +++ b/packages/builder/src/userInterface/ComponentPanel.svelte @@ -42,28 +42,29 @@ -
  • - -
  • -
  • - -
  • + {#if !component._component.startsWith('##')} +
  • + +
  • +
  • + +
  • + {/if} {$store.currentFrontEndType} -
    {#if current_view === 'props'} @@ -81,8 +82,6 @@
    - - \ No newline at end of file + diff --git a/packages/builder/src/userInterface/EventsEditor/EventsEditor.svelte b/packages/builder/src/userInterface/EventsEditor/EventsEditor.svelte index 108fd383a2..edbaefdadb 100644 --- a/packages/builder/src/userInterface/EventsEditor/EventsEditor.svelte +++ b/packages/builder/src/userInterface/EventsEditor/EventsEditor.svelte @@ -32,7 +32,7 @@ let modalOpen = false let events = [] let selectedEvent = null - + $: console.log(component) $: { events = Object.keys(component) @@ -42,8 +42,9 @@ function findType(propName) { if (!component._component) return - return components.find(({ name }) => name === component._component) - .props[propName] + return components.find(({ name }) => name === component._component).props[ + propName + ] } const openModal = event => { diff --git a/packages/client/src/render/screenRouter.js b/packages/client/src/render/screenRouter.js index 0a49533493..f846175219 100644 --- a/packages/client/src/render/screenRouter.js +++ b/packages/client/src/render/screenRouter.js @@ -9,6 +9,7 @@ export const screenRouter = (screens, onScreenSelected) => { let current function route(url) { + const _url = url.state || url current = routes.findIndex( p => p !== "*" && new RegExp("^" + p + "$").test(_url) @@ -42,7 +43,11 @@ export const screenRouter = (screens, onScreenSelected) => { onScreenSelected(screens[fallback], store, _url) } - !url.state && history.pushState(_url, null, _url) + try { + !url.state && history.pushState(_url, null, _url) + } catch (_) { + // ignoring an exception here as the builder runs an iframe, which does not like this + } } function click(e) { diff --git a/packages/standard-components/src/button.svelte b/packages/standard-components/src/button.svelte index 9220aac5ee..cd628e992d 100644 --- a/packages/standard-components/src/button.svelte +++ b/packages/standard-components/src/button.svelte @@ -34,7 +34,8 @@ return all } - $: if(_bb.props._children.length > 0) theButton && _bb.attachChildren(theButton) + $: if (_bb.props._children.length > 0) + theButton && _bb.attachChildren(theButton) $: { cssVariables = { @@ -73,7 +74,7 @@ disabled={disabled || false} on:click={clickHandler} style={buttonStyles}> - {#if _bb.props_children.length === 0}{contentText}{/if} + {#if _bb.props._children.length === 0}{contentText}{/if}