lots
This commit is contained in:
@@ -4,12 +4,14 @@
|
||||
export let record;
|
||||
export let schema;
|
||||
export let isCreateMode;
|
||||
export let active = "_default";
|
||||
export let active = "";
|
||||
|
||||
let tabs = schema.fields.filter((f) => f.ui === "tab");
|
||||
let tabs = schema.groups?.map((group) => {
|
||||
return {label: group, name: group}
|
||||
}) ?? [];
|
||||
let mainTab = {
|
||||
label: "Main",
|
||||
name: "_default",
|
||||
name: "",
|
||||
};
|
||||
let graphTab = {
|
||||
label: "Graph",
|
||||
@@ -41,10 +43,10 @@
|
||||
{#each tabs as tab}
|
||||
<li class="nav-item">
|
||||
<button
|
||||
on:click={(e) => changeTab(e, tab.name)}
|
||||
class="nav-link"
|
||||
class:active={active === tab.name}
|
||||
aria-current="page"
|
||||
on:click={(e) => changeTab(e, tab.name)}
|
||||
class="nav-link"
|
||||
class:active={active === tab.name}
|
||||
aria-current="page"
|
||||
>
|
||||
{tab.label}
|
||||
</button>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
export let isCreateMode;
|
||||
export let users;
|
||||
let originalContent;
|
||||
let activeContentTab = "_default";
|
||||
let activeContentTab = "";
|
||||
let recordGraph = null;
|
||||
$: hasUnsavedData = false;
|
||||
$: validationErrors = null;
|
||||
@@ -38,16 +38,6 @@
|
||||
(f) => f.name !== "id"
|
||||
);
|
||||
|
||||
let tabname = "_default";
|
||||
let fieldToTabs = schema.fields.reduce((c, f) => {
|
||||
if (f.ui === "tab") {
|
||||
tabname = f.name;
|
||||
return c;
|
||||
}
|
||||
|
||||
c[tabname] = [...(c[tabname] ?? []), f.name];
|
||||
return c;
|
||||
}, []);
|
||||
|
||||
onMount(() => {
|
||||
setOriginalContent();
|
||||
@@ -56,6 +46,8 @@
|
||||
function setOriginalContent() {
|
||||
originalContent = {
|
||||
data: JSON.parse(JSON.stringify(record.data)),
|
||||
schema: record.schema,
|
||||
status: record.status,
|
||||
_sys: JSON.parse(JSON.stringify(record._sys)),
|
||||
_file: JSON.parse(JSON.stringify(record._file)),
|
||||
edges: JSON.parse(JSON.stringify(graph.edges)),
|
||||
@@ -88,6 +80,8 @@
|
||||
}
|
||||
return !isEqual(originalContent, {
|
||||
data: record.data,
|
||||
schema: record.schema,
|
||||
status: record.status,
|
||||
_sys: record._sys,
|
||||
_file: record._file,
|
||||
edges: graph.edges,
|
||||
@@ -165,34 +159,34 @@
|
||||
|
||||
{#if !["_graph", "_info"].includes(activeContentTab)}
|
||||
<div
|
||||
style="position:fixed;bottom:0;left:0px;width:100%;background:rgba(255,255,255,.7);z-index:10"
|
||||
style="position:fixed;bottom:0;left:0px;width:100%;background:rgba(255,255,255,.7);z-index:10"
|
||||
>
|
||||
<div
|
||||
class="d-flex mt-4 mb-3 align-items-center justify-content-center"
|
||||
class="d-flex mt-4 mb-3 align-items-center justify-content-center"
|
||||
>
|
||||
<StatusSelect bind:status={record._sys.status} {schema}/>
|
||||
<StatusSelect bind:status={record.status} {schema}/>
|
||||
{#if isCreateMode}
|
||||
<button
|
||||
class="ms-2 btn btn-primary btn-spinner"
|
||||
on:click={save}
|
||||
class="ms-2 btn btn-primary btn-spinner"
|
||||
on:click={save}
|
||||
>
|
||||
<span
|
||||
class="spinner-border spinner-border-sm"
|
||||
role="status"
|
||||
aria-hidden="true"
|
||||
class="spinner-border spinner-border-sm"
|
||||
role="status"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
Create
|
||||
</button>
|
||||
{:else if hasUnsavedData}
|
||||
<button
|
||||
type="button"
|
||||
class="ms-2 btn btn-primary btn-spinner"
|
||||
on:click={save}
|
||||
type="button"
|
||||
class="ms-2 btn btn-primary btn-spinner"
|
||||
on:click={save}
|
||||
>
|
||||
<span
|
||||
class="spinner-border spinner-border-sm"
|
||||
role="status"
|
||||
aria-hidden="true"
|
||||
class="spinner-border spinner-border-sm"
|
||||
role="status"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
Save
|
||||
</button>
|
||||
@@ -205,25 +199,25 @@
|
||||
|
||||
<div class=" mt-4" style="margin-bottom:150px">
|
||||
<ContentTabs
|
||||
{schema}
|
||||
{isCreateMode}
|
||||
bind:active={activeContentTab}
|
||||
{record}
|
||||
bind:recordGraph
|
||||
{schema}
|
||||
{isCreateMode}
|
||||
bind:active={activeContentTab}
|
||||
{record}
|
||||
bind:recordGraph
|
||||
/>
|
||||
{#if !["_graph", "_info"].includes(activeContentTab)}
|
||||
<FilePreview {record} {schema}/>
|
||||
<!-- <fieldset disabled="disabled"> -->
|
||||
{#each activeFields as field (field.name)}
|
||||
{#if fieldToTabs[activeContentTab].includes(field.name)}
|
||||
{#if activeContentTab === field.group}
|
||||
<FormField
|
||||
bind:data={record.data}
|
||||
bind:graph={graph}
|
||||
{field}
|
||||
{schema}
|
||||
{record}
|
||||
{validationErrors}
|
||||
{isCreateMode}
|
||||
bind:data={record.data}
|
||||
bind:graph={graph}
|
||||
{field}
|
||||
{schema}
|
||||
{record}
|
||||
{validationErrors}
|
||||
{isCreateMode}
|
||||
/>
|
||||
{/if}
|
||||
{/each}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
if (!carry[schemaField]) {
|
||||
carry[schemaField] = {
|
||||
field: channel.schemas
|
||||
.find((s) => s.name === record._sys.schema)
|
||||
.find((s) => s.name === record.schema)
|
||||
.fields.find((f) => f.name === edge.field),
|
||||
nodes: [],
|
||||
};
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
selectedRevision?._sys.version}
|
||||
>
|
||||
<div class="col-2">
|
||||
<Status status={revision._sys.status}/>
|
||||
<Status status={revision.status}/>
|
||||
</div>
|
||||
<div class="col-2">version {revision._sys.version}</div>
|
||||
<div class="col-5">
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
function setOriginalContent() {
|
||||
originalContent = {
|
||||
data: JSON.parse(JSON.stringify(record.data)),
|
||||
schema: record.schema,
|
||||
status: record.status,
|
||||
_sys: JSON.parse(JSON.stringify(record._sys)),
|
||||
_file: JSON.parse(JSON.stringify(record._file)),
|
||||
edges: JSON.parse(JSON.stringify(graph.edges)),
|
||||
@@ -81,6 +83,8 @@
|
||||
}
|
||||
return !isEqual(originalContent, {
|
||||
data: record.data,
|
||||
schema: record.schema,
|
||||
status: record.status,
|
||||
_sys: record._sys,
|
||||
_file: record._file,
|
||||
edges: graph.edges,
|
||||
@@ -181,7 +185,7 @@
|
||||
<div>
|
||||
<div class="d-flex mt-3 align-items-center justify-content-center">
|
||||
{#if schema.hasDrafts}
|
||||
<StatusSelect bind:status={record._sys.status} {schema}/>
|
||||
<StatusSelect bind:status={record.status} {schema}/>
|
||||
{/if}
|
||||
{#if isCreateMode}
|
||||
<button
|
||||
|
||||
@@ -2,7 +2,7 @@ import Mustache from "mustache";
|
||||
import {stripHtml} from "../../helpers";
|
||||
|
||||
export function previewTitle(schemas, record, graph) {
|
||||
let schema = schemas.find((aschema) => aschema.name === record?._sys.schema);
|
||||
let schema = schemas.find((aschema) => aschema.name === record?.schema);
|
||||
|
||||
if (!schema?.titleTemplate) {
|
||||
return noTemplate(schema, record);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
export let classes = "";
|
||||
export let hasDelete = false;
|
||||
|
||||
let schema = channel.schemas.find((aschema) => aschema.name === record._sys.schema);
|
||||
let schema = channel.schemas.find((aschema) => aschema.name === record.schema);
|
||||
let cardTitle = previewTitle(channel.schemas, record, graph);
|
||||
function remove(e) {
|
||||
e.preventDefault();
|
||||
@@ -44,8 +44,8 @@
|
||||
{schema.label}
|
||||
</small>
|
||||
<small class="text-muted">
|
||||
{#if record._sys.status === "draft"}
|
||||
<Status status={record._sys.status} />
|
||||
{#if record.status === "draft"}
|
||||
<Status status={record.status} />
|
||||
{/if}
|
||||
</small>
|
||||
</div>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
export let schemas;
|
||||
export let record;
|
||||
let editRecord;
|
||||
let schema = schemas.find((aschema) => aschema.name === record._sys.schema);
|
||||
let schema = schemas.find((aschema) => aschema.name === record.schema);
|
||||
$: editMode = false;
|
||||
$: expanded = false;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
const channel = getContext("channel");
|
||||
export let record;
|
||||
export let graph;
|
||||
$: schema = channel.schemas.find((aschema) => aschema.name === record._sys.schema);
|
||||
$: schema = channel.schemas.find((aschema) => aschema.name === record.schema);
|
||||
|
||||
$: title = previewTitle(channel.schemas, record, graph);
|
||||
</script>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import Status from "./Status.svelte";
|
||||
import {getStatus, getStatusList} from "./StatusText";
|
||||
|
||||
export let status;
|
||||
export let status = "draft";
|
||||
export let schema;
|
||||
let dropdown;
|
||||
$: currentStatus = getStatus(status);
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
const action = e.detail.action;
|
||||
let newEdges = recordsToInsert.map((r) => {
|
||||
return {
|
||||
schema: r._sys.schema,
|
||||
schema: r.schema,
|
||||
target: r.data.id,
|
||||
source: record.data.id,
|
||||
field: field.name,
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
}
|
||||
|
||||
async function reorder(e) {
|
||||
graph.edges = await sortByField(e.detail.from, e.detail.to, graph.edges, field.name);
|
||||
console.log(e.detail)
|
||||
graph.edges = await sortByField(e.detail.source, e.detail.target, graph.edges, field.name);
|
||||
}
|
||||
|
||||
function insert(e) {
|
||||
@@ -48,8 +49,8 @@
|
||||
return {
|
||||
target: r.id,
|
||||
source: record.id,
|
||||
sourceSchema: record._sys.schema,
|
||||
targetSchema: r._sys.schema,
|
||||
sourceSchema: record.schema,
|
||||
targetSchema: r.schema,
|
||||
field: field.name,
|
||||
rank: ""
|
||||
};
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
return {
|
||||
target: r.id,
|
||||
source: record.id,
|
||||
sourceSchema: record._sys.schema,
|
||||
targetSchema: r._sys.schema,
|
||||
sourceSchema: record.schema,
|
||||
targetSchema: r.schema,
|
||||
field: field.name,
|
||||
rank: ""
|
||||
};
|
||||
|
||||
@@ -74,8 +74,8 @@
|
||||
return {
|
||||
target: r.id,
|
||||
source: record.id,
|
||||
sourceSchema: record._sys.schema,
|
||||
targetSchema: r._sys.schema,
|
||||
sourceSchema: record.schema,
|
||||
targetSchema: r.schema,
|
||||
field: field.name,
|
||||
rank: ""
|
||||
};
|
||||
|
||||
@@ -54,8 +54,8 @@
|
||||
return {
|
||||
target: r.id,
|
||||
source: record.id,
|
||||
sourceSchema: record._sys.schema,
|
||||
targetSchema: r._sys.schema,
|
||||
sourceSchema: record.schema,
|
||||
targetSchema: r.schema,
|
||||
field: field.name,
|
||||
rank: ""
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user