publish operations
This commit is contained in:
@@ -2,13 +2,14 @@
|
||||
import { post } from "../../../modules/remote";
|
||||
import { getApp } from "../../../app";
|
||||
import { getLocaleName } from "../locale.svelte.js";
|
||||
let { channel, record, schemaField, dataField, locale, errors } = $props();
|
||||
let { channel, record, schemaField, dataField, locale, validationError } =
|
||||
$props();
|
||||
let originalValue = dataField?.value ?? schemaField.props.default;
|
||||
let newValue = $state(originalValue);
|
||||
let valuesChanged = $derived(newValue !== originalValue);
|
||||
let errorMessage = $state("");
|
||||
let validationErrors = $state(errors);
|
||||
let hasErrors = $derived(validationErrors.length > 0);
|
||||
// let validationErrorState = $state(validationError);
|
||||
let hasError = $derived(!!validationError);
|
||||
const app = getApp();
|
||||
|
||||
function save() {
|
||||
@@ -28,7 +29,7 @@
|
||||
if (err.isNotEmpty()) {
|
||||
errorMessage = err.first();
|
||||
} else {
|
||||
validationErrors = data.validationErrors;
|
||||
validationError = data.validationError;
|
||||
originalValue = newValue;
|
||||
}
|
||||
},
|
||||
@@ -119,11 +120,11 @@
|
||||
onblur={handleBlur}
|
||||
oncompositionstart={handleCompositionStart}
|
||||
oncompositionend={handleCompositionEnd}
|
||||
aria-invalid={hasErrors ? "true" : ""}
|
||||
aria-invalid={hasError ? "true" : ""}
|
||||
/>
|
||||
{#if hasErrors}
|
||||
{#if hasError}
|
||||
<small id={schemaField.id + "-help"}
|
||||
>{validationErrors[0].message}</small
|
||||
>{validationError.message}</small
|
||||
>
|
||||
{:else if schemaField.help != ""}
|
||||
<small id={schemaField.id + "-help"}>{schemaField.help}</small>
|
||||
|
||||
Reference in New Issue
Block a user