tidy up
This commit is contained in:
parent
57c3598d9f
commit
ad8617406f
|
@ -47,7 +47,6 @@
|
||||||
"safe-buffer": "^5.1.2",
|
"safe-buffer": "^5.1.2",
|
||||||
"shortid": "^2.2.8",
|
"shortid": "^2.2.8",
|
||||||
"string_decoder": "^1.2.0",
|
"string_decoder": "^1.2.0",
|
||||||
"svelte-routing": "^1.4.2",
|
|
||||||
"uikit": "^3.1.7"
|
"uikit": "^3.1.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -57,11 +57,6 @@ export const getBackendUiStore = () => {
|
||||||
modals: {
|
modals: {
|
||||||
show: modal => store.update(state => ({ ...state, visibleModal: modal })),
|
show: modal => store.update(state => ({ ...state, visibleModal: modal })),
|
||||||
hide: () => store.update(state => ({ ...state, visibleModal: null }))
|
hide: () => store.update(state => ({ ...state, visibleModal: null }))
|
||||||
},
|
|
||||||
nodes: {
|
|
||||||
select: () => {},
|
|
||||||
update: () => {},
|
|
||||||
delete: () => {},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,9 @@
|
||||||
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 { store } from "../builderStore"
|
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"
|
import { hierarchy as hierarchyFunctions, common } from "../../../core/src"
|
||||||
|
|
||||||
const pipe = common.$
|
|
||||||
|
|
||||||
const SNIPPET_EDITORS = {
|
const SNIPPET_EDITORS = {
|
||||||
MAP: "Map",
|
MAP: "Map",
|
||||||
FILTER: "Filter",
|
FILTER: "Filter",
|
||||||
|
@ -19,25 +17,26 @@
|
||||||
let indexableRecords = []
|
let indexableRecords = []
|
||||||
let currentSnippetEditor = SNIPPET_EDITORS.MAP
|
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 => {
|
store.subscribe($store => {
|
||||||
index = $store.currentNode
|
index = $store.currentNode
|
||||||
indexableRecords = pipe(
|
indexableRecords = indexableRecordsFromIndex($store.hierarchy)
|
||||||
$store.hierarchy,
|
|
||||||
[
|
|
||||||
hierarchyFunctions.getFlattenedHierarchy,
|
|
||||||
filter(hierarchyFunctions.isDecendant(index.parent())),
|
|
||||||
filter(hierarchyFunctions.isRecord),
|
|
||||||
map(node => ({
|
|
||||||
node,
|
|
||||||
isallowed: index.allowedRecordNodeIds.some(id => node.nodeId === id),
|
|
||||||
})),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const toggleAllowedRecord = record => {
|
const toggleAllowedRecord = record => {
|
||||||
if (record.isallowed) {
|
if (record.isallowed) {
|
||||||
index.allowedRecordNodeIds = index.allowedRecordNodeIds.filter(id => id !== record.node.nodeId)
|
index.allowedRecordNodeIds = index.allowedRecordNodeIds.filter(
|
||||||
|
id => id !== record.node.nodeId
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
index.allowedRecordNodeIds.push(record.node.nodeId)
|
index.allowedRecordNodeIds.push(record.node.nodeId)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue