[#1703] updated json field string data normalizations and fixed the field vizualization in the Admin UI

This commit is contained in:
Gani Georgiev
2023-01-29 12:37:10 +02:00
parent c51148e4d7
commit deccb3dbdb
37 changed files with 174 additions and 81 deletions
@@ -6,10 +6,10 @@
export let field = new SchemaField();
export let value = undefined;
$: if (typeof value !== "undefined" && typeof value !== "string" && value !== null) {
// the JSON field support both js primitives and encoded JSON string
// so we are normalizing the value to only a string
value = JSON.stringify(value, null, 2);
let serialized = undefined;
$: if (value !== serialized?.trim()) {
serialized = JSON.stringify(value, null, 2);
}
</script>
@@ -18,5 +18,14 @@
<i class={CommonHelper.getFieldTypeIcon(field.type)} />
<span class="txt">{field.name}</span>
</label>
<textarea id={uniqueId} required={field.required} class="txt-mono" bind:value />
<textarea
id={uniqueId}
class="txt-mono"
required={field.required}
value={serialized}
on:input={(e) => {
serialized = e.target.value;
value = e.target.value.trim(); // trim the submitted value
}}
/>
</Field>