Lot of updates to Svelte 5 syntax
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
<script lang="ts">
|
||||
interface Props {
|
||||
person_id: string;
|
||||
display_mode?: string; // 'default', 'compact', 'minimal', 'launcher'
|
||||
}
|
||||
|
||||
let { person_id, display_mode = 'default' }: Props = $props();
|
||||
|
||||
console.log(`ae_core person_view.svelte`);
|
||||
|
||||
import { createEventDispatcher, onMount } from 'svelte';
|
||||
import { liveQuery } from "dexie";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
import { api } from '$lib/api';
|
||||
// import { api } from '$lib/api';
|
||||
import Element_ae_crud from '$lib/element_ae_crud.svelte';
|
||||
// import Element_data_store from '$lib/element_data_store_v2.svelte';
|
||||
|
||||
@@ -19,46 +23,45 @@ import { db_core } from "$lib/ae_core/db_core";
|
||||
// import { events_loc, events_sess, events_slct, events_trigger } from '$lib/ae_events_stores';
|
||||
// import { events_func } from '$lib/ae_events_functions';
|
||||
|
||||
// Exports
|
||||
export let person_id: string;
|
||||
export let display_mode: string = 'default'; // 'default', 'compact', 'minimal', 'launcher'
|
||||
|
||||
|
||||
|
||||
let ae_placeholder_li: key_val = {};
|
||||
let ae_promises: key_val = {}; // Promise<any>;
|
||||
let ae_tmp: key_val = {};
|
||||
let ae_promises: key_val = $state({}); // Promise<any>;
|
||||
let ae_tmp: key_val = $state({});
|
||||
ae_tmp.value__hide = null;
|
||||
|
||||
let ae_triggers: key_val = {};
|
||||
let ae_triggers: key_val = $state({});
|
||||
|
||||
console.log(`person_id:`, person_id);
|
||||
let lq__person_obj = liveQuery(
|
||||
async () => await db_core.person.get(person_id)
|
||||
);
|
||||
let lq__person_obj = $derived(liveQuery(async () => {
|
||||
let results = await db_core.person.get(person_id);
|
||||
return results;
|
||||
}));
|
||||
|
||||
ae_tmp.value__data_json = null;
|
||||
$: if ($lq__person_obj?.data_json && ae_tmp.value__data_json === null) {
|
||||
ae_tmp.value__data_json = JSON.stringify($lq__person_obj.data_json, null, 4);
|
||||
// ae_tmp.value__data_json = JSON.parse(JSON.stringify($lq__person_obj.data_json));
|
||||
// JSON.stringify(jsObj, null, 4);
|
||||
}
|
||||
$effect(() => {
|
||||
if ($lq__person_obj?.data_json && ae_tmp.value__data_json === null) {
|
||||
ae_tmp.value__data_json = JSON.stringify($lq__person_obj.data_json, null, 4);
|
||||
// ae_tmp.value__data_json = JSON.parse(JSON.stringify($lq__person_obj.data_json));
|
||||
// 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);
|
||||
$effect(() => {
|
||||
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);
|
||||
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_sess.pres_mgmt.disable_submit__opt_out = false;
|
||||
});
|
||||
|
||||
// let tmp_agree = false;
|
||||
// let tmp_opt_out: key_val = {
|
||||
@@ -67,12 +70,6 @@ $: if (ae_tmp.value__data_json && ae_tmp.value__data_json.length) {
|
||||
// transcription_and_publication: false,
|
||||
// publication_in_app: false
|
||||
// };
|
||||
|
||||
onMount(() => {
|
||||
console.log('ae_core: person_view.svelte');
|
||||
console.log(`person_id:`, person_id);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -382,7 +379,7 @@ onMount(() => {
|
||||
{($lq__person_obj?.hide ? 'Hidden' : 'Not Hidden')}
|
||||
{/if}
|
||||
<button
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
ae_tmp.value__hide = !$lq__person_obj?.hide;
|
||||
|
||||
// $events_slct.exhibit_tracking_obj.hide = !$lq__person_obj?.hide;
|
||||
@@ -429,7 +426,7 @@ onMount(() => {
|
||||
{($lq__person_obj?.enable ? 'Enabled' : 'Disabled')}
|
||||
{/if}
|
||||
<button
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
ae_tmp.value__enable = !$lq__person_obj?.enable;
|
||||
|
||||
// $events_slct.exhibit_tracking_obj.hide = !$lq__person_obj?.hide;
|
||||
@@ -476,7 +473,7 @@ onMount(() => {
|
||||
{($lq__person_obj?.priority ? 'Priority' : 'Not Priority')}
|
||||
{/if}
|
||||
<button
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
ae_tmp.value__priority = !$lq__person_obj?.priority;
|
||||
|
||||
// $events_slct.exhibit_tracking_obj.hide = !$lq__person_obj?.hide;
|
||||
@@ -523,7 +520,7 @@ onMount(() => {
|
||||
{($lq__person_obj?.allow_auth_key ? 'Allow Auth Key' : 'Not Allow Auth Key')}
|
||||
{/if}
|
||||
<button
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
ae_tmp.value__allow_auth_key = !$lq__person_obj?.allow_auth_key;
|
||||
|
||||
// $events_slct.exhibit_tracking_obj.hide = !$lq__person_obj?.hide;
|
||||
@@ -581,7 +578,7 @@ onMount(() => {
|
||||
type="button"
|
||||
class="btn btn-md preset-tonal-primary hover:preset-filled-primary-500"
|
||||
disabled={(!$ae_loc.trusted_access || ae_tmp.value__data_json == $lq__person_obj.data_json)}
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
console.log('*** Save button clicked ***');
|
||||
|
||||
// We need to parse the JSON string into an object. In the future this should be dynamic and allow for basic key_val object.
|
||||
|
||||
Reference in New Issue
Block a user