Now with JSON validity checking. Done for the day.
This commit is contained in:
@@ -43,6 +43,19 @@ $: if ($lq__person_obj?.data_json && ae_tmp.value__data_json === null) {
|
|||||||
// JSON.stringify(jsObj, null, 4);
|
// JSON.stringify(jsObj, null, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ae_tmp.valid__data_json = null;
|
||||||
|
$: if (ae_tmp.value__data_json && ae_tmp.value__data_json.length) {
|
||||||
|
console.log(`ae_tmp.value__data_json.length:`, ae_tmp.value__data_json.length);
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSON.parse(ae_tmp.value__data_json);
|
||||||
|
ae_tmp.valid__data_json = true;
|
||||||
|
} catch (e) {
|
||||||
|
ae_tmp.valid__data_json = false;
|
||||||
|
console.error(`JSON.parse error:`, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// $events_slct.person_obj = $lq__person_obj;
|
// $events_slct.person_obj = $lq__person_obj;
|
||||||
|
|
||||||
@@ -553,13 +566,22 @@ onMount(() => {
|
|||||||
<!-- {/if} -->
|
<!-- {/if} -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>JSON length: {(ae_tmp.value__data_json ? ae_util.number_w_commas(ae_tmp.value__data_json.length) : 0)} characters</p>
|
<p>
|
||||||
|
JSON length: {(ae_tmp.value__data_json ? ae_util.number_w_commas(ae_tmp.value__data_json.length) : 0)} characters
|
||||||
|
|
||||||
|
{#if ae_tmp.valid__data_json}
|
||||||
|
<span class="fas fa-check text-green-500"></span>
|
||||||
|
{:else}
|
||||||
|
<span class="fas fa-exclamation-triangle text-red-500"></span>
|
||||||
|
Invalid JSON
|
||||||
|
{/if}
|
||||||
|
</p>
|
||||||
|
|
||||||
<div class="flex flex-wrap gap-2 p-1">
|
<div class="flex flex-wrap gap-2 p-1">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-md variant-glass-primary hover:variant-filled-primary"
|
class="btn btn-md variant-glass-primary hover:variant-filled-primary"
|
||||||
disabled={(ae_tmp.value__data_json == $lq__person_obj.data_json)}
|
disabled={(!$ae_loc.trusted_access || ae_tmp.value__data_json == $lq__person_obj.data_json)}
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
console.log('*** Save button clicked ***');
|
console.log('*** Save button clicked ***');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user