2024-08-16 16:00:48 +03:00
|
|
|
<script>
|
|
|
|
|
import Icon from "../../common/Icon.svelte";
|
|
|
|
|
|
2024-08-19 17:48:10 +03:00
|
|
|
import {createEventDispatcher, getContext} from "svelte";
|
|
|
|
|
import {previewTitle} from "./../Preview";
|
2024-08-16 16:00:48 +03:00
|
|
|
import Status from "./../Status.svelte";
|
2024-08-19 17:48:10 +03:00
|
|
|
import Preview from "../../files/Preview.svelte";
|
|
|
|
|
|
2024-08-16 16:00:48 +03:00
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
const channel = getContext("channel");
|
|
|
|
|
export let graph;
|
|
|
|
|
export let record;
|
|
|
|
|
export let hasDelete = false;
|
|
|
|
|
|
|
|
|
|
let schema = channel.schemas.find((aschema) => aschema.name === record.schema);
|
|
|
|
|
let cardTitle = previewTitle(channel.schemas, record, graph);
|
2024-08-19 17:48:10 +03:00
|
|
|
const cardImageEdge = graph.edges.find(e => e.source === record.id && e.field === schema.cardImage);
|
|
|
|
|
let cardImageRecord = graph.records.find(r => r.id === cardImageEdge?.target);
|
|
|
|
|
|
2024-08-16 16:00:48 +03:00
|
|
|
function remove(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
dispatch("remove", record.id);
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="preview-reference">
|
|
|
|
|
<div style="display: flex;align-items: center;gap: 10px;">
|
|
|
|
|
|
2024-08-19 17:48:10 +03:00
|
|
|
{#if cardImageRecord}
|
|
|
|
|
<div class="image">
|
|
|
|
|
<Preview record={cardImageRecord} size="small"/>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2024-08-16 16:00:48 +03:00
|
|
|
<div class="title">
|
|
|
|
|
<div>
|
|
|
|
|
<a
|
|
|
|
|
class="record-title"
|
|
|
|
|
href="{channel.lucentUrl}/records/{record.id}"
|
|
|
|
|
>
|
|
|
|
|
{cardTitle}
|
|
|
|
|
</a>
|
|
|
|
|
<small class="d-block">
|
|
|
|
|
from {schema.label}
|
|
|
|
|
{#if record.status === "draft"}
|
|
|
|
|
<Status status={record.status}/>
|
|
|
|
|
{/if}
|
|
|
|
|
</small>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{#if hasDelete}
|
2024-08-19 17:48:10 +03:00
|
|
|
<div class="reference-action">
|
2024-08-16 16:00:48 +03:00
|
|
|
<button
|
|
|
|
|
class="button"
|
|
|
|
|
on:click={remove}
|
|
|
|
|
>
|
|
|
|
|
<Icon icon="trash-can"/>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
|