More work on IDAA and LCI style and themes.

This commit is contained in:
Scott Idem
2025-06-23 18:26:49 -04:00
parent 626f0f2351
commit 2816c09003
12 changed files with 675 additions and 156 deletions

View File

@@ -1,6 +1,5 @@
<script lang="ts">
import { run } from 'svelte/legacy';
import { page } from '$app/state';
interface Props {
/** @type {import('./$types').PageData} */
@@ -9,7 +8,8 @@ interface Props {
let { data }: Props = $props();
let log_lvl: number = 0;
let log_lvl: number = $state(0);
if (log_lvl) {
console.log(`ae_idaa_bb +page.svelte data:`, data);
}
@@ -42,7 +42,7 @@ if (!post_id) {
$idaa_trig.post_id = post_id;
}
// Functions and Logic
let lq__post_obj_li = $derived(liveQuery(async () => {
let results = await db_posts.post
.where('account_id')

View File

@@ -1,4 +1,8 @@
<script lang="ts">
/** @type {import('./$types').PageData} */
export let data: any;
let log_lvl: number = 0;
// *** Import Svelte core
import { onMount } from 'svelte';
import { Spinner } from 'flowbite-svelte';
@@ -11,7 +15,9 @@ import { idaa_loc, idaa_sess, idaa_slct } from '$lib/ae_idaa_stores';
export let lq__post_obj_li: any;
onMount(() => {
console.log('** Component Mounted: ** List - Bulletin Board (Post) Obj');
if (log_lvl) {
console.log('** Component Mounted: ** List - Bulletin Board (Post) Obj', data?.route.toString() ?? 'unknown');
}
});
</script>
@@ -23,7 +29,7 @@ onMount(() => {
{#if idaa_post_obj} <!-- This check for the idaa_post_obj is here in case the IDB entry is deleted. -->
<div
class="container bb_post post_obj border border p-2 mb-2 space-y-2 w-full max-w-(--breakpoint-lg) flex flex-col items-center justify-center bg-white rounded-lg"
class="container bb_post post_obj border p-2 mb-2 space-y-2 w-full max-w-(--breakpoint-lg) flex flex-col items-center justify-center bg-white rounded-lg"
class:dim={idaa_post_obj?.hide}
class:bg-warning-100={!idaa_post_obj?.enable}
class:hidden={(idaa_post_obj.hide && $idaa_loc.bb.qry__hidden != 'all') || (!idaa_post_obj.enable && $idaa_loc.bb.qry__enabled != 'all')}
@@ -123,6 +129,7 @@ onMount(() => {
{#if $ae_loc.trusted_access && idaa_post_obj.email}
(<a href="mailto:{idaa_post_obj.email}?subject=IDAA BB Post">{idaa_post_obj.email}</a>)
{/if}
</span>
</div>
{/if}

View File

@@ -1,5 +1,12 @@
<script lang="ts">
import { run } from 'svelte/legacy';
import { page } from '$app/state';
interface Props {
/** @type {import('./$types').PageData} */
data: any;
}
let { data }: Props = $props();
let log_lvl: number = $state(0);
// console.log(`ae_events_pres_mgmt event [event_id] +page.svelte data:`, data);
@@ -25,25 +32,20 @@ import Comp__event_obj_qry from './ae_idaa_comp__event_obj_qry.svelte';
import Comp__event_obj_li from './ae_idaa_comp__event_obj_li.svelte';
import Comp__event_obj_id_edit from './ae_idaa_comp__event_obj_id_edit.svelte';
import Comp__event_obj_id_view from './ae_idaa_comp__event_obj_id_view.svelte';
interface Props {
/** @type {import('./$types').PageData} */
data: any;
}
let { data }: Props = $props();
let event_id_random_li: Array<string> = $state();
let event_id = page.url.searchParams.get('event_id') ?? null;
if (!event_id) {
$idaa_slct.event_id = null;
} else {
console.log(`ae Recovery Meetings - [event_id] +page.ts: event_id = `, event_id);
$idaa_slct.event_id = event_id;
$idaa_trig.event_id = event_id;
}
// Functions and Logic
let lq__event_obj = $derived(liveQuery(async () => {
let results = await db_events.events
.get($idaa_slct.event_id ?? '');
return results;
}));
let lq_new__event_obj_li = $derived(liveQuery(async () => {
let link_to_type: string = 'account';
let link_to_id: string = $slct.account_id;
@@ -98,10 +100,17 @@ let lq_new__event_obj_li = $derived(liveQuery(async () => {
}
}));
let lq__event_obj = $derived(liveQuery(async () => {
let results = await db_events.events
.get($idaa_slct.event_id ?? '');
return results;
}));
// This (event_li trigger for IDAA) is not currently being used.
// Updated 2024-11-19
run(() => {
$effect(() => {
if ($idaa_trig.event_li) {
$idaa_trig.event_li = false;
@@ -134,147 +143,195 @@ run(() => {
// Updated 2024-11-19
run(() => {
$effect(() => {
if ($idaa_trig.event_li_qry) {
$idaa_trig.event_li_qry = false;
$idaa_trig.event_li_qry = false;
if (log_lvl) {
console.log(`Triggered: $idaa_trig.event_li_qry`);
}
// $idaa_sess.recovery_meetings.qry__status = 'loading';
let and_physical = $idaa_loc.recovery_meetings.qry__physical;
let and_virtual = $idaa_loc.recovery_meetings.qry__virtual;
let and_type = $idaa_loc.recovery_meetings.qry__type;
let order_by_li = $idaa_loc.recovery_meetings.qry__order_by_li;
let search_delay = 15;
let max_tries = 5;
let try_cache = true;
// let params = {
// 'qry__enabled': $idaa_loc.recovery_meetings.qry__enabled ?? 'enabled',
// 'qry__hidden': $idaa_loc.recovery_meetings.qry__hidden ?? 'not_hidden',
// 'qry__limit': $idaa_loc.recovery_meetings.qry__limit ?? 35,
// };
if ($idaa_loc.recovery_meetings.qry__enabled !== 'all' || $idaa_loc.recovery_meetings.qry__hidden !== 'all') {
console.log(`Deleting disabled or hidden event.`);
let results = db_events.events
.clear();
console.log(`Deleted ${results} disabled event.`);
}
if ($idaa_sess.recovery_meetings?.qry__status != null && $idaa_sess.recovery_meetings?.qry__status != 'done') {
console.log('*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status != done ***');
// WARNING: This is a temporary fix for the search string. It needs to be fixed in the future. Using lk_search_str for now.
$idaa_sess.recovery_meetings.status_qry__last_request_str = $idaa_loc.recovery_meetings.qry__fulltext_str;
// We want to delay the initial search request to give the previous search request to finish.
let random_delay = Math.floor(Math.random() * 50);
search_delay += 50+random_delay;
}
log_lvl = 0;
let count = 0;
let request_loop = setInterval(() => {
count++;
if (log_lvl) {
console.log(`*** TEST SEARCH - Search delay: ${search_delay} *** loop count=${count}`);
console.log(`Triggered: $idaa_trig.event_li_qry`);
}
if (count >= max_tries) {
console.log('*** TEST SEARCH - Max tries reached ***');
clearInterval(request_loop);
// $idaa_sess.recovery_meetings.qry__status = 'loading';
let and_physical = $idaa_loc.recovery_meetings.qry__physical;
let and_virtual = $idaa_loc.recovery_meetings.qry__virtual;
let and_type = $idaa_loc.recovery_meetings.qry__type;
let order_by_li = $idaa_loc.recovery_meetings.qry__order_by_li;
let search_delay = 15;
let max_tries = 5;
let try_cache = true;
// let params = {
// 'qry__enabled': $idaa_loc.recovery_meetings.qry__enabled ?? 'enabled',
// 'qry__hidden': $idaa_loc.recovery_meetings.qry__hidden ?? 'not_hidden',
// 'qry__limit': $idaa_loc.recovery_meetings.qry__limit ?? 35,
// };
if ($idaa_loc.recovery_meetings.qry__enabled !== 'all' || $idaa_loc.recovery_meetings.qry__hidden !== 'all') {
console.log(`Deleting disabled or hidden event.`);
let results = db_events.events
.clear();
console.log(`Deleted ${results} disabled event.`);
}
if ($idaa_sess.recovery_meetings?.qry__status != null && $idaa_sess.recovery_meetings?.qry__status != 'done') {
let random_delay = Math.floor(Math.random() * 25);
search_delay += 25+random_delay;
console.log(`*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status == loading wait *** search_delay=${search_delay}`);
// $idaa_sess.status_qry__last_request_str = $idaa_loc.recovery_meetings.qry__fulltext_str;
} else {
console.log('*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status != loading ***');
console.log('*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status != done ***');
// WARNING: This is a temporary fix for the search string. It needs to be fixed in the future. Using lk_search_str for now.
$idaa_sess.recovery_meetings.status_qry__last_request_str = $idaa_loc.recovery_meetings.qry__fulltext_str;
$idaa_sess.recovery_meetings.qry__status = 'loading';
(and_physical) ?? null;
(and_virtual) ?? null;
(and_type) ?? null;
// if (and_type) and_type = and_type;
// if (!and_type) {
// and_type = null;
// }
console.log(`TEST - and_physical: ${and_physical}; and_virtual: ${and_virtual}; and_type: ${and_type}; qry__fulltext_str: ${$idaa_loc.recovery_meetings.qry__fulltext_str}`);
$idaa_prom.load__event_obj_qry = events_func.qry_ae_obj_li__event({
api_cfg: $ae_api,
for_obj_type: 'account',
for_obj_id: $ae_loc.account_id,
qry_conference: false,
qry_physical: and_physical,
qry_virtual: and_virtual,
qry_type: and_type,
qry_str: $idaa_loc.recovery_meetings.qry__fulltext_str,
enabled: $idaa_loc.recovery_meetings.qry__enabled,
hidden: $idaa_loc.recovery_meetings.qry__hidden,
order_by_li: $idaa_loc.recovery_meetings.qry__order_by_li,
limit: $idaa_loc.recovery_meetings.qry__limit,
try_cache: try_cache,
log_lvl: log_lvl,
})
.then(function (search_results) {
// Processing the results from the search.
$idaa_sess.recovery_meetings.qry__status = 'processing';
$idaa_slct.event_obj_li = search_results;
console.log(search_results);
// $idaa_sess.recovery_meetings.qry__status = 'done';
if (log_lvl) {
console.log('TEST SEARCH - Search done. Pulling out the event_id_randoms.');
}
// console.log(`TEST search: ${$lq_kv__event_obj_li}`);
// event_id_random_li = [];
// We need to loop through the array of objects and get the event_id_random from each object a new list of event_id_randoms. Then we can use this list to get the full objects from the database.
let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
if (search_results && search_results.length) {
for (let i = 0; i < search_results.length; i++) {
tmp_li.push($idaa_slct.event_obj_li[i].event_id_random);
}
}
event_id_random_li = tmp_li;
})
.finally(() => {
// event_id_random_li = $idaa_slct.event_obj_li.map(session_obj => session_obj.event_id_random);
// Finally done with the search.
$idaa_sess.recovery_meetings.qry__status = 'done';
if (log_lvl > 1) {
console.log(`TEST SEARCH - event_id_random_li:`, event_id_random_li);
// console.log(`TEST SEARCH - search live query: ${$lq_kv__event_obj_li}`);
}
});
clearInterval(request_loop);
// We want to delay the initial search request to give the previous search request to finish.
let random_delay = Math.floor(Math.random() * 50);
search_delay += 50+random_delay;
}
}, search_delay);
}
log_lvl = 0;
let count = 0;
let request_loop = setInterval(() => {
count++;
if (log_lvl) {
console.log(`*** TEST SEARCH - Search delay: ${search_delay} *** loop count=${count}`);
}
if (count >= max_tries) {
console.log('*** TEST SEARCH - Max tries reached ***');
clearInterval(request_loop);
}
if ($idaa_sess.recovery_meetings?.qry__status != null && $idaa_sess.recovery_meetings?.qry__status != 'done') {
let random_delay = Math.floor(Math.random() * 25);
search_delay += 25+random_delay;
console.log(`*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status == loading wait *** search_delay=${search_delay}`);
// $idaa_sess.status_qry__last_request_str = $idaa_loc.recovery_meetings.qry__fulltext_str;
} else {
console.log('*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status != loading ***');
$idaa_sess.recovery_meetings.qry__status = 'loading';
(and_physical) ?? null;
(and_virtual) ?? null;
(and_type) ?? null;
// if (and_type) and_type = and_type;
// if (!and_type) {
// and_type = null;
// }
console.log(`TEST - and_physical: ${and_physical}; and_virtual: ${and_virtual}; and_type: ${and_type}; qry__fulltext_str: ${$idaa_loc.recovery_meetings.qry__fulltext_str}`);
$idaa_prom.load__event_obj_qry = events_func.qry_ae_obj_li__event({
api_cfg: $ae_api,
for_obj_type: 'account',
for_obj_id: $ae_loc.account_id,
qry_conference: false,
qry_physical: and_physical,
qry_virtual: and_virtual,
qry_type: and_type,
qry_str: $idaa_loc.recovery_meetings.qry__fulltext_str,
enabled: $idaa_loc.recovery_meetings.qry__enabled,
hidden: $idaa_loc.recovery_meetings.qry__hidden,
order_by_li: $idaa_loc.recovery_meetings.qry__order_by_li,
limit: $idaa_loc.recovery_meetings.qry__limit,
try_cache: try_cache,
log_lvl: log_lvl,
})
.then(function (search_results) {
// Processing the results from the search.
$idaa_sess.recovery_meetings.qry__status = 'processing';
$idaa_slct.event_obj_li = search_results;
console.log(search_results);
// $idaa_sess.recovery_meetings.qry__status = 'done';
if (log_lvl) {
console.log('TEST SEARCH - Search done. Pulling out the event_id_randoms.');
}
// console.log(`TEST search: ${$lq_kv__event_obj_li}`);
// event_id_random_li = [];
// We need to loop through the array of objects and get the event_id_random from each object a new list of event_id_randoms. Then we can use this list to get the full objects from the database.
let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
if (search_results && search_results.length) {
for (let i = 0; i < search_results.length; i++) {
tmp_li.push($idaa_slct.event_obj_li[i].event_id_random);
}
}
event_id_random_li = tmp_li;
})
.finally(() => {
// event_id_random_li = $idaa_slct.event_obj_li.map(session_obj => session_obj.event_id_random);
// Finally done with the search.
$idaa_sess.recovery_meetings.qry__status = 'done';
if (log_lvl > 1) {
console.log(`TEST SEARCH - event_id_random_li:`, event_id_random_li);
// console.log(`TEST SEARCH - search live query: ${$lq_kv__event_obj_li}`);
}
});
clearInterval(request_loop);
}
}, search_delay);
}
});
$effect(() => {
if ($idaa_trig.event_id) {
// log_lvl = 1;
$idaa_trig.event_id = false;
if (log_lvl) {
console.log(`Triggered: $idaa_trig.event_id`);
}
$idaa_prom.load__event_obj = events_func.load_ae_obj_id__event({
api_cfg: $ae_api,
event_id: $idaa_slct.event_id,
// enabled: $idaa_loc.recovery_meetings.qry__enabled,
// hidden: $idaa_loc.recovery_meetings.qry__hidden,
// limit: $idaa_loc.recovery_meetings.qry__limit,
try_cache: true,
log_lvl: log_lvl,
})
.then((event_obj) => {
if (log_lvl) {
console.log(`Event object loaded: `, event_obj);
}
$idaa_slct.event_obj = event_obj;
// $idaa_sess.recovery_meetings.show__modal_view = $idaa_slct.event_id;
// $idaa_sess.recovery_meetings.show__modal_edit = false;
});
// $idaa_slct.event_obj = $idaa_prom.load__event_obj;
if (!page.url.searchParams.get('event_id')) {
const url = new URL(location);
url.searchParams.set('event_id', $idaa_slct.event_id);
history.pushState({}, '', url);
let message = {'event_id': $idaa_slct.event_id};
window.parent.postMessage(message, "*");
}
$idaa_sess.recovery_meetings.show__modal_view = $idaa_slct.event_id;
$idaa_sess.recovery_meetings.show__modal_view__event_id = $idaa_slct.event_id;
$idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_sess.recovery_meetings.show__modal_edit__event_id = false;
}
});
if (browser) {
console.log('Browser environment detected.');
if (!$idaa_sess.recovery_meetings.show__modal_edit && !$idaa_sess.recovery_meetings.show__modal_view) {
if (!$idaa_sess.recovery_meetings.show__modal_edit && !$idaa_sess.recovery_meetings.show__modal_view__event_id) {
$idaa_slct.event_id = null;
}
@@ -397,7 +454,7 @@ function add_activity_log(
<!-- Modal: Event (Recovery Meeting) edit ID -->
<!-- title="{$lq__event_obj?.name} - {$lq__event_obj?.id}" -->
<Modal
bind:open={$idaa_sess.recovery_meetings.show__modal_edit}
bind:open={$idaa_sess.recovery_meetings.show__modal_edit__event_id}
autoclose={false}
placement="top-center"
size="xl"
@@ -416,7 +473,9 @@ function add_activity_log(
// history.pushState({}, '', url);
$idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_sess.recovery_meetings.show__modal_edit__event_id = false;
$idaa_sess.recovery_meetings.show__modal_view = true;
$idaa_sess.recovery_meetings.show__modal_view__event_id = $lq__event_obj?.event_id;
add_activity_log(
{
@@ -472,7 +531,7 @@ function add_activity_log(
<!-- Modal: Event (Recovery Meeting) view ID -->
<!-- title="{$lq__event_obj?.name} - {$lq__event_obj?.id}" -->
<Modal
bind:open={$idaa_sess.recovery_meetings.show__modal_view}
bind:open={$idaa_sess.recovery_meetings.show__modal_view__event_id}
autoclose={false}
outsideclose={true}
placement="top-center"
@@ -491,7 +550,9 @@ function add_activity_log(
// history.pushState({}, '', url);
$idaa_sess.recovery_meetings.show__modal_view = false;
$idaa_sess.recovery_meetings.show__modal_view__event_id = false;
$idaa_sess.recovery_meetings.show__modal_edit = true;
$idaa_sess.recovery_meetings.show__modal_edit__event_id = $lq__event_obj?.event_id;
add_activity_log(
{
@@ -524,7 +585,9 @@ function add_activity_log(
class="btn btn-sm btn-secondary absolute top-2 right-2"
onclick={() => {
$idaa_sess.recovery_meetings.show__modal_view = false;
$idaa_sess.recovery_meetings.show__modal_view__event_id = false;
$idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_sess.recovery_meetings.show__modal_edit__event_id = false;
}}
>
<span class="fas fa-times"></span>
@@ -536,4 +599,21 @@ function add_activity_log(
lq__event_obj={lq__event_obj}
/>
{#snippet footer()}
<button
type="button"
class="btn btn-sm btn-secondary"
onclick={() => {
$idaa_sess.recovery_meetings.show__modal_view = false;
$idaa_sess.recovery_meetings.show__modal_view__event_id = false;
$idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_sess.recovery_meetings.show__inline_edit__event_obj = false;
}}
>
<span class="fas fa-times"></span>
Close
</button>
{/snippet}
</Modal>

View File

@@ -12,6 +12,7 @@ export let lq__event_obj: any;
if ($idaa_slct.event_id) {
console.log(`Event ID selected: ${$idaa_slct.event_id}`);
console.log(`Event Object selected: ${$lq__event_obj}`)
console.log(`Event Object name: ${$lq__event_obj?.name}`);
$slct_trigger = 'load__event_obj';
}

View File

@@ -12,16 +12,17 @@ import { browser } from '$app/environment';
import { ae_util } from '$lib/ae_utils/ae_utils';
import { core_func } from '$lib/ae_core/ae_core_functions';
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { idaa_loc, idaa_sess, idaa_slct } from '$lib/ae_idaa_stores';
import { idaa_loc, idaa_sess, idaa_slct, idaa_trig } from '$lib/ae_idaa_stores';
export let lq__event_obj_li: any;
onMount(() => {
console.log('** Component Mounted: ** List - Recovery Meeting (Event) Obj');
if (log_lvl) {
console.log('** Component Mounted: ** List - Recovery Meeting (Event) Obj');
}
});
if (browser) {
add_activity_log(
{
@@ -31,7 +32,6 @@ if (browser) {
);
}
function add_activity_log(
{
action = 'idaa_meetings_page',
@@ -48,7 +48,7 @@ function add_activity_log(
${$idaa_loc.novi_full_name ?? 'none'} ${$idaa_loc.novi_email ?? 'no-email'}
allow=${$ae_loc?.allow_access}
last_cache_refresh=${last_cache_refresh_iso.toLocaleString()}
data_route=${data?.route.toString() ?? 'unknown'}
data_route=${data?.route?.toString() ?? 'unknown'}
`;
let data_kv = {
@@ -113,7 +113,7 @@ function add_activity_log(
{#if idaa_event_obj} <!-- This check for the idaa_event_obj is here in case the IDB entry is deleted. -->
<div
class="container recovery_meeting event_obj border border rounded-lg p-2 mb-2 space-y-2 w-full max-w-(--breakpoint-lg) flex flex-col items-center justify-center bg-white"
class="container recovery_meeting event_obj border rounded-lg p-2 mb-2 space-y-2 w-full max-w-(--breakpoint-lg) flex flex-col items-center justify-center bg-white"
class:hidden={(idaa_event_obj?.hide || !idaa_event_obj?.enable) && !$ae_loc.trusted_access}
class:dim={idaa_event_obj?.hide}
class:bg-warning-100={!idaa_event_obj?.enable}
@@ -175,8 +175,11 @@ function add_activity_log(
// $idaa_sess.recovery_meetings.show_main__options = true;
// $idaa_sess.recovery_meetings.show_list__event_obj_li = true;
$idaa_trig.event_id = true;
$idaa_sess.recovery_meetings.show__modal_view = true;
$idaa_sess.recovery_meetings.show__modal_view__event_id = idaa_event_obj?.event_id;
$idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_sess.recovery_meetings.show__modal_edit__event_id
}}
class="novi_btn btn btn-secondary btn-md preset-tonal-primary border border-primary-500 hover:preset-filled-primary-500 transition"
title={`Open to see details: ${idaa_event_obj?.name}`}
@@ -201,7 +204,9 @@ function add_activity_log(
// $idaa_sess.recovery_meetings.show_main__options = true;
// $idaa_sess.recovery_meetings.show_list__event_obj_li = true;
$idaa_sess.recovery_meetings.show__modal_view = false;
$idaa_sess.recovery_meetings.show__modal_view__event_id = false;
$idaa_sess.recovery_meetings.show__modal_edit = true;
$idaa_sess.recovery_meetings.show__modal_edit__event_id = idaa_event_obj?.event_id;
}}
class="novi_btn btn btn-tertiary btn-sm preset-tonal-warning border border-warning-500 hover:preset-filled-warning-500 transition"
title={`Edit meeting: ${idaa_event_obj?.name}`}