diff --git a/packages/builder/src/builderStore/loadComponentLibraries.js b/packages/builder/src/builderStore/loadComponentLibraries.js index 8a1201f602..cc474060e7 100644 --- a/packages/builder/src/builderStore/loadComponentLibraries.js +++ b/packages/builder/src/builderStore/loadComponentLibraries.js @@ -2,14 +2,19 @@ import { map } from "lodash/fp"; export const loadLibs = async (appName, appPackage) => { - const makeUrl = l => - `/_builder/api/${appName}/componentlibrary?lib=${encodeURI(l)}` - const allLibraries = {}; for(let lib of appPackage.pages.componentLibraries) { - const libModule = await import(makeUrl(lib)); + const libModule = await import(makeLibraryUrl(appName, lib)); allLibraries[lib] = libModule; } return allLibraries; } + +export const loadLib = async (appName, lib, allLibs) => { + allLibs[lib] = await import(makeLibraryUrl(appName, lib)); + return allLibs; +} + +export const makeLibraryUrl = (appName, lib) => + `/_builder/api/${appName}/componentlibrary?lib=${encodeURI(lib)}` \ No newline at end of file diff --git a/packages/builder/src/builderStore/store.js b/packages/builder/src/builderStore/store.js index 96802e5699..618bc160fb 100644 --- a/packages/builder/src/builderStore/store.js +++ b/packages/builder/src/builderStore/store.js @@ -47,6 +47,7 @@ export const getStore = () => { currentFrontEndItem:null, currentComponentInfo:null, currentComponentIsNew:false, + currentPageName: "", currentNodeIsNew: false, errors: [], activeNav: "database", @@ -87,6 +88,7 @@ export const getStore = () => { store.removeComponentLibrary =removeComponentLibrary(store); store.addStylesheet = addStylesheet(store); store.removeStylesheet = removeStylesheet(store); + store.savePage = savePage(store); return store; } @@ -113,6 +115,7 @@ const initialise = (store, initial) => async () => { initial.hasAppPackage = true; initial.hierarchy = pkg.appDefinition.hierarchy; initial.accessLevels = pkg.accessLevels; + initial.derivedComponents = pkg.derivedComponents; initial.allComponents = combineComponents( pkg.derivedComponents, pkg.rootComponents); initial.actions = reduce((arr, action) => { @@ -456,6 +459,18 @@ const renameDerivedComponent = store => (oldname, newname) => { }) } +const savePage = store => async page => { + store.update(s => { + if(s.currentFrontEndIsComponent || !s.currentFrontEndItem) { + return; + } + + s.pages[currentPageName] = page; + savePackage(); + + }); +} + const addComponentLibrary = store => async lib => { const response = @@ -571,9 +586,9 @@ const setCurrentComponent = store => component => { const setCurrentPage = store => pageName => { store.update(s => { - const props = s.pages[pageName]; - s.currentFrontEndItem = {props, name:pageName}; + s.currentFrontEndItem = s.pages[pageName]; s.currentFrontEndIsComponent = false; + s.currentPageName = pageName; return s; }) } diff --git a/packages/builder/src/userInterface/CurrentItemPreview.svelte b/packages/builder/src/userInterface/CurrentItemPreview.svelte index 8f5e773c04..30a6b19d2f 100644 --- a/packages/builder/src/userInterface/CurrentItemPreview.svelte +++ b/packages/builder/src/userInterface/CurrentItemPreview.svelte @@ -1,5 +1,6 @@