A lot of code clean up. Also making things look better.
This commit is contained in:
@@ -34,6 +34,14 @@ export type key_val = {
|
|||||||
};
|
};
|
||||||
// export type key_val = 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.
|
// *** BEGIN *** Longer-term app data. This should be stored to local storage.
|
||||||
export let ae_app_local_data_struct: key_val = {
|
export let ae_app_local_data_struct: key_val = {
|
||||||
'ver': '2024-06-26_13',
|
'ver': '2024-06-26_13',
|
||||||
|
|||||||
13
src/lib/ae_string_snippets.ts
Normal file
13
src/lib/ae_string_snippets.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
// These are shared snippets of text, This is mostly HTML and CSS.
|
||||||
|
|
||||||
|
let html__not_set = `
|
||||||
|
<span
|
||||||
|
class="text-sm text-gray-500 bg-gray-100 p-1 rounded-md border border-gray-200"
|
||||||
|
>-- not set --
|
||||||
|
</span>
|
||||||
|
`;
|
||||||
|
|
||||||
|
|
||||||
|
export {
|
||||||
|
html__not_set,
|
||||||
|
};
|
||||||
@@ -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 = {
|
type key_str = {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
@@ -8,135 +11,6 @@ type key_val = {
|
|||||||
[key: string]: any;
|
[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(
|
function format_bytes(
|
||||||
bytes: number,
|
bytes: number,
|
||||||
decimals: number = 2
|
decimals: number = 2
|
||||||
@@ -282,11 +156,16 @@ export let extract_prefixed_form_data = function extract_prefixed_form_data({pre
|
|||||||
* em: Email Address
|
* em: Email Address
|
||||||
*/
|
*/
|
||||||
// Updated 2022-02-11
|
// 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('*** process_data_string() ***');
|
||||||
// console.log(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(':')
|
let colon_index = data_string.indexOf(':')
|
||||||
if (colon_index) {
|
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).
|
// This function will update the URL and send a message to the parent window (iframe).
|
||||||
// The name should be something like "example_id".
|
// 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 = {
|
export let ae_util = {
|
||||||
|
process_permission_checks: process_permission_checks,
|
||||||
iso_datetime_formatter: iso_datetime_formatter,
|
iso_datetime_formatter: iso_datetime_formatter,
|
||||||
format_bytes: format_bytes,
|
format_bytes: format_bytes,
|
||||||
number_w_commas: number_w_commas,
|
number_w_commas: number_w_commas,
|
||||||
extract_prefixed_form_data: extract_prefixed_form_data,
|
extract_prefixed_form_data: extract_prefixed_form_data,
|
||||||
process_data_string: process_data_string,
|
process_data_string: process_data_string,
|
||||||
process_permission_checks: process_permission_checks,
|
|
||||||
handle_url_and_message: handle_url_and_message,
|
handle_url_and_message: handle_url_and_message,
|
||||||
create_a_element: create_a_element,
|
create_a_element: create_a_element,
|
||||||
create_img_element: create_img_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,
|
set_obj_prop_display_name: set_obj_prop_display_name,
|
||||||
return_obj_type_path: return_obj_type_path,
|
return_obj_type_path: return_obj_type_path,
|
||||||
};
|
};
|
||||||
// export default ae_util;
|
|
||||||
129
src/lib/ae_utils__datetime_format.ts
Normal file
129
src/lib/ae_utils__datetime_format.ts
Normal file
@@ -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;
|
||||||
|
}
|
||||||
169
src/lib/ae_utils__perm_checks.ts
Normal file
169
src/lib/ae_utils__perm_checks.ts
Normal file
@@ -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;
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ export let field_type: string = 'text'; // button, text, textarea, template (old
|
|||||||
export let field_value: any;
|
export let field_value: any;
|
||||||
export let allow_null: boolean = false;
|
export let allow_null: boolean = false;
|
||||||
export let select_option_li: key_val = {};
|
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 edit_label: string = 'Edit';
|
||||||
export let display_inline: boolean = false;
|
export let display_inline: boolean = false;
|
||||||
export let display_block_edit: 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;
|
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: 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.
|
// 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 = {}
|
// let patch_data = {}
|
||||||
|
|||||||
@@ -72,8 +72,17 @@ onMount(() => {
|
|||||||
Refresh Files
|
Refresh Files
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<h3 class="h4">
|
<h3
|
||||||
Manage Files: {$lq__event_file_obj_li ? `${$lq__event_file_obj_li.length}x` : '-- none --'}
|
class="h6"
|
||||||
|
class:hidden={!$lq__event_file_obj_li?.length}
|
||||||
|
>
|
||||||
|
Manage Files:
|
||||||
|
<span class="font-bold bg-success-100 px-4 border rounded-lg border-success-200"
|
||||||
|
title="Files for {link_to_type ?? '-- not set --'} {link_to_id ?? '-- not set --'}: {$events_slct.session_obj_li.length ?? 'None'}"
|
||||||
|
>
|
||||||
|
<span class="fas fa-folder-open mx-1"></span>
|
||||||
|
{$lq__event_file_obj_li ? `${$lq__event_file_obj_li.length}x` : '-- none --'}
|
||||||
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
{#if $lq__event_file_obj_li && $lq__event_file_obj_li.length}
|
{#if $lq__event_file_obj_li && $lq__event_file_obj_li.length}
|
||||||
@@ -250,7 +259,7 @@ onMount(() => {
|
|||||||
|
|
||||||
// ae_triggers.update_event_file_purpose = true;
|
// 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"
|
||||||
>
|
>
|
||||||
<option value={null} selected={!event_file_obj.file_purpose} class="text-xs">-- purpose not set --</option>
|
<option value={null} selected={!event_file_obj.file_purpose} class="text-xs">-- purpose not set --</option>
|
||||||
<option value="outline" selected={event_file_obj.file_purpose === 'outline'}>1. Outline</option>
|
<option value="outline" selected={event_file_obj.file_purpose === 'outline'}>1. Outline</option>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import Element_data_store from '$lib/element_data_store.svelte';
|
|||||||
import { liveQuery } from "dexie";
|
import { liveQuery } from "dexie";
|
||||||
import { core_func } from '$lib/ae_core_functions';
|
import { core_func } from '$lib/ae_core_functions';
|
||||||
import { db_events } from "$lib/db_events";
|
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_loc, events_sess, events_slct, events_trigger } from '$lib/ae_events_stores';
|
||||||
import { events_func } from '$lib/ae_events_functions';
|
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')}
|
{ae_util.iso_datetime_formatter(session_obj.end_datetime,'time_short')}
|
||||||
</span>
|
</span>
|
||||||
{:else}
|
{:else}
|
||||||
-- not set --
|
{@html ae_html.not_set}
|
||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
<td>{session_obj.event_location_name ?? '-- not set --'}</td>
|
<td>{session_obj.event_location_name ?? '-- not set --'}</td>
|
||||||
@@ -452,7 +452,7 @@ function handle_search__event_session(search_str: string) {
|
|||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
-- not set --
|
{@html ae_html.not_set}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if $ae_loc.trusted_access}
|
{#if $ae_loc.trusted_access}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -148,7 +148,7 @@ async function handle_update__event_presenter({
|
|||||||
|
|
||||||
// api.send_email({
|
// api.send_email({
|
||||||
// api_cfg: $ae_api,
|
// api_cfg: $ae_api,
|
||||||
// from_email: 'noreply+agree@oneskyit.com',
|
// from_email: 'noreply+presmgmt@oneskyit.com',
|
||||||
// from_name: 'LCI 2024 Pres Mgmt Hub',
|
// from_name: 'LCI 2024 Pres Mgmt Hub',
|
||||||
// to_email: 'test+agree@oneskyit.com',
|
// to_email: 'test+agree@oneskyit.com',
|
||||||
// subject: subject,
|
// subject: subject,
|
||||||
|
|||||||
Reference in New Issue
Block a user