From fc9c1a1fbe1f055d12739065d51cf4b78c47b65f Mon Sep 17 00:00:00 2001 From: michael shanks Date: Wed, 31 Jul 2019 08:09:04 +0100 Subject: [PATCH] renaming store --- packages/builder/rollup.config.js | 4 +- packages/builder/src/App.svelte | 6 +-- packages/builder/src/NoPackage.svelte | 4 +- packages/builder/src/PackageRoot.svelte | 10 ++-- .../src/accessLevels/AccessLevelsRoot.svelte | 18 +++---- .../src/actionsAndTriggers/Actions.svelte | 8 +-- .../ActionsAndTriggersRoot.svelte | 10 ++-- .../src/actionsAndTriggers/Triggers.svelte | 10 ++-- .../builder/src/builderStore/createPackage.js | 4 +- packages/builder/src/builderStore/index.js | 8 +-- packages/builder/src/builderStore/store.js | 52 +++++++++++++------ .../builder/src/database/ActionsHeader.svelte | 16 +++--- .../builder/src/database/DatabaseRoot.svelte | 22 ++++---- .../builder/src/database/FieldView.svelte | 8 +-- .../builder/src/database/HierarchyRow.svelte | 4 +- .../builder/src/database/IndexView.svelte | 8 +-- .../builder/src/database/RecordView.svelte | 18 +++---- packages/builder/src/nav/Nav.svelte | 1 - packages/builder/src/nav/NavItem.svelte | 6 +-- .../userInterface/UserInterfaceRoot.svelte | 7 ++- .../pagesParsing/searchComponents.js | 2 +- 21 files changed, 125 insertions(+), 101 deletions(-) diff --git a/packages/builder/rollup.config.js b/packages/builder/rollup.config.js index 58278d37d6..c2155343f6 100644 --- a/packages/builder/rollup.config.js +++ b/packages/builder/rollup.config.js @@ -11,7 +11,7 @@ import browsersync from "rollup-plugin-browsersync"; import proxy from "http-proxy-middleware"; import corePackageJson from "../core/package.json"; -const target = 'http://localhost:4001/_builder'; +const target = 'http://localhost:4001'; const _builderProxy = proxy('/_builder', { target:"http://localhost:3000", pathRewrite: {'^/_builder' : ''} @@ -126,7 +126,7 @@ export default { !production && livereload(outputpath), !production && browsersync({ server: outputpath, - middleware: [_builderProxy, apiProxy] + middleware: [apiProxy,_builderProxy] }), // If we're building for production (npm run build diff --git a/packages/builder/src/App.svelte b/packages/builder/src/App.svelte index cc1beff9bd..e23e1535a6 100644 --- a/packages/builder/src/App.svelte +++ b/packages/builder/src/App.svelte @@ -2,7 +2,7 @@ import NoPackage from "./NoPackage.svelte"; import PackageRoot from "./PackageRoot.svelte"; - import {database, initialise} from "./builderStore"; + import {store, initialise} from "./builderStore"; import { onMount } from 'svelte'; let init = initialise(); @@ -16,11 +16,11 @@

loading

{:then result} - {#if $database.hasAppPackage} + {#if $store.hasAppPackage} {/if} - {#if !$database.hasAppPackage} + {#if !$store.hasAppPackage} {/if} diff --git a/packages/builder/src/NoPackage.svelte b/packages/builder/src/NoPackage.svelte index e95f335346..c3ff8c1aff 100644 --- a/packages/builder/src/NoPackage.svelte +++ b/packages/builder/src/NoPackage.svelte @@ -1,7 +1,7 @@ diff --git a/packages/builder/src/actionsAndTriggers/Triggers.svelte b/packages/builder/src/actionsAndTriggers/Triggers.svelte index bccd45ee19..de882c232c 100644 --- a/packages/builder/src/actionsAndTriggers/Triggers.svelte +++ b/packages/builder/src/actionsAndTriggers/Triggers.svelte @@ -1,6 +1,6 @@ @@ -21,29 +21,29 @@ const deleteCurrentNode = () => {
- - {#if !$database.currentNodeIsNew} + {#if !$store.currentNodeIsNew} {/if} - {#if !!$database.errors && $database.errors.length > 0} + {#if !!$store.errors && $store.errors.length > 0}
- +
{/if} -
Are you sure you want to delete {$database.currentNode.name} ?
+
Are you sure you want to delete {$store.currentNode.name} ?
diff --git a/packages/builder/src/database/DatabaseRoot.svelte b/packages/builder/src/database/DatabaseRoot.svelte index bcfd7c2e76..2b22ab5f71 100644 --- a/packages/builder/src/database/DatabaseRoot.svelte +++ b/packages/builder/src/database/DatabaseRoot.svelte @@ -4,7 +4,7 @@ import HierarchyRow from "./HierarchyRow.svelte"; import RecordView from "./RecordView.svelte"; import IndexView from "./IndexView.svelte"; import ActionsHeader from "./ActionsHeader.svelte"; -import {database} from "../builderStore"; +import {store} from "../builderStore"; import getIcon from "../common/icon"; import DropdownButton from "../common/DropdownButton.svelte"; import {hierarchy as hierarchyFunctions} from "../../../core/src"; @@ -13,18 +13,18 @@ const hierarchyWidth = "200px"; const defaultNewIndexActions = [{ label:"New Root Index", - onclick: database.newRootIndex + onclick: store.newRootIndex }]; const defaultNewRecordActions = [{ label:"New Root Record", - onclick: database.newRootRecord + onclick: store.newRootRecord }]; let newIndexActions = defaultNewIndexActions; let newRecordActions = defaultNewRecordActions; -database.subscribe(db => { +store.subscribe(db => { if(!db.currentNode || hierarchyFunctions.isIndex(db.currentNode)) { newRecordActions = defaultNewRecordActions; newIndexActions = defaultNewIndexActions; @@ -32,13 +32,13 @@ database.subscribe(db => { newRecordActions = [ ...defaultNewRecordActions, {label: `New Child Record of ${db.currentNode.name}`, - onclick: database.newChildRecord} + onclick: store.newChildRecord} ]; newIndexActions = [ ...defaultNewIndexActions, {label: `New Index on ${db.currentNode.name}`, - onclick: database.newChildIndex} + onclick: store.newChildIndex} ]; } }); @@ -52,7 +52,7 @@ database.subscribe(db => {
Records
- {#each $database.hierarchy.children as record} + {#each $store.hierarchy.children as record} {/each} @@ -60,20 +60,20 @@ database.subscribe(db => {
Indexes
- {#each $database.hierarchy.indexes as index} + {#each $store.hierarchy.indexes as index} {/each}
- {#if $database.currentNode} + {#if $store.currentNode} {/if}
- {#if !$database.currentNode} + {#if !$store.currentNode}

:)

- {:else if $database.currentNode.type === "record"} + {:else if $store.currentNode.type === "record"} {:else} diff --git a/packages/builder/src/database/FieldView.svelte b/packages/builder/src/database/FieldView.svelte index 5e26dd0c3c..f6abcbfe45 100644 --- a/packages/builder/src/database/FieldView.svelte +++ b/packages/builder/src/database/FieldView.svelte @@ -17,7 +17,7 @@ import {allTypes, validate, getPotentialReferenceIndexes, export let field; export let allFields; export let onFinished = () => {}; -export let database; +export let store; let errors = []; let clonedField = cloneDeep(field); @@ -25,19 +25,19 @@ let clonedField = cloneDeep(field); $: isNew = !!field && field.name.length === 0; $: possibleReferenceIndexes = getPotentialReferenceIndexes( - database.hierarchy, database.currentNode + store.hierarchy, store.currentNode ); $: selectedReverseRefIndex = !clonedField.typeOptions.indexNodeKey ? "" - : getNode(database.hierarchy, clonedField.typeOptions.indexNodeKey); + : getNode(store.hierarchy, clonedField.typeOptions.indexNodeKey); $: possibleReverseReferenceIndexes = !selectedReverseRefIndex ? [] : getPotentialReverseReferenceIndexes( - database.hierarchy, selectedReverseRefIndex); + store.hierarchy, selectedReverseRefIndex); const typeChanged = (ev) => clonedField.typeOptions = getDefaultTypeOptions(ev.detail); diff --git a/packages/builder/src/database/HierarchyRow.svelte b/packages/builder/src/database/HierarchyRow.svelte index 7d5ec35d08..7194260713 100644 --- a/packages/builder/src/database/HierarchyRow.svelte +++ b/packages/builder/src/database/HierarchyRow.svelte @@ -1,6 +1,6 @@
-
database.selectExistingNode(node.nodeId)} style="padding-left: {20 + (level * 20)}px"> +
store.selectExistingNode(node.nodeId)} style="padding-left: {20 + (level * 20)}px"> {node.name}
{#if node.children} diff --git a/packages/builder/src/database/IndexView.svelte b/packages/builder/src/database/IndexView.svelte index 8635c8c056..123e058e8c 100644 --- a/packages/builder/src/database/IndexView.svelte +++ b/packages/builder/src/database/IndexView.svelte @@ -4,7 +4,7 @@ import Textbox from "../common/Textbox.svelte"; import CodeArea from "../common/CodeArea.svelte"; import Button from "../common/Button.svelte"; import Dropdown from "../common/Dropdown.svelte"; -import {database} from "../builderStore"; +import {store} from "../builderStore"; import {filter, some, map} from "lodash/fp"; import {hierarchy as hierarchyFunctions, common} from "../../../core/src"; @@ -13,9 +13,9 @@ const chain = common.$; let index; let indexableRecords = []; -database.subscribe($database => { - index = $database.currentNode; - indexableRecords = chain($database.hierarchy,[ +store.subscribe($store => { + index = $store.currentNode; + indexableRecords = chain($store.hierarchy,[ hierarchyFunctions.getFlattenedHierarchy, filter(hierarchyFunctions.isDecendant(index.parent())), filter(hierarchyFunctions.isRecord), diff --git a/packages/builder/src/database/RecordView.svelte b/packages/builder/src/database/RecordView.svelte index 33751fc147..73d1a03771 100644 --- a/packages/builder/src/database/RecordView.svelte +++ b/packages/builder/src/database/RecordView.svelte @@ -7,7 +7,7 @@ import FieldView from "./FieldView.svelte"; import Modal from "../common/Modal.svelte"; import {map, join, filter, some, find, keys, isDate} from "lodash/fp"; -import { database } from "../builderStore"; +import { store } from "../builderStore"; import {common, hierarchy as h} from "../../../core/src"; import {templateApi, chain, validate} from "../common/core"; @@ -22,9 +22,9 @@ let deleteField; let onFinishedFieldEdit; let editIndex; -database.subscribe($database => { - record = $database.currentNode; - const flattened = h.getFlattenedHierarchy($database.hierarchy); +store.subscribe($store => { + record = $store.currentNode; + const flattened = h.getFlattenedHierarchy($store.hierarchy); getIndexAllowedRecords = index => chain(index.allowedRecordNodeIds, [ filter(id => some(n => n.nodeId === id)(flattened)), @@ -35,13 +35,13 @@ database.subscribe($database => { newField = () => { isNewField = true; - fieldToEdit = templateApi($database.hierarchy).getNewField("string"); + fieldToEdit = templateApi($store.hierarchy).getNewField("string"); editingField = true; } onFinishedFieldEdit = (field) => { if(field) { - database.saveField(field); + store.saveField(field); } editingField = false; } @@ -53,11 +53,11 @@ database.subscribe($database => { } deleteField = (field) => { - database.deleteField(field); + store.deleteField(field); } editIndex = index => { - database.selectExistingNode(index.nodeId); + store.selectExistingNode(index.nodeId); } }) @@ -131,7 +131,7 @@ let getTypeOptions = typeOptions => + store={$store}/> {/if} diff --git a/packages/builder/src/nav/Nav.svelte b/packages/builder/src/nav/Nav.svelte index 667c29087a..7af01132f6 100644 --- a/packages/builder/src/nav/Nav.svelte +++ b/packages/builder/src/nav/Nav.svelte @@ -13,7 +13,6 @@ export let width=50; - diff --git a/packages/builder/src/nav/NavItem.svelte b/packages/builder/src/nav/NavItem.svelte index 5feebab580..e045d47733 100644 --- a/packages/builder/src/nav/NavItem.svelte +++ b/packages/builder/src/nav/NavItem.svelte @@ -1,6 +1,6 @@ diff --git a/packages/builder/src/userInterface/UserInterfaceRoot.svelte b/packages/builder/src/userInterface/UserInterfaceRoot.svelte index f1a001c5eb..51b5fa6de9 100644 --- a/packages/builder/src/userInterface/UserInterfaceRoot.svelte +++ b/packages/builder/src/userInterface/UserInterfaceRoot.svelte @@ -1,13 +1,14 @@
- +
@@ -20,12 +21,14 @@ import ComingSoon from "../common/ComingSoon.svelte"; .root { display: grid; - grid-template-columns: [uiNav] 200px [preview] auto; + grid-template-columns: [uiNav] 300px [preview] auto; height: 100%; + width: 100%; } .ui-nav { grid-column-start: uiNav; + background-color: red; } .component-preview { diff --git a/packages/builder/src/userInterface/pagesParsing/searchComponents.js b/packages/builder/src/userInterface/pagesParsing/searchComponents.js index 3f7b7e8fe6..e063f967ce 100644 --- a/packages/builder/src/userInterface/pagesParsing/searchComponents.js +++ b/packages/builder/src/userInterface/pagesParsing/searchComponents.js @@ -15,7 +15,7 @@ const pipe = common.$; const normalString = s => (s||"").trim().toLowerCase(); -const isRootComponent = c => isUndefined(c.inherits); +export const isRootComponent = c => isUndefined(c.inherits); export const searchAllComponents = (derivedComponents, rootComponents, phrase) => {