From ad8617406fce8d874da2ec150ed3ab19d25eef49 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 24 Mar 2020 19:59:30 +0000 Subject: [PATCH] tidy up --- packages/builder/package.json | 1 - .../builder/src/builderStore/store/backend.js | 5 --- .../builder/src/database/IndexView.svelte | 31 +++++++++---------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/packages/builder/package.json b/packages/builder/package.json index 70a9602309..fa92be46a2 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -47,7 +47,6 @@ "safe-buffer": "^5.1.2", "shortid": "^2.2.8", "string_decoder": "^1.2.0", - "svelte-routing": "^1.4.2", "uikit": "^3.1.7" }, "devDependencies": { diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index 5fa14b5c5f..0a3da2fb50 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -57,11 +57,6 @@ export const getBackendUiStore = () => { modals: { show: modal => store.update(state => ({ ...state, visibleModal: modal })), hide: () => store.update(state => ({ ...state, visibleModal: null })) - }, - nodes: { - select: () => {}, - update: () => {}, - delete: () => {}, } } diff --git a/packages/builder/src/database/IndexView.svelte b/packages/builder/src/database/IndexView.svelte index b60c4b4cb4..22a868ea15 100644 --- a/packages/builder/src/database/IndexView.svelte +++ b/packages/builder/src/database/IndexView.svelte @@ -4,11 +4,9 @@ import Button from "../common/Button.svelte" import Dropdown from "../common/Dropdown.svelte" import { store } from "../builderStore" - import { filter, some, map } from "lodash/fp" + import { filter, some, map, compose } from "lodash/fp" import { hierarchy as hierarchyFunctions, common } from "../../../core/src" - const pipe = common.$ - const SNIPPET_EDITORS = { MAP: "Map", FILTER: "Filter", @@ -19,25 +17,26 @@ let indexableRecords = [] let currentSnippetEditor = SNIPPET_EDITORS.MAP + const indexableRecordsFromIndex = compose( + map(node => ({ + node, + isallowed: index.allowedRecordNodeIds.some(id => node.nodeId === id), + })), + filter(hierarchyFunctions.isRecord), + filter(hierarchyFunctions.isDecendant(index.parent())), + hierarchyFunctions.getFlattenedHierarchy + ) + store.subscribe($store => { index = $store.currentNode - indexableRecords = pipe( - $store.hierarchy, - [ - hierarchyFunctions.getFlattenedHierarchy, - filter(hierarchyFunctions.isDecendant(index.parent())), - filter(hierarchyFunctions.isRecord), - map(node => ({ - node, - isallowed: index.allowedRecordNodeIds.some(id => node.nodeId === id), - })), - ] - ) + indexableRecords = indexableRecordsFromIndex($store.hierarchy) }) const toggleAllowedRecord = record => { if (record.isallowed) { - index.allowedRecordNodeIds = index.allowedRecordNodeIds.filter(id => id !== record.node.nodeId) + index.allowedRecordNodeIds = index.allowedRecordNodeIds.filter( + id => id !== record.node.nodeId + ) } else { index.allowedRecordNodeIds.push(record.node.nodeId) }