lots
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
<script>
|
||||
import ErrorAlert from "../common/ErrorAlert.svelte";
|
||||
import SpinnerButton from "../common/SpinnerButton.svelte";
|
||||
import {getContext} from "svelte";
|
||||
|
||||
import Nav from "./Nav.svelte";
|
||||
|
||||
const channel = getContext("channel");
|
||||
let name = "";
|
||||
export let userCount = 1;
|
||||
export let email = "";
|
||||
export let token = "";
|
||||
let password = "";
|
||||
let errorMessage = "";
|
||||
|
||||
function register(e) {
|
||||
@@ -16,15 +13,12 @@
|
||||
errorMessage = "";
|
||||
|
||||
axios
|
||||
.post("/register", {
|
||||
.post(channel.lucentUrl + "/register", {
|
||||
name: name,
|
||||
password: password,
|
||||
email: email,
|
||||
token: token,
|
||||
isAdmin: userCount === 0,
|
||||
})
|
||||
.then(() => {
|
||||
window.location = "/login";
|
||||
window.location = channel.lucentUrl + "/login";
|
||||
})
|
||||
.catch((error) => {
|
||||
errorMessage = error.response?.data.error;
|
||||
@@ -33,60 +27,33 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Nav active="Register"/>
|
||||
<div class="wrapper-tiny">
|
||||
{#if token || userCount === 0}
|
||||
<ErrorAlert message={errorMessage}/>
|
||||
<ErrorAlert message={errorMessage}/>
|
||||
|
||||
<form on:submit={register}>
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Name</label>
|
||||
<input
|
||||
<form on:submit={register}>
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Name</label>
|
||||
<input
|
||||
type="text"
|
||||
bind:value={name}
|
||||
class="form-control"
|
||||
id="name"
|
||||
/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email address</label>
|
||||
<input
|
||||
/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email address</label>
|
||||
<input
|
||||
type="email"
|
||||
bind:value={email}
|
||||
class="form-control"
|
||||
id="email"
|
||||
disabled={userCount !== 0}
|
||||
/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input
|
||||
type="password"
|
||||
bind:value={password}
|
||||
class="form-control"
|
||||
id="password"
|
||||
/>
|
||||
</div>
|
||||
<div class="mb-3 form-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="form-check-input"
|
||||
id="terms"
|
||||
required
|
||||
/>
|
||||
<label class="form-check-label" for="terms"
|
||||
>I Agree to the <a
|
||||
href="https://www.radical-elements.com/terms-of-service"
|
||||
target="_blank">terms and conditions</a
|
||||
></label
|
||||
>
|
||||
</div>
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-center mt-5 d-block">
|
||||
<SpinnerButton label="Register"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="text-center mt-5 d-block">
|
||||
<SpinnerButton label="Register"/>
|
||||
</div>
|
||||
</form>
|
||||
{:else}
|
||||
<p class="text-center mb-0">Registrations are currently closed</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
class="btn btn-sm btn-outline-primary">Make Draft
|
||||
</button
|
||||
>
|
||||
{#if filter["_sys.status_in"] === "trashed"}
|
||||
{#if filter["status_in"] === "trashed"}
|
||||
<button
|
||||
on:click|preventDefault={(e) => changeStatus(e, "published")}
|
||||
type="button"
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
<RenderField {record} {schema} {graph} {field}/>
|
||||
</td>
|
||||
{/each}
|
||||
{#if schema.visible.includes("_sys.status")}
|
||||
{#if schema.visible.includes("status")}
|
||||
<td
|
||||
class="text-center"
|
||||
class:is-sort={"-_sys.status" == sort || "_sys.status" == sort}
|
||||
class:is-sort={"-status" == sort || "status" == sort}
|
||||
>
|
||||
<Status status={record._sys.status}/>
|
||||
<Status status={record.status}/>
|
||||
</td>
|
||||
{/if}
|
||||
{#if schema.visible.includes("_sys.createdBy")}
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<li>
|
||||
<a
|
||||
class="dropdown-item"
|
||||
href="{channel.lucentUrl}/content/{schema.name}?filter[_sys.status_in]=trashed"
|
||||
href="{channel.lucentUrl}/content/{schema.name}?filter[status_in]=trashed"
|
||||
>View trashed records</a
|
||||
>
|
||||
</li>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export function sortByField(from, to, edges, fieldName) {
|
||||
|
||||
console.log(from)
|
||||
console.log(to)
|
||||
if (from === to) {
|
||||
return edges;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script>
|
||||
import Icon from "../common/Icon.svelte";
|
||||
import { imgurl } from "../files/imageserver";
|
||||
import { getContext } from "svelte";
|
||||
import {imgurl} from "../files/imageserver";
|
||||
import {getContext} from "svelte";
|
||||
|
||||
export let record;
|
||||
const channel = getContext("channel");
|
||||
export let size = "small";
|
||||
@@ -32,37 +33,36 @@
|
||||
{#if record._file.mime.startsWith("image")}
|
||||
<!-- href={imgurl(record)} -->
|
||||
<a
|
||||
href="{channel.lucentUrl}/records/{record.id}"
|
||||
title={record._file.path}
|
||||
class="d-flex align-items-center justify-content-center "
|
||||
style="width:{imageSide}px;height:{imageSide}px"
|
||||
href="{channel.lucentUrl}/records/{record.id}"
|
||||
title={record._file.path}
|
||||
class="d-flex align-items-center justify-content-center "
|
||||
style="width:{imageSide}px;height:{imageSide}px"
|
||||
>
|
||||
<img
|
||||
class="rounded w-100"
|
||||
src={imgurl(record, imageSide, imageSide, "crop")}
|
||||
alt={record._file.path}
|
||||
class="rounded w-100"
|
||||
src={imgurl(record, imageSide, imageSide, "crop")}
|
||||
alt={record._file.path}
|
||||
/>
|
||||
</a>
|
||||
{:else}
|
||||
<!-- href="{channelurl}/files/download?schema={record._sys.schema}&path={record._file.path}" -->
|
||||
<a
|
||||
href="{channel.lucentUrl}/records/{record.id}"
|
||||
title={record._file.path}
|
||||
class="btn btn-outline-primary btn-sm d-flex align-items-center justify-content-center"
|
||||
style="width:{imageSide}px;height:{imageSide}px"
|
||||
href="{channel.lucentUrl}/records/{record.id}"
|
||||
title={record._file.path}
|
||||
class="btn btn-outline-primary btn-sm d-flex align-items-center justify-content-center"
|
||||
style="width:{imageSide}px;height:{imageSide}px"
|
||||
>
|
||||
<Icon icon="file" width={fileSide} height={fileSide} />
|
||||
<Icon icon="file" width={fileSide} height={fileSide}/>
|
||||
<span class="ms-2" style="font-size:{fontSize}px"
|
||||
>.{record._file.path.split(".").pop()}</span
|
||||
>.{record._file.path.split(".").pop()}</span
|
||||
>
|
||||
</a>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if showFilename}
|
||||
<a
|
||||
href="{channel.lucentUrl}/records/{record.id}"
|
||||
title={record._file.path}
|
||||
class="preview-file-filename lx-small-text text-decoration-none"
|
||||
>{record._file.path}</a
|
||||
href="{channel.lucentUrl}/records/{record.id}"
|
||||
title={record._file.path}
|
||||
class="preview-file-filename lx-small-text text-decoration-none"
|
||||
>{record._file.path}</a
|
||||
>
|
||||
{/if}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
export let users;
|
||||
export let graph;
|
||||
export let record;
|
||||
let schema = channel.schemas.find((s) => s.name === record._sys.schema);
|
||||
let schema = channel.schemas.find((s) => s.name === record.schema);
|
||||
let frieldlyUpdatedAt = formatDistanceToNow(
|
||||
parseJSON(record._sys.updatedAt),
|
||||
{addSuffix: true}
|
||||
@@ -38,7 +38,7 @@
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
<Status status={record._sys.status}/>
|
||||
<Status status={record.status}/>
|
||||
</td>
|
||||
<td>
|
||||
<div class="d-flex">
|
||||
|
||||
@@ -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