|
|
|
@ -50,7 +50,7 @@ export const getStore = () => { |
|
|
|
|
|
|
|
const store = writable(initial) |
|
|
|
|
|
|
|
store.initialise = initialise(store, initial) |
|
|
|
store.setPackage = setPackage(store, initial) |
|
|
|
|
|
|
|
store.newChildRecord = backendStoreActions.newRecord(store, false) |
|
|
|
store.newRootRecord = backendStoreActions.newRecord(store, true) |
|
|
|
@ -101,22 +101,12 @@ export const getStore = () => { |
|
|
|
|
|
|
|
export default getStore |
|
|
|
|
|
|
|
const initialise = (store, initial) => async () => { |
|
|
|
if (!appname) { |
|
|
|
initial.apps = await api.get(`/_builder/api/apps`).then(r => r.json()) |
|
|
|
initial.hasAppPackage = false |
|
|
|
store.set(initial) |
|
|
|
return initial |
|
|
|
} |
|
|
|
|
|
|
|
const pkg = await api |
|
|
|
.get(`/_builder/api/${appname}/appPackage`) |
|
|
|
.then(r => r.json()) |
|
|
|
const setPackage = (store, initial) => async (pkg) => { |
|
|
|
|
|
|
|
const [main_screens, unauth_screens] = await Promise.all([ |
|
|
|
api.get(`/_builder/api/${appname}/pages/main/screens`).then(r => r.json()), |
|
|
|
api.get(`/_builder/api/${pkg.application.name}/pages/main/screens`).then(r => r.json()), |
|
|
|
api |
|
|
|
.get(`/_builder/api/${appname}/pages/unauthenticated/screens`) |
|
|
|
.get(`/_builder/api/${pkg.application.name}/pages/unauthenticated/screens`) |
|
|
|
.then(r => r.json()), |
|
|
|
]) |
|
|
|
|
|
|
|
@ -131,12 +121,12 @@ const initialise = (store, initial) => async () => { |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
initial.libraries = await loadLibs(appname, pkg) |
|
|
|
initial.libraries = await loadLibs(pkg.application.name, pkg) |
|
|
|
initial.loadLibraryUrls = pageName => { |
|
|
|
const libs = libUrlsForPreview(pkg, pageName) |
|
|
|
return libs |
|
|
|
} |
|
|
|
initial.appname = appname |
|
|
|
initial.appname = pkg.application.name |
|
|
|
initial.pages = pkg.pages |
|
|
|
initial.hasAppPackage = true |
|
|
|
initial.hierarchy = pkg.appDefinition.hierarchy |
|
|
|
|