Various bug fixes and improvements. Now able to correctly create and delete Recovery Meetings.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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).');
|
||||
|
||||
Reference in New Issue
Block a user