Various bug fixes and improvements. Now able to correctly create and delete Recovery Meetings.

This commit is contained in:
Scott Idem
2025-07-11 13:12:45 -04:00
parent 6e4649882c
commit b133aa1285
6 changed files with 81 additions and 34 deletions

View File

@@ -218,7 +218,7 @@ onDestroy(() => {
{/if}
</div>
{#if $idaa_sess.recovery_meetings.edit__event_obj}
{#if $idaa_sess.recovery_meetings.edit__event_obj || $idaa_loc.recovery_meetings.edit__event_obj}
<Event_obj_id_edit
lq__event_obj={lq__event_obj}
bind:obj_changed={$idaa_sess.recovery_meetings.obj_changed}

View File

@@ -17,6 +17,7 @@ let {
// import { onDestroy, onMount } from 'svelte';
import { fade } from 'svelte/transition';
import { browser } from '$app/environment';
import { goto } from '$app/navigation';
// *** Import other supporting libraries
@@ -37,6 +38,14 @@ if (!$idaa_slct.event_obj) {
}
// Create a copy of the event object
let orig_event_obj: any = { ...$idaa_slct.event_obj };
if (browser) {
// console.log(`$lq__event_obj = `, $lq__event_obj);
console.log(`$idaa_slct.event_obj = `, $idaa_slct.event_obj);
// orig_event_obj = { ...$idaa_slct.event_obj }; // Create a copy of the event object
console.log(`orig_event_obj = `, orig_event_obj);
// JSON.stringify($idaa_slct.event_obj) !== JSON.stringify(orig_event_obj)
}
if ($idaa_loc.recovery_meetings.edit__event_obj) {
$idaa_sess.recovery_meetings.edit__event_obj = $idaa_loc.recovery_meetings.edit__event_obj;
@@ -45,7 +54,6 @@ if ($idaa_loc.recovery_meetings.edit__event_obj) {
let prom_api__event_obj: any = $state();
let description_new_html = $state('');
let description_changed = $state(false);
let location_text_new_html = $state('');
@@ -512,6 +520,10 @@ async function handle_submit_form(event: any) {
disable_submit_btn = false;
$idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_sess.recovery_meetings.show__modal_view = true;
if (!$ae_loc.administrator_access && $ae_loc.site_cfg_json?.recovery_mtg_send_staff_new_email) {
send_staff_notification_email();
}
});
log_lvl = 0;
@@ -546,9 +558,9 @@ async function handle_submit_form(event: any) {
$idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_sess.recovery_meetings.show__modal_view = true;
// if (!$ae_loc.administrator_access && $ae_loc.site_cfg_json?.recovery_mtg_send_staff_update_email) {
if (!$ae_loc.administrator_access && $ae_loc.site_cfg_json?.recovery_mtg_send_staff_update_email) {
send_staff_notification_email();
// }
}
});
log_lvl = 0;
@@ -580,8 +592,9 @@ async function handle_delete_event_obj(
log_lvl: log_lvl
})
.then(function (event_obj_delete_result) {
$idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_sess.recovery_meetings.show__modal_view = false;
// $idaa_sess.recovery_meetings.show__modal_edit = false;
// $idaa_sess.recovery_meetings.show__modal_view = false;
$idaa_sess.recovery_meetings.edit__event_obj = false;
})
.catch(function (error) {
console.log('The result was null or false when trying to delete.', error);
@@ -590,6 +603,7 @@ async function handle_delete_event_obj(
// $idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_slct.event_id = null;
$idaa_slct.event_obj = null;
goto('/idaa/recovery_meetings', { replaceState: true });
});
return prom_api__event_obj;

View File

@@ -582,30 +582,18 @@ function preventDefault(fn) {
$idaa_slct.event_id = null;
$idaa_slct.event_obj = {};
// const url = new URL(location);
// url.searchParams.delete('event_id');
// history.pushState({}, '', url);
// $idaa_loc.recovery_meetings.show_main__options = false;
// $idaa_loc.recovery_meetings.show_list__event_obj_li = false;
// $idaa_loc.recovery_meetings.show_view__event_obj = false;
// $idaa_loc.recovery_meetings.show_edit__event_obj = true;
// $idaa_sess.recovery_meetings.show__modal_view = false;
// $idaa_sess.recovery_meetings.show__modal_edit = true;
// Get the users current timezone
// let timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
// let timezone = $ae_loc.timezone || 'UTC'; // Fallback to UTC if timezone is not set
let data_kv = {
name: 'NEW Recovery Meeting',
name: 'Change NEW Recovery Meeting Name',
// timezone: timezone,
};
if (log_lvl) {
console.log('Creating new event (recovery meeting) with data_kv:', data_kv);
}
events_func.create_ae_obj__event({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
@@ -616,7 +604,18 @@ function preventDefault(fn) {
console.log('New event (recovery meeting) created:', results);
}
$idaa_slct.event_id = results?.event_id_random;
$idaa_loc.recovery_meetings.edit_kv[$idaa_slct.event_id] = 'current';
$idaa_slct.event_obj = {
...results
};
$idaa_sess.recovery_meetings.edit__event_obj = $idaa_slct.event_id;
$idaa_loc.recovery_meetings.edit__event_obj = $idaa_slct.event_id;
// if (!$idaa_loc.recovery_meetings.edit_kv) {
// $idaa_loc.recovery_meetings.edit_kv = {};
// }
// $idaa_loc.recovery_meetings.edit_kv[$idaa_slct.event_id] = 'current';
// alert(`Event created successfully! ${$idaa_slct.event_id}`);
}).catch((error) => {
console.error('Error updating event (recovery meeting):', error);
alert('Failed to update event (recovery meeting).');