1
0
Fork 0
mirror of synced 2024-10-02 10:08:09 +13:00
This commit is contained in:
Martin McKeaveney 2020-03-24 19:59:30 +00:00
parent a91b89b7c2
commit 88db9bbc02
3 changed files with 15 additions and 22 deletions

View file

@ -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": {

View file

@ -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: () => {},
}
}

View file

@ -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)
}