2019-07-13 11:35:57 +02:00
|
|
|
<script>
|
|
|
|
|
|
|
|
import Textbox from "../common/Textbox.svelte";
|
|
|
|
import CodeArea from "../common/CodeArea.svelte";
|
|
|
|
import Button from "../common/Button.svelte";
|
|
|
|
import Dropdown from "../common/Dropdown.svelte";
|
2019-07-31 09:09:04 +02:00
|
|
|
import {store} from "../builderStore";
|
2019-07-13 11:35:57 +02:00
|
|
|
import {filter, some, map} from "lodash/fp";
|
2019-07-30 10:08:40 +02:00
|
|
|
import {hierarchy as hierarchyFunctions, common} from "../../../core/src";
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2019-08-02 15:54:10 +02:00
|
|
|
const pipe = common.$;
|
2019-07-13 11:35:57 +02:00
|
|
|
|
|
|
|
let index;
|
|
|
|
let indexableRecords = [];
|
|
|
|
|
2019-07-31 09:09:04 +02:00
|
|
|
store.subscribe($store => {
|
|
|
|
index = $store.currentNode;
|
2019-08-02 15:54:10 +02:00
|
|
|
indexableRecords = pipe($store.hierarchy,[
|
2019-07-13 11:35:57 +02:00
|
|
|
hierarchyFunctions.getFlattenedHierarchy,
|
|
|
|
filter(hierarchyFunctions.isDecendant(index.parent())),
|
|
|
|
filter(hierarchyFunctions.isRecord),
|
|
|
|
map(n => ({
|
|
|
|
node:n,
|
|
|
|
isallowed: some(id => n.nodeId === id)(index.allowedRecordNodeIds)
|
|
|
|
}))
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
const toggleAllowedRecord = record => {
|
|
|
|
if(record.isallowed) {
|
|
|
|
index.allowedRecordNodeIds = filter(id => id !== record.node.nodeId)
|
|
|
|
(index.allowedRecordNodeIds);
|
|
|
|
} else {
|
|
|
|
index.allowedRecordNodeIds.push(record.node.nodeId);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
2019-08-07 10:03:49 +02:00
|
|
|
<form class="uk-form-horizontal root">
|
2019-07-13 11:35:57 +02:00
|
|
|
<Textbox bind:text={index.name} label="Name"/>
|
|
|
|
|
|
|
|
<div class="allowed-records">
|
|
|
|
<div>Records to Index</div>
|
|
|
|
{#each indexableRecords as rec}
|
|
|
|
<input type="checkbox" checked={rec.isallowed} on:change={() => toggleAllowedRecord(rec)}/>
|
|
|
|
<span>{rec.node.name}</span>
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<Dropdown label="Index Type" bind:selected={index.indexType} options={["ancestor", "reference"]} />
|
|
|
|
|
|
|
|
<CodeArea bind:text={index.map} label="Map (javascript)"/>
|
|
|
|
<CodeArea bind:text={index.filter} label="Filter (javascript expression)"/>
|
|
|
|
<CodeArea bind:text={index.getShardName} label="Shard Name (javascript expression)"/>
|
|
|
|
|
|
|
|
|
2019-08-07 10:03:49 +02:00
|
|
|
</form>
|
2019-07-13 11:35:57 +02:00
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
.root {
|
|
|
|
height: 100%;
|
|
|
|
padding: 15px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.allowed-records {
|
|
|
|
margin: 20px 0px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.allowed-records > span {
|
|
|
|
margin-right:30px;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|