Bug fix for event_id being added as a URL param. Other fixes.

This commit is contained in:
Scott Idem
2025-07-09 14:05:51 -04:00
parent d97e6e74aa
commit 8bd42d1896
5 changed files with 60 additions and 234 deletions

View File

@@ -28,7 +28,7 @@ import { idaa_loc, idaa_sess, idaa_slct, idaa_trig, idaa_prom } from '$lib/ae_id
import { posts_func } from '$lib/ae_posts/ae_posts_functions';
import Comp__post_obj_li from './ae_idaa_comp__post_obj_li.svelte';
import Comp__post_obj_id_view from './ae_idaa_comp__post_obj_id_view.svelte';
// import Comp__post_obj_id_view from './ae_idaa_comp__post_obj_id_view.svelte';
import Comp__post_options from './ae_idaa_comp__post_options.svelte';
@@ -278,103 +278,3 @@ function add_activity_log(
<!-- </section> -->
<!-- Modal: Post (Bulletin Board) view ID -->
<!-- title="{$lq__post_obj?.title ?? 'New Post'} - {$lq__post_obj?.id ?? 'Not Saved Yet'}" -->
{#if 1===3}
<Modal
bind:open={$idaa_sess.bb.show__modal_view__post_id}
autoclose={false}
outsideclose={true}
placement="top-center"
size="lg"
class="top-center bg-white dark:bg-gray-800 text-gray-800 dark:text-gray-200 rounded-lg border-gray-200 dark:border-gray-700 divide-gray-200 dark:divide-gray-700 shadow-md relative flex flex-col mx-auto w-full divide-y"
onclose={() => {
// We want to cancel the inline edit if the modal is closed
$idaa_sess.bb.show__inline_edit__post_obj = false;
}}
>
{#snippet header()}
<div class="flex flex-row items-center justify-between w-full">
<h3 class="text-lg font-semibold">
{#if $ae_loc.trusted_access || $lq__post_obj?.external_person_id === $idaa_loc.novi_uuid}
<button
onclick={() => {
// const url = new URL(location);
// url.searchParams.set('post_id', $lq__post_obj?.post_id_random);
// history.pushState({}, '', url);
// $idaa_sess.bb.show__modal_view = false;
if ($idaa_sess.bb.show__inline_edit__post_obj) {
$idaa_sess.bb.show__inline_edit__post_obj = false;
} else {
$idaa_sess.bb.show__inline_edit__post_obj = true;
}
}}
class="novi_btn btn btn-sm preset-tonal-warning border border-warning-500 hover:preset-filled-warning-500 transition"
title={`Edit meeting: ${$lq__post_obj?.title}`}
>
{#if $idaa_sess.bb.show__inline_edit__post_obj}
<span class="fas fa-times m-1"></span> Cancel Edit
{:else}
<span class="fas fa-edit m-1"></span> Edit
{/if}
</button>
{/if}
<!-- {$lq__post_obj?.title ?? 'New Post'} -->
<span class="">
<span class="fas fa-comment-alt m-1"></span>
{@html $lq__post_obj?.title ?? 'New Post'}
<!-- - {$lq__post_obj?.id ?? 'Not Yet Saved'} -->
</span>
{#if $lq__post_obj?.topic_id}<span class="badge badge-info preset-tonal-secondary"><span class="fas fa-user-md m-1"></span> {$lq__post_obj?.topic_name}</span>{/if}
</h3>
</div>
<button
type="button"
class="btn btn-sm btn-secondary absolute top-2 right-2"
onclick={() => {
$idaa_sess.bb.show__modal_view__post_id = false;
$idaa_sess.bb.show__inline_edit__post_obj = false;
$idaa_slct.post_id = null;
$idaa_slct.post_obj = null;
let message = {'post_id': $idaa_slct.post_id ?? null};
window.parent.postMessage(message, "*");
}}
>
<span class="fas fa-times"></span>
Close
</button>
{/snippet}
<Comp__post_obj_id_view
lq__post_obj={lq__post_obj}
lq__post_comment_obj_li={lq__post_comment_obj_li}
lq__post_comment_obj={lq__post_comment_obj}
/>
{#snippet footer()}
<button
type="button"
class="btn btn-sm btn-secondary"
onclick={() => {
$idaa_sess.bb.show__modal_view__post_id = false;
$idaa_sess.bb.show__inline_edit__post_obj = false;
$idaa_slct.post_id = null;
$idaa_slct.post_obj = null;
let message = {'post_id': $idaa_slct.post_id ?? null};
window.parent.postMessage(message, "*");
}}
>
<span class="fas fa-times"></span>
Close
</button>
{/snippet}
</Modal>
{/if}

View File

@@ -1,9 +1,13 @@
<script lang="ts">
let log_lvl: number = 0;
// *** Import Svelte specific
import { page } from '$app/state';
// *** Import Aether specific variables and 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, idaa_prom } from '$lib/ae_idaa_stores';
import { events_func } from '$lib/ae_events_functions';
interface Props {
/** @type {import('./$types').LayoutData} */
@@ -29,6 +33,56 @@ $idaa_slct.event_obj_li = ae_acct.slct.event_obj_li;
// $idaa_slct.event_id = ae_acct.slct.event_id; // Not set here yet.
// *** Set initial variables
$effect(() => {
if ($idaa_trig.event_id && $idaa_slct.event_id) {
log_lvl = 1;
$idaa_trig.event_id = false;
if (log_lvl) {
console.log(`Triggered: $idaa_slct.event_id = ${$idaa_slct.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);
url.searchParams.delete('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;
}
});
</script>

View File

@@ -30,8 +30,8 @@ import Element_data_store from '$lib/element_data_store_v2.svelte';
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';
// 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';
// let event_id = page.url.searchParams.get('event_id') ?? null;
@@ -280,61 +280,11 @@ $effect(() => {
});
$effect(() => {
if ($idaa_trig.event_id && $idaa_slct.event_id) {
log_lvl = 1;
$idaa_trig.event_id = false;
if (log_lvl) {
console.log(`Triggered: $idaa_slct.event_id = ${$idaa_slct.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__event_id) {
// $idaa_slct.event_id = null;
// }
let message = {'event_id': $idaa_slct?.event_id ?? null};
window.parent.postMessage(message, "*");

View File

@@ -5,7 +5,7 @@ import { browser } from '$app/environment';
import { ae_util } from '$lib/ae_utils/ae_utils';
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: any;
@@ -15,6 +15,7 @@ if ($idaa_slct.event_id) {
console.log(`Event Object name: ${$lq__event_obj?.name}`);
$slct_trigger = 'load__event_obj';
$idaa_trig.event_id = $idaa_slct.event_id;
}
// $: if (browser && $lq__event_obj?.event_id) {

View File

@@ -182,85 +182,6 @@ function add_activity_log(
<!-- <span class="fas fa-info-circle"></span> -->
Meeting Details
</a>
<button
type="button"
disabled={true}
on:click={() => {
$idaa_slct.event_id = idaa_event_obj?.event_id;
$idaa_slct.event_obj = idaa_event_obj;
// $slct_trigger = 'load__event_obj';
// // handle_load_event_id_obj({event_id: $idaa_slct.event_id, try_cache: false});
const url = new URL(location);
url.searchParams.set('event_id', idaa_event_obj?.event_id);
history.pushState({}, '', url);
let message = {'event_id': idaa_event_obj?.event_id};
window.parent.postMessage(message, "*");
if ($ae_loc?.iframe && $ae_loc.browser_type == 'safari') {
console.log('In Safari iframe, sending message to parent window to scroll to top as well');
window.parent.postMessage({'scroll_to': 0}, "*"); // This should be in pixels
}
// $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;
var is_safari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
if (is_safari) {
console.log('Safari detected, using forced scroll to top...');
// Safari does not support smooth scroll, so we use a regular scroll
document.getElementById('ae_idaa')?.scrollTo(0, 0);
// document.getElementById('ae_idaa')?.scrollTo({
// top: 0,
// behavior: 'smooth'
// });
}
}}
class="novi_btn btn btn-secondary btn-md preset-tonal-primary border border-primary-500 hover:preset-filled-primary-500 transition hidden"
title={`Open to see details: ${idaa_event_obj?.name}`}
>
<span class="fas fa-envelope-open m-1"></span>
<!-- <span class="fas fa-info-circle"></span> -->
Info
</button>
<!-- This checks if the currently logged in Novi user has a matching UUID or email address. -->
{#if ($ae_loc.trusted_access && $ae_loc.edit_mode) || idaa_event_obj?.external_person_id === $idaa_loc.novi_uuid || idaa_event_obj?.contact_li_json[0].email === $idaa_loc.novi_email}
<button
type="button"
disabled={true}
on:click={() => {
$idaa_slct.event_id = idaa_event_obj?.event_id;
$idaa_slct.event_obj = idaa_event_obj;
// $slct_trigger = 'load__event_obj';
// const url = new URL(location);
// url.searchParams.set('event_id', idaa_event_obj?.event_id);
// history.pushState({}, '', url);
// $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 hidden"
title={`Edit meeting: ${idaa_event_obj?.name}`}
>
<span class="fas fa-edit m-1"></span>
Edit Meeting
</button>
{/if}
</div>