From c976a133c0ce18fc07b3ab41792c06e0a71af5f1 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 11 Feb 2020 11:19:17 +0000 Subject: [PATCH] auto update state origins when attaching click handlers --- packages/builder/src/builderStore/store.js | 26 +++---- .../EventsEditor/HandlerSelector.svelte | 76 +++++++++---------- .../src/userInterface/PropertyCascader.svelte | 3 +- packages/server/utilities/builder/index.js | 4 + 4 files changed, 53 insertions(+), 56 deletions(-) diff --git a/packages/builder/src/builderStore/store.js b/packages/builder/src/builderStore/store.js index 5d914586bf..efd264f74f 100644 --- a/packages/builder/src/builderStore/store.js +++ b/packages/builder/src/builderStore/store.js @@ -462,22 +462,18 @@ const saveScreen = store => screen => { } const _saveScreen = (store, s, screen) => { - const screens = pipe(s.pages[s.currentPageName]._screens, [ - filter(c => c.name !== screen.name), - concat([screen]), - ]) - // console.log('saveScreen', screens, screen) - s.pages[s.currentPageName]._screens = screens - s.screens = s.pages[s.currentPageName]._screens - // s.currentPreviewItem = screen - // s.currentComponentInfo = screen.props + s.currentFrontEndItem = screen + s.currentComponentInfo = getScreenInfo(s.components, screen) api - .post( - `/_builder/api/${s.appname}/pages/${s.currentPageName}/screen`, - screen - ) - .then(() => _savePage(s)) + .post(`/_builder/api/${s.appname}/screen`, screen) + .then(async savedScreen => { + const updatedScreen = await savedScreen.json(); + const screens = [...s.screens.filter(storeScreen => storeScreen.name !== updatedScreen.name), updatedScreen]; + s.pages[s.currentPageName]._screens = screens + s.screens = screens + _savePage(s); + }); return s } @@ -580,7 +576,7 @@ const renameScreen = store => (oldname, newname) => { const saveAllChanged = async () => { for (let screenName of changedScreens) { const changedScreen = getExactComponent(screens, screenName) - await api.post(`/_builder/api/${s.appname}/screen`, changedScreen) + const updatedScreen = await api.post(`/_builder/api/${s.appname}/screen`, changedScreen) } } diff --git a/packages/builder/src/userInterface/EventsEditor/HandlerSelector.svelte b/packages/builder/src/userInterface/EventsEditor/HandlerSelector.svelte index b3fabb5a43..8f35e64485 100644 --- a/packages/builder/src/userInterface/EventsEditor/HandlerSelector.svelte +++ b/packages/builder/src/userInterface/EventsEditor/HandlerSelector.svelte @@ -1,27 +1,28 @@
@@ -93,10 +94,7 @@ {#each parameters as param, idx}
{param.name} - +
{/each} {/if} diff --git a/packages/builder/src/userInterface/PropertyCascader.svelte b/packages/builder/src/userInterface/PropertyCascader.svelte index 3c51c85241..7e317214b7 100644 --- a/packages/builder/src/userInterface/PropertyCascader.svelte +++ b/packages/builder/src/userInterface/PropertyCascader.svelte @@ -61,7 +61,7 @@ @@ -119,7 +119,6 @@ } li { - transition: 0.2s all; list-style-type: none; } diff --git a/packages/server/utilities/builder/index.js b/packages/server/utilities/builder/index.js index 8629d4f0d1..1ddc6c55db 100644 --- a/packages/server/utilities/builder/index.js +++ b/packages/server/utilities/builder/index.js @@ -63,6 +63,8 @@ module.exports.saveScreen = async (config, appname, pagename, screen) => { flag: "w", spaces: 2, }) + component.stateOrigins = buildStateOrigins(component); + return component; } module.exports.renameScreen = async ( @@ -167,6 +169,8 @@ const buildStateOrigins = screenDefinition => { return origins; }; +module.exports.buildStateOrigins = buildStateOrigins; + const fetchscreens = async (appPath, relativePath = "") => { const currentDir = join(appPath, "components", relativePath)