From deac79b861a5f718adc7cdc2fa5ab9df228abda6 Mon Sep 17 00:00:00 2001
From: Scott Idem
Date: Mon, 4 Nov 2024 15:29:16 -0500
Subject: [PATCH] Lots of work related to the IDAA Recovery Meetings. Better
pulling in off lookup list data.
---
src/lib/ae_core/core__countries.ts | 3 +-
src/lib/ae_core/core__country_subdivisions.ts | 35 +-
src/lib/ae_events/ae_events__event.ts | 14 +-
src/lib/db_events.ts | 15 +-
src/lib/element_tiptap_editor.svelte | 9 +-
.../(idaa)/recovery_meetings/+page.svelte | 92 ++--
.../ae_idaa_comp__event_obj_id_edit.svelte | 438 +++++++++---------
.../ae_idaa_comp__event_obj_id_view.svelte | 102 ++--
.../ae_idaa_comp__event_obj_qry.svelte | 4 +
9 files changed, 361 insertions(+), 351 deletions(-)
diff --git a/src/lib/ae_core/core__countries.ts b/src/lib/ae_core/core__countries.ts
index 903cbdb4..c59a8104 100644
--- a/src/lib/ae_core/core__countries.ts
+++ b/src/lib/ae_core/core__countries.ts
@@ -29,6 +29,7 @@ export async function load_ae_obj_li__country(
let limit: number = (params.qry__limit ?? 300); // Actual is 249 in 2024
let offset: number = (params.qry__offset ?? 0); // 0
+ let order_by_li = {'sort': 'DESC', 'english_short_name': 'ASC', 'alpha_2_code': 'ASC'};
let params_json: key_val = {};
@@ -43,7 +44,7 @@ export async function load_ae_obj_li__country(
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
enabled: enabled,
hidden: hidden,
- order_by_li: {'english_short_name': 'ASC'},
+ order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
diff --git a/src/lib/ae_core/core__country_subdivisions.ts b/src/lib/ae_core/core__country_subdivisions.ts
index 160eddf3..a04f8c71 100644
--- a/src/lib/ae_core/core__country_subdivisions.ts
+++ b/src/lib/ae_core/core__country_subdivisions.ts
@@ -8,27 +8,30 @@ let ae_promises: key_val = {};
// Updated 2024-10-14
export async function load_ae_obj_li__country_subdivision(
- {
- api_cfg,
- // account_id,
- params = {},
- try_cache = true,
- log_lvl = 0
- }: {
- api_cfg: any,
- // account_id: string,
- params?: key_val,
- try_cache?: boolean,
- log_lvl?: number
- }
- ) {
- console.log(`*** load_ae_obj_li__country_subdivision() ***`);
+ {
+ api_cfg,
+ // account_id,
+ params = {},
+ try_cache = true,
+ log_lvl = 0
+ }: {
+ api_cfg: any,
+ // account_id: string,
+ params?: key_val,
+ try_cache?: boolean,
+ log_lvl?: number
+ }
+ ) {
+ if (log_lvl) {
+ console.log(`*** load_ae_obj_li__country_subdivision() ***`);
+ }
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
let limit: number = (params.qry__limit ?? 300); // Actual is 249 in 2024
let offset: number = (params.qry__offset ?? 0); // 0
+ let order_by_li = {'sort': 'DESC', 'name': 'ASC', 'code': 'ASC'};
let params_json: key_val = {};
@@ -43,7 +46,7 @@ export async function load_ae_obj_li__country_subdivision(
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
enabled: enabled,
hidden: hidden,
- order_by_li: {'name': 'ASC', 'code': 'ASC'},
+ order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
diff --git a/src/lib/ae_events/ae_events__event.ts b/src/lib/ae_events/ae_events__event.ts
index 5d04199e..6319f584 100644
--- a/src/lib/ae_events/ae_events__event.ts
+++ b/src/lib/ae_events/ae_events__event.ts
@@ -510,13 +510,19 @@ export function db_save_ae_obj_li__event(
created_on: obj.created_on,
updated_on: obj.updated_on,
- // IDAA Recovery Meetings
+ // IDAA Recovery Meetings:
+ // Currently only really used for IDAA
contact_li_json: obj.contact_li_json,
external_person_id: obj.external_person_id,
physical: obj.physical,
virtual: obj.virtual,
+ recurring: obj.recurring,
+ recurring_start_time: obj.recurring_start_time,
+ recurring_end_time: obj.recurring_end_time,
+ recurring_text: obj.recurring_text,
+
weekday_sunday: obj.weekday_sunday,
weekday_monday: obj.weekday_monday,
weekday_tuesday: obj.weekday_tuesday,
@@ -525,7 +531,11 @@ export function db_save_ae_obj_li__event(
weekday_friday: obj.weekday_friday,
weekday_saturday: obj.weekday_saturday,
- recurring_start_time: obj.recurring_start_time,
+ attend_url: obj.attend_url,
+ attend_url_text: obj.attend_url_text,
+ attend_url_passcode: obj.attend_url_passcode,
+ attend_phone: obj.attend_phone,
+ attend_phone_passcode: obj.attend_phone_passcode,
// From SQL view
file_count: obj.file_count,
diff --git a/src/lib/db_events.ts b/src/lib/db_events.ts
index ace12b54..d69f6724 100644
--- a/src/lib/db_events.ts
+++ b/src/lib/db_events.ts
@@ -47,13 +47,20 @@ export interface Event {
created_on: Date;
updated_on?: null|Date;
- // IDAA Recovery Meetings
+ // IDAA Recovery Meetings:
+ // Currently only really used for IDAA
contact_li_json?: null|string[]; // full_name, email, phone_mobile, phone_home, phone_office, other_text
+ // contact_li_json_ext?: null|string;
external_person_id?: null|string;
physical?: null|boolean;
virtual?: null|boolean;
+ recurring?: null|boolean;
+ recurring_start_time?: null|string;
+ recurring_end_time?: null|string;
+ recurring_text?: null|string;
+
weekday_sunday?: null|boolean;
weekday_monday?: null|boolean;
weekday_tuesday?: null|boolean;
@@ -62,7 +69,11 @@ export interface Event {
weekday_friday?: null|boolean;
weekday_saturday?: null|boolean;
- recurring_start_time?: null|string;
+ attend_url?: null|string;
+ attend_url_text?: null|string;
+ attend_url_passcode?: null|string;
+ attend_phone?: null|string;
+ attend_phone_passcode?: null|string;
// Additional fields for convenience (database views)
file_count?: null|number;
diff --git a/src/lib/element_tiptap_editor.svelte b/src/lib/element_tiptap_editor.svelte
index 8436e574..83553768 100644
--- a/src/lib/element_tiptap_editor.svelte
+++ b/src/lib/element_tiptap_editor.svelte
@@ -19,6 +19,7 @@ import "./element_tiptap_editor.scss";
export let html_text: string = '';
export let default_minimal: boolean = false;
export let show_menu: boolean = true;
+export let placeholder: string = 'Type your text here...';
if (default_minimal) {
show_menu = false;
@@ -415,7 +416,13 @@ function getContent() {
+ >
+
'}
+ >{placeholder}
+
diff --git a/src/routes/idaa/(idaa)/recovery_meetings/+page.svelte b/src/routes/idaa/(idaa)/recovery_meetings/+page.svelte
index a788eba4..aa0ed8b9 100644
--- a/src/routes/idaa/(idaa)/recovery_meetings/+page.svelte
+++ b/src/routes/idaa/(idaa)/recovery_meetings/+page.svelte
@@ -28,15 +28,8 @@ import Comp__event_obj_id_view from './ae_idaa_comp__event_obj_id_view.svelte';
let event_id_random_li: Array;
-// $: lq__event_obj_li = liveQuery(async () => {
-// let results = await db_events.events
-// .where('account_id')
-// .equals($slct.account_id)
-// .sortBy('name');
-
-// return results;
-// });
+// Functions and Logic
$: lq__event_obj = liveQuery(async () => {
let results = await db_events.events
.get($idaa_slct.event_id);
@@ -45,12 +38,7 @@ $: lq__event_obj = liveQuery(async () => {
});
-
-
-// Functions and Logic
$: lq_new__event_obj_li = liveQuery(async () => {
- console.log('Trying... HERE!!! BEGIN');
-
let link_to_type: string = 'account';
let link_to_id: string = $slct.account_id;
console.log(`link_to_type: ${link_to_type}; link_to_id: ${link_to_id}`);
@@ -74,25 +62,8 @@ $: lq_new__event_obj_li = liveQuery(async () => {
console.log('Trying... Nothing to load');
return null;
}
- console.log('Trying... HERE!!! END');
});
-// $: lq_bulk__event_obj_li = liveQuery(async () => {
-// console.log('Trying... HERE!!! BULK BEGIN');
-
-// if (event_id_random_li.length) {
-// console.log(`Trying bulkGet:`, event_id_random_li);
-// let results = await db_events.events
-// .bulkGet(event_id_random_li);
-
-// return results;
-// } else {
-// console.log('Trying... Nothing to load');
-// return null;
-// }
-// console.log('Trying... HERE!!! BULK END');
-// });
-
@@ -134,10 +105,38 @@ $: lq_new__event_obj_li = liveQuery(async () => {
title="{$lq__event_obj?.name} - {$lq__event_obj?.id}"
bind:open={$idaa_sess.recovery_meetings.show__modal_edit}
autoclose={false}
+ placement="top-center"
size="xl"
- class="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"
+ 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"
>
+
+
+
+ {#if $ae_loc.trusted_access || $lq__event_obj?.external_person_id === $ae_loc.novi_uuid || $lq__event_obj?.contact_li_json[0]?.email === $ae_loc.novi_email}
+
+
+
+ {/if}
+
+ Edit Meeting: {$lq__event_obj?.name}
+
+
+
+
@@ -161,15 +160,42 @@ $: lq_new__event_obj_li = liveQuery(async () => {
-
+
+
+
+
+
+ {#if $ae_loc.trusted_access || $lq__event_obj?.external_person_id === $ae_loc.novi_uuid || $lq__event_obj?.contact_li_json[0].email === $ae_loc.novi_email}
+
+ {/if}
+ {$lq__event_obj?.name}
+
+
+
+
diff --git a/src/routes/idaa/(idaa)/recovery_meetings/ae_idaa_comp__event_obj_id_edit.svelte b/src/routes/idaa/(idaa)/recovery_meetings/ae_idaa_comp__event_obj_id_edit.svelte
index 11377876..6ebb46c5 100644
--- a/src/routes/idaa/(idaa)/recovery_meetings/ae_idaa_comp__event_obj_id_edit.svelte
+++ b/src/routes/idaa/(idaa)/recovery_meetings/ae_idaa_comp__event_obj_id_edit.svelte
@@ -21,9 +21,7 @@ type key_val = {
[key: string]: any;
};
-let create_event_obj_promise: any;
-let delete_event_obj_promise: any;
-let update_event_obj_promise: any;
+let prom_api__event_obj: any;
let disable_submit_btn = true;
@@ -148,9 +146,11 @@ if ($ae_loc.lu_time_zone_list && $ae_loc.lu_time_zone_list.length > 0) {
// });
}
-// $ae_loc.lu_country_list = [];
-if ($ae_loc.lu_country_list && $ae_loc.lu_country_list.length > 150) {
- // console.log('Already have country list!', $ae_loc.lu_country_list);
+let lu_country_list = localStorage.getItem('lu_country_list') ? JSON.parse(localStorage.getItem('lu_country_list')) : [];
+$ae_loc.lu_country_list = [];
+// Refresh the list at least 20% of the time.
+if (lu_country_list && lu_country_list.length > 50 && Math.random() > 0.8) {
+ console.log(`Already have country list! ${lu_country_list.length}`, lu_country_list);
} else {
console.log('No country list');
@@ -160,64 +160,44 @@ if ($ae_loc.lu_country_list && $ae_loc.lu_country_list.length > 150) {
})
.then(function (lu_country_li_get_result) {
if (lu_country_li_get_result) {
- $ae_loc.lu_country_list = lu_country_li_get_result;
- console.log(`Country list:`, $ae_loc.lu_country_list);
- console.log($ae_loc.lu_country_list[0]);
- console.log($ae_loc.lu_country_list[10]);
+ lu_country_list = lu_country_li_get_result;
+ localStorage.setItem('lu_country_list', JSON.stringify(lu_country_li_get_result));
+ if (log_lvl) {
+ console.log(`Country list:`, lu_country_list);
+ }
} else {
console.log(`No countries returned!`);
- $ae_loc.lu_country_list = [];
+ // $ae_loc.lu_country_list = [];
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
-
- // let lu_country_li_get_promise = api.get_ae_obj_li_for_obj_id_crud({
- // api_cfg: $ae_api,
- // obj_type: 'lu', // "lu" = a lookup table
- // for_obj_type: 'country',
- // enabled: null,
- // hidden: null,
- // // order_by_li: {'sort': 'DESC', 'english_short_name': 'ASC'},
- // log_lvl: 1
- // })
-
- // .then(function (lu_country_li_get_result) {
- // if (lu_country_li_get_result) {
- // $ae_loc.lu_country_list = lu_country_li_get_result;
- // console.log(`Country list:`, $ae_loc.lu_country_list);
- // console.log($ae_loc.lu_country_list[0]);
- // console.log($ae_loc.lu_country_list[10]);
- // } else {
- // console.log(`No countries returned!`);
- // $ae_loc.lu_country_list = [];
- // }
- // })
- // .catch(function (error) {
- // console.log('No results returned or failed.', error);
- // });
}
+let lu_country_subdivision_list = localStorage.getItem('lu_country_subdivision_list') ? JSON.parse(localStorage.getItem('lu_country_subdivision_list')) : [];
$ae_loc.lu_country_subdivision_list = [];
-if ($ae_loc.lu_country_subdivision_list && $ae_loc.lu_country_subdivision_list.length > 0) {
- // console.log('Already have country subdivision list!', $ae_loc.lu_country_subdivision_list);
+// Refresh the list at least 20% of the time.
+if (lu_country_subdivision_list && lu_country_subdivision_list.length > 50 && Math.random() > 0.8) {
+ console.log(`Already have country subdivision list! ${lu_country_subdivision_list.length}`, lu_country_subdivision_list);
} else {
- console.log('No country subdivision list');
+ console.log('No country subdivision list. Requesting new list.');
let lu_country_subdivision_li_get_promise = core_func.load_ae_obj_li__country_subdivision({
api_cfg: $ae_api,
- log_lvl: 2
+ log_lvl: 1
})
.then(function (lu_country_subdivision_li_get_result) {
+ /* We need to save the country subdivision list to localStore */
if (lu_country_subdivision_li_get_result) {
- $ae_loc.lu_country_subdivision_list = lu_country_subdivision_li_get_result;
- console.log(`Country subdivision list:`, $ae_loc.lu_country_subdivision_list);
- console.log($ae_loc.lu_country_subdivision_list[0]);
- console.log($ae_loc.lu_country_subdivision_list[10]);
+ lu_country_subdivision_list = lu_country_subdivision_li_get_result;
+ localStorage.setItem('lu_country_subdivision_list', JSON.stringify(lu_country_subdivision_li_get_result));
+ if (log_lvl) {
+ console.log(`Country subdivision list:`, lu_country_subdivision_list);
+ }
} else {
console.log(`No country subdivisions returned!`);
- $ae_loc.lu_country_subdivision_list = [];
+ // $ae_loc.lu_country_subdivision_list = [];
}
})
.catch(function (error) {
@@ -242,8 +222,9 @@ if ($ae_loc.lu_country_subdivision_list && $ae_loc.lu_country_subdivision_list.l
$: if ($idaa_slct.event_obj) {
- console.log('Selected Event object changed?');
- console.log($idaa_slct.event_obj);
+ if (log_lvl) {
+ console.log('Selected Event object changed?', $idaa_slct.event_obj);
+ }
if ($idaa_slct.event_obj == null) {
// $idaa_slct.event_obj = {code: null, name: null, description: null, start_datetime: null, end_datetime: null, notes: null};
@@ -261,201 +242,194 @@ async function handle_submit_form(event: any) {
let form_data = new FormData(event.target);
console.log(form_data);
- let event_meeting_data = ae_util.extract_prefixed_form_data({prefix: null, form_data: form_data, trim_values: true, bool_tf_str: true, log_lvl: 0});
- console.log(event_meeting_data);
+ let event_meeting_fd = ae_util.extract_prefixed_form_data({prefix: null, form_data: form_data, trim_values: true, bool_tf_str: true, log_lvl: 0});
+ console.log(event_meeting_fd);
- let event_data: key_val = {};
+ let event_do: key_val = {}; // Data out for API object
- event_data['account_id_random'] = $ae_loc.account_id;
+ event_do['account_id_random'] = $ae_loc.account_id;
- event_data['name'] = event_meeting_data.name;
+ event_do['name'] = event_meeting_fd.name;
// Check if the description_new_html exists and is a string
if (typeof $idaa_slct.event_obj.description_new_html === 'string') {
console.log('New description is a string');
- event_data['description'] = $idaa_slct.event_obj.description_new_html;
+ event_do['description'] = $idaa_slct.event_obj.description_new_html;
} else {
console.log('New description is not a string. Do nothing.');
- // event_data['description'] = event_meeting_data.description;
+ // event_do['description'] = event_meeting_fd.description;
}
- event_data['type'] = event_meeting_data.type;
- event_data['physical'] = !!event_meeting_data.physical;
- event_data['virtual'] = !!event_meeting_data.virtual;
+ event_do['type'] = event_meeting_fd.type;
+ event_do['physical'] = !!event_meeting_fd.physical;
+ event_do['virtual'] = !!event_meeting_fd.virtual;
let address: key_val = {};
- address['name'] = event_meeting_data.address_name;
- address['line_1'] = event_meeting_data.address_line_1;
- address['line_2'] = event_meeting_data.address_line_2;
- address['line_3'] = event_meeting_data.address_line_3;
- address['city'] = event_meeting_data.address_city;
- address['country_subdivision_code'] = event_meeting_data.address_country_subdivision_code;
- if (event_meeting_data.address_country_subdivision_code) {
- address['country_subdivision_code'] = event_meeting_data.address_country_subdivision_code;
+ address['name'] = event_meeting_fd.address_name;
+ address['line_1'] = event_meeting_fd.address_line_1;
+ address['line_2'] = event_meeting_fd.address_line_2;
+ address['line_3'] = event_meeting_fd.address_line_3;
+ address['city'] = event_meeting_fd.address_city;
+ address['country_subdivision_code'] = event_meeting_fd.address_country_subdivision_code;
+ if (event_meeting_fd.address_country_subdivision_code) {
+ address['country_subdivision_code'] = event_meeting_fd.address_country_subdivision_code;
- let country_subdivision_data = ae_util.get_obj_li_w_match_prop({'obj_li': $ae_loc.lu_country_subdivision_list, 'property': 'code', 'value': event_meeting_data.address_country_subdivision_code});
+ let country_subdivision_data = ae_util.get_obj_li_w_match_prop({'obj_li': lu_country_subdivision_list, 'property': 'code', 'value': event_meeting_fd.address_country_subdivision_code});
address['state_province'] = country_subdivision_data[0].name; // Assume there is only one match
// address['country_subdivision_name'] = country_subdivision_data[0].name;
}
- address['postal_code'] = event_meeting_data.address_postal_code;
- if (event_meeting_data.address_country_alpha_2_code) {
- address['country_alpha_2_code'] = event_meeting_data.address_country_alpha_2_code;
+ address['postal_code'] = event_meeting_fd.address_postal_code;
+ if (event_meeting_fd.address_country_alpha_2_code) {
+ address['country_alpha_2_code'] = event_meeting_fd.address_country_alpha_2_code;
- let country_data = ae_util.get_obj_li_w_match_prop({'obj_li': $ae_loc.lu_country_list, 'property': 'alpha_2_code', 'value': event_meeting_data.address_country_alpha_2_code});
+ let country_data = ae_util.get_obj_li_w_match_prop({'obj_li': lu_country_list, 'property': 'alpha_2_code', 'value': event_meeting_fd.address_country_alpha_2_code});
console.log(country_data);
address['country'] = country_data[0].english_short_name; // Assume there is only one match
// address['country_name'] = country_data[0].english_short_name;
}
- // event_data['location_address_json'] = address;
+ event_do['location_address_json'] = address;
// Check if the location_text_new_html exists and is a string
if (typeof $idaa_slct.event_obj.location_text_new_html === 'string') {
- event_data['location_text'] = $idaa_slct.event_obj.location_text_new_html;
+ event_do['location_text'] = $idaa_slct.event_obj.location_text_new_html;
} else {
console.log('New location text is not a string. Do nothing.');
}
- event_data['attend_url'] = event_meeting_data.attend_url;
- event_data['attend_url_passcode'] = event_meeting_data.attend_url_passcode;
- event_data['attend_phone'] = event_meeting_data.attend_phone;
- event_data['attend_phone_passcode'] = event_meeting_data.attend_phone_passcode;
+ event_do['attend_url'] = event_meeting_fd.attend_url;
+ event_do['attend_url_passcode'] = event_meeting_fd.attend_url_passcode;
+ event_do['attend_phone'] = event_meeting_fd.attend_phone;
+ event_do['attend_phone_passcode'] = event_meeting_fd.attend_phone_passcode;
// Check if the attend_text_new_html exists and is a string
if (typeof $idaa_slct.event_obj.attend_text_new_html === 'string') {
- event_data['attend_text'] = $idaa_slct.event_obj.attend_text_new_html;
+ event_do['attend_text'] = $idaa_slct.event_obj.attend_text_new_html;
} else {
console.log('New attend text is not a string. Do nothing.');
}
- event_data['timezone'] = event_meeting_data.timezone;
+ event_do['timezone'] = event_meeting_fd.timezone;
- event_data['recurring'] = !!event_meeting_data.recurring;
- event_data['recurring_pattern'] = event_meeting_data.recurring_pattern;
+ event_do['recurring'] = !!event_meeting_fd.recurring;
+ event_do['recurring_pattern'] = event_meeting_fd.recurring_pattern;
// NOTE: !! converts to boolean based on truthiness
- event_data['weekday_sunday'] = !!event_meeting_data.weekday_sunday;
- event_data['weekday_monday'] = !!event_meeting_data.weekday_monday;
- event_data['weekday_tuesday'] = !!event_meeting_data.weekday_tuesday;
- event_data['weekday_wednesday'] = !!event_meeting_data.weekday_wednesday;
- event_data['weekday_thursday'] = !!event_meeting_data.weekday_thursday;
- event_data['weekday_friday'] = !!event_meeting_data.weekday_friday;
- event_data['weekday_saturday'] = !!event_meeting_data.weekday_saturday;
- // event_data['weekday_sunday'] = event_meeting_data.weekday_sunday;
- // event_data['weekday_monday'] = event_meeting_data.weekday_monday;
- // event_data['weekday_tuesday'] = event_meeting_data.weekday_tuesday;
- // event_data['weekday_wednesday'] = event_meeting_data.weekday_wednesday;
- // event_data['weekday_thursday'] = event_meeting_data.weekday_thursday;
- // event_data['weekday_friday'] = event_meeting_data.weekday_friday;
- // event_data['weekday_saturday'] = event_meeting_data.weekday_saturday;
+ event_do['weekday_sunday'] = !!event_meeting_fd.weekday_sunday;
+ event_do['weekday_monday'] = !!event_meeting_fd.weekday_monday;
+ event_do['weekday_tuesday'] = !!event_meeting_fd.weekday_tuesday;
+ event_do['weekday_wednesday'] = !!event_meeting_fd.weekday_wednesday;
+ event_do['weekday_thursday'] = !!event_meeting_fd.weekday_thursday;
+ event_do['weekday_friday'] = !!event_meeting_fd.weekday_friday;
+ event_do['weekday_saturday'] = !!event_meeting_fd.weekday_saturday;
- if (event_meeting_data['recurring_start_time'] ) {
- event_data['recurring_start_time'] = event_meeting_data.recurring_start_time;
+ if (event_meeting_fd['recurring_start_time'] ) {
+ event_do['recurring_start_time'] = event_meeting_fd.recurring_start_time;
}
- if (event_meeting_data['recurring_end_time']) {
- event_data['recurring_end_time'] = event_meeting_data.recurring_end_time;
+ if (event_meeting_fd['recurring_end_time']) {
+ event_do['recurring_end_time'] = event_meeting_fd.recurring_end_time;
}
// Check if the recurring_text_new_html exists and is a string
if (typeof $idaa_slct.event_obj.recurring_text_new_html === 'string') {
- event_data['recurring_text'] = $idaa_slct.event_obj.recurring_text_new_html;
+ event_do['recurring_text'] = $idaa_slct.event_obj.recurring_text_new_html;
} else {
console.log('New recurring text is not a string. Do nothing.');
}
- console.log(event_data['recurring_text']);
- if (!event_data['recurring_text'] || event_data['recurring_text'].includes('*gen*')) {
+ console.log(event_do['recurring_text']);
+ if (!event_do['recurring_text'] || event_do['recurring_text'].includes('*gen*')) {
let days_of_week = [];
- if (event_data['weekday_sunday']) {
+ if (event_do['weekday_sunday']) {
days_of_week.push('Sunday');
}
- if (event_data['weekday_monday']) {
+ if (event_do['weekday_monday']) {
days_of_week.push('Monday');
}
- if (event_data['weekday_tuesday']) {
+ if (event_do['weekday_tuesday']) {
days_of_week.push('Tuesday');
}
- if (event_data['weekday_wednesday']) {
+ if (event_do['weekday_wednesday']) {
days_of_week.push('Wednesday');
}
- if (event_data['weekday_thursday']) {
+ if (event_do['weekday_thursday']) {
days_of_week.push('Thursday');
}
- if (event_data['weekday_friday']) {
+ if (event_do['weekday_friday']) {
days_of_week.push('Friday');
}
- if (event_data['weekday_saturday']) {
+ if (event_do['weekday_saturday']) {
days_of_week.push('Saturday');
}
let current_date_iso = ae_util.iso_datetime_formatter(new Date(), 'YYYY-MM-DD');
- // event_data['recurring_text'] = `This meeting occurs every ${days_of_week.join(', ')} at ${ae_util.iso_datetime_formatter(`${current_date_iso} ${event_data['recurring_start_time']}`, 'time_short_no_leading')} to ${ae_util.iso_datetime_formatter(`${current_date_iso} ${event_data['recurring_end_time']}`, 'time_short_no_leading')}.`;
+ // event_do['recurring_text'] = `This meeting occurs every ${days_of_week.join(', ')} at ${ae_util.iso_datetime_formatter(`${current_date_iso} ${event_do['recurring_start_time']}`, 'time_short_no_leading')} to ${ae_util.iso_datetime_formatter(`${current_date_iso} ${event_do['recurring_end_time']}`, 'time_short_no_leading')}.`;
- // event_data['recurring_text'] = `This meeting occurs every ${days_of_week.join(', ')} at ${ae_util.iso_datetime_formatter(`${current_date_iso} ${event_data['recurring_start_time']}`, 'time_short_no_leading')}.`;
+ // event_do['recurring_text'] = `This meeting occurs every ${days_of_week.join(', ')} at ${ae_util.iso_datetime_formatter(`${current_date_iso} ${event_do['recurring_start_time']}`, 'time_short_no_leading')}.`;
- event_data['recurring_text'] = `*gen* ${days_of_week.join(', ')} at ${ae_util.iso_datetime_formatter(`${current_date_iso} ${event_data['recurring_start_time']}`, 'time_short_no_leading')}`;
+ event_do['recurring_text'] = `*gen* ${days_of_week.join(', ')} at ${ae_util.iso_datetime_formatter(`${current_date_iso} ${event_do['recurring_start_time']}`, 'time_short_no_leading')}`;
}
- event_data['external_person_id'] = event_meeting_data.external_person_id; // NOTE: Defaults to the Novi user that created/owns this event
+ event_do['external_person_id'] = event_meeting_fd.external_person_id; // NOTE: Defaults to the Novi user that created/owns this event
- event_data['contact_li_json'] = [];
+ event_do['contact_li_json'] = [];
let contact_1: key_val = {};
- // contact_1['external_person_id'] = event_meeting_data.external_person_id; // NOTE: From the Novi user that created/owns this event
- contact_1['full_name'] = event_meeting_data.contact_1_full_name; // NOTE: From the Novi user that created/owns this event
- contact_1['email'] = event_meeting_data.contact_1_email; // NOTE: From the Novi user that created/owns this event
- if (event_meeting_data.contact_1_phone_mobile) {
- contact_1['phone_mobile'] = event_meeting_data.contact_1_phone_mobile; // NOTE: From the Novi user that created/owns this event, but allow them to change or hide it
+ // contact_1['external_person_id'] = event_meeting_fd.external_person_id; // NOTE: From the Novi user that created/owns this event
+ contact_1['full_name'] = event_meeting_fd.contact_1_full_name; // NOTE: From the Novi user that created/owns this event
+ contact_1['email'] = event_meeting_fd.contact_1_email; // NOTE: From the Novi user that created/owns this event
+ if (event_meeting_fd.contact_1_phone_mobile) {
+ contact_1['phone_mobile'] = event_meeting_fd.contact_1_phone_mobile; // NOTE: From the Novi user that created/owns this event, but allow them to change or hide it
}
- if (event_meeting_data.contact_1_phone_home) {
- contact_1['phone_home'] = event_meeting_data.contact_1_phone_home;
+ if (event_meeting_fd.contact_1_phone_home) {
+ contact_1['phone_home'] = event_meeting_fd.contact_1_phone_home;
}
- if (event_meeting_data.contact_1_phone_office) {
- contact_1['phone_office'] = event_meeting_data.contact_1_phone_office;
+ if (event_meeting_fd.contact_1_phone_office) {
+ contact_1['phone_office'] = event_meeting_fd.contact_1_phone_office;
}
- // event_data['contact_li_json'].push(contact_1);
+ event_do['contact_li_json'].push(contact_1);
let contact_2: key_val = {};
- contact_2['full_name'] = event_meeting_data.contact_2_full_name;
- contact_2['email'] = event_meeting_data.contact_2_email;
- if (event_meeting_data.contact_2_phone_mobile) {
- contact_2['phone_mobile'] = event_meeting_data.contact_2_phone_mobile;
+ contact_2['full_name'] = event_meeting_fd.contact_2_full_name;
+ contact_2['email'] = event_meeting_fd.contact_2_email;
+ if (event_meeting_fd.contact_2_phone_mobile) {
+ contact_2['phone_mobile'] = event_meeting_fd.contact_2_phone_mobile;
}
- if (event_meeting_data.contact_2_phone_home) {
- contact_2['phone_home'] = event_meeting_data.contact_2_phone_home;
+ if (event_meeting_fd.contact_2_phone_home) {
+ contact_2['phone_home'] = event_meeting_fd.contact_2_phone_home;
}
- if (event_meeting_data.contact_2_phone_office) {
- contact_2['phone_office'] = event_meeting_data.contact_2_phone_office;
+ if (event_meeting_fd.contact_2_phone_office) {
+ contact_2['phone_office'] = event_meeting_fd.contact_2_phone_office;
}
- // event_data['contact_li_json'].push(contact_2);
+ event_do['contact_li_json'].push(contact_2);
- event_data['hide'] = !!event_meeting_data.hide;
- event_data['priority'] = !!event_meeting_data.priority;
- if (event_meeting_data['sort']) {
- event_data['sort'] = Number(event_meeting_data.sort);
+ event_do['hide'] = !!event_meeting_fd.hide;
+ event_do['priority'] = !!event_meeting_fd.priority;
+ if (event_meeting_fd['sort']) {
+ event_do['sort'] = Number(event_meeting_fd.sort);
}
- if (event_data['group']) {
- event_data['group'] = event_meeting_data.group;
+ if (event_meeting_fd['group']) {
+ event_do['group'] = event_meeting_fd.group;
} else {
- event_data['group'] = null;
+ event_do['group'] = null;
}
- if (event_meeting_data['enable']) {
- event_data['enable'] = !!event_meeting_data.enable;
+ if (event_meeting_fd['enable']) {
+ event_do['enable'] = !!event_meeting_fd.enable;
}
// Check if the notes_new_html exists and is a string
if (typeof $idaa_slct.event_obj.notes_new_html === 'string') {
- event_data['notes'] = $idaa_slct.event_obj.notes_new_html;
+ event_do['notes'] = $idaa_slct.event_obj.notes_new_html;
} else {
console.log('New notes is not a string. Do nothing.');
}
- console.log(event_data);
+ console.log(event_do);
if (!$idaa_slct.event_id) {
- create_event_obj_promise = api.create_ae_obj_crud({
+ prom_api__event_obj = api.create_ae_obj_crud({
api_cfg: $ae_api,
obj_type: 'event',
- fields: event_data,
+ fields: event_do,
key: $ae_api.api_crud_super_key,
log_lvl: 2
})
@@ -483,30 +457,19 @@ async function handle_submit_form(event: any) {
return false;
});
- return create_event_obj_promise;
+ return prom_api__event_obj;
} else {
- events_func.update_ae_obj__event({
+ prom_api__event_obj = events_func.update_ae_obj__event({
api_cfg: $ae_api,
event_id: $idaa_slct.event_id,
- data_kv: event_data,
+ data_kv: event_do,
log_lvl: log_lvl
})
-
-
-
- // update_event_obj_promise = api.update_ae_obj_id_crud({
- // api_cfg: $ae_api,
- // obj_type: 'event',
- // obj_id: $idaa_slct.event_id,
- // fields: event_data,
- // key: $ae_api.api_crud_super_key,
- // return_obj: true,
- // log_lvl: 2
- // })
.then(function (event_obj_update_result) {
if (!event_obj_update_result) {
console.log('The result was null or false.');
+ disable_submit_btn = false; // Enable the submit button even if something didn't go right
return false;
}
@@ -527,40 +490,9 @@ async function handle_submit_form(event: any) {
return false;
});
- return update_event_obj_promise;
+ return prom_api__event_obj;
}
-
-
- // if (!$idaa_slct.event_id) {
- // event_meeting_data['event_id_random'] = $idaa_slct.event_id;
- // event_meeting_data['enable'] = true;
-
- // create_event_obj_promise = await create_event_obj({event_id: $idaa_slct.event_id, data: event_meeting_data})
- // console.log(create_event_obj_promise);
- // $idaa_slct.event_id = create_event_obj_promise;
-
- // dispatch(
- // 'created__event_obj',
- // {
- // event_id: $idaa_slct.event_id,
- // }
- // );
- // } else {
- // update_event_obj_promise = await update_event_obj({event_id: $idaa_slct.event_id, data: event_meeting_data, log_lvl: 0})
- // console.log(update_event_obj_promise);
-
- // dispatch(
- // 'updated__event_obj',
- // {
- // event_id: $idaa_slct.event_id,
- // }
- // );
- // }
-
- // post_promise = null;
- // update_event_obj_promise = null;
-
disable_submit_btn = false;
return true;
@@ -569,7 +501,7 @@ async function handle_submit_form(event: any) {
async function handle_delete_event_obj({event_id, method='disable'}) {
console.log('*** handle_delete_event_obj() ***');
- delete_event_obj_promise = api.delete_ae_obj_id_crud({
+ prom_api__event_obj = api.delete_ae_obj_id_crud({
api_cfg: $ae_api,
obj_type: 'event',
obj_id: event_id,
@@ -594,7 +526,7 @@ async function handle_delete_event_obj({event_id, method='disable'}) {
console.log('The result was null or false when trying to delete.', error);
});
- return delete_event_obj_promise;
+ return prom_api__event_obj;
}
@@ -607,11 +539,11 @@ async function handle_delete_event_obj({event_id, method='disable'}) {