import and export

This commit is contained in:
2026-05-07 17:42:46 +03:00
parent 8cf1dd9bfd
commit 639ee895cd
10 changed files with 343 additions and 86 deletions
@@ -1,5 +1,6 @@
<script>
import {getContext} from "svelte";
import { getContext } from "svelte";
import { apiPost } from "../../helpers";
const channel = getContext("channel");
export let selected;
@@ -8,10 +9,9 @@
function deleteRecords(e) {
e.preventDefault();
axios
.post(channel.lucentUrl + "/records/delete", {
ids: selected.map((s) => s.id),
})
apiPost(channel.lucentUrl + "/records/delete", {
ids: selected.map((s) => s.id),
})
.then((response) => {
window.location.reload();
})
@@ -21,11 +21,10 @@
}
function changeStatus(e, status) {
axios
.post(channel.lucentUrl + "/records/status/" + status, {
schemaName: schema.name,
records: selected
})
apiPost(channel.lucentUrl + "/records/status/" + status, {
schemaName: schema.name,
records: selected,
})
.then((response) => {
window.location.reload();
})
@@ -38,44 +37,44 @@
<div style="display: flex;align-items: center; gap: 8px">
<span class="me-2">{selected.length} records selected</span>
<button
on:click|preventDefault={(e) => changeStatus(e, "published")}
type="button"
class="button">Publish
</button
>
on:click|preventDefault={(e) => changeStatus(e, "published")}
type="button"
class="button"
>Publish
</button>
<button
on:click|preventDefault={(e) => changeStatus(e, "draft")}
type="button"
class="button">Make Draft
</button
>
on:click|preventDefault={(e) => changeStatus(e, "draft")}
type="button"
class="button"
>Make Draft
</button>
{#if filter["status_in"] === "trashed"}
<button
on:click|preventDefault={(e) => changeStatus(e, "published")}
type="button"
class="button">Publish
</button
>
on:click|preventDefault={(e) => changeStatus(e, "published")}
type="button"
class="button"
>Publish
</button>
{#if schema.hasDrafts}
<button
on:click|preventDefault={(e) => changeStatus(e, "draft")}
type="button"
class="button">Make Draft
</button
>
on:click|preventDefault={(e) => changeStatus(e, "draft")}
type="button"
class="button"
>Make Draft
</button>
{/if}
<button
on:click|preventDefault={deleteRecords}
type="button"
class="button">Delete forever
</button
>
on:click|preventDefault={deleteRecords}
type="button"
class="button"
>Delete forever
</button>
{:else}
<button
type="button"
on:click|preventDefault={(e) => changeStatus(e, "trashed")}
class="button">Move to trash
</button
>
type="button"
on:click|preventDefault={(e) => changeStatus(e, "trashed")}
class="button"
>Move to trash
</button>
{/if}
</div>
@@ -1,8 +1,9 @@
<script>
import {getContext} from "svelte";
import { getContext } from "svelte";
import Icon from "../../common/Icon.svelte";
import Dropdown from "../../common/Dropdown.svelte";
import StatusSelect from "./StatusSelect.svelte";
import { apiPost } from "../../../helpers";
const channel = getContext("channel");
export let schema;
@@ -12,45 +13,42 @@
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 => {
});
apiPost(channel.lucentUrl + "/records/clone/" + record.id)
.then((response) => {
window.location = channel.lucentUrl + "/records/" + response.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>