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

@@ -552,13 +552,13 @@ export async function qry_ae_obj_li__event(
}
// Updated 2024-12-02
// Updated 2025-07-11
export async function create_ae_obj__event(
{
api_cfg,
account_id,
data_kv,
params={},
params = {},
try_cache = true,
log_lvl = 0
}: {
@@ -574,6 +574,11 @@ export async function create_ae_obj__event(
console.log(`*** create_ae_obj__event() *** account_id=${account_id}`);
}
if (!account_id) {
console.log(`ERROR: Events - Event - account_id required to create`);
return false;
}
ae_promises.create__event = await api.create_ae_obj_crud({
api_cfg: api_cfg,
obj_type: 'event',

View File

@@ -52,6 +52,10 @@ let idaa_local_data_struct: key_val = {
limit: 150,
offset: 0,
edit_kv: {}, // Used to track which archive objects are being edited
edit__archive_obj: null,
edit__archive_content_obj: null,
// qry__order_by: 'updated_on', // For the IDB index query
// qry__order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'name': 'ASC'}, // For the SQL query
},
@@ -61,6 +65,11 @@ let idaa_local_data_struct: key_val = {
hidden: 'not_hidden', // all, hidden, not_hidden
limit: 50,
offset: 0,
edit_kv: {}, // Used to track which post objects are being edited
edit__post_obj: null,
edit__post_comment_obj: null,
show_list__post_obj_li: true,
qry__enabled: 'enabled', // all, disabled, enabled
@@ -70,11 +79,13 @@ let idaa_local_data_struct: key_val = {
qry__order_by: 'updated_on', // For the IDB index query
qry__order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'title': 'ASC'}, // For the SQL query
edit_kv: {}, // Used to track which post objects are being edited
},
recovery_meetings: {
edit_kv: {},
edit_kv: {}, // Used to track which event objects are being edited
edit__event_obj: null,
qry__enabled: 'enabled', // all, disabled, enabled
qry__hidden: 'not_hidden', // all, hidden, not_hidden
qry__limit: 150,
@@ -117,6 +128,9 @@ let idaa_session_data_struct: key_val = {
bb: {
qry__status: null,
edit__post_obj: null,
show__inline_edit__post_obj: null,
show__modal_edit__post_id: null,
show__modal_view__post_id: null,
@@ -127,6 +141,9 @@ let idaa_session_data_struct: key_val = {
recovery_meetings: {
qry__status: null,
qry__fulltext_str: null,
edit__event_obj: null,
status_qry__last_request_str: null,
show__modal_edit: false,

View File

@@ -1,15 +1,24 @@
<script lang="ts">
interface Props {
log_lvl?: number;
}
let {
log_lvl = 0
}: Props = $props();
// *** Import Svelte specific
import { goto } from '$app/navigation';
// *** Import Aether core variables and functions
export let log_lvl: number = 0;
// *** Import other supporting libraries
// *** Import Aether specific variables and functions
// import type { key_val } from '$lib/ae_stores';
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, idaa_trig, idaa_prom } from '$lib/ae_idaa_stores';
import { posts_func } from '$lib/ae_posts/ae_posts_functions';
// let ae_promises: key_val = {};
// let ae_tmp: key_val = {};
// let ae_trigger: any = null;
@@ -38,7 +47,7 @@ if (log_lvl) console.log('** Component Loaded: ** Post Options');
<select
id="qry_limit__posts"
bind:value={$idaa_loc.bb.qry__limit}
on:change={() => {
onchange={() => {
$idaa_trig.post_li = true;
}}
class="
@@ -64,7 +73,7 @@ if (log_lvl) console.log('** Component Loaded: ** Post Options');
{#if $ae_loc.trusted_access && (!$idaa_loc.bb.qry__hidden || $idaa_loc.bb.qry__hidden == 'not_hidden')}
<button
type="button"
on:click={() => {
onclick={() => {
$idaa_loc.bb.qry__hidden = 'all';
$idaa_loc.bb.qry__limit = 100;
$idaa_trig.post_li = true;
@@ -81,7 +90,7 @@ if (log_lvl) console.log('** Component Loaded: ** Post Options');
{:else if $ae_loc.trusted_access && $idaa_loc.bb.qry__hidden != 'not_hidden'}
<button
type="button"
on:click={() => {
onclick={() => {
$idaa_loc.bb.qry__hidden = 'not_hidden';
$idaa_trig.post_li = true;
}}
@@ -99,7 +108,7 @@ if (log_lvl) console.log('** Component Loaded: ** Post Options');
{#if $ae_loc.administrator_access && (!$idaa_loc.bb.qry__enabled || $idaa_loc.bb.qry__enabled == 'enabled')}
<button
type="button"
on:click={() => {
onclick={() => {
$idaa_loc.bb.qry__enabled = 'all';
$idaa_loc.bb.qry__hidden = 'all';
$idaa_loc.bb.qry__limit = 500;
@@ -117,7 +126,7 @@ if (log_lvl) console.log('** Component Loaded: ** Post Options');
{:else if $ae_loc.administrator_access && $idaa_loc.bb.qry__enabled != 'enabled'}
<button
type="button"
on:click={() => {
onclick={() => {
$idaa_loc.bb.qry__enabled = 'enabled';
$idaa_trig.post_li = true;
}}
@@ -136,7 +145,7 @@ if (log_lvl) console.log('** Component Loaded: ** Post Options');
<button
type="button"
disabled={!$ae_loc.authenticated_access}
on:click={() => {
onclick={() => {
if (!confirm('Create new post?')) {
return false;
}
@@ -145,7 +154,7 @@ if (log_lvl) console.log('** Component Loaded: ** Post Options');
let data_kv = {
external_person_id: $idaa_loc.novi_uuid,
title: 'Change Me',
title: 'Change NEW Post Title',
full_name: $idaa_loc.novi_full_name,
email: $idaa_loc.novi_email,
enable: true,
@@ -153,6 +162,7 @@ if (log_lvl) console.log('** Component Loaded: ** Post Options');
if (log_lvl) {
console.log('Creating new post with data_kv:', data_kv);
}
posts_func.create_ae_obj__post({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
@@ -168,10 +178,12 @@ if (log_lvl) console.log('** Component Loaded: ** Post Options');
};
$idaa_sess.bb.edit__post_obj = $idaa_slct.post_id;
$idaa_loc.bb.edit__post_obj = $idaa_slct.post_id;
// if (!$idaa_loc.bb.edit_kv) {
// $idaa_loc.bb.edit_kv = {};
// }
// $idaa_loc.bb.edit_kv[$idaa_slct.post_id] = 'current';
// alert(`Post created successfully! ${$idaa_slct.post_id}`);
}).catch((error) => {
console.error('Error updating post:', error);

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).');