edges reordser fix

This commit is contained in:
2023-11-01 13:09:32 +02:00
parent 7ac59fc0fe
commit 1442b68503
4 changed files with 24 additions and 24 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"main.js": { "main.js": {
"file": "assets/main.016edc6c.js", "file": "assets/main.96863591.js",
"src": "main.js", "src": "main.js",
"isEntry": true, "isEntry": true,
"css": [ "css": [
@@ -21,7 +21,6 @@
.map((edge) => { .map((edge) => {
return graph.records.find((increc) => increc.id === edge.target && record.id === edge.source); return graph.records.find((increc) => increc.id === edge.target && record.id === edge.source);
}).filter((rec) => (rec?.id ? true : false)) ?? []; }).filter((rec) => (rec?.id ? true : false)) ?? [];
let collections = channel.schemas.filter((aschema) => let collections = channel.schemas.filter((aschema) =>
field.collections.includes(aschema.name) field.collections.includes(aschema.name)
); );
@@ -44,7 +43,7 @@
function insert(e) { function insert(e) {
e.preventDefault(); e.preventDefault();
graph = insertEdges(graph,record,e.detail.records,field.name,e.detail.action); graph = insertEdges(graph, record, e.detail.records, field.name, e.detail.action);
} }
$:visibleColumns = []; $:visibleColumns = [];
@@ -62,11 +61,11 @@
{/if} {/if}
<div class="inline-card-wrapper"> <div class="inline-card-wrapper">
<ReferenceInlineButtons <ReferenceInlineButtons
buttonClass="mt-2" buttonClass="mt-2"
recordId={null} recordId={null}
schemas={collections} schemas={collections}
on:insert={insert} on:insert={insert}
on:save={insert} on:save={insert}
/> />
</div> </div>
{#if references.length > 0} {#if references.length > 0}
@@ -78,11 +77,11 @@
{#each visibleColumns as field} {#each visibleColumns as field}
<th <th
class="field-ui-{field.ui}" class="field-ui-{field.ui}"
scope="col" scope="col"
title={field.help} title={field.help}
data-bs-toggle="tooltip" data-bs-toggle="tooltip"
data-bs-placement="top">{field.label}</th data-bs-placement="top">{field.label}</th
> >
{/each} {/each}
<th/> <th/>
@@ -95,9 +94,9 @@
<div class=""> <div class="">
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<a <a
class="me-2 text-decoration-none text-dark fs-6" class="me-2 text-decoration-none text-dark fs-6"
href="{channel.lucentUrl}/records/{record.id}" href="{channel.lucentUrl}/records/{record.id}"
target="_blank" target="_blank"
> >
{previewTitle(channel.schemas, record)} {previewTitle(channel.schemas, record)}
</a> </a>
@@ -107,17 +106,17 @@
{#each visibleColumns as field, index} {#each visibleColumns as field, index}
<td class="field-ui-{field.ui}"> <td class="field-ui-{field.ui}">
<RenderField <RenderField
{record} {record}
{graph} {graph}
schema={collection} schema={collection}
{field} {field}
/> />
</td> </td>
{/each} {/each}
<td> <td>
<button <button
class="trash-button text-dark btn btn-sm btn-link" class="trash-button text-dark btn btn-sm btn-link"
on:click={(e) => on:click={(e) =>
removeReference(e, record.id)} removeReference(e, record.id)}
> >
<Icon icon="trash-can"/> <Icon icon="trash-can"/>
@@ -8,6 +8,7 @@ export function insertEdges(graph, sourceRecord, targetRecords, fieldName, actio
sourceSchema: sourceRecord.schema, sourceSchema: sourceRecord.schema,
targetSchema: r.schema, targetSchema: r.schema,
field: fieldName, field: fieldName,
depth: 1,
rank: "" rank: ""
}; };
}); });
@@ -18,6 +19,6 @@ export function insertEdges(graph, sourceRecord, targetRecords, fieldName, actio
} }
graph.records = uniqBy([...graph.records, ...targetRecords], (r) => r.id); graph.records = uniqBy([...graph.records, ...targetRecords], (r) => r.id);
graph.edges = uniqBy([...replacedEdges, ...newEdges], (edge) => edge.source + edge.target + edge.field); graph.edges = uniqBy([...replacedEdges, ...newEdges], (edge) => edge.source + edge.target + edge.field + edge.depth);
return graph; return graph;
} }