diff --git a/src/lib/ae_stores.ts b/src/lib/ae_stores.ts index a7a8cd00..3ecbaa19 100644 --- a/src/lib/ae_stores.ts +++ b/src/lib/ae_stores.ts @@ -34,6 +34,14 @@ export type key_val = { }; // export type key_val = key_val; + +import { html__not_set } from './ae_string_snippets'; + +export let ae_html = + { + 'not_set': html__not_set, + }; + // *** BEGIN *** Longer-term app data. This should be stored to local storage. export let ae_app_local_data_struct: key_val = { 'ver': '2024-06-26_13', diff --git a/src/lib/ae_string_snippets.ts b/src/lib/ae_string_snippets.ts new file mode 100644 index 00000000..b6bbcf99 --- /dev/null +++ b/src/lib/ae_string_snippets.ts @@ -0,0 +1,13 @@ +// These are shared snippets of text, This is mostly HTML and CSS. + +let html__not_set = ` +-- not set -- + +`; + + +export { + html__not_set, +}; \ No newline at end of file diff --git a/src/lib/ae_utils.ts b/src/lib/ae_utils.ts index 5bc2def3..46e1c31b 100644 --- a/src/lib/ae_utils.ts +++ b/src/lib/ae_utils.ts @@ -1,4 +1,7 @@ -import dayjs from 'dayjs'; +// Import external files first. Eventually this will be broken up in to smaller files. +import { process_permission_checks } from './ae_utils__perm_checks'; +import { iso_datetime_formatter } from './ae_utils__datetime_format'; + type key_str = { [key: string]: string; @@ -8,135 +11,6 @@ type key_val = { [key: string]: any; }; -export let iso_datetime_formatter = function iso_datetime_formatter( - raw_datetime: null|string|Date = null, - named_format: string = 'datetime_iso_no_seconds', // date_iso, datetime_iso_no_seconds - ) { - // console.log('*** iso_datetime_formatter() ***'); - - // https://en.wikipedia.org/wiki/ISO_8601 - // https://day.js.org/docs/en/display/format - // ISO 8601-1:2019 includes the T before the time portion - // ISO 8601-1:2019 midnight may only be referred to as "00:00", corresponding to the beginning of a calendar day - // and "24:00" is no longer allowed corresponding to the end of a day - // 60 is only used to denote an added leap second - - // ISO 8601 UTC: 2021-03-04T19:04:44+00:00 - // ISO 8601 UTC: 2021-03-04T19:04:44Z - // ISO 8601 UTC: 20210304T190444Z - - //datetime_iso 'YYYY-MM-DD HH:mm:ss' - //datetime_iso_12 'YYYY-MM-DD hh:mm:ss A' - //datetime_iso_12_short 'YY-MM-DD hh:mm A' - //datetime_iso_tz 'YYYY-MM-DD HH:mm:ss' - - //datetime_long 'dddd, MMMM D, YYYY hh:mm:ss A' - //datetime_medium 'ddd, MMM D, YYYY hh:mm:ss A' - //datetime_short 'MMM D, YY hh:mm A' - - //date_iso 'YYYY-MM-DD' - - //date_long 'dddd, MMMM D, YYYY' - //date_medium 'ddd, MMM D, YYYY' - //date_short 'MMM D, YY' - - //time_iso 'HH:mm:ss' - //time_iso_12 'hh:mm:ss A' - - //time_long 'hh:mm:ss A' - //time_medium 'h:m:s A' - //time_short 'hh:mm A' - - //dayjs(raw_datetime).format('dddd, MMMM D, YYYY hh:mm:ss A'); - - if (!raw_datetime) { - raw_datetime = new Date(); // Get the current datetime if one was not passed. - } - - let datetime_string = null; - - switch (named_format) { - case 'datetime_iso': - datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss'); - break; - case 'datetime_iso_no_seconds': - datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm'); - break; - case 'datetime_iso_12_short': - datetime_string = dayjs(raw_datetime).format('YY-MM-DD hh:mm A'); - break; - case 'datetime_iso_12_short_month': - datetime_string = dayjs(raw_datetime).format('MM-DD hh:mm A'); - break; - case 'datetime_short': - datetime_string = dayjs(raw_datetime).format('MMM D, YY hh:mm A'); - break; - case 'datetime_medium': - datetime_string = dayjs(raw_datetime).format('MMM D, YYYY h:mm A'); - break; - case 'datetime_long': - datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY hh:mm A'); - break; - case 'datetime_short_month': - datetime_string = dayjs(raw_datetime).format('MMM D hh:mm A'); - break; - case 'datetime_long_month': - datetime_string = dayjs(raw_datetime).format('MMMM D hh:mm A'); - break; - case 'datetime_short_day': - datetime_string = dayjs(raw_datetime).format('D hh:mm A'); - break; - case 'date_iso': - datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD'); - break; - case 'date_long_month_day': - datetime_string = dayjs(raw_datetime).format('MMMM D'); - break; - case 'date_short': - datetime_string = dayjs(raw_datetime).format('MMM D, YY'); - break; - case 'date_short_no_year': - datetime_string = dayjs(raw_datetime).format('MMM D'); - break; - case 'date_long': - datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY'); - break; - case 'date_full': - datetime_string = dayjs(raw_datetime).format('dddd, MMMM D, YYYY'); - break; - case 'date_full_no_year': - datetime_string = dayjs(raw_datetime).format('dddd, MMMM D'); - break; - case 'time_iso': - datetime_string = dayjs(raw_datetime).format('HH:mm:ss'); - break; - case 'time_long': - datetime_string = dayjs(raw_datetime).format('hh:mm:ss A'); - break; - case 'time_short': - datetime_string = dayjs(raw_datetime).format('hh:mm A'); - break; - case 'time_short_no_leading': - datetime_string = dayjs(raw_datetime).format('h:mm A'); - break; - case 'week_long': - datetime_string = dayjs(raw_datetime).format('dddd'); - break; - case 'week_medium': - datetime_string = dayjs(raw_datetime).format('ddd'); - break; - case 'week_short': - datetime_string = dayjs(raw_datetime).format('dd'); - break; - default: - console.log(`The named format passed (${named_format}) did not match a common name. Trying to format with the named format value.`); - datetime_string = dayjs(raw_datetime).format(named_format); - // datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss'); - } - return datetime_string; -} - - function format_bytes( bytes: number, decimals: number = 2 @@ -282,11 +156,16 @@ export let extract_prefixed_form_data = function extract_prefixed_form_data({pre * em: Email Address */ // Updated 2022-02-11 -export let process_data_string = function process_data_string(data_string) { +export let process_data_string = function process_data_string(data_string: string) { console.log('*** process_data_string() ***'); // console.log(data_string); - let obj = {}; + if (!data_string || data_string.length < 1) { + console.log('No data string found.'); + return false; + } + + let obj: key_val = {}; let colon_index = data_string.indexOf(':') if (colon_index) { @@ -354,172 +233,6 @@ export let process_data_string = function process_data_string(data_string) { } -// NOTE: I know there is a better more efficient way to do this, but I don't have time for that right now. -export let process_permission_checks = function process_permission_checks(access_type: string) { - // let access_checks = { 'access_type': null, 'super_check': null }; - let access_checks: key_val = {}; - - if (access_type == 'super') { - access_checks.access_type = 'super'; - - access_checks.super_check = true; - access_checks.manager_check = false; - access_checks.administrator_check = false; - access_checks.support_check = false; - access_checks.assistant_check = false; - access_checks.trusted_check = false; - access_checks.verified_check = false; - access_checks.provisional_check = false; - access_checks.public_check = false; - access_checks.authenticated_check = true; - access_checks.anonymous_check = false; - - access_checks.super_access = true; - access_checks.manager_access = true; - access_checks.administrator_access = true; - access_checks.support_access = true; - access_checks.assistant_access = true; - access_checks.trusted_access = true; - access_checks.verified_access = true; - access_checks.provisional_access = true; - access_checks.public_access = true; - access_checks.authenticated_access = true; - access_checks.anonymous_access = true; - } else if (access_type == 'manager') { - access_checks.access_type = 'manager'; - - access_checks.super_check = false; - access_checks.manager_check = true; - access_checks.administrator_check = false; - access_checks.support_check = false; - access_checks.assistant_check = false; - access_checks.trusted_check = false; - access_checks.verified_check = false; - access_checks.provisional_check = false; - access_checks.public_check = false; - access_checks.authenticated_check = true; - access_checks.anonymous_check = false; - - access_checks.super_access = false; - access_checks.manager_access = true; - access_checks.administrator_access = true; - access_checks.support_access = true; - access_checks.assistant_access = true; - access_checks.trusted_access = true; - access_checks.verified_access = true; - access_checks.provisional_access = true; - access_checks.public_access = true; - access_checks.authenticated_access = true; - access_checks.anonymous_access = true; - } else if (access_type == 'administrator') { - access_checks.access_type = 'administrator'; - - access_checks.super_check = false; - access_checks.manager_check = false; - access_checks.administrator_check = true; - access_checks.support_check = false; - access_checks.assistant_check = false; - access_checks.trusted_check = false; - access_checks.verified_check = false; - access_checks.provisional_check = false; - access_checks.public_check = false; - access_checks.authenticated_check = false; - access_checks.anonymous_check = false; - - access_checks.super_access = false; - access_checks.manager_access = false; - access_checks.administrator_access = true; - access_checks.support_access = true; - access_checks.assistant_access = true; - access_checks.trusted_access = true; - access_checks.verified_access = true; - access_checks.provisional_access = true; - access_checks.public_access = true; - access_checks.authenticated_access = true; - access_checks.anonymous_access = true; - } else if (access_type == 'trusted') { - access_checks.access_type = 'trusted'; - - access_checks.super_check = false; - access_checks.manager_check = false; - access_checks.administrator_check = false; - access_checks.support_check = false; - access_checks.assistant_check = false; - access_checks.trusted_check = true; - access_checks.verified_check = false; - access_checks.provisional_check = false; - access_checks.public_check = false; - access_checks.authenticated_check = true; - access_checks.anonymous_check = false; - - access_checks.super_access = false; - access_checks.manager_access = false; - access_checks.administrator_access = false; - access_checks.support_access = false; - access_checks.assistant_access = false; - access_checks.trusted_access = true; - access_checks.verified_access = true; - access_checks.provisional_access = true; - access_checks.public_access = true; - access_checks.authenticated_access = true; - access_checks.anonymous_access = true; - } else if (access_type == 'authenticated') { - access_checks.access_type = 'authenticated'; - - access_checks.super_check = false; - access_checks.manager_check = false; - access_checks.administrator_check = false; - access_checks.support_check = false; - access_checks.assistant_check = false; - access_checks.trusted_check = false; - access_checks.verified_check = false; - access_checks.provisional_check = false; - access_checks.public_check = false; - access_checks.authenticated_check = true; - access_checks.anonymous_check = false; - - access_checks.super_access = false; - access_checks.manager_access = false; - access_checks.administrator_access = false; - access_checks.support_access = false; - access_checks.assistant_access = false; - access_checks.trusted_access = false; - access_checks.verified_access = false; - access_checks.provisional_access = false; - access_checks.public_access = false; - access_checks.authenticated_access = true; - access_checks.anonymous_access = true; - } else { - access_checks.access_type = 'anonymous'; - - access_checks.super_check = false; - access_checks.manager_check = false; - access_checks.administrator_check = false; - access_checks.support_check = false; - access_checks.assistant_check = false; - access_checks.trusted_check = false; - access_checks.verified_check = false; - access_checks.provisional_check = false; - access_checks.public_check = false; - access_checks.authenticated_check = false; - access_checks.anonymous_check = true; - - access_checks.super_access = false; - access_checks.manager_access = false; - access_checks.administrator_access = false; - access_checks.support_access = false; - access_checks.assistant_access = false; - access_checks.trusted_access = false; - access_checks.verified_access = false; - access_checks.provisional_access = false; - access_checks.public_access = false; - access_checks.authenticated_access = false; - access_checks.anonymous_access = true; - } - - return access_checks; -} - // This function will update the URL and send a message to the parent window (iframe). // The name should be something like "example_id". @@ -1006,14 +719,13 @@ function return_obj_type_path({obj_type=null, obj_type_prop_name=null}) { - export let ae_util = { + process_permission_checks: process_permission_checks, iso_datetime_formatter: iso_datetime_formatter, format_bytes: format_bytes, number_w_commas: number_w_commas, extract_prefixed_form_data: extract_prefixed_form_data, process_data_string: process_data_string, - process_permission_checks: process_permission_checks, handle_url_and_message: handle_url_and_message, create_a_element: create_a_element, create_img_element: create_img_element, @@ -1026,4 +738,3 @@ export let ae_util = { set_obj_prop_display_name: set_obj_prop_display_name, return_obj_type_path: return_obj_type_path, }; -// export default ae_util; \ No newline at end of file diff --git a/src/lib/ae_utils__datetime_format.ts b/src/lib/ae_utils__datetime_format.ts new file mode 100644 index 00000000..ea5018cd --- /dev/null +++ b/src/lib/ae_utils__datetime_format.ts @@ -0,0 +1,129 @@ +import dayjs from 'dayjs'; + +export let iso_datetime_formatter = function iso_datetime_formatter( + raw_datetime: null|string|Date = null, + named_format: string = 'datetime_iso_no_seconds', // date_iso, datetime_iso_no_seconds + ) { + // console.log('*** iso_datetime_formatter() ***'); + + // https://en.wikipedia.org/wiki/ISO_8601 + // https://day.js.org/docs/en/display/format + // ISO 8601-1:2019 includes the T before the time portion + // ISO 8601-1:2019 midnight may only be referred to as "00:00", corresponding to the beginning of a calendar day + // and "24:00" is no longer allowed corresponding to the end of a day + // 60 is only used to denote an added leap second + + // ISO 8601 UTC: 2021-03-04T19:04:44+00:00 + // ISO 8601 UTC: 2021-03-04T19:04:44Z + // ISO 8601 UTC: 20210304T190444Z + + //datetime_iso 'YYYY-MM-DD HH:mm:ss' + //datetime_iso_12 'YYYY-MM-DD hh:mm:ss A' + //datetime_iso_12_short 'YY-MM-DD hh:mm A' + //datetime_iso_tz 'YYYY-MM-DD HH:mm:ss' + + //datetime_long 'dddd, MMMM D, YYYY hh:mm:ss A' + //datetime_medium 'ddd, MMM D, YYYY hh:mm:ss A' + //datetime_short 'MMM D, YY hh:mm A' + + //date_iso 'YYYY-MM-DD' + + //date_long 'dddd, MMMM D, YYYY' + //date_medium 'ddd, MMM D, YYYY' + //date_short 'MMM D, YY' + + //time_iso 'HH:mm:ss' + //time_iso_12 'hh:mm:ss A' + + //time_long 'hh:mm:ss A' + //time_medium 'h:m:s A' + //time_short 'hh:mm A' + + //dayjs(raw_datetime).format('dddd, MMMM D, YYYY hh:mm:ss A'); + + if (!raw_datetime) { + raw_datetime = new Date(); // Get the current datetime if one was not passed. + } + + let datetime_string = null; + + switch (named_format) { + case 'datetime_iso': + datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss'); + break; + case 'datetime_iso_no_seconds': + datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm'); + break; + case 'datetime_iso_12_short': + datetime_string = dayjs(raw_datetime).format('YY-MM-DD hh:mm A'); + break; + case 'datetime_iso_12_short_month': + datetime_string = dayjs(raw_datetime).format('MM-DD hh:mm A'); + break; + case 'datetime_short': + datetime_string = dayjs(raw_datetime).format('MMM D, YY hh:mm A'); + break; + case 'datetime_medium': + datetime_string = dayjs(raw_datetime).format('MMM D, YYYY h:mm A'); + break; + case 'datetime_long': + datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY hh:mm A'); + break; + case 'datetime_short_month': + datetime_string = dayjs(raw_datetime).format('MMM D hh:mm A'); + break; + case 'datetime_long_month': + datetime_string = dayjs(raw_datetime).format('MMMM D hh:mm A'); + break; + case 'datetime_short_day': + datetime_string = dayjs(raw_datetime).format('D hh:mm A'); + break; + case 'date_iso': + datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD'); + break; + case 'date_long_month_day': + datetime_string = dayjs(raw_datetime).format('MMMM D'); + break; + case 'date_short': + datetime_string = dayjs(raw_datetime).format('MMM D, YY'); + break; + case 'date_short_no_year': + datetime_string = dayjs(raw_datetime).format('MMM D'); + break; + case 'date_long': + datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY'); + break; + case 'date_full': + datetime_string = dayjs(raw_datetime).format('dddd, MMMM D, YYYY'); + break; + case 'date_full_no_year': + datetime_string = dayjs(raw_datetime).format('dddd, MMMM D'); + break; + case 'time_iso': + datetime_string = dayjs(raw_datetime).format('HH:mm:ss'); + break; + case 'time_long': + datetime_string = dayjs(raw_datetime).format('hh:mm:ss A'); + break; + case 'time_short': + datetime_string = dayjs(raw_datetime).format('hh:mm A'); + break; + case 'time_short_no_leading': + datetime_string = dayjs(raw_datetime).format('h:mm A'); + break; + case 'week_long': + datetime_string = dayjs(raw_datetime).format('dddd'); + break; + case 'week_medium': + datetime_string = dayjs(raw_datetime).format('ddd'); + break; + case 'week_short': + datetime_string = dayjs(raw_datetime).format('dd'); + break; + default: + console.log(`The named format passed (${named_format}) did not match a common name. Trying to format with the named format value.`); + datetime_string = dayjs(raw_datetime).format(named_format); + // datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss'); + } + return datetime_string; +} diff --git a/src/lib/ae_utils__perm_checks.ts b/src/lib/ae_utils__perm_checks.ts new file mode 100644 index 00000000..73c57009 --- /dev/null +++ b/src/lib/ae_utils__perm_checks.ts @@ -0,0 +1,169 @@ +type key_val = { + [key: string]: any; +}; + +// NOTE: I know there is a better more efficient way to do this, but I don't have time for that right now. +export let process_permission_checks = function process_permission_checks(access_type: string) { + // let access_checks = { 'access_type': null, 'super_check': null }; + let access_checks: key_val = {}; + + if (access_type == 'super') { + access_checks.access_type = 'super'; + + access_checks.super_check = true; + access_checks.manager_check = false; + access_checks.administrator_check = false; + access_checks.support_check = false; + access_checks.assistant_check = false; + access_checks.trusted_check = false; + access_checks.verified_check = false; + access_checks.provisional_check = false; + access_checks.public_check = false; + access_checks.authenticated_check = true; + access_checks.anonymous_check = false; + + access_checks.super_access = true; + access_checks.manager_access = true; + access_checks.administrator_access = true; + access_checks.support_access = true; + access_checks.assistant_access = true; + access_checks.trusted_access = true; + access_checks.verified_access = true; + access_checks.provisional_access = true; + access_checks.public_access = true; + access_checks.authenticated_access = true; + access_checks.anonymous_access = true; + } else if (access_type == 'manager') { + access_checks.access_type = 'manager'; + + access_checks.super_check = false; + access_checks.manager_check = true; + access_checks.administrator_check = false; + access_checks.support_check = false; + access_checks.assistant_check = false; + access_checks.trusted_check = false; + access_checks.verified_check = false; + access_checks.provisional_check = false; + access_checks.public_check = false; + access_checks.authenticated_check = true; + access_checks.anonymous_check = false; + + access_checks.super_access = false; + access_checks.manager_access = true; + access_checks.administrator_access = true; + access_checks.support_access = true; + access_checks.assistant_access = true; + access_checks.trusted_access = true; + access_checks.verified_access = true; + access_checks.provisional_access = true; + access_checks.public_access = true; + access_checks.authenticated_access = true; + access_checks.anonymous_access = true; + } else if (access_type == 'administrator') { + access_checks.access_type = 'administrator'; + + access_checks.super_check = false; + access_checks.manager_check = false; + access_checks.administrator_check = true; + access_checks.support_check = false; + access_checks.assistant_check = false; + access_checks.trusted_check = false; + access_checks.verified_check = false; + access_checks.provisional_check = false; + access_checks.public_check = false; + access_checks.authenticated_check = false; + access_checks.anonymous_check = false; + + access_checks.super_access = false; + access_checks.manager_access = false; + access_checks.administrator_access = true; + access_checks.support_access = true; + access_checks.assistant_access = true; + access_checks.trusted_access = true; + access_checks.verified_access = true; + access_checks.provisional_access = true; + access_checks.public_access = true; + access_checks.authenticated_access = true; + access_checks.anonymous_access = true; + } else if (access_type == 'trusted') { + access_checks.access_type = 'trusted'; + + access_checks.super_check = false; + access_checks.manager_check = false; + access_checks.administrator_check = false; + access_checks.support_check = false; + access_checks.assistant_check = false; + access_checks.trusted_check = true; + access_checks.verified_check = false; + access_checks.provisional_check = false; + access_checks.public_check = false; + access_checks.authenticated_check = true; + access_checks.anonymous_check = false; + + access_checks.super_access = false; + access_checks.manager_access = false; + access_checks.administrator_access = false; + access_checks.support_access = false; + access_checks.assistant_access = false; + access_checks.trusted_access = true; + access_checks.verified_access = true; + access_checks.provisional_access = true; + access_checks.public_access = true; + access_checks.authenticated_access = true; + access_checks.anonymous_access = true; + } else if (access_type == 'authenticated') { + access_checks.access_type = 'authenticated'; + + access_checks.super_check = false; + access_checks.manager_check = false; + access_checks.administrator_check = false; + access_checks.support_check = false; + access_checks.assistant_check = false; + access_checks.trusted_check = false; + access_checks.verified_check = false; + access_checks.provisional_check = false; + access_checks.public_check = false; + access_checks.authenticated_check = true; + access_checks.anonymous_check = false; + + access_checks.super_access = false; + access_checks.manager_access = false; + access_checks.administrator_access = false; + access_checks.support_access = false; + access_checks.assistant_access = false; + access_checks.trusted_access = false; + access_checks.verified_access = false; + access_checks.provisional_access = false; + access_checks.public_access = false; + access_checks.authenticated_access = true; + access_checks.anonymous_access = true; + } else { + access_checks.access_type = 'anonymous'; + + access_checks.super_check = false; + access_checks.manager_check = false; + access_checks.administrator_check = false; + access_checks.support_check = false; + access_checks.assistant_check = false; + access_checks.trusted_check = false; + access_checks.verified_check = false; + access_checks.provisional_check = false; + access_checks.public_check = false; + access_checks.authenticated_check = false; + access_checks.anonymous_check = true; + + access_checks.super_access = false; + access_checks.manager_access = false; + access_checks.administrator_access = false; + access_checks.support_access = false; + access_checks.assistant_access = false; + access_checks.trusted_access = false; + access_checks.verified_access = false; + access_checks.provisional_access = false; + access_checks.public_access = false; + access_checks.authenticated_access = false; + access_checks.anonymous_access = true; + } + + return access_checks; +} diff --git a/src/lib/element_ae_crud.svelte b/src/lib/element_ae_crud.svelte index 67029907..8aaf83a0 100644 --- a/src/lib/element_ae_crud.svelte +++ b/src/lib/element_ae_crud.svelte @@ -24,6 +24,7 @@ export let field_type: string = 'text'; // button, text, textarea, template (old export let field_value: any; export let allow_null: boolean = false; export let select_option_li: key_val = {}; +export let val_empty_is_null: boolean = false; // This was added to help with a select option list. If the value is empty (''), it will be set to null. export let edit_label: string = 'Edit'; export let display_inline: boolean = false; export let display_block_edit: boolean = false; @@ -78,6 +79,11 @@ async function handle_obj_field_patch(new_field_value: any) { patch_result = null; + // This was added to help with a select option list. If the value is empty (''), it will be set to null. + if (val_empty_is_null && new_field_value == '') { + new_field_value = null; + } + // NOTE: Is this needed? The field_name, field_value, and fields parameters for update_ae_obj_id_crud() already take care of the data portion. They are added to data_list object as part of the JSON request. // NOTE: Currently this only handles one field and value at a time. This may need to be changed in the future to use the "fields" parameter as well. // let patch_data = {} diff --git a/src/lib/element_manage_event_file_li.svelte b/src/lib/element_manage_event_file_li.svelte index 759ec918..1308d0e2 100644 --- a/src/lib/element_manage_event_file_li.svelte +++ b/src/lib/element_manage_event_file_li.svelte @@ -72,8 +72,17 @@ onMount(() => { Refresh Files -

- Manage Files: {$lq__event_file_obj_li ? `${$lq__event_file_obj_li.length}x` : '-- none --'} +

+ Manage Files: + + + {$lq__event_file_obj_li ? `${$lq__event_file_obj_li.length}x` : '-- none --'} +

{#if $lq__event_file_obj_li && $lq__event_file_obj_li.length} @@ -250,7 +259,7 @@ onMount(() => { // ae_triggers.update_event_file_purpose = true; }} - class="select min-w-fit max-w-fit text-sm mx-1" + class="select min-w-fit max-w-fit text-sm mx-1 border border-gray-300 rounded-md p-1 hover:border-gray-400" > diff --git a/src/routes/events_pres_mgmt/event/[slug]/+page.svelte b/src/routes/events_pres_mgmt/event/[slug]/+page.svelte index 5b9289ac..87f20713 100644 --- a/src/routes/events_pres_mgmt/event/[slug]/+page.svelte +++ b/src/routes/events_pres_mgmt/event/[slug]/+page.svelte @@ -17,7 +17,7 @@ import Element_data_store from '$lib/element_data_store.svelte'; import { liveQuery } from "dexie"; import { core_func } from '$lib/ae_core_functions'; import { db_events } from "$lib/db_events"; -import { ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores'; +import { ae_html, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores'; import { events_loc, events_sess, events_slct, events_trigger } from '$lib/ae_events_stores'; import { events_func } from '$lib/ae_events_functions'; @@ -432,7 +432,7 @@ function handle_search__event_session(search_str: string) { {ae_util.iso_datetime_formatter(session_obj.end_datetime,'time_short')} {:else} - -- not set -- + {@html ae_html.not_set} {/if} {session_obj.event_location_name ?? '-- not set --'} @@ -452,7 +452,7 @@ function handle_search__event_session(search_str: string) { {/if} {:else} - -- not set -- + {@html ae_html.not_set} {/if} {#if $ae_loc.trusted_access} diff --git a/src/routes/events_pres_mgmt/session/[slug]/+page.svelte b/src/routes/events_pres_mgmt/session/[slug]/+page.svelte index 3ac28115..eea307eb 100644 --- a/src/routes/events_pres_mgmt/session/[slug]/+page.svelte +++ b/src/routes/events_pres_mgmt/session/[slug]/+page.svelte @@ -20,7 +20,7 @@ let ae_triggers: key_val = {}; import { liveQuery } from "dexie"; import { core_func } from '$lib/ae_core_functions'; import { db_events } from "$lib/db_events"; -import { ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores'; +import { ae_html, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores'; import { events_loc, events_sess, events_slct, events_trigger, events_trig_kv } from '$lib/ae_events_stores'; import { events_func } from '$lib/ae_events_functions'; @@ -28,6 +28,11 @@ import Form_agree from './form_agree.svelte'; import Presenter_view from './presenter_view.svelte'; import Element_manage_event_file_li from '$lib/element_manage_event_file_li.svelte'; +import { browser } from '$app/environment'; +if (browser) { + console.log('Browser environment detected.'); +} + // Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other. $slct.account_id = data.account_id; // console.log(`$slct.account_id = `, $slct.account_id); @@ -103,8 +108,20 @@ let lq__event_session_obj = liveQuery( () => db_events.sessions.get($events_slct.event_session_id) ); + + let lq__event_presentation_obj_li = liveQuery( - () => db_events.presentations.where('event_session_id_random').equals($events_slct.event_session_id_random).toArray() + () => db_events.presentations + // .where({event_session_id_random: $events_slct.event_session_id}) + .where('event_session_id_random') + .equals($events_slct.event_session_id) + .sortBy('name') + + // This works, but does it need to be async? + // async () => await db_events.presentations + // .where('event_session_id_random') + // .equals($events_slct.event_session_id) + // .sortBy('name') ); let lq__event_presentation_obj = liveQuery( @@ -114,8 +131,20 @@ let lq__event_presentation_obj = liveQuery( let lq__event_presenter_obj = liveQuery( () => db_events.presenters.get($events_slct.event_presenter_id) ); +// $events_slct.event_presenter_obj = $lq__event_presenter_obj; -$events_slct.event_presenter_obj = $lq__event_presenter_obj; +// We will filter out the presenters based on the presentation ID when they are rendered below. +let lq__event_presenter_obj_li = liveQuery( + () => db_events.presenters + .where('event_session_id_random') + .equals($events_slct.event_session_id) + + // Why does the slct presentation ID not seem to work? + // .where('event_presentation_id_random') + // .equals($events_slct.event_presentation_id) + // .equals($events_slct.event_presentation_id?? '') + .sortBy('full_name') +); let lq__event_file_obj_li = liveQuery( () => db_events.files.where('event_session_id_random').equals($events_slct.event_session_id).toArray() @@ -158,6 +187,8 @@ $slct.person_obj_kv = {}; // This is intended for the POC lookup list when gener onMount(() => { console.log('Events Session [slug]: +page.svelte'); + console.log(`onMount - lq__event_presentation_obj:`, $lq__event_presentation_obj_li); + // console.log(`ae_events_pres_mgmt presenter [slug] +page.svelte data:`, data); // if (!$events_slct.event_id) { @@ -340,6 +371,8 @@ function send_init_confirm_email( ) { console.log(`*** send_init_confirm_email() *** to ${to_email}.`); + // let new_passcode = Math.floor(Math.random() * 900000) + 100000 + // to_email = 'test+agree@oneskyit.com'; let sign_in_url = encodeURI(`${data.url.origin}/events_pres_mgmt/session/${$events_slct.event_session_id}?person_id=${person_id}&person_pass=${person_passcode}&presentation_id=${presentation_id}&presenter_id=${presenter_id}`) @@ -365,7 +398,7 @@ function send_init_confirm_email( api.send_email({ api_cfg: $ae_api, - from_email: 'noreply+agree@oneskyit.com', + from_email: 'noreply+presmgmt@oneskyit.com', from_name: 'LCI 2024 Pres Mgmt Hub', to_email: to_email, subject: subject, @@ -413,7 +446,7 @@ function send_sign_in_poc_email( `; api.send_email({ api_cfg: $ae_api, - from_email: 'noreply+agree@oneskyit.com', + from_email: 'noreply+presmgmt@oneskyit.com', from_name: 'LCI 2024 Pres Mgmt Hub', to_email: to_email, subject: subject, @@ -421,6 +454,8 @@ function send_sign_in_poc_email( }); } + + @@ -486,7 +521,9 @@ function send_sign_in_poc_email( {#if $events_slct.event_session_id && $lq__event_session_obj} -

{$lq__event_session_obj?.name ?? '-- not set --'}

+

+ {@html $lq__event_session_obj?.name ?? ae_html.not_set} +

@@ -603,7 +640,7 @@ function send_sign_in_poc_email(
  • - Location/Room: {$lq__event_session_obj.event_location_name ? $lq__event_session_obj.event_location_name : '-- not set --'} + Location/Room: {@html $lq__event_session_obj.event_location_name ? $lq__event_session_obj.event_location_name : ae_html.not_set} {#if $ae_loc.trusted_access} Moderator/Champion: - {$lq__event_session_obj.poc_person_full_name ? $lq__event_session_obj.poc_person_full_name : '-- not set --'} + {@html $lq__event_session_obj.poc_person_full_name ? $lq__event_session_obj.poc_person_full_name : ae_html.not_set} {#if $ae_loc.trusted_access} @@ -872,10 +910,10 @@ function send_sign_in_poc_email( send_sign_in_poc_email( { to_email: $lq__event_session_obj.poc_person_primary_email, - to_name: $lq__event_session_obj.poc_person_full_name, - person_id: $lq__event_session_obj.poc_person_id_random, - person_passcode: $lq__event_session_obj.poc_person_passcode, - session_id: $lq__event_session_obj.event_session_id_random, + to_name: $lq__event_session_obj?.poc_person_full_name?? '-- not set --', + person_id: $lq__event_session_obj?.poc_person_id_random?? '-- not set --', + person_passcode: $lq__event_session_obj?.poc_person_passcode?? '-- not set --', + session_id: $lq__event_session_obj?.event_session_id_random?? '-- not set --', } ); }} @@ -907,7 +945,7 @@ function send_sign_in_poc_email( {#if $ae_loc.administrator_access}
  • - Session passcode: {$lq__event_session_obj.passcode ? $lq__event_session_obj.passcode : '-- not set --'} + Session passcode: {@html $lq__event_session_obj.passcode ? $lq__event_session_obj.passcode : ae_html.not_set}
  • {/if} @@ -938,6 +976,7 @@ function send_sign_in_poc_email( Session description: + {#if $lq__event_session_obj.description} - {/if} + events_func.handle_create_ae_obj__event_presenter({ + api_cfg: $ae_api, + event_id: $events_slct.event_id, + event_session_id: $events_slct.event_session_id, + event_presentation_id: event_presentation_obj.event_presentation_id_random, + data_kv: presenter_data, + log_lvl: 1, + }) + }} + class="btn btn-sm variant-soft-warning hover:variant-filled-warning" + > + + Add Presenter + + {/if} - - - {#if event_presentation_obj && $ae_loc.trusted_access} - {#if $events_slct.event_presentation_id == event_presentation_obj.event_presentation_id_random && ae_tmp[$events_slct.event_presentation_id]?.show__edit_presentation_name} - - {:else} - - {/if} - - {#if $events_slct.event_presentation_id == event_presentation_obj.event_presentation_id_random && ae_tmp[$events_slct.event_presentation_id]?.show__edit_presentation_name && $events_slct.event_presentation_obj} - - { - console.log(`ae_crud_updated:`, e.detail); - - events_func.handle_load_ae_obj_id__event_presentation({api_cfg: $ae_api, event_presentation_id: $events_slct.event_presentation_obj.event_presentation_id_random, log_lvl: 1}) - .then(function (load_results) { - // We need to force reload the Indexed DB - Dexie.js? - // Sometimes the changes are not seen. The file disappears when the Save button is pressed. - - // Maybe reload page? - // window.location.reload(); - }) - .finally(function () { - ae_tmp[$events_slct.event_presentation_id].show__edit_presentation_name = false; - - // Careful with the trigger_patch. It will keep firing if not reset. - ae_triggers.update_event_presentation_name = false; - }); - }} - > - - - - - - {/if} - - {/if} - - -

    - "{event_presentation_obj.name}" - {#if event_presentation_obj.code || event_presentation_obj.abstract_code} - - - {event_presentation_obj.code ?? ''} {event_presentation_obj.abstract_code ?? ''} - - {/if} -

    - -
    +

    { console.log(`ae_crud_updated:`, e.detail); - events_func.handle_load_ae_obj_id__event_presentation({api_cfg: $ae_api, event_presentation_id: event_presentation_obj.event_presentation_id_random, log_lvl: 1}); + events_func.handle_load_ae_obj_id__event_presentation({api_cfg: $ae_api, event_presentation_id: event_presentation_obj.event_presentation_id_random, log_lvl: 1}) + .then(function (load_results) { + }) + .then(function (load_results) { + // $events_trigger = 'load__event_presentation_obj_id'; + // $events_trig_kv['event_presentation_id'] = event_presentation_obj.event_presentation_id_random; + }); }} > - {#if event_presentation_obj.description} - - Description: - - - - -
    {event_presentation_obj.description}
    - {:else} -
    - - No description provided. -
    - {/if} + + "{event_presentation_obj.name}"
    + + {#if event_presentation_obj.code || event_presentation_obj.abstract_code} + + + {event_presentation_obj.code ?? ''} {event_presentation_obj.abstract_code ?? ''} + + {/if} +

    + +
    + { + console.log(`ae_crud_updated:`, e.detail); + + events_func.handle_load_ae_obj_id__event_presentation({api_cfg: $ae_api, event_presentation_id: event_presentation_obj.event_presentation_id_random, log_lvl: 1}); + }} + > + + Description: + + + {#if event_presentation_obj.description} + + +
    {event_presentation_obj.description}
    + + {:else} + {@html ae_html.not_set} + {/if} + +
    +
    - - {#await event_presentation_obj.event_presenter_li} -

    Loading...

    - {:then event_presenter_li} - {#if event_presenter_li && event_presenter_li.length > 0} - Presenters: - - {/if} - {:catch error} -

    Error: {error.message}

    - {/await} - - - - - - + + Email Access Link + + {/if} + + + {#if event_presenter_obj.agree} + + + {:else} + + {/if} + + + + {#if $ae_loc.trusted_access} + + + + {#if event_presenter_obj.file_count} + + + {event_presenter_obj.file_count ? `(${event_presenter_obj.file_count}x files)` : '(0 files)'} + + {/if} + + + + + {/if} + + + + + + +
    + {#if $ae_loc.administrator_access && !event_presenter_obj.person_id_random} + + {/if} +
    + + + {/if} + {/each} + + {:else} +

    No presenters found...!

    + {$events_slct.event_presentation_id} + {$lq__event_presentation_obj} + {$lq__event_presenter_obj_li?.length} + {/if} + + + + + + + {/each} + +{:else} + Nothing to show yet...! +{/if} + + - - {/each} - - {:else} - Nothing to show yet... - {/if} -{:catch error} -

    Error: {error.message}

    -{/await}
    diff --git a/src/routes/events_pres_mgmt/session/[slug]/form_agree.svelte b/src/routes/events_pres_mgmt/session/[slug]/form_agree.svelte index a59a9aaa..8d328886 100644 --- a/src/routes/events_pres_mgmt/session/[slug]/form_agree.svelte +++ b/src/routes/events_pres_mgmt/session/[slug]/form_agree.svelte @@ -148,7 +148,7 @@ async function handle_update__event_presenter({ // api.send_email({ // api_cfg: $ae_api, -// from_email: 'noreply+agree@oneskyit.com', +// from_email: 'noreply+presmgmt@oneskyit.com', // from_name: 'LCI 2024 Pres Mgmt Hub', // to_email: 'test+agree@oneskyit.com', // subject: subject,