2023-10-02 23:10:49 +03:00
|
|
|
<script>
|
|
|
|
|
import {getContext} from "svelte";
|
2024-10-05 15:19:53 +03:00
|
|
|
import axios from "axios";
|
2023-10-02 23:10:49 +03:00
|
|
|
|
|
|
|
|
const channel = getContext("channel");
|
|
|
|
|
export let selected;
|
|
|
|
|
export let schema;
|
|
|
|
|
export let filter;
|
|
|
|
|
|
|
|
|
|
function deleteRecords(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
axios
|
|
|
|
|
.post(channel.lucentUrl + "/records/delete", {
|
|
|
|
|
ids: selected.map((s) => s.id),
|
|
|
|
|
})
|
|
|
|
|
.then((response) => {
|
|
|
|
|
window.location.reload();
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2024-10-10 17:40:29 +03:00
|
|
|
console.error(error);
|
2023-10-02 23:10:49 +03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function changeStatus(e, status) {
|
|
|
|
|
axios
|
|
|
|
|
.post(channel.lucentUrl + "/records/status/" + status, {
|
|
|
|
|
schemaName: schema.name,
|
2024-10-05 15:19:53 +03:00
|
|
|
records: selected.map((s) => s.id),
|
2023-10-02 23:10:49 +03:00
|
|
|
})
|
|
|
|
|
.then((response) => {
|
|
|
|
|
window.location.reload();
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2024-10-10 17:40:29 +03:00
|
|
|
console.error(error);
|
2023-10-02 23:10:49 +03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2024-08-15 18:52:53 +03:00
|
|
|
<div style="display: flex;align-items: center; gap: 8px">
|
2023-10-02 23:10:49 +03:00
|
|
|
<span class="me-2">{selected.length} records selected</span>
|
2024-08-15 22:11:26 +03:00
|
|
|
<button
|
2023-10-02 23:10:49 +03:00
|
|
|
on:click|preventDefault={(e) => changeStatus(e, "published")}
|
|
|
|
|
type="button"
|
2024-08-15 18:52:53 +03:00
|
|
|
class="button">Publish
|
2024-08-15 22:11:26 +03:00
|
|
|
</button
|
|
|
|
|
>
|
|
|
|
|
<button
|
2023-10-02 23:10:49 +03:00
|
|
|
on:click|preventDefault={(e) => changeStatus(e, "draft")}
|
|
|
|
|
type="button"
|
2024-08-15 18:52:53 +03:00
|
|
|
class="button">Make Draft
|
2024-08-15 22:11:26 +03:00
|
|
|
</button
|
|
|
|
|
>
|
|
|
|
|
{#if filter["status_in"] === "trashed"}
|
|
|
|
|
<button
|
2023-10-02 23:10:49 +03:00
|
|
|
on:click|preventDefault={deleteRecords}
|
|
|
|
|
type="button"
|
2024-08-15 18:52:53 +03:00
|
|
|
class="button">Delete forever
|
2024-08-15 22:11:26 +03:00
|
|
|
</button
|
|
|
|
|
>
|
|
|
|
|
{:else}
|
|
|
|
|
<button
|
2023-10-02 23:10:49 +03:00
|
|
|
type="button"
|
|
|
|
|
on:click|preventDefault={(e) => changeStatus(e, "trashed")}
|
2024-08-15 18:52:53 +03:00
|
|
|
class="button">Move to trash
|
2024-08-15 22:11:26 +03:00
|
|
|
</button
|
|
|
|
|
>
|
|
|
|
|
{/if}
|
2023-10-02 23:10:49 +03:00
|
|
|
</div>
|