create record wip
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { friendlyDate } from "../../helpers";
|
||||
import Avatar from "../../common/Avatar.svelte";
|
||||
import { usernameById } from "../account/users";
|
||||
import Icon from "../common/Icon.svelte";
|
||||
import Icon from "../../common/Icon.svelte";
|
||||
import RevisionCell from "./revisions/RevisionCell.svelte";
|
||||
import { getContext } from "svelte";
|
||||
import RevisionEdgeRow from "./revisions/RevisionEdgeRow.svelte";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script>
|
||||
import {createEventDispatcher, getContext} from "svelte";
|
||||
import Icon from "../../common/Icon.svelte";
|
||||
import { createEventDispatcher, getContext } from "svelte";
|
||||
import Icon from "../../../common/Icon.svelte";
|
||||
import InlineEdit from "../InlineEdit.svelte";
|
||||
import Dialog from "../../dialog/Dialog.svelte";
|
||||
import DialogRecord from "../../dialog/DialogRecord.svelte";
|
||||
@@ -24,7 +24,7 @@
|
||||
e.preventDefault();
|
||||
console.log("Save inline");
|
||||
inLineCreateRecord = null;
|
||||
dialogRecord.close()
|
||||
dialogRecord.close();
|
||||
dispatch("save", {
|
||||
records: e.detail.records,
|
||||
after: recordId,
|
||||
@@ -48,7 +48,7 @@
|
||||
.get(channel.lucentUrl + "/records/newInline?schema=" + schemaUId)
|
||||
.then((response) => {
|
||||
inLineCreateRecord = response.data;
|
||||
dialogRecord.open()
|
||||
dialogRecord.open();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
@@ -57,60 +57,53 @@
|
||||
</script>
|
||||
|
||||
{#if schemas.length > 1}
|
||||
<div
|
||||
style="display: flex;align-items: center;gap:4px"
|
||||
>
|
||||
<div style="display: flex;align-items: center;gap:4px">
|
||||
<Dropdown>
|
||||
<div slot="button">New</div>
|
||||
{#each schemas as schema}
|
||||
<button
|
||||
class=" button"
|
||||
on:click={(e) =>
|
||||
createInlineReference(e, schema.name)}
|
||||
>{schema.label}
|
||||
class=" button"
|
||||
on:click={(e) => createInlineReference(e, schema.name)}
|
||||
>{schema.label}
|
||||
</button>
|
||||
{/each}
|
||||
|
||||
</Dropdown>
|
||||
<Dropdown>
|
||||
<div slot="button"> <Icon icon="magnifying-glass"/></div>
|
||||
<div slot="button"><Icon icon="magnifying-glass" /></div>
|
||||
{#each schemas as schema}
|
||||
<button
|
||||
class="button"
|
||||
on:click={(e) => openBrowseModal(e, schema.name)}
|
||||
>{schema.label}
|
||||
class="button"
|
||||
on:click={(e) => openBrowseModal(e, schema.name)}
|
||||
>{schema.label}
|
||||
</button>
|
||||
{/each}
|
||||
|
||||
</Dropdown>
|
||||
</div>
|
||||
{:else}
|
||||
<div style="display:flex;align-items: center;gap: 4px">
|
||||
<button
|
||||
class="button"
|
||||
on:click={(e) => createInlineReference(e, schemas[0].name)}
|
||||
>New
|
||||
class="button"
|
||||
on:click={(e) => createInlineReference(e, schemas[0].name)}
|
||||
>New
|
||||
</button>
|
||||
<button
|
||||
class="button"
|
||||
on:click={(e) => openBrowseModal(e, schemas[0].name)}
|
||||
>
|
||||
<Icon icon="magnifying-glass"/>
|
||||
</button
|
||||
class="button"
|
||||
on:click={(e) => openBrowseModal(e, schemas[0].name)}
|
||||
>
|
||||
<Icon icon="magnifying-glass" />
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<DialogRecord bind:this={dialogRecord}>
|
||||
{#if inLineCreateRecord}
|
||||
<InlineEdit
|
||||
{...inLineCreateRecord}
|
||||
isCreateMode={true}
|
||||
on:cancel={(e) => (inLineCreateRecord = null)}
|
||||
on:inlinesaved={save}
|
||||
{...inLineCreateRecord}
|
||||
isCreateMode={true}
|
||||
on:cancel={(e) => (inLineCreateRecord = null)}
|
||||
on:inlinesaved={save}
|
||||
/>
|
||||
|
||||
{/if}
|
||||
</DialogRecord>
|
||||
|
||||
<Dialog bind:this={browseModal} on:insert={insert}/>
|
||||
<Dialog bind:this={browseModal} on:insert={insert} />
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { previewTitle } from "../Preview";
|
||||
import { getErrorMessage } from "./errorMessage";
|
||||
import { insertEdges } from "./reference.js";
|
||||
import Icon from "../../common/Icon.svelte";
|
||||
import Icon from "../../../common/Icon.svelte";
|
||||
|
||||
const channel = getContext("channel");
|
||||
export let field;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script>
|
||||
import { getContext } from "svelte";
|
||||
import Icon from "../../common/Icon.svelte";
|
||||
import Icon from "../../../common/Icon.svelte";
|
||||
import { getErrorMessage } from "./errorMessage";
|
||||
const channelurl = getContext("channelurl");
|
||||
export let validationErrors;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script>
|
||||
import {getContext} from "svelte";
|
||||
import Icon from "../../common/Icon.svelte";
|
||||
import { getContext } from "svelte";
|
||||
import Icon from "../../../common/Icon.svelte";
|
||||
import Dropdown from "../../common/Dropdown.svelte";
|
||||
import StatusSelect from "./StatusSelect.svelte";
|
||||
|
||||
@@ -12,45 +12,44 @@
|
||||
|
||||
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 => {
|
||||
|
||||
});
|
||||
axios
|
||||
.post(channel.lucentUrl + "/records/clone/" + record.id)
|
||||
.then((response) => {
|
||||
window.location =
|
||||
channel.lucentUrl + "/records/" + response.data.id;
|
||||
})
|
||||
.catch((error) => {});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<div style="display: flex;align-items: center; gap:10px;">
|
||||
{#if !isCreateMode}
|
||||
<Dropdown >
|
||||
<Dropdown>
|
||||
<div slot="button">
|
||||
<Icon icon="ellipsis"/>
|
||||
<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
|
||||
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}
|
||||
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
|
||||
on:click|preventDefault={(e) => (activeContentTab = "_info")}
|
||||
class="dropdown-item"
|
||||
href={channel.lucentUrl}>Revisions</a
|
||||
>
|
||||
</Dropdown>
|
||||
{/if}
|
||||
|
||||
<StatusSelect bind:status={record.status} {record}></StatusSelect>
|
||||
</div>
|
||||
<StatusSelect bind:status={record.status} {record}></StatusSelect>
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script>
|
||||
import Icon from "../../common/Icon.svelte";
|
||||
import Icon from "../../../common/Icon.svelte";
|
||||
|
||||
import {createEventDispatcher, getContext} from "svelte";
|
||||
import { createEventDispatcher, getContext } from "svelte";
|
||||
import Preview from "../../files/Preview.svelte";
|
||||
import {previewTitle} from "./../Preview";
|
||||
import {fileurl, htmlurl} from "../../files/imageserver.js"
|
||||
import { previewTitle } from "./../Preview";
|
||||
import { fileurl, htmlurl } from "../../files/imageserver.js";
|
||||
import Status from "./../Status.svelte";
|
||||
import Dropdown from "../../common/Dropdown.svelte";
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
export let hasDelete = false;
|
||||
export let hasInsert = false;
|
||||
|
||||
let schema = channel.schemas.find((aschema) => aschema.name === record.schema);
|
||||
let schema = channel.schemas.find(
|
||||
(aschema) => aschema.name === record.schema,
|
||||
);
|
||||
let cardTitle = previewTitle(channel.schemas, record);
|
||||
let imagePresets = Object.keys(channel.imageFilters);
|
||||
|
||||
@@ -25,67 +27,69 @@
|
||||
|
||||
function insert(e, preset) {
|
||||
e.preventDefault();
|
||||
let html = htmlurl(channel, record, preset)
|
||||
let url = !preset ? `/${record._file.path}` : `/templates/${preset}/${record._file.path}`;
|
||||
let html = htmlurl(channel, record, preset);
|
||||
let url = !preset
|
||||
? `/${record._file.path}`
|
||||
: `/templates/${preset}/${record._file.path}`;
|
||||
dispatch("editor-insert", {
|
||||
html: html,
|
||||
url: channel.filesUrl + url,
|
||||
originalUrl: channel.filesUrl + "/" + record._file.path,
|
||||
record: record
|
||||
url: channel.filesUrl + url,
|
||||
originalUrl: channel.filesUrl + "/" + record._file.path,
|
||||
record: record,
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="preview-file">
|
||||
<div style="display: flex;align-items: center;gap: 10px;">
|
||||
<div class="image">
|
||||
<Preview {record} size="small"/>
|
||||
<Preview {record} size="small" />
|
||||
</div>
|
||||
<div class="title">
|
||||
<div>
|
||||
<a
|
||||
class="record-title"
|
||||
href="{channel.lucentUrl}/records/{record.id}"
|
||||
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}/>
|
||||
<Status status={record.status} />
|
||||
{/if}
|
||||
</small>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex;gap:4px; align-items: center; margin-right: 10px;">
|
||||
<div
|
||||
style="display: flex;gap:4px; align-items: center; margin-right: 10px;"
|
||||
>
|
||||
{#if hasInsert}
|
||||
<div class="reference-action">
|
||||
<Dropdown>
|
||||
<div slot="button">
|
||||
<Icon icon="photo-film"/>
|
||||
<Icon icon="photo-film" />
|
||||
</div>
|
||||
<button class="dropdown-item button" on:click={e => insert(e,null)}>original</button>
|
||||
<button
|
||||
class="dropdown-item button"
|
||||
on:click={(e) => insert(e, null)}>original</button
|
||||
>
|
||||
{#each imagePresets as preset}
|
||||
<button class="dropdown-item button" on:click={e => insert(e,preset)}>{preset}</button>
|
||||
<button
|
||||
class="dropdown-item button"
|
||||
on:click={(e) => insert(e, preset)}>{preset}</button
|
||||
>
|
||||
{/each}
|
||||
</Dropdown>
|
||||
|
||||
</div>
|
||||
{/if}
|
||||
{#if hasDelete}
|
||||
<div class="reference-action">
|
||||
<button
|
||||
class="button"
|
||||
on:click={remove}
|
||||
>
|
||||
<Icon icon="trash-can"/>
|
||||
<button class="button" on:click={remove}>
|
||||
<Icon icon="trash-can" />
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script>
|
||||
import Icon from "../../common/Icon.svelte";
|
||||
import Icon from "../../../common/Icon.svelte";
|
||||
|
||||
import {createEventDispatcher, getContext} from "svelte";
|
||||
import {previewTitle} from "./../Preview";
|
||||
import { createEventDispatcher, getContext } from "svelte";
|
||||
import { previewTitle } from "./../Preview";
|
||||
import Status from "./../Status.svelte";
|
||||
import Preview from "../../files/Preview.svelte";
|
||||
|
||||
@@ -12,10 +12,16 @@
|
||||
export let record;
|
||||
export let hasDelete = false;
|
||||
|
||||
let schema = channel.schemas.find((aschema) => aschema.name === record.schema);
|
||||
let schema = channel.schemas.find(
|
||||
(aschema) => aschema.name === record.schema,
|
||||
);
|
||||
let cardTitle = previewTitle(channel.schemas, record, graph);
|
||||
const cardImageEdge = graph.edges.find(e => e.source === record.id && e.field === schema.cardImage);
|
||||
let cardImageRecord = graph.records.find(r => r.id === cardImageEdge?.target);
|
||||
const cardImageEdge = graph.edges.find(
|
||||
(e) => e.source === record.id && e.field === schema.cardImage,
|
||||
);
|
||||
let cardImageRecord = graph.records.find(
|
||||
(r) => r.id === cardImageEdge?.target,
|
||||
);
|
||||
|
||||
function remove(e) {
|
||||
e.preventDefault();
|
||||
@@ -23,43 +29,35 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<div class="preview-reference">
|
||||
<div style="display: flex;align-items: center;gap: 10px;">
|
||||
|
||||
{#if cardImageRecord}
|
||||
<div class="image">
|
||||
<Preview record={cardImageRecord} size="small"/>
|
||||
<Preview record={cardImageRecord} size="small" />
|
||||
</div>
|
||||
{/if}
|
||||
<div class="title">
|
||||
<div>
|
||||
<a
|
||||
class="record-title"
|
||||
href="{channel.lucentUrl}/records/{record.id}"
|
||||
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}/>
|
||||
<Status status={record.status} />
|
||||
{/if}
|
||||
</small>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{#if hasDelete}
|
||||
<div class="reference-action">
|
||||
<button
|
||||
class="button"
|
||||
on:click={remove}
|
||||
>
|
||||
<Icon icon="trash-can"/>
|
||||
<button class="button" on:click={remove}>
|
||||
<Icon icon="trash-can" />
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user