1
0
Fork 0
mirror of synced 2024-07-03 21:40:55 +12:00

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)
}
return `return ({ ${allfunctions} });`
return `({ ${allfunctions} });`
}
const buildComponentCode = componentProps =>

View file

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