2026-01-08 15:19:08 +02:00
|
|
|
<script>
|
2026-01-08 18:50:32 +02:00
|
|
|
import SchemaLayout from "../../layouts/SchemaLayout.svelte";
|
2026-01-08 15:19:08 +02:00
|
|
|
import Sortable from "../../common/Sortable.svelte";
|
2026-01-08 18:13:17 +02:00
|
|
|
import DeleteButton from "../../common/DeleteButton.svelte";
|
2026-01-08 15:19:08 +02:00
|
|
|
import { post } from "../../modules/remote";
|
|
|
|
|
import { getApp } from "../../app";
|
|
|
|
|
let { channel, user, data } = $props();
|
|
|
|
|
const app = getApp();
|
|
|
|
|
|
|
|
|
|
function handleSchemaCreate(e) {
|
|
|
|
|
e.preventDefault();
|
2026-01-08 18:13:17 +02:00
|
|
|
post(
|
|
|
|
|
channel.lucentUrl + "/schemas/update",
|
|
|
|
|
{
|
|
|
|
|
id: data.schema.id,
|
|
|
|
|
name: data.schema.name,
|
|
|
|
|
alias: data.schema.alias,
|
|
|
|
|
revisions: data.schema.revisions,
|
|
|
|
|
},
|
|
|
|
|
(data, err) => {
|
|
|
|
|
if (err.isEmpty()) {
|
|
|
|
|
Turbo.visit(channel.lucentUrl + "/schemas");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleDelete() {
|
|
|
|
|
post(
|
|
|
|
|
app.url("schemas/delete"),
|
|
|
|
|
{
|
|
|
|
|
schemaId: data.schema.id,
|
|
|
|
|
},
|
|
|
|
|
(data, err) => {
|
|
|
|
|
if (err.isEmpty()) {
|
|
|
|
|
Turbo.visit(app.url("schemas"));
|
|
|
|
|
} else {
|
|
|
|
|
console.log(err);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
2026-01-08 15:19:08 +02:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2026-01-08 18:50:32 +02:00
|
|
|
<SchemaLayout {body} {channel} {user}></SchemaLayout>
|
2026-01-08 15:19:08 +02:00
|
|
|
{#snippet body()}
|
|
|
|
|
<h3>Edit Schema</h3>
|
|
|
|
|
|
|
|
|
|
<form onsubmit={handleSchemaCreate}>
|
|
|
|
|
<fieldset>
|
|
|
|
|
<label>
|
|
|
|
|
Name
|
|
|
|
|
<input
|
|
|
|
|
bind:value={data.schema.name}
|
|
|
|
|
placeholder="ex. Blog Posts"
|
|
|
|
|
minlength="2"
|
|
|
|
|
maxlength="30"
|
|
|
|
|
required
|
|
|
|
|
/>
|
|
|
|
|
<small id="alias-helper">Plural is recommended</small>
|
|
|
|
|
</label>
|
|
|
|
|
<label>
|
|
|
|
|
Alias
|
|
|
|
|
<input
|
|
|
|
|
bind:value={data.schema.alias}
|
|
|
|
|
placeholder="ex. blog_posts"
|
|
|
|
|
minlength="2"
|
|
|
|
|
maxlength="30"
|
|
|
|
|
required
|
|
|
|
|
aria-describedby="alias-helper"
|
|
|
|
|
/>
|
|
|
|
|
<small id="alias-helper">
|
|
|
|
|
Developers will use this to reference the field
|
|
|
|
|
</small>
|
|
|
|
|
</label>
|
2026-01-08 18:13:17 +02:00
|
|
|
<label>
|
|
|
|
|
Revision number
|
|
|
|
|
<input
|
|
|
|
|
bind:value={data.schema.revisions}
|
|
|
|
|
type="number"
|
|
|
|
|
required
|
|
|
|
|
aria-describedby="revision-helper"
|
|
|
|
|
/>
|
|
|
|
|
<small id="revision-helper">
|
|
|
|
|
How many revisions per document will be kept
|
|
|
|
|
</small>
|
|
|
|
|
</label>
|
2026-01-08 15:19:08 +02:00
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
|
|
<button type="submit">Update</button>
|
|
|
|
|
</form>
|
2026-01-08 18:13:17 +02:00
|
|
|
|
|
|
|
|
<DeleteButton onDelete={handleDelete}>
|
|
|
|
|
{#snippet text()}
|
|
|
|
|
Delete schema
|
|
|
|
|
{/snippet}
|
|
|
|
|
</DeleteButton>
|
2026-01-08 15:19:08 +02:00
|
|
|
{/snippet}
|