cleanup
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
<script>
|
||||
import { uniqueId } from "lodash";
|
||||
export let label;
|
||||
export let name;
|
||||
export let group;
|
||||
export let value;
|
||||
export let help = "";
|
||||
let id = uniqueId();
|
||||
</script>
|
||||
|
||||
<div class="form-check">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="radio"
|
||||
{value}
|
||||
{name}
|
||||
bind:group
|
||||
{id}
|
||||
/>
|
||||
<label class="form-check-label" for={id}>
|
||||
{label}
|
||||
</label>
|
||||
{#if help}
|
||||
<span class="text-muted">{help}</span>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -2,7 +2,6 @@
|
||||
import Text from "./elements/Text.svelte";
|
||||
import Slug from "./elements/Slug.svelte";
|
||||
import Reference from "./elements/Reference.svelte";
|
||||
import ReferenceInline from "./elements/ReferenceInline.svelte";
|
||||
import Color from "./elements/Color.svelte";
|
||||
import Checkbox from "./elements/Checkbox.svelte";
|
||||
import Number from "./elements/Number.svelte";
|
||||
@@ -46,15 +45,8 @@
|
||||
</script>
|
||||
|
||||
<div class="editor-field">
|
||||
<FieldHeader {field} {id}/>
|
||||
{#if field.info.name === "reference" && field.layout === "inline"}
|
||||
<ReferenceInline
|
||||
bind:graph
|
||||
{record}
|
||||
{field}
|
||||
{validationErrors}
|
||||
/>
|
||||
{:else if field.info.name === "reference" && field.layout === "tags"}
|
||||
<FieldHeader {field} {id}/>
|
||||
{#if field.info.name === "reference" && field.layout === "tags"}
|
||||
<ReferenceTags
|
||||
bind:graph
|
||||
{id}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
<script>
|
||||
|
||||
import Icon from "../common/Icon.svelte";
|
||||
import PreviewCardSmall from "./PreviewCardSmall.svelte";
|
||||
|
||||
export let managerRecords;
|
||||
|
||||
export let graph;
|
||||
</script>
|
||||
|
||||
{#if managerRecords.length > 0}
|
||||
<div
|
||||
class="record-history d-flex justify-content-center align-items-center w-100 mb-4 mt-4"
|
||||
>
|
||||
{#each managerRecords.reverse() as arecord, i}
|
||||
{#if i !== 0}
|
||||
<Icon icon="angle-right"/>
|
||||
{/if}
|
||||
|
||||
<div class="mx-3 p-0 my-0">
|
||||
<PreviewCardSmall record={arecord} {graph}/>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.record-history {
|
||||
/* background-color: #fff; */
|
||||
padding: 15px 10px;
|
||||
border-radius: 32px;
|
||||
line-height: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -42,7 +42,7 @@ function noTemplate(schema, record) {
|
||||
record?.data[schema.fields.filter((f) => f.info.name === "text")[0]?.name]
|
||||
).slice(0, 300);
|
||||
|
||||
if(title.trim() == ""){
|
||||
if(title.trim() === ""){
|
||||
return "~Untitled~";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
<script>
|
||||
import Icon from "../common/Icon.svelte";
|
||||
|
||||
import { getContext, createEventDispatcher } from "svelte";
|
||||
import Preview from "../files/Preview.svelte";
|
||||
import { previewTitle } from "./Preview";
|
||||
import Status from "./Status.svelte";
|
||||
const dispatch = createEventDispatcher();
|
||||
const channel = getContext("channel");
|
||||
export let graph;
|
||||
export let record;
|
||||
export let classes = "";
|
||||
export let hasDelete = false;
|
||||
|
||||
let schema = channel.schemas.find((aschema) => aschema.name === record.schema);
|
||||
let cardTitle = previewTitle(channel.schemas, record, graph);
|
||||
function remove(e) {
|
||||
e.preventDefault();
|
||||
|
||||
dispatch("remove", record.id);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
|
||||
class="card mb-2 bg-light {classes}"
|
||||
style="border-color:{schema.color ?? '#ccc'}; border-width: 1px;"
|
||||
>
|
||||
<div class="card-body d-flex">
|
||||
{#if schema.type === "files"}
|
||||
<div style="max-width:94px;margin-right:15px">
|
||||
<Preview {record} size="small" />
|
||||
</div>
|
||||
{/if}
|
||||
<div class="overflow-hidden">
|
||||
<a
|
||||
class="title-link m-0 fs-5 text-decoration-none text-dark d-block"
|
||||
href="{channel.lucentUrl}/records/{record.id}"
|
||||
title={cardTitle}
|
||||
>
|
||||
{cardTitle}
|
||||
</a>
|
||||
<small class="text-muted">
|
||||
{schema.label}
|
||||
</small>
|
||||
<small class="text-muted">
|
||||
{#if record.status === "draft"}
|
||||
<Status status={record.status} />
|
||||
{/if}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if hasDelete}
|
||||
<div class="position-absolute end-0" style="top:5px">
|
||||
<button
|
||||
class="trash-button text-dark btn btn-sm btn-link"
|
||||
on:click={remove}
|
||||
><Icon icon="trash-can" />
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
.card .trash-button {
|
||||
display: none;
|
||||
}
|
||||
.card:hover .trash-button {
|
||||
display: block;
|
||||
}
|
||||
.title-link {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
@@ -1,230 +0,0 @@
|
||||
<script>
|
||||
import Icon from "../common/Icon.svelte";
|
||||
|
||||
|
||||
import {createEventDispatcher, onMount, getContext} from "svelte";
|
||||
import Preview from "../files/Preview.svelte";
|
||||
import InlineEdit from "./InlineEdit.svelte";
|
||||
import Reference from "../content/elements/Reference.svelte";
|
||||
import File from "../content/elements/File.svelte";
|
||||
|
||||
const channel = getContext("channel");
|
||||
const dispatch = createEventDispatcher();
|
||||
export let isFirst;
|
||||
export let isLast;
|
||||
export let toDelete = false;
|
||||
export let record;
|
||||
let editRecord;
|
||||
let editGraph;
|
||||
let schema = channel.schemas.find((aschema) => aschema.name === record.schema);
|
||||
$: editMode = false;
|
||||
$: expanded = false;
|
||||
|
||||
function editInline(e) {
|
||||
e.preventDefault();
|
||||
axios
|
||||
.get(channel.lucentUrl + "/records/editInline/" + record.id)
|
||||
.then((response) => {
|
||||
record = response.data;
|
||||
editRecord = response.data.record;
|
||||
editGraph = response.data.graph;
|
||||
editMode = true;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
|
||||
function moveup(e) {
|
||||
e.preventDefault();
|
||||
dispatch("moveup");
|
||||
}
|
||||
|
||||
function movedn(e) {
|
||||
e.preventDefault();
|
||||
dispatch("movedn");
|
||||
}
|
||||
|
||||
function handleInlinesaved(e) {
|
||||
e.preventDefault();
|
||||
dispatch("inlinesaved", e.detail);
|
||||
editMode = false;
|
||||
}
|
||||
|
||||
function remove(e) {
|
||||
e.preventDefault();
|
||||
dispatch("remove", record.id);
|
||||
}
|
||||
|
||||
function trash(e) {
|
||||
e.preventDefault();
|
||||
dispatch("trash", record.id);
|
||||
}
|
||||
|
||||
function undo(e) {
|
||||
e.preventDefault();
|
||||
dispatch("undoremove", record.id);
|
||||
}
|
||||
|
||||
function cancel(e) {
|
||||
e.preventDefault();
|
||||
editMode = false;
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
editMode = false;
|
||||
});
|
||||
|
||||
function deleteFromChannel(e) {
|
||||
e.preventDefault();
|
||||
axios
|
||||
.post(channel.lucentUrl +"/records/status/trashed", [record])
|
||||
.then((response) => {
|
||||
dispatch("remove", record.id);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<div>
|
||||
{#if toDelete}
|
||||
<div class="lx-card bg-danger bg-opacity-10 text-center">
|
||||
<p>Item was removed from the current record.</p>
|
||||
<p>
|
||||
<button
|
||||
class="btn btn-sm btn-outline border border-1 border-dark"
|
||||
on:click={undo}>Undo
|
||||
</button
|
||||
>
|
||||
<button
|
||||
class="btn btn-sm btn-danger "
|
||||
on:click={deleteFromChannel}
|
||||
>Delete completely from channel
|
||||
</button
|
||||
>
|
||||
</p>
|
||||
<button class="btn btn-sm btn-link" on:click={remove}
|
||||
>Dismiss Message
|
||||
</button
|
||||
>
|
||||
</div>
|
||||
{:else if editMode === true}
|
||||
<InlineEdit
|
||||
{schema}
|
||||
record={editRecord}
|
||||
graph={editGraph}
|
||||
isCreateMode={false}
|
||||
on:cancel={cancel}
|
||||
on:inlinesaved={handleInlinesaved}
|
||||
/>
|
||||
{:else}
|
||||
<div class="lx-card mt-4 bg-primary bg-opacity-10">
|
||||
<div class="actions">
|
||||
<small class="text-muted">{schema.label}</small>
|
||||
<button
|
||||
class="btn btn-sm btn-link"
|
||||
on:click|preventDefault={editInline}
|
||||
>
|
||||
<Icon icon="pencil" width={12} height={12}/>
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-sm btn-link"
|
||||
on:click={(e) => (expanded = !expanded)}
|
||||
>
|
||||
{#if expanded}
|
||||
<Icon icon="compress" width={12} height={12}/>
|
||||
{:else}
|
||||
<Icon icon="expand" width={12} height={12}/>
|
||||
{/if}
|
||||
</button>
|
||||
<div class="dropdown d-inline-block">
|
||||
<button
|
||||
class="btn btn-link btn-sm"
|
||||
type="button"
|
||||
data-bs-toggle="dropdown"
|
||||
aria-expanded="false"
|
||||
>
|
||||
<Icon icon="ellipsis"/>
|
||||
</button>
|
||||
|
||||
<div class="dropdown-menu">
|
||||
<a
|
||||
class="dropdown-item"
|
||||
href="/records/{record.id}"
|
||||
target="_blank"
|
||||
>Edit in new tab
|
||||
</a>
|
||||
<button class="dropdown-item" on:click={trash}>
|
||||
Remove
|
||||
</button>
|
||||
<div class="text-center mt-3">
|
||||
<!-- <a class="dropdown-item" href="#">Clone</a> -->
|
||||
|
||||
{#if !isFirst}
|
||||
<button
|
||||
class="btn btn-sm btn-outline-primary border-0"
|
||||
on:click|preventDefault={moveup}
|
||||
>
|
||||
<Icon icon="circle-chevron-up"/>
|
||||
</button>
|
||||
{/if}
|
||||
{#if !isLast}
|
||||
<button
|
||||
class="btn btn-sm btn-outline-primary border-0"
|
||||
on:click|preventDefault={movedn}
|
||||
>
|
||||
<Icon icon="circle-chevron-down"/>
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="inline-preview" class:expanded>
|
||||
{#if schema.type === "files"}
|
||||
<Preview {record} size="small"/>
|
||||
{/if}
|
||||
{#each schema.fields.filter((f) => !(f.trashed || ["tab"].includes(f.ui) || ["id"].includes(f.name))) as field}
|
||||
<span class="text-muted d-block mt-2" style="font-size:13px"
|
||||
>{field.label}</span
|
||||
>
|
||||
{#if field.ui === "reference"}
|
||||
<Reference {record} {field}/>
|
||||
{:else if field.ui === "file"}
|
||||
<File {record} {field}/>
|
||||
{:else}
|
||||
{@html record.data[field.name]}
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.lx-card {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.lx-card .inline-preview {
|
||||
max-height: 120px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.lx-card .inline-preview.expanded {
|
||||
max-height: none;
|
||||
}
|
||||
|
||||
.lx-card .actions {
|
||||
top: 10px;
|
||||
right: 44px;
|
||||
position: absolute;
|
||||
/* visibility: hidden; */
|
||||
}
|
||||
|
||||
/* .lx-card:hover .actions {
|
||||
visibility: visible;
|
||||
} */
|
||||
</style>
|
||||
@@ -1,167 +0,0 @@
|
||||
<script>
|
||||
import {getContext} from "svelte";
|
||||
import {uniqBy} from "lodash";
|
||||
import PreviewCardInline from "../PreviewCardInline.svelte";
|
||||
import {getErrorMessage} from "./errorMessage";
|
||||
import {sortByField} from "../../edges/sortEdges";
|
||||
import ReferenceInlineButtons from "./ReferenceInlineButtons.svelte";
|
||||
import {flip} from "svelte/animate";
|
||||
import {quintOut} from 'svelte/easing';
|
||||
|
||||
const channel = getContext("channel");
|
||||
export let field;
|
||||
export let record;
|
||||
export let graph;
|
||||
export let validationErrors;
|
||||
|
||||
$: errorMessage = getErrorMessage(validationErrors, field.name);
|
||||
|
||||
$: references = graph.edges
|
||||
.filter((edge) => edge.field === field.name)
|
||||
.map((edge) => {
|
||||
return graph.records.find((increc) => increc.id == edge.target && record.id == edge.source);
|
||||
}).filter((rec) => (rec?.id ? true : false)) ?? [];
|
||||
|
||||
|
||||
let collections = channel.schemas.filter((aschema) =>
|
||||
field.collections.includes(aschema.name)
|
||||
);
|
||||
|
||||
function handleInlinesaved(e) {
|
||||
const updatedRecord = e.detail.records[0];
|
||||
graph.edges = graph.edges.map((child) => {
|
||||
if (child.source === updatedRecord.id) {
|
||||
return updatedRecord;
|
||||
}
|
||||
return child;
|
||||
});
|
||||
}
|
||||
|
||||
function removeReference(e) {
|
||||
e.preventDefault();
|
||||
graph.edges = graph.edges.filter(
|
||||
(edge) => !(edge.target === e.detail && edge.field === field.name)
|
||||
);
|
||||
}
|
||||
|
||||
function trashReference(e) {
|
||||
e.preventDefault();
|
||||
graph.edges = graph.edges.map((edge) => {
|
||||
if (edge.target === e.detail && edge.field === field.name) {
|
||||
edge._isTrashed = true;
|
||||
}
|
||||
return edge;
|
||||
});
|
||||
}
|
||||
|
||||
function undoRemoveReference(e) {
|
||||
e.preventDefault();
|
||||
graph.edges = graph.edges.map((edge) => {
|
||||
if (edge.target === e.detail && edge.field === field.name) {
|
||||
delete edge._isTrashed;
|
||||
}
|
||||
return edge;
|
||||
});
|
||||
}
|
||||
|
||||
function insert(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const recordsToInsert = e.detail.records;
|
||||
const insertAfter = e.detail.after ?? null;
|
||||
const action = e.detail.action;
|
||||
let newEdges = recordsToInsert.map((r) => {
|
||||
return {
|
||||
target: r.id,
|
||||
source: record.id,
|
||||
sourceSchema: record.schema,
|
||||
targetSchema: r.schema,
|
||||
field: field.name,
|
||||
rank: ""
|
||||
};
|
||||
});
|
||||
|
||||
let replacedEdges = graph.edges;
|
||||
if (action === "replace") {
|
||||
replacedEdges = replacedEdges.filter((edge) => edge.field !== field.name);
|
||||
}
|
||||
graph.records = uniqBy([...graph.records, ...recordsToInsert], (r) => r.id);
|
||||
graph.edges = uniqBy([...replacedEdges, ...newEdges], (edge) => edge.target + edge.field);
|
||||
|
||||
if (!insertAfter) {
|
||||
graph.edges = uniqBy(
|
||||
[...newEdges, ...replacedEdges],
|
||||
(edge) => edge.target + edge.field
|
||||
);
|
||||
} else {
|
||||
let isAfter = false;
|
||||
let beforeAfter = replacedEdges.reduce(
|
||||
(c, edge) => {
|
||||
if (isAfter) {
|
||||
c.after.push(edge);
|
||||
} else {
|
||||
c.before.push(edge);
|
||||
}
|
||||
|
||||
if (isAfter === false && edge.target === insertAfter) {
|
||||
isAfter = true;
|
||||
}
|
||||
return c;
|
||||
},
|
||||
{before: [], after: []}
|
||||
);
|
||||
|
||||
graph.edges = uniqBy(
|
||||
[...beforeAfter.before, ...newEdges, ...beforeAfter.after],
|
||||
(e) => e.target + e.field
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function move(e, from, to) {
|
||||
graph.edges = sortByField(from, to, graph.edges, field.name, references);
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if errorMessage}
|
||||
<div class="invalid-feedback d-block mb-3">
|
||||
{errorMessage}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="inline-card-wrapper">
|
||||
<ReferenceInlineButtons
|
||||
{field}
|
||||
recordId={null}
|
||||
schemas={collections}
|
||||
on:insert={insert}
|
||||
on:save={insert}
|
||||
/>
|
||||
</div>
|
||||
{#if references.length > 0}
|
||||
{#each references as reference, i (reference.id)}
|
||||
<div class="inline-card-wrapper" animate:flip="{{delay: 250, duration: 250, easing: quintOut}}">
|
||||
<PreviewCardInline
|
||||
isFirst={i === 0}
|
||||
isLast={i + 1 === references.length}
|
||||
bind:record={reference}
|
||||
toDelete={graph.edges.find(
|
||||
(edge) =>
|
||||
edge.field === field.name && edge.target === reference.id
|
||||
)._isTrashed}
|
||||
on:inlinesaved={handleInlinesaved}
|
||||
on:moveup={(e) => move(e, i, i - 1)}
|
||||
on:movedn={(e) => move(e, i, i + 1)}
|
||||
on:remove={removeReference}
|
||||
on:undoremove={undoRemoveReference}
|
||||
on:trash={trashReference}
|
||||
/>
|
||||
<ReferenceInlineButtons
|
||||
{field}
|
||||
recordId={reference.id}
|
||||
schemas={collections}
|
||||
on:insert={insert}
|
||||
on:save={insert}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
Reference in New Issue
Block a user