renaming store
This commit is contained in:
parent
6cd61a4a63
commit
fc9c1a1fbe
|
@ -11,7 +11,7 @@ import browsersync from "rollup-plugin-browsersync";
|
||||||
import proxy from "http-proxy-middleware";
|
import proxy from "http-proxy-middleware";
|
||||||
import corePackageJson from "../core/package.json";
|
import corePackageJson from "../core/package.json";
|
||||||
|
|
||||||
const target = 'http://localhost:4001/_builder';
|
const target = 'http://localhost:4001';
|
||||||
const _builderProxy = proxy('/_builder', {
|
const _builderProxy = proxy('/_builder', {
|
||||||
target:"http://localhost:3000",
|
target:"http://localhost:3000",
|
||||||
pathRewrite: {'^/_builder' : ''}
|
pathRewrite: {'^/_builder' : ''}
|
||||||
|
@ -126,7 +126,7 @@ export default {
|
||||||
!production && livereload(outputpath),
|
!production && livereload(outputpath),
|
||||||
!production && browsersync({
|
!production && browsersync({
|
||||||
server: outputpath,
|
server: outputpath,
|
||||||
middleware: [_builderProxy, apiProxy]
|
middleware: [apiProxy,_builderProxy]
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// If we're building for production (npm run build
|
// If we're building for production (npm run build
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import NoPackage from "./NoPackage.svelte";
|
import NoPackage from "./NoPackage.svelte";
|
||||||
import PackageRoot from "./PackageRoot.svelte";
|
import PackageRoot from "./PackageRoot.svelte";
|
||||||
import {database, initialise} from "./builderStore";
|
import {store, initialise} from "./builderStore";
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
let init = initialise();
|
let init = initialise();
|
||||||
|
@ -16,11 +16,11 @@
|
||||||
<h1>loading</h1>
|
<h1>loading</h1>
|
||||||
|
|
||||||
{:then result}
|
{:then result}
|
||||||
{#if $database.hasAppPackage}
|
{#if $store.hasAppPackage}
|
||||||
<PackageRoot />
|
<PackageRoot />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if !$database.hasAppPackage}
|
{#if !$store.hasAppPackage}
|
||||||
<NoPackage />
|
<NoPackage />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import Button from "./common/Button.svelte"
|
import Button from "./common/Button.svelte"
|
||||||
import { database } from "./builderStore";
|
import { store } from "./builderStore";
|
||||||
|
|
||||||
let errors = [];
|
let errors = [];
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ let errors = [];
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h4 style="margin-bottom: 20px">Choose an Application</h4>
|
<h4 style="margin-bottom: 20px">Choose an Application</h4>
|
||||||
{#each $database.apps as app}
|
{#each $store.apps as app}
|
||||||
<a href={`#/${app}`} class="app-link">{app}</a>
|
<a href={`#/${app}`} class="app-link">{app}</a>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,7 +7,7 @@ import ActionsAndTriggers from "./actionsAndTriggers/ActionsAndTriggersRoot.svel
|
||||||
import AccessLevels from "./accessLevels/AccessLevelsRoot.svelte" ;
|
import AccessLevels from "./accessLevels/AccessLevelsRoot.svelte" ;
|
||||||
import ComingSoon from "./common/ComingSoon.svelte";
|
import ComingSoon from "./common/ComingSoon.svelte";
|
||||||
|
|
||||||
import {database} from "./builderStore";
|
import {store} from "./builderStore";
|
||||||
|
|
||||||
export let navWidth = "50px";
|
export let navWidth = "50px";
|
||||||
|
|
||||||
|
@ -18,13 +18,13 @@ export let navWidth = "50px";
|
||||||
<Nav width={navWidth} />
|
<Nav width={navWidth} />
|
||||||
<div class="content"
|
<div class="content"
|
||||||
style="width: calc(100% - {navWidth}); left: {navWidth}">
|
style="width: calc(100% - {navWidth}); left: {navWidth}">
|
||||||
{#if $database.activeNav === "database"}
|
{#if $store.activeNav === "database"}
|
||||||
<Database />
|
<Database />
|
||||||
{:else if $database.activeNav === "actions"}
|
{:else if $store.activeNav === "actions"}
|
||||||
<ActionsAndTriggers />
|
<ActionsAndTriggers />
|
||||||
{:else if $database.activeNav === "access levels"}
|
{:else if $store.activeNav === "access levels"}
|
||||||
<AccessLevels />
|
<AccessLevels />
|
||||||
{:else if $database.activeNav === "user interface"}
|
{:else if $store.activeNav === "user interface"}
|
||||||
<UserInterface />
|
<UserInterface />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import ButtonGroup from "../common/ButtonGroup.svelte";
|
import ButtonGroup from "../common/ButtonGroup.svelte";
|
||||||
import Button from "../common/Button.svelte";
|
import Button from "../common/Button.svelte";
|
||||||
import {database} from "../builderStore";
|
import {store} from "../builderStore";
|
||||||
import {generateFullPermissions, getNewAccessLevel} from "../common/core";
|
import {generateFullPermissions, getNewAccessLevel} from "../common/core";
|
||||||
import getIcon from "../common/icon";
|
import getIcon from "../common/icon";
|
||||||
import AccessLevelView from "./AccessLevelView.svelte";
|
import AccessLevelView from "./AccessLevelView.svelte";
|
||||||
|
@ -13,7 +13,7 @@ let editingLevelIsNew = false;
|
||||||
$: isEditing = (editingLevel !== null);
|
$: isEditing = (editingLevel !== null);
|
||||||
|
|
||||||
let allPermissions = [];
|
let allPermissions = [];
|
||||||
database.subscribe(db => {
|
store.subscribe(db => {
|
||||||
allPermissions = generateFullPermissions(db.hierarchy, db.actions);
|
allPermissions = generateFullPermissions(db.hierarchy, db.actions);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ let onLevelCancel = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
let onLevelDelete = (level) => {
|
let onLevelDelete = (level) => {
|
||||||
database.deleteLevel(level);
|
store.deleteLevel(level);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ let createNewLevel = () => {
|
||||||
|
|
||||||
let onEditingFinished = (level) => {
|
let onEditingFinished = (level) => {
|
||||||
if(level) {
|
if(level) {
|
||||||
database.saveLevel(level, editingLevelIsNew, editingLevel);
|
store.saveLevel(level, editingLevelIsNew, editingLevel);
|
||||||
}
|
}
|
||||||
editingLevel = null;
|
editingLevel = null;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ const getPermissionsString = perms => {
|
||||||
<Button grouped color="secondary" on:click={createNewLevel}>Create New Access Level</Button>
|
<Button grouped color="secondary" on:click={createNewLevel}>Create New Access Level</Button>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
|
|
||||||
{#if $database.accessLevels}
|
{#if $store.accessLevels}
|
||||||
<table class="fields-table uk-table uk-table-small">
|
<table class="fields-table uk-table uk-table-small">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -65,7 +65,7 @@ const getPermissionsString = perms => {
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each $database.accessLevels as level}
|
{#each $store.accessLevels as level}
|
||||||
<tr>
|
<tr>
|
||||||
<td >{level.name}</td>
|
<td >{level.name}</td>
|
||||||
<td >{getPermissionsString(level.permissions)}</td>
|
<td >{getPermissionsString(level.permissions)}</td>
|
||||||
|
@ -88,9 +88,9 @@ const getPermissionsString = perms => {
|
||||||
allPermissions={allPermissions}
|
allPermissions={allPermissions}
|
||||||
onFinished={onEditingFinished}
|
onFinished={onEditingFinished}
|
||||||
isNew={editingLevelIsNew}
|
isNew={editingLevelIsNew}
|
||||||
allLevels={$database.accessLevels}
|
allLevels={$store.accessLevels}
|
||||||
hierarchy={$database.hierarchy}
|
hierarchy={$store.hierarchy}
|
||||||
actions={$database.actions} />
|
actions={$store.actions} />
|
||||||
{/if}
|
{/if}
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import getIcon from "../common/icon";
|
import getIcon from "../common/icon";
|
||||||
import {database} from "../builderStore";
|
import {store} from "../builderStore";
|
||||||
import Button from "../common/Button.svelte";
|
import Button from "../common/Button.svelte";
|
||||||
import ButtonGroup from "../common/ButtonGroup.svelte";
|
import ButtonGroup from "../common/ButtonGroup.svelte";
|
||||||
import ActionView from "./ActionView.svelte";
|
import ActionView from "./ActionView.svelte";
|
||||||
|
@ -39,7 +39,7 @@ let actionEditingFinished = (action) => {
|
||||||
|
|
||||||
<h3>Actions</h3>
|
<h3>Actions</h3>
|
||||||
|
|
||||||
{#if $database.actions}
|
{#if $store.actions}
|
||||||
<table class="fields-table uk-table uk-table-small">
|
<table class="fields-table uk-table uk-table-small">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -51,7 +51,7 @@ let actionEditingFinished = (action) => {
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each $database.actions as action}
|
{#each $store.actions as action}
|
||||||
<tr>
|
<tr>
|
||||||
<td >{action.name}</td>
|
<td >{action.name}</td>
|
||||||
<td >{action.behaviourSource}</td>
|
<td >{action.behaviourSource}</td>
|
||||||
|
@ -73,7 +73,7 @@ let actionEditingFinished = (action) => {
|
||||||
<Modal bind:isOpen={isEditing}>
|
<Modal bind:isOpen={isEditing}>
|
||||||
{#if isEditing}
|
{#if isEditing}
|
||||||
<ActionView action={editingAction}
|
<ActionView action={editingAction}
|
||||||
allActions={$database.actions}
|
allActions={$store.actions}
|
||||||
onFinished={actionEditingFinished}
|
onFinished={actionEditingFinished}
|
||||||
isNew={editingActionIsNew}/>
|
isNew={editingActionIsNew}/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import getIcon from "../common/icon";
|
import getIcon from "../common/icon";
|
||||||
import {database} from "../builderStore";
|
import {store} from "../builderStore";
|
||||||
import Button from "../common/Button.svelte";
|
import Button from "../common/Button.svelte";
|
||||||
import ButtonGroup from "../common/ButtonGroup.svelte";
|
import ButtonGroup from "../common/ButtonGroup.svelte";
|
||||||
import Actions from "./Actions.svelte";
|
import Actions from "./Actions.svelte";
|
||||||
|
@ -31,7 +31,7 @@ let newAction = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
let onActionDelete = (action) => {
|
let onActionDelete = (action) => {
|
||||||
database.deleteAction(action);
|
store.deleteAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
let deleteTrigger = () => {}
|
let deleteTrigger = () => {}
|
||||||
|
@ -47,7 +47,7 @@ let newTrigger = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
let onActionSave = action => {
|
let onActionSave = action => {
|
||||||
database.saveAction(
|
store.saveAction(
|
||||||
action,
|
action,
|
||||||
editingActionIsNew,
|
editingActionIsNew,
|
||||||
editingAction);
|
editingAction);
|
||||||
|
@ -60,7 +60,7 @@ let onActionCancel = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
let onTriggerSave = trigger => {
|
let onTriggerSave = trigger => {
|
||||||
database.saveTrigger(
|
store.saveTrigger(
|
||||||
trigger,
|
trigger,
|
||||||
editingTriggerIsNew,
|
editingTriggerIsNew,
|
||||||
editingTrigger);
|
editingTrigger);
|
||||||
|
@ -79,7 +79,7 @@ let onTriggerEdit = (trigger) => {
|
||||||
|
|
||||||
|
|
||||||
let onTriggerDelete = (trigger) => {
|
let onTriggerDelete = (trigger) => {
|
||||||
database.deleteTrigger(trigger);
|
store.deleteTrigger(trigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import {database} from "../builderStore";
|
import {store} from "../builderStore";
|
||||||
import getIcon from "../common/icon";
|
import getIcon from "../common/icon";
|
||||||
import Button from "../common/Button.svelte";
|
import Button from "../common/Button.svelte";
|
||||||
import Modal from "../common/Modal.svelte";
|
import Modal from "../common/Modal.svelte";
|
||||||
|
@ -29,7 +29,7 @@ let triggerEditingFinished = (trigger) => {
|
||||||
|
|
||||||
<h3>Triggers</h3>
|
<h3>Triggers</h3>
|
||||||
|
|
||||||
{#if $database.triggers}
|
{#if $store.triggers}
|
||||||
<table class="fields-table uk-table uk-table-small">
|
<table class="fields-table uk-table uk-table-small">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -41,7 +41,7 @@ let triggerEditingFinished = (trigger) => {
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each $database.triggers as trigger}
|
{#each $store.triggers as trigger}
|
||||||
<tr>
|
<tr>
|
||||||
<td >{trigger.eventName}</td>
|
<td >{trigger.eventName}</td>
|
||||||
<td >{trigger.actionName}</td>
|
<td >{trigger.actionName}</td>
|
||||||
|
@ -63,8 +63,8 @@ let triggerEditingFinished = (trigger) => {
|
||||||
<Modal bind:isOpen={isEditing}>
|
<Modal bind:isOpen={isEditing}>
|
||||||
{#if isEditing}
|
{#if isEditing}
|
||||||
<TriggerView trigger={editingTrigger}
|
<TriggerView trigger={editingTrigger}
|
||||||
allActions={$database.actions}
|
allActions={$store.actions}
|
||||||
allTriggers={$database.triggers}
|
allTriggers={$store.triggers}
|
||||||
onFinished={triggerEditingFinished}
|
onFinished={triggerEditingFinished}
|
||||||
isNew={editingTriggerIsNew}/>
|
isNew={editingTriggerIsNew}/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import {createNewHierarchy} from "../common/core";
|
import {createNewHierarchy} from "../common/core";
|
||||||
|
|
||||||
export const createPackage = (packageInfo, database) => {
|
export const createPackage = (packageInfo, store) => {
|
||||||
packageInfo.createNewPackage("");
|
packageInfo.createNewPackage("");
|
||||||
const root = createNewHierarchy();
|
const root = createNewHierarchy();
|
||||||
database.importAppDefinition({
|
store.importAppDefinition({
|
||||||
hierarchy:root,
|
hierarchy:root,
|
||||||
actions:[],
|
actions:[],
|
||||||
triggers:[],
|
triggers:[],
|
||||||
|
|
|
@ -2,15 +2,15 @@ import {createPackage} from "./createPackage";
|
||||||
import getStore from "./store";
|
import getStore from "./store";
|
||||||
import { last } from "lodash/fp";
|
import { last } from "lodash/fp";
|
||||||
|
|
||||||
export const database = getStore();
|
export const store = getStore();
|
||||||
|
|
||||||
export const createNewPackage = () =>
|
export const createNewPackage = () =>
|
||||||
createPackage(packageInfo, database);
|
createPackage(packageInfo, store);
|
||||||
|
|
||||||
export const initialise = async () => {
|
export const initialise = async () => {
|
||||||
try {
|
try {
|
||||||
setupRouter(database);
|
setupRouter(store);
|
||||||
await database.initialise();
|
await store.initialise();
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import {
|
||||||
import {writable} from "svelte/store";
|
import {writable} from "svelte/store";
|
||||||
import { defaultPagesObject } from "../userInterface/pagesParsing/defaultPagesObject"
|
import { defaultPagesObject } from "../userInterface/pagesParsing/defaultPagesObject"
|
||||||
import api from "./api";
|
import api from "./api";
|
||||||
|
import { isRootComponent } from "../userInterface/pagesParsing/searchComponents";
|
||||||
|
|
||||||
const pipe = common.$;
|
const pipe = common.$;
|
||||||
|
|
||||||
|
@ -39,8 +40,7 @@ export const getStore = () => {
|
||||||
pages:defaultPagesObject(),
|
pages:defaultPagesObject(),
|
||||||
mainUi:{},
|
mainUi:{},
|
||||||
unauthenticatedUi:{},
|
unauthenticatedUi:{},
|
||||||
derivedComponents:[],
|
allComponents:[],
|
||||||
rootComponents:[],
|
|
||||||
currentNodeIsNew: false,
|
currentNodeIsNew: false,
|
||||||
errors: [],
|
errors: [],
|
||||||
activeNav: "database",
|
activeNav: "database",
|
||||||
|
@ -98,8 +98,8 @@ const initialise = (store, initial) => async () => {
|
||||||
initial.hasAppPackage = true;
|
initial.hasAppPackage = true;
|
||||||
initial.hierarchy = pkg.appDefinition.hierarchy;
|
initial.hierarchy = pkg.appDefinition.hierarchy;
|
||||||
initial.accessLevels = pkg.accessLevels;
|
initial.accessLevels = pkg.accessLevels;
|
||||||
initial.derivedComponents = pkg.derivedComponents;
|
initial.allComponents = combineComponents(
|
||||||
initial.rootComponents = pkg.rootComponents;
|
pkg.derivedComponents, pkg.rootComponents);
|
||||||
initial.actions = reduce((arr, action) => {
|
initial.actions = reduce((arr, action) => {
|
||||||
arr.push(action);
|
arr.push(action);
|
||||||
return arr;
|
return arr;
|
||||||
|
@ -118,6 +118,17 @@ const initialise = (store, initial) => async () => {
|
||||||
return initial;
|
return initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const combineComponents = (root, derived) => {
|
||||||
|
const all = []
|
||||||
|
for(let r in root) {
|
||||||
|
all.push(root[r]);
|
||||||
|
}
|
||||||
|
for(let d in derived) {
|
||||||
|
all.push(root[d]);
|
||||||
|
}
|
||||||
|
return all;
|
||||||
|
}
|
||||||
|
|
||||||
const newRecord = (store, useRoot) => () => {
|
const newRecord = (store, useRoot) => () => {
|
||||||
store.update(s => {
|
store.update(s => {
|
||||||
s.currentNodeIsNew = true;
|
s.currentNodeIsNew = true;
|
||||||
|
@ -359,11 +370,12 @@ const saveDerivedComponent = store => (derivedComponent) => {
|
||||||
|
|
||||||
store.update(s => {
|
store.update(s => {
|
||||||
|
|
||||||
const derivedComponents = pipe(s.derivedComponents, [
|
const components = pipe(s.allComponents, [
|
||||||
filter(c => c._name !== derivedComponent._name)
|
filter(c => c._name !== derivedComponent._name),
|
||||||
|
concat([derivedComponent])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
s.derivedComponents = derivedComponents;
|
s.allComponents = components;
|
||||||
|
|
||||||
api.post(`/_builder/api/${s.appname}/derivedcomponent`, derivedComponent);
|
api.post(`/_builder/api/${s.appname}/derivedcomponent`, derivedComponent);
|
||||||
|
|
||||||
|
@ -374,11 +386,11 @@ const saveDerivedComponent = store => (derivedComponent) => {
|
||||||
const deleteDerivedComponent = store => name => {
|
const deleteDerivedComponent = store => name => {
|
||||||
store.update(s => {
|
store.update(s => {
|
||||||
|
|
||||||
const derivedComponents = pipe(s.derivedComponents, [
|
const allComponents = pipe(s.allComponents, [
|
||||||
filter(c => c._name !== name)
|
filter(c => c._name !== name)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
s.derivedComponents = derivedComponents;
|
s.allComponents = allComponents;
|
||||||
|
|
||||||
api.delete(`/_builder/api/${s.appname}/derivedcomponent/${name}`);
|
api.delete(`/_builder/api/${s.appname}/derivedcomponent/${name}`);
|
||||||
|
|
||||||
|
@ -389,18 +401,18 @@ const deleteDerivedComponent = store => name => {
|
||||||
const renameDerivedComponent = store => (oldname, newname) => {
|
const renameDerivedComponent = store => (oldname, newname) => {
|
||||||
store.update(s => {
|
store.update(s => {
|
||||||
|
|
||||||
const component = pipe(s.derivedComponents, [
|
const component = pipe(s.allComponents, [
|
||||||
find(c => c._name === name)
|
find(c => c._name === name)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
component._name = newname;
|
component._name = newname;
|
||||||
|
|
||||||
const derivedComponents = pipe(s.derivedComponents, [
|
const allComponents = pipe(s.allComponents, [
|
||||||
filter(c => c._name !== name),
|
filter(c => c._name !== name),
|
||||||
concat(component)
|
concat([component])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
s.derivedComponent = derivedComponents;
|
s.allComponents = allComponents;
|
||||||
|
|
||||||
api.patch(`/_builder/api/${s.appname}/derivedcomponent`, {
|
api.patch(`/_builder/api/${s.appname}/derivedcomponent`, {
|
||||||
oldname, newname
|
oldname, newname
|
||||||
|
@ -430,8 +442,13 @@ const addComponentLibrary = store => async lib => {
|
||||||
store.update(s => {
|
store.update(s => {
|
||||||
s.componentsErrors.addComponent = error;
|
s.componentsErrors.addComponent = error;
|
||||||
if(success) {
|
if(success) {
|
||||||
|
|
||||||
|
s.allComponents = pipe(s.allComponents, [
|
||||||
|
filter(c => !isRootComponent(c)),
|
||||||
|
concat(components)
|
||||||
|
]);
|
||||||
|
|
||||||
s.pages.componentLibraries.push(lib);
|
s.pages.componentLibraries.push(lib);
|
||||||
s.rootComponents = [...s.rootComponents, components];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
@ -440,6 +457,8 @@ const addComponentLibrary = store => async lib => {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const refreshComponents = store => async () => {
|
const refreshComponents = store => async () => {
|
||||||
|
|
||||||
const components =
|
const components =
|
||||||
|
@ -451,7 +470,10 @@ const refreshComponents = store => async () => {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
store.update(s => {
|
store.update(s => {
|
||||||
s.rootComponents = rootComponents;
|
s.allComponents = pipe(s.allComponents, [
|
||||||
|
filter(c => !isRootComponent(c)),
|
||||||
|
concat(rootComponents)
|
||||||
|
]);
|
||||||
return s;
|
return s;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import Button from "../common/Button.svelte";
|
import Button from "../common/Button.svelte";
|
||||||
import ButtonGroup from "../common/ButtonGroup.svelte";
|
import ButtonGroup from "../common/ButtonGroup.svelte";
|
||||||
import {database} from "../builderStore";
|
import {store} from "../builderStore";
|
||||||
import Modal from "../common/Modal.svelte";
|
import Modal from "../common/Modal.svelte";
|
||||||
import ErrorsBox from "../common/ErrorsBox.svelte";
|
import ErrorsBox from "../common/ErrorsBox.svelte";
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ const openConfirmDelete = () => {
|
||||||
|
|
||||||
const deleteCurrentNode = () => {
|
const deleteCurrentNode = () => {
|
||||||
confirmDelete = false;
|
confirmDelete = false;
|
||||||
database.deleteCurrentNode();
|
store.deleteCurrentNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -21,29 +21,29 @@ const deleteCurrentNode = () => {
|
||||||
<div class="root" style="left: {left}">
|
<div class="root" style="left: {left}">
|
||||||
|
|
||||||
<ButtonGroup>
|
<ButtonGroup>
|
||||||
<Button color="secondary" grouped on:click={database.saveCurrentNode}>
|
<Button color="secondary" grouped on:click={store.saveCurrentNode}>
|
||||||
{#if $database.currentNodeIsNew}
|
{#if $store.currentNodeIsNew}
|
||||||
Create
|
Create
|
||||||
{:else}
|
{:else}
|
||||||
Update
|
Update
|
||||||
{/if}
|
{/if}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{#if !$database.currentNodeIsNew}
|
{#if !$store.currentNodeIsNew}
|
||||||
<Button color="secondary" grouped on:click={openConfirmDelete}>
|
<Button color="secondary" grouped on:click={openConfirmDelete}>
|
||||||
Delete
|
Delete
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
|
|
||||||
{#if !!$database.errors && $database.errors.length > 0}
|
{#if !!$store.errors && $store.errors.length > 0}
|
||||||
<div style="width: 500px">
|
<div style="width: 500px">
|
||||||
<ErrorsBox errors={$database.errors}/>
|
<ErrorsBox errors={$store.errors}/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<Modal bind:isOpen={confirmDelete}>
|
<Modal bind:isOpen={confirmDelete}>
|
||||||
<div style="margin: 10px 0px 20px 0px">Are you sure you want to delete {$database.currentNode.name} ?</div>
|
<div style="margin: 10px 0px 20px 0px">Are you sure you want to delete {$store.currentNode.name} ?</div>
|
||||||
<div style="float:right">
|
<div style="float:right">
|
||||||
<Button color="primary" on:click={deleteCurrentNode}>Yes</Button>
|
<Button color="primary" on:click={deleteCurrentNode}>Yes</Button>
|
||||||
<Button color="secondary" on:click={() => confirmDelete = false}>No</Button>
|
<Button color="secondary" on:click={() => confirmDelete = false}>No</Button>
|
||||||
|
|
|
@ -4,7 +4,7 @@ import HierarchyRow from "./HierarchyRow.svelte";
|
||||||
import RecordView from "./RecordView.svelte";
|
import RecordView from "./RecordView.svelte";
|
||||||
import IndexView from "./IndexView.svelte";
|
import IndexView from "./IndexView.svelte";
|
||||||
import ActionsHeader from "./ActionsHeader.svelte";
|
import ActionsHeader from "./ActionsHeader.svelte";
|
||||||
import {database} from "../builderStore";
|
import {store} from "../builderStore";
|
||||||
import getIcon from "../common/icon";
|
import getIcon from "../common/icon";
|
||||||
import DropdownButton from "../common/DropdownButton.svelte";
|
import DropdownButton from "../common/DropdownButton.svelte";
|
||||||
import {hierarchy as hierarchyFunctions} from "../../../core/src";
|
import {hierarchy as hierarchyFunctions} from "../../../core/src";
|
||||||
|
@ -13,18 +13,18 @@ const hierarchyWidth = "200px";
|
||||||
|
|
||||||
const defaultNewIndexActions = [{
|
const defaultNewIndexActions = [{
|
||||||
label:"New Root Index",
|
label:"New Root Index",
|
||||||
onclick: database.newRootIndex
|
onclick: store.newRootIndex
|
||||||
}];
|
}];
|
||||||
|
|
||||||
const defaultNewRecordActions = [{
|
const defaultNewRecordActions = [{
|
||||||
label:"New Root Record",
|
label:"New Root Record",
|
||||||
onclick: database.newRootRecord
|
onclick: store.newRootRecord
|
||||||
}];
|
}];
|
||||||
|
|
||||||
let newIndexActions = defaultNewIndexActions;
|
let newIndexActions = defaultNewIndexActions;
|
||||||
let newRecordActions = defaultNewRecordActions;
|
let newRecordActions = defaultNewRecordActions;
|
||||||
|
|
||||||
database.subscribe(db => {
|
store.subscribe(db => {
|
||||||
if(!db.currentNode || hierarchyFunctions.isIndex(db.currentNode)) {
|
if(!db.currentNode || hierarchyFunctions.isIndex(db.currentNode)) {
|
||||||
newRecordActions = defaultNewRecordActions;
|
newRecordActions = defaultNewRecordActions;
|
||||||
newIndexActions = defaultNewIndexActions;
|
newIndexActions = defaultNewIndexActions;
|
||||||
|
@ -32,13 +32,13 @@ database.subscribe(db => {
|
||||||
newRecordActions = [
|
newRecordActions = [
|
||||||
...defaultNewRecordActions,
|
...defaultNewRecordActions,
|
||||||
{label: `New Child Record of ${db.currentNode.name}`,
|
{label: `New Child Record of ${db.currentNode.name}`,
|
||||||
onclick: database.newChildRecord}
|
onclick: store.newChildRecord}
|
||||||
];
|
];
|
||||||
|
|
||||||
newIndexActions = [
|
newIndexActions = [
|
||||||
...defaultNewIndexActions,
|
...defaultNewIndexActions,
|
||||||
{label: `New Index on ${db.currentNode.name}`,
|
{label: `New Index on ${db.currentNode.name}`,
|
||||||
onclick: database.newChildIndex}
|
onclick: store.newChildIndex}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -52,7 +52,7 @@ database.subscribe(db => {
|
||||||
<div class="hierarchy-title">Records</div>
|
<div class="hierarchy-title">Records</div>
|
||||||
<DropdownButton iconName="plus" actions={newRecordActions} />
|
<DropdownButton iconName="plus" actions={newRecordActions} />
|
||||||
</div>
|
</div>
|
||||||
{#each $database.hierarchy.children as record}
|
{#each $store.hierarchy.children as record}
|
||||||
<HierarchyRow node={record} />
|
<HierarchyRow node={record} />
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
|
@ -60,20 +60,20 @@ database.subscribe(db => {
|
||||||
<div class="hierarchy-title">Indexes</div>
|
<div class="hierarchy-title">Indexes</div>
|
||||||
<DropdownButton iconName="plus" actions={newIndexActions} />
|
<DropdownButton iconName="plus" actions={newIndexActions} />
|
||||||
</div>
|
</div>
|
||||||
{#each $database.hierarchy.indexes as index}
|
{#each $store.hierarchy.indexes as index}
|
||||||
<HierarchyRow node={index} />
|
<HierarchyRow node={index} />
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
<div class="node-container">
|
<div class="node-container">
|
||||||
<div class="actions-header">
|
<div class="actions-header">
|
||||||
{#if $database.currentNode}
|
{#if $store.currentNode}
|
||||||
<ActionsHeader left={hierarchyWidth}/>
|
<ActionsHeader left={hierarchyWidth}/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="node-view">
|
<div class="node-view">
|
||||||
{#if !$database.currentNode}
|
{#if !$store.currentNode}
|
||||||
<h1 style="margin-left: 100px">:)</h1>
|
<h1 style="margin-left: 100px">:)</h1>
|
||||||
{:else if $database.currentNode.type === "record"}
|
{:else if $store.currentNode.type === "record"}
|
||||||
<RecordView />
|
<RecordView />
|
||||||
{:else}
|
{:else}
|
||||||
<IndexView />
|
<IndexView />
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {allTypes, validate, getPotentialReferenceIndexes,
|
||||||
export let field;
|
export let field;
|
||||||
export let allFields;
|
export let allFields;
|
||||||
export let onFinished = () => {};
|
export let onFinished = () => {};
|
||||||
export let database;
|
export let store;
|
||||||
|
|
||||||
let errors = [];
|
let errors = [];
|
||||||
let clonedField = cloneDeep(field);
|
let clonedField = cloneDeep(field);
|
||||||
|
@ -25,19 +25,19 @@ let clonedField = cloneDeep(field);
|
||||||
$: isNew = !!field && field.name.length === 0;
|
$: isNew = !!field && field.name.length === 0;
|
||||||
|
|
||||||
$: possibleReferenceIndexes = getPotentialReferenceIndexes(
|
$: possibleReferenceIndexes = getPotentialReferenceIndexes(
|
||||||
database.hierarchy, database.currentNode
|
store.hierarchy, store.currentNode
|
||||||
);
|
);
|
||||||
|
|
||||||
$: selectedReverseRefIndex =
|
$: selectedReverseRefIndex =
|
||||||
!clonedField.typeOptions.indexNodeKey
|
!clonedField.typeOptions.indexNodeKey
|
||||||
? ""
|
? ""
|
||||||
: getNode(database.hierarchy, clonedField.typeOptions.indexNodeKey);
|
: getNode(store.hierarchy, clonedField.typeOptions.indexNodeKey);
|
||||||
|
|
||||||
$: possibleReverseReferenceIndexes =
|
$: possibleReverseReferenceIndexes =
|
||||||
!selectedReverseRefIndex
|
!selectedReverseRefIndex
|
||||||
? []
|
? []
|
||||||
: getPotentialReverseReferenceIndexes(
|
: getPotentialReverseReferenceIndexes(
|
||||||
database.hierarchy, selectedReverseRefIndex);
|
store.hierarchy, selectedReverseRefIndex);
|
||||||
|
|
||||||
const typeChanged = (ev) =>
|
const typeChanged = (ev) =>
|
||||||
clonedField.typeOptions = getDefaultTypeOptions(ev.detail);
|
clonedField.typeOptions = getDefaultTypeOptions(ev.detail);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import {database} from "../builderStore";
|
import {store} from "../builderStore";
|
||||||
import {cloneDeep} from "lodash";
|
import {cloneDeep} from "lodash";
|
||||||
export let level = 0;
|
export let level = 0;
|
||||||
export let node;
|
export let node;
|
||||||
|
@ -8,7 +8,7 @@ export let node;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="root">
|
<div class="root">
|
||||||
<div class="title" on:click={() => database.selectExistingNode(node.nodeId)} style="padding-left: {20 + (level * 20)}px">
|
<div class="title" on:click={() => store.selectExistingNode(node.nodeId)} style="padding-left: {20 + (level * 20)}px">
|
||||||
{node.name}
|
{node.name}
|
||||||
</div>
|
</div>
|
||||||
{#if node.children}
|
{#if node.children}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import Textbox from "../common/Textbox.svelte";
|
||||||
import CodeArea from "../common/CodeArea.svelte";
|
import CodeArea from "../common/CodeArea.svelte";
|
||||||
import Button from "../common/Button.svelte";
|
import Button from "../common/Button.svelte";
|
||||||
import Dropdown from "../common/Dropdown.svelte";
|
import Dropdown from "../common/Dropdown.svelte";
|
||||||
import {database} from "../builderStore";
|
import {store} from "../builderStore";
|
||||||
import {filter, some, map} from "lodash/fp";
|
import {filter, some, map} from "lodash/fp";
|
||||||
import {hierarchy as hierarchyFunctions, common} from "../../../core/src";
|
import {hierarchy as hierarchyFunctions, common} from "../../../core/src";
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@ const chain = common.$;
|
||||||
let index;
|
let index;
|
||||||
let indexableRecords = [];
|
let indexableRecords = [];
|
||||||
|
|
||||||
database.subscribe($database => {
|
store.subscribe($store => {
|
||||||
index = $database.currentNode;
|
index = $store.currentNode;
|
||||||
indexableRecords = chain($database.hierarchy,[
|
indexableRecords = chain($store.hierarchy,[
|
||||||
hierarchyFunctions.getFlattenedHierarchy,
|
hierarchyFunctions.getFlattenedHierarchy,
|
||||||
filter(hierarchyFunctions.isDecendant(index.parent())),
|
filter(hierarchyFunctions.isDecendant(index.parent())),
|
||||||
filter(hierarchyFunctions.isRecord),
|
filter(hierarchyFunctions.isRecord),
|
||||||
|
|
|
@ -7,7 +7,7 @@ import FieldView from "./FieldView.svelte";
|
||||||
import Modal from "../common/Modal.svelte";
|
import Modal from "../common/Modal.svelte";
|
||||||
import {map, join, filter, some,
|
import {map, join, filter, some,
|
||||||
find, keys, isDate} from "lodash/fp";
|
find, keys, isDate} from "lodash/fp";
|
||||||
import { database } from "../builderStore";
|
import { store } from "../builderStore";
|
||||||
import {common, hierarchy as h} from "../../../core/src";
|
import {common, hierarchy as h} from "../../../core/src";
|
||||||
import {templateApi, chain, validate} from "../common/core";
|
import {templateApi, chain, validate} from "../common/core";
|
||||||
|
|
||||||
|
@ -22,9 +22,9 @@ let deleteField;
|
||||||
let onFinishedFieldEdit;
|
let onFinishedFieldEdit;
|
||||||
let editIndex;
|
let editIndex;
|
||||||
|
|
||||||
database.subscribe($database => {
|
store.subscribe($store => {
|
||||||
record = $database.currentNode;
|
record = $store.currentNode;
|
||||||
const flattened = h.getFlattenedHierarchy($database.hierarchy);
|
const flattened = h.getFlattenedHierarchy($store.hierarchy);
|
||||||
getIndexAllowedRecords = index =>
|
getIndexAllowedRecords = index =>
|
||||||
chain(index.allowedRecordNodeIds, [
|
chain(index.allowedRecordNodeIds, [
|
||||||
filter(id => some(n => n.nodeId === id)(flattened)),
|
filter(id => some(n => n.nodeId === id)(flattened)),
|
||||||
|
@ -35,13 +35,13 @@ database.subscribe($database => {
|
||||||
|
|
||||||
newField = () => {
|
newField = () => {
|
||||||
isNewField = true;
|
isNewField = true;
|
||||||
fieldToEdit = templateApi($database.hierarchy).getNewField("string");
|
fieldToEdit = templateApi($store.hierarchy).getNewField("string");
|
||||||
editingField = true;
|
editingField = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onFinishedFieldEdit = (field) => {
|
onFinishedFieldEdit = (field) => {
|
||||||
if(field) {
|
if(field) {
|
||||||
database.saveField(field);
|
store.saveField(field);
|
||||||
}
|
}
|
||||||
editingField = false;
|
editingField = false;
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,11 @@ database.subscribe($database => {
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteField = (field) => {
|
deleteField = (field) => {
|
||||||
database.deleteField(field);
|
store.deleteField(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
editIndex = index => {
|
editIndex = index => {
|
||||||
database.selectExistingNode(index.nodeId);
|
store.selectExistingNode(index.nodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -131,7 +131,7 @@ let getTypeOptions = typeOptions =>
|
||||||
<FieldView field={fieldToEdit}
|
<FieldView field={fieldToEdit}
|
||||||
onFinished={onFinishedFieldEdit}
|
onFinished={onFinishedFieldEdit}
|
||||||
allFields={record.fields}
|
allFields={record.fields}
|
||||||
database={$database}/>
|
store={$store}/>
|
||||||
</Modal>
|
</Modal>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ export let width=50;
|
||||||
<NavItem name="actions" label="Actions" icon="zap" />
|
<NavItem name="actions" label="Actions" icon="zap" />
|
||||||
<NavItem name="access levels" label="Access Levels" icon="user" />
|
<NavItem name="access levels" label="Access Levels" icon="user" />
|
||||||
<NavItem name="user interface" label="User Interface" icon="monitor"/>
|
<NavItem name="user interface" label="User Interface" icon="monitor"/>
|
||||||
<NavItem name="package" label="Package" icon="package"/>
|
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import {database} from "../builderStore";
|
import {store} from "../builderStore";
|
||||||
import getIcon from "../common/icon";
|
import getIcon from "../common/icon";
|
||||||
|
|
||||||
export let name = "";
|
export let name = "";
|
||||||
|
@ -9,12 +9,12 @@ export let icon = "";
|
||||||
|
|
||||||
let navActive = "";
|
let navActive = "";
|
||||||
|
|
||||||
database.subscribe(db => {
|
store.subscribe(db => {
|
||||||
navActive = (db.activeNav === name ? "active" : "")
|
navActive = (db.activeNav === name ? "active" : "")
|
||||||
});
|
});
|
||||||
|
|
||||||
const setActive = () =>
|
const setActive = () =>
|
||||||
database.setActiveNav(name);
|
store.setActiveNav(name);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import ComingSoon from "../common/ComingSoon.svelte";
|
import ComingSoon from "../common/ComingSoon.svelte";
|
||||||
|
import { store } from "../builderStore";
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="root">
|
<div class="root">
|
||||||
|
|
||||||
<div class="ui-nav">
|
<div class="ui-nav">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="component-preview">
|
<div class="component-preview">
|
||||||
|
@ -20,12 +21,14 @@ import ComingSoon from "../common/ComingSoon.svelte";
|
||||||
|
|
||||||
.root {
|
.root {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: [uiNav] 200px [preview] auto;
|
grid-template-columns: [uiNav] 300px [preview] auto;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ui-nav {
|
.ui-nav {
|
||||||
grid-column-start: uiNav;
|
grid-column-start: uiNav;
|
||||||
|
background-color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.component-preview {
|
.component-preview {
|
||||||
|
|
|
@ -15,7 +15,7 @@ const pipe = common.$;
|
||||||
|
|
||||||
const normalString = s => (s||"").trim().toLowerCase();
|
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) => {
|
export const searchAllComponents = (derivedComponents, rootComponents, phrase) => {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue