show screenslot if there's no screens

This commit is contained in:
Martin McKeaveney 2020-04-06 17:06:04 +01:00
parent 0178d66ee9
commit 65de002c57
3 changed files with 9 additions and 8 deletions

View File

@ -29,10 +29,12 @@
[map(s => `<link rel="stylesheet" href="${s}"/>`), join("\n")]
)
$: screensExist = $store.currentPreviewItem._screens && $store.currentPreviewItem._screens.length > 0
$: frontendDefinition = {
componentLibraries: $store.loadLibraryUrls($store.currentPageName),
page: $store.currentPreviewItem,
screens: [{
screens: screensExist ? $store.currentPreviewItem._screens : [{
name: "Screen Placeholder",
route: "*",
props: {

View File

@ -34,9 +34,9 @@ export const createApp = (
routeTo,
appRootPath: frontendDefinition.appRootPath,
})
const getAttchChildrenParams = attachChildrenParams(stateManager)
const getAttachChildrenParams = attachChildrenParams(stateManager)
screenSlotNode.props._children = [screen.props]
const initialiseChildParams = getAttchChildrenParams(screenSlotNode)
const initialiseChildParams = getAttachChildrenParams(screenSlotNode)
attachChildren(initialiseChildParams)(screenSlotNode.rootElement, {
hydrate: true,
force: true,
@ -102,6 +102,7 @@ export const createApp = (
return rootTreeNode
}
return {
initialisePage,
screenStore: () => screenStateManager.store,

View File

@ -44,11 +44,9 @@ export const screenRouter = (screens, onScreenSelected, appRootPath) => {
storeInitial["##routeParams"] = params
const store = writable(storeInitial)
if (current !== -1) {
onScreenSelected(screens[current], store, _url)
} else {
onScreenSelected(screens[fallback], store, _url)
}
const screenIndex = current !== -1 ? current : fallback;
onScreenSelected(screens[screenIndex], store, _url)
try {
!url.state && history.pushState(_url, null, _url)