👔 Logic work for multi-page support

This commit is contained in:
Alicia Sykes 2022-04-30 23:28:58 +01:00
parent 52a0ba5a6c
commit eb9a5abec5
6 changed files with 23 additions and 10 deletions

View File

@ -8,7 +8,7 @@ import { searchTiles } from '@/utils/Search';
const HomeMixin = { const HomeMixin = {
props: { props: {
confPath: String, subPageInfo: Object,
}, },
computed: { computed: {
sections() { sections() {
@ -40,8 +40,9 @@ const HomeMixin = {
}, },
methods: { methods: {
async getConfigForRoute() { async getConfigForRoute() {
if (this.confPath) { // Get config for sub-page this.$store.commit(Keys.SET_CURRENT_SUB_PAGE, this.subPageInfo);
await this.$store.dispatch(Keys.INITIALIZE_MULTI_PAGE_CONFIG, this.confPath); if (this.subPageInfo && this.subPageInfo.confPath) { // Get config for sub-page
await this.$store.dispatch(Keys.INITIALIZE_MULTI_PAGE_CONFIG, this.subPageInfo.confPath);
} else { // Otherwise, use main config } else { // Otherwise, use main config
this.$store.commit(Keys.USE_MAIN_CONFIG); this.$store.commit(Keys.USE_MAIN_CONFIG);
} }

View File

@ -11,8 +11,6 @@ import { Progress } from 'rsup-progress';
// Import views, that are not lazy-loaded // Import views, that are not lazy-loaded
import Home from '@/views/Home.vue'; import Home from '@/views/Home.vue';
// import Workspace from '@/views/Workspace.vue';
// import Minimal from '@/views/Minimal.vue';
import ConfigAccumulator from '@/utils/ConfigAccumalator'; import ConfigAccumulator from '@/utils/ConfigAccumalator';
// Import helper functions, config data and defaults // Import helper functions, config data and defaults
@ -68,6 +66,7 @@ const makeMetaTags = (defaultTitle) => ({
}); });
const makeSubConfigPath = (rawPath) => { const makeSubConfigPath = (rawPath) => {
if (!rawPath) return '';
if (rawPath.startsWith('/') || rawPath.startsWith('http')) return rawPath; if (rawPath.startsWith('/') || rawPath.startsWith('http')) return rawPath;
else return `/${rawPath}`; else return `/${rawPath}`;
}; };
@ -77,6 +76,9 @@ const makeMultiPageRoutes = (userPages) => {
if (!userPages) return []; if (!userPages) return [];
const multiPageRoutes = []; const multiPageRoutes = [];
userPages.forEach((page) => { userPages.forEach((page) => {
if (!page.name || !page.path) {
ErrorHandler('Additional pages must have both a `name` and `path`');
}
// Props to be passed to home mixin // Props to be passed to home mixin
const subPageInfo = { const subPageInfo = {
subPageInfo: { subPageInfo: {
@ -88,21 +90,21 @@ const makeMultiPageRoutes = (userPages) => {
// Create route for default homepage // Create route for default homepage
multiPageRoutes.push({ multiPageRoutes.push({
path: makePageSlug(page.name, 'home'), path: makePageSlug(page.name, 'home'),
name: `${subPageInfo.pageId}-home`, name: `${subPageInfo.subPageInfo.pageId}-home`,
component: Home, component: Home,
props: subPageInfo, props: subPageInfo,
}); });
// Create route for the workspace view // Create route for the workspace view
multiPageRoutes.push({ multiPageRoutes.push({
path: makePageSlug(page.name, 'workspace'), path: makePageSlug(page.name, 'workspace'),
name: `${subPageInfo.pageId}-workspace`, name: `${subPageInfo.subPageInfo.pageId}-workspace`,
component: () => import('./views/Workspace.vue'), component: () => import('./views/Workspace.vue'),
props: subPageInfo, props: subPageInfo,
}); });
// Create route for the minimal view // Create route for the minimal view
multiPageRoutes.push({ multiPageRoutes.push({
path: makePageSlug(page.name, 'minimal'), path: makePageSlug(page.name, 'minimal'),
name: `${subPageInfo.pageId}-minimal`, name: `${subPageInfo.subPageInfo.pageId}-minimal`,
component: () => import('./views/Minimal.vue'), component: () => import('./views/Minimal.vue'),
props: subPageInfo, props: subPageInfo,
}); });

View File

@ -31,6 +31,7 @@ const {
SET_PAGE_INFO, SET_PAGE_INFO,
SET_APP_CONFIG, SET_APP_CONFIG,
SET_SECTIONS, SET_SECTIONS,
SET_PAGES,
UPDATE_SECTION, UPDATE_SECTION,
INSERT_SECTION, INSERT_SECTION,
REMOVE_SECTION, REMOVE_SECTION,
@ -179,6 +180,12 @@ const store = new Vuex.Store({
state.config = newConfig; state.config = newConfig;
InfoHandler('App config updated', InfoKeys.EDITOR); InfoHandler('App config updated', InfoKeys.EDITOR);
}, },
[SET_PAGES](state, multiPages) {
const newConfig = state.config;
newConfig.pages = multiPages;
state.config = newConfig;
InfoHandler('Pages updated', InfoKeys.EDITOR);
},
[SET_SECTIONS](state, newSections) { [SET_SECTIONS](state, newSections) {
const newConfig = state.config; const newConfig = state.config;
newConfig.sections = newSections; newConfig.sections = newSections;

View File

@ -12,7 +12,7 @@
text-decoration: underline; text-decoration: underline;
} }
} }
div[data-fs-wrapper] { div[data-fs-wrapper], div[data-fs-kind=object] {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
align-items: flex-start; align-items: flex-start;
@ -81,7 +81,7 @@
box-shadow: 1px 1px 6px var(--interactive-editor-color); box-shadow: 1px 1px 6px var(--interactive-editor-color);
} }
} }
div[data-fs-input=array] button { div[data-fs-input=array] button, div[data-fs-buttons] button {
font-size: 1rem; font-size: 1rem;
margin: 0.25rem; margin: 0.25rem;
border-radius: var(--curve-factor); border-radius: var(--curve-factor);

View File

@ -16,6 +16,7 @@ const KEY_NAMES = [
'UPDATE_ITEM', 'UPDATE_ITEM',
'SET_PAGE_INFO', 'SET_PAGE_INFO',
'SET_APP_CONFIG', 'SET_APP_CONFIG',
'SET_PAGES',
'SET_SECTIONS', 'SET_SECTIONS',
'UPDATE_SECTION', 'UPDATE_SECTION',
'INSERT_SECTION', 'INSERT_SECTION',

View File

@ -60,6 +60,7 @@ module.exports = {
'nord', 'nord',
'oblivion', 'oblivion',
'adventure', 'adventure',
'crayola',
'minimal-dark', 'minimal-dark',
'minimal-light', 'minimal-light',
'thebe', 'thebe',
@ -144,6 +145,7 @@ module.exports = {
EDIT_SECTION: 'EDIT_SECTION', EDIT_SECTION: 'EDIT_SECTION',
EDIT_PAGE_INFO: 'EDIT_PAGE_INFO', EDIT_PAGE_INFO: 'EDIT_PAGE_INFO',
EDIT_APP_CONFIG: 'EDIT_APP_CONFIG', EDIT_APP_CONFIG: 'EDIT_APP_CONFIG',
EDIT_MULTI_PAGES: 'EDIT_MULTI_PAGES',
EXPORT_CONFIG_MENU: 'EXPORT_CONFIG_MENU', EXPORT_CONFIG_MENU: 'EXPORT_CONFIG_MENU',
MOVE_ITEM_TO: 'MOVE_ITEM_TO', MOVE_ITEM_TO: 'MOVE_ITEM_TO',
}, },