added support for linking to the record preview/update form and some other minor improvements
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
export let record;
|
||||
export let collection;
|
||||
export let isNew = !record.id;
|
||||
export let isNew = !record?.id;
|
||||
|
||||
let originalUsername = record.username || null;
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
text: "Make email public or private",
|
||||
position: "top-right",
|
||||
}}
|
||||
on:click={() => (record.emailVisibility = !record.emailVisibility)}
|
||||
on:click|preventDefault={() => (record.emailVisibility = !record.emailVisibility)}
|
||||
>
|
||||
<span class="txt">Public: {record.emailVisibility ? "On" : "Off"}</span>
|
||||
</button>
|
||||
|
||||
@@ -2,25 +2,49 @@
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import Field from "@/components/base/Field.svelte";
|
||||
import TinyMCE from "@tinymce/tinymce-svelte";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
export let field;
|
||||
export let value = undefined;
|
||||
|
||||
let mounted = false;
|
||||
let mountedTimeoutId = null;
|
||||
|
||||
$: conf = Object.assign(CommonHelper.defaultEditorOptions(), {
|
||||
convert_urls: field.options?.convertUrls,
|
||||
relative_urls: false,
|
||||
});
|
||||
|
||||
// normalize value
|
||||
// (depending on the editor plugins, `undefined` may throw an error in case the TinyMCE text functions are used)
|
||||
$: if (typeof value == "undefined") {
|
||||
value = "";
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
mountedTimeoutId = setTimeout(() => {
|
||||
mounted = true;
|
||||
}, 100);
|
||||
|
||||
return () => {
|
||||
clearTimeout(mountedTimeoutId);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<Field class="form-field {field.required ? 'required' : ''}" name={field.name} let:uniqueId>
|
||||
<Field class="form-field form-field-editor {field.required ? 'required' : ''}" name={field.name} let:uniqueId>
|
||||
<label for={uniqueId}>
|
||||
<i class={CommonHelper.getFieldTypeIcon(field.type)} />
|
||||
<span class="txt">{field.name}</span>
|
||||
</label>
|
||||
<TinyMCE
|
||||
id={uniqueId}
|
||||
scriptSrc="{import.meta.env.BASE_URL}libs/tinymce/tinymce.min.js"
|
||||
{conf}
|
||||
bind:value
|
||||
/>
|
||||
{#if mounted}
|
||||
<TinyMCE
|
||||
id={uniqueId}
|
||||
scriptSrc="{import.meta.env.BASE_URL}libs/tinymce/tinymce.min.js"
|
||||
{conf}
|
||||
bind:value
|
||||
/>
|
||||
{:else}
|
||||
<div class="tinymce-wrapper" />
|
||||
{/if}
|
||||
</Field>
|
||||
|
||||
@@ -101,6 +101,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<div
|
||||
class="block"
|
||||
on:dragover|preventDefault={() => {
|
||||
|
||||
@@ -74,7 +74,8 @@
|
||||
loadPromises.push(
|
||||
ApiClient.collection(field?.options?.collectionId).getFullList(batchSize, {
|
||||
filter: filters.join("||"),
|
||||
$autoCancel: false,
|
||||
fields: "*:excerpt(200)",
|
||||
requestKey: null,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user