content and edit record

This commit is contained in:
2024-08-15 18:52:53 +03:00
parent f9806f60c9
commit 113533408d
38 changed files with 577 additions and 289 deletions
@@ -0,0 +1,54 @@
<script>
export let schema;
export let isCreateMode;
export let active = "";
let tabs = schema.groups?.map((group) => {
return {label: group, name: group}
}) ?? [];
let mainTab = {
label: "Main",
name: "",
};
let graphTab = {
label: "Graph",
name: "_graph",
};
if (isCreateMode) {
tabs = [mainTab, ...tabs];
} else {
tabs = [mainTab, ...tabs, graphTab];
}
function showGraph(e) {
e.preventDefault();
active = "_graph";
}
function changeTab(e, tabName) {
e.preventDefault();
if (tabName == "_graph") {
showGraph(e);
} else {
active = tabName;
}
}
</script>
{#if tabs.length > 1}
<ul class="tabs">
{#each tabs as tab}
<li class="tab">
<button
on:click={(e) => changeTab(e, tab.name)}
class="button"
class:active={active === tab.name}
aria-current="page"
>
{tab.label}
</button>
</li>
{/each}
</ul>
{/if}
@@ -0,0 +1,54 @@
<script>
import {getContext} from "svelte";
import Icon from "../../common/Icon.svelte";
import Dropdown from "../../common/Dropdown.svelte";
import StatusSelect from "./StatusSelect.svelte";
const channel = getContext("channel");
export let schema;
export let record;
export let isCreateMode;
export let activeContentTab;
function clone(e) {
e.preventDefault();
axios.post(channel.lucentUrl + "/records/clone/" + record.id).then(response => {
window.location = channel.lucentUrl + "/records/" + response.data.id;
}).catch(error => {
});
}
</script>
<StatusSelect bind:status={record.status} {record}></StatusSelect>
{#if !isCreateMode}
<Dropdown orientation="right">
<div slot="button">
<Icon icon="ellipsis"/>
</div>
<h6 class="dropdown-header">Record Actions</h6>
<a
class="dropdown-item"
href="{channel.lucentUrl}/records/new?schema={schema.name}"
>Create new</a
>
{#if !isCreateMode}
<a
class="dropdown-item"
on:click={clone}
href={channel.lucentUrl}
>
Clone
</a>
{/if}
<a
on:click|preventDefault={(e) =>
(activeContentTab = "_info")}
class="dropdown-item"
href="{channel.lucentUrl}">Revisions</a
>
</Dropdown>
{/if}
@@ -0,0 +1,26 @@
<script>
import Switch from "../../common/Switch.svelte";
export let status = "draft";
export let record;
function updateStatus(e) {
if(e.target.checked){
status = "published";
}else{
status = "draft";
}
}
</script>
{#if record.status !== "trashed"}
<Switch value="published" on:change={updateStatus} checked={record.status === "published"}></Switch>
{/if}
{#if record.status === "published"}
Published
{:else if record.status === "draft"}
Draft
{:else if record.status === "trashed"}
Trashed
{/if}
@@ -0,0 +1,27 @@
<script>
import {getContext} from "svelte";
import {previewTitle} from "./../Preview";
const channel = getContext("channel");
export let schema;
export let record;
export let isCreateMode;
</script>
<div class="record-header">
<span class="record-title">
{#if !isCreateMode}
{previewTitle(channel.schemas, record)}
{:else}
New Record
{/if}
</span>
<a
class="schema-name"
href="{channel.lucentUrl}/content/{schema.name}"
>{schema.label.toUpperCase()}</a
>
</div>