bugfix: custom code not getting attached poperly

This commit is contained in:
Michael Shanks 2020-02-24 14:56:11 +00:00
parent 1657beb8fc
commit d1a48ec3a6
3 changed files with 10 additions and 12 deletions

View File

@ -23,7 +23,7 @@ export const buildCodeForScreens = screens => {
allfunctions += buildCodeForSingleScreen(screen) allfunctions += buildCodeForSingleScreen(screen)
} }
return `return ({ ${allfunctions} });` return `({ ${allfunctions} });`
} }
const buildComponentCode = componentProps => const buildComponentCode = componentProps =>

View File

@ -12,6 +12,6 @@ export const insertCodeMetadata = props => {
const codeMetaData = code => { const codeMetaData = code => {
return { return {
dependsOnStore: RegExp(/(store.)/g).test(code), dependsOnStore: RegExp(/(state.)/g).test(code),
} }
} }

View File

@ -517,7 +517,7 @@ const setCurrentScreen = store => screenName => {
getContainerComponent(s.components), getContainerComponent(s.components),
screen.props screen.props
) )
setCurrentScreenFunctions(s) setCurrentPageFunctions(s)
return s return s
}) })
} }
@ -675,7 +675,7 @@ const _savePage = async s => {
await api.post(`/_builder/api/${appname}/pages/${s.currentPageName}`, { await api.post(`/_builder/api/${appname}/pages/${s.currentPageName}`, {
page: { componentLibraries: s.pages.componentLibraries, ...page }, page: { componentLibraries: s.pages.componentLibraries, ...page },
uiFunctions: "{'1234':() => 'test return'}", uiFunctions: s.currentPageFunctions,
screens: page._screens, screens: page._screens,
}) })
} }
@ -713,7 +713,7 @@ const setCurrentPage = store => pageName => {
screen._css = generate_screen_css([screen.props]) screen._css = generate_screen_css([screen.props])
} }
setCurrentScreenFunctions(s) setCurrentPageFunctions(s)
return s return s
}) })
} }
@ -823,7 +823,7 @@ const setComponentCode = store => code => {
store.update(s => { store.update(s => {
s.currentComponentInfo._code = code s.currentComponentInfo._code = code
setCurrentScreenFunctions(s) setCurrentPageFunctions(s)
// save without messing with the store // save without messing with the store
_saveScreenApi(s.currentPreviewItem, s) _saveScreenApi(s.currentPreviewItem, s)
@ -831,15 +831,13 @@ const setComponentCode = store => code => {
}) })
} }
const setCurrentScreenFunctions = s => { const setCurrentPageFunctions = s => {
s.currentScreenFunctions = s.currentPageFunctions = buildPageCode(s.screens, s.pages[s.currentPageName])
s.currentPreviewItem === "screen"
? buildCodeForScreens([s.currentPreviewItem])
: "({});"
insertCodeMetadata(s.currentPreviewItem.props) insertCodeMetadata(s.currentPreviewItem.props)
} }
const buildPageCode = (screens, page) => buildCodeForScreens([page, ...screens])
const setScreenType = store => type => { const setScreenType = store => type => {
store.update(s => { store.update(s => {
s.currentFrontEndType = type s.currentFrontEndType = type