A lot of cosmetic clean up and some code clean up. Also new util functions from old Svelte NPM library.
This commit is contained in:
@@ -1488,8 +1488,10 @@ function handle_db_save_ae_obj_li__event_file({obj_type, obj_li}) {
|
||||
|
||||
try {
|
||||
const id_random = await db_events.files.put({
|
||||
id: obj.event_file_id_random,
|
||||
id_random: obj.event_file_id_random,
|
||||
event_file_id_random: obj.event_file_id_random,
|
||||
|
||||
hosted_file_id_random: obj.hosted_file_id_random,
|
||||
hash_sha256: obj.hash_sha256, // Renamed with alias in FastAPI model
|
||||
|
||||
@@ -1549,8 +1551,11 @@ function handle_db_save_ae_obj_li__event_session({obj_type, obj_li}) {
|
||||
|
||||
try {
|
||||
const id_random = await db_events.sessions.put({
|
||||
id_random: obj.event_session_id_random,
|
||||
id: obj.event_session_id_random,
|
||||
// id_random: obj.event_session_id_random,
|
||||
event_session_id: obj.event_session_id_random,
|
||||
event_session_id_random: obj.event_session_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
@@ -1690,19 +1695,28 @@ function handle_db_save_ae_obj_li__event_presenter({obj_type, obj_li}) {
|
||||
|
||||
try {
|
||||
const id_random = await db_events.presenters.put({
|
||||
id_random: obj.event_presenter_id_random,
|
||||
id: obj.event_presenter_id_random,
|
||||
// id_random: obj.event_presenter_id_random,
|
||||
event_presenter_id: obj.event_presenter_id_random,
|
||||
event_presenter_id_random: obj.event_presenter_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
// for_type: obj.for_type,
|
||||
// for_id_random: obj.for_id_random,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
event_session_id: obj.event_session_id_random,
|
||||
event_session_id_random: obj.event_session_id_random,
|
||||
event_person_id_random: obj.event_person_id_random,
|
||||
event_presentation_id: obj.event_presentation_id_random,
|
||||
event_presentation_id_random: obj.event_presentation_id_random,
|
||||
event_person_id: obj.event_person_id_random,
|
||||
event_person_id_random: obj.event_person_id_random,
|
||||
person_id: obj.person_id_random,
|
||||
person_id_random: obj.person_id_random,
|
||||
person_profile_id: obj.person_profile_id_random,
|
||||
person_profile_id_random: obj.person_profile_id_random, // The new table person_profile will be used soon...
|
||||
|
||||
pronouns: obj.pronouns,
|
||||
@@ -1742,6 +1756,12 @@ function handle_db_save_ae_obj_li__event_presenter({obj_type, obj_li}) {
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
file_count: obj.file_count,
|
||||
|
||||
person_given_name: obj.person_given_name,
|
||||
person_family_name: obj.person_family_name,
|
||||
person_full_name: obj.person_full_name,
|
||||
person_primary_email: obj.person_primary_email,
|
||||
person_passcode: obj.person_passcode,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_presenter_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
type key_str = {
|
||||
[key: string]: string;
|
||||
};
|
||||
|
||||
type key_val = {
|
||||
[key: string]: any;
|
||||
};
|
||||
@@ -610,9 +614,6 @@ function count_words(text: string) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Adapted from: To Title Case © 2018 David Gouch | https://github.com/gouch/to-title-case */
|
||||
|
||||
// eslint-disable-next-line no-extend-native
|
||||
@@ -660,6 +661,158 @@ function to_title_case (text_string) {
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-19
|
||||
export let shorten_string = function shorten_string(
|
||||
{
|
||||
string,
|
||||
max_length=45,
|
||||
begin_length=15,
|
||||
end_length=5,
|
||||
wildcard_length=3
|
||||
} : {
|
||||
string: string,
|
||||
max_length?: number,
|
||||
begin_length?: number,
|
||||
end_length?: number,
|
||||
wildcard_length?: number
|
||||
}
|
||||
) {
|
||||
// console.log('*** shorten_filename() ***');
|
||||
|
||||
if (!string || typeof string != 'string') {
|
||||
console.log('Invalid string value passed');
|
||||
return false;
|
||||
}
|
||||
|
||||
// NOTE: max_length is not the actual end result length. The actual max will be 45 characters.
|
||||
// 20 part 1 characters, 5 part 2 characters, 20 part 3 characters
|
||||
|
||||
// let length = string.length;
|
||||
let char_over = string.length-max_length;
|
||||
let new_string = null;
|
||||
let wildcards = char_over;
|
||||
if (char_over > 0) {
|
||||
let part1 = string.slice(0, begin_length);
|
||||
|
||||
let part2 = '';
|
||||
if (char_over > 5) {
|
||||
wildcards = 5;
|
||||
} else {
|
||||
}
|
||||
|
||||
if (wildcard_length) {
|
||||
part2 = '.'.repeat(wildcard_length);
|
||||
} else {
|
||||
part2 = '.'.repeat(wildcards);
|
||||
}
|
||||
|
||||
let part3 = string.slice(end_length*-1);
|
||||
|
||||
new_string = part1+part2+part3;
|
||||
} else {
|
||||
new_string = string;
|
||||
}
|
||||
return new_string;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-19
|
||||
// This function should return a shorted version of a filename if over the max length. It should always contain at least the first character of the original filename and the complete extension.
|
||||
// Example 1: The Original Long File Name.pdf -> The Orig....pdf
|
||||
// Example 2: The Original Long File Name.html -> The Ori....html
|
||||
function shorten_filename(
|
||||
{
|
||||
filename,
|
||||
max_length=20,
|
||||
slice_end_at=15,
|
||||
max_end_length=5
|
||||
} : {
|
||||
filename: string,
|
||||
max_length?: number,
|
||||
slice_end_at?: number,
|
||||
max_end_length?: number
|
||||
}
|
||||
) {
|
||||
// console.log('*** shorten_filename() ***');
|
||||
|
||||
if (typeof filename !== 'string' || filename.length <= max_length) {
|
||||
return filename;
|
||||
}
|
||||
|
||||
let new_filename = null;
|
||||
let char_over = filename.length - max_length;
|
||||
let wildcards = char_over - 4; // The number of characters over the max length
|
||||
if (wildcards < 1) {
|
||||
return filename; // No point in changing the filename?
|
||||
}
|
||||
|
||||
let part_1 = filename.slice(0, slice_end_at);
|
||||
if (wildcards > 3) {
|
||||
wildcards = 3;
|
||||
} else {
|
||||
}
|
||||
let part_2 = '.'.repeat(wildcards);
|
||||
let part_3 = filename.slice(max_end_length*-1);
|
||||
|
||||
new_filename = part_1+part_2+part_3;
|
||||
|
||||
return new_filename;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-6-19
|
||||
function file_extension_icon(
|
||||
extension: string
|
||||
) {
|
||||
// console.log('*** file_extension_icon() ***');
|
||||
|
||||
let file_icons: key_str = {
|
||||
'file': 'file',
|
||||
'3gp': 'file-video',
|
||||
'7z': 'file-archive',
|
||||
'aac': 'file-audio',
|
||||
'ac3': 'file-audio',
|
||||
'aif': 'file-audio',
|
||||
'aiff': 'file-audio',
|
||||
'avi': 'file-video',
|
||||
'bmp': 'file-image',
|
||||
'csv': 'file-csv',
|
||||
'doc': 'file-word',
|
||||
'docx': 'file-word',
|
||||
'eps': 'file-image',
|
||||
'flac': 'file-audio',
|
||||
'gif': 'file-image',
|
||||
'htm': 'file-code',
|
||||
'html': 'file-code',
|
||||
'jpeg': 'file-image',
|
||||
'jpg': 'file-image',
|
||||
'key': 'file-powerpoint',
|
||||
'mkv': 'file-video',
|
||||
'mov': 'file-video',
|
||||
'mp3': 'file-audio',
|
||||
'mp4': 'file-video',
|
||||
'odp': 'file-powerpoint',
|
||||
'pdf': 'file-pdf',
|
||||
'png': 'file-image',
|
||||
'ppt': 'file-powerpoint',
|
||||
'pptx': 'file-powerpoint',
|
||||
'txt': 'file-alt',
|
||||
'wav': 'file-audio',
|
||||
'webp': 'file-image',
|
||||
'xls': 'file-excel',
|
||||
'xlsx': 'file-excel',
|
||||
'zip': 'file-archive'
|
||||
};
|
||||
|
||||
if (file_icons[extension]) {
|
||||
return file_icons[extension];
|
||||
} else {
|
||||
// return null;
|
||||
return file_icons['file'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2023-08-18
|
||||
function set_obj_prop_display_name({prop_name, obj_type=null, prefix_w_obj_type=true, prefix_all_w_obj_type=false, replace_underscores=true, title_case=true, override=null}) {
|
||||
console.log('*** set_obj_prop_display_name() ***');
|
||||
@@ -850,6 +1003,9 @@ export let ae_util = {
|
||||
create_video_element: create_video_element,
|
||||
count_words: count_words,
|
||||
to_title_case: to_title_case,
|
||||
shorten_string: shorten_string,
|
||||
shorten_filename: shorten_filename,
|
||||
file_extension_icon: file_extension_icon,
|
||||
set_obj_prop_display_name: set_obj_prop_display_name,
|
||||
return_obj_type_path: return_obj_type_path,
|
||||
};
|
||||
|
||||
@@ -179,8 +179,10 @@ export interface Exhibit_tracking {
|
||||
}
|
||||
|
||||
export interface File {
|
||||
id: string;
|
||||
id_random: string;
|
||||
event_file_id_random: string;
|
||||
|
||||
hosted_file_id_random: string;
|
||||
hash_sha256: string;
|
||||
|
||||
@@ -218,27 +220,35 @@ export interface File {
|
||||
hosted_file_size: number; // In bytes
|
||||
}
|
||||
|
||||
// Updated 2024-06-19
|
||||
export interface Session {
|
||||
id_random: string;
|
||||
id: string;
|
||||
// id_random: string;
|
||||
event_session_id: string;
|
||||
event_session_id_random: string;
|
||||
external_id: string;
|
||||
code: string;
|
||||
|
||||
external_id: null|string;
|
||||
code: null|string;
|
||||
|
||||
for_type: string;
|
||||
for_id: string;
|
||||
for_id_random: string;
|
||||
|
||||
type_code: string;
|
||||
|
||||
event_id: string;
|
||||
event_id_random: string;
|
||||
event_location_id_random: string;
|
||||
event_location_id: null|string;
|
||||
event_location_id_random: null|string;
|
||||
|
||||
poc_person_id_random: string;
|
||||
poc_person_id: null|string;
|
||||
poc_person_id_random: null|string;
|
||||
|
||||
name: string;
|
||||
description: null|string;
|
||||
|
||||
start_datetime: Date;
|
||||
end_datetime: Date;
|
||||
start_datetime: null|Date;
|
||||
end_datetime: null|Date;
|
||||
|
||||
passcode: null|string;
|
||||
|
||||
@@ -259,42 +269,49 @@ export interface Session {
|
||||
updated_on: null|Date;
|
||||
|
||||
// Additional fields for convenience (database views)
|
||||
file_count: number;
|
||||
file_count: null|number;
|
||||
|
||||
poc_person_given_name: string;
|
||||
poc_person_family_name: string;
|
||||
poc_person_full_name: string;
|
||||
poc_person_primary_email: string;
|
||||
poc_person_passcode: string;
|
||||
poc_person_given_name: null|string;
|
||||
poc_person_family_name: null|string;
|
||||
poc_person_full_name: null|string;
|
||||
poc_person_primary_email: null|string;
|
||||
poc_person_passcode: null|string;
|
||||
poc_kv_json: null|string;
|
||||
|
||||
event_location_code: string;
|
||||
event_location_name: string;
|
||||
event_location_code: null|string;
|
||||
event_location_name: null|string;
|
||||
}
|
||||
|
||||
// Updated 2024-06-10
|
||||
export interface Presentation {
|
||||
id: string;
|
||||
id_random: string;
|
||||
event_presentation_id: string;
|
||||
event_presentation_id_random: string;
|
||||
external_id: string;
|
||||
code: string;
|
||||
|
||||
external_id: null|string;
|
||||
code: null|string;
|
||||
|
||||
for_type: string;
|
||||
for_id: string;
|
||||
for_id_random: string;
|
||||
|
||||
type_code: string;
|
||||
|
||||
event_id: string;
|
||||
event_id_random: string;
|
||||
event_session_id: string;
|
||||
event_session_id_random: string;
|
||||
event_abstract_id_random: string;
|
||||
event_abstract_id: null|string;
|
||||
event_abstract_id_random: null|string;
|
||||
|
||||
abstract_code: string;
|
||||
abstract_code: null|string;
|
||||
|
||||
name: string;
|
||||
description: null|string;
|
||||
|
||||
start_datetime: Date;
|
||||
end_datetime: Date;
|
||||
start_datetime: null|Date;
|
||||
end_datetime: null|Date;
|
||||
|
||||
hide_event_launcher: null|boolean;
|
||||
|
||||
@@ -306,21 +323,36 @@ export interface Presentation {
|
||||
notes: null|string;
|
||||
created_on: Date;
|
||||
updated_on: null|Date;
|
||||
|
||||
// Additional fields for convenience (database views)
|
||||
// file_count: null|number;
|
||||
|
||||
event_session_code: null|string;
|
||||
event_session_name: null|string;
|
||||
}
|
||||
|
||||
// Updated 2024-06-10
|
||||
export interface Presenter {
|
||||
id_random: string;
|
||||
id: string;
|
||||
// id_random: string;
|
||||
event_presenter_id: string;
|
||||
event_presenter_id_random: string;
|
||||
|
||||
external_id: string;
|
||||
code: string;
|
||||
|
||||
event_id: string;
|
||||
event_id_random: string;
|
||||
event_session_id: string;
|
||||
event_session_id_random: string;
|
||||
event_person_id_random: string;
|
||||
event_person_id: null|string;
|
||||
event_person_id_random: null|string;
|
||||
event_presentation_id: string;
|
||||
event_presentation_id_random: string;
|
||||
person_id_random: string;
|
||||
person_profile_id_random: string; // The new table person_profile will be used soon...
|
||||
person_id: null|string;
|
||||
person_id_random: null|string;
|
||||
person_profile_id: null|string;
|
||||
person_profile_id_random: null|string; // The new table person_profile will be used soon...
|
||||
|
||||
pronouns: null|string;
|
||||
informal_name: null|string;
|
||||
@@ -359,9 +391,13 @@ export interface Presenter {
|
||||
updated_on: null|Date;
|
||||
|
||||
// Additional fields for convenience (database views)
|
||||
file_count: number;
|
||||
person_passcode: string;
|
||||
person_primary_email: string;
|
||||
file_count: null|number;
|
||||
|
||||
person_given_name: null|string;
|
||||
person_family_name: null|string;
|
||||
person_full_name: null|string;
|
||||
person_primary_email: null|string;
|
||||
person_passcode: null|string;
|
||||
}
|
||||
|
||||
|
||||
@@ -385,7 +421,7 @@ export class MySubClassedDexie extends Dexie {
|
||||
id_random, event_id_random,
|
||||
code, account_id_random,
|
||||
conference, type,
|
||||
name, summary, description,
|
||||
name,
|
||||
start_datetime, end_datetime,
|
||||
timezone, location_address_json,
|
||||
mod_abstracts_json, mod_badges_json, mod_exhibits_json, mod_pres_mgmt_json,
|
||||
@@ -414,14 +450,17 @@ export class MySubClassedDexie extends Dexie {
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
||||
|
||||
sessions: `
|
||||
id_random, event_session_id_random, external_id, code,
|
||||
for_type, for_id_random, type_code,
|
||||
event_session_id, event_session_id_random,
|
||||
external_id, code,
|
||||
for_type, for_id, for_id_random,
|
||||
type_code,
|
||||
event_id, event_location_id,
|
||||
poc_person_id,
|
||||
event_id_random, event_location_id_random,
|
||||
poc_person_id_random, poc_person_given_name, poc_person_family_name, poc_person_full_name, poc_person_primary_email, poc_kv_json,
|
||||
name, description, start_datetime, end_datetime,
|
||||
passcode,
|
||||
poc_person_id_random,
|
||||
name, start_datetime, end_datetime,
|
||||
hide_event_launcher,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
||||
|
||||
files: `
|
||||
id_random, event_file_id_random, hosted_file_id_random, hash_sha256,
|
||||
@@ -442,12 +481,15 @@ export class MySubClassedDexie extends Dexie {
|
||||
`,
|
||||
|
||||
presenters: `
|
||||
id_random, event_presenter_id_random, external_id, code,
|
||||
event_presenter_id, event_presenter_id_random,
|
||||
external_id, code,
|
||||
event_id, event_session_id, event_person_id, event_presentation_id,
|
||||
event_id_random, event_session_id_random, event_person_id_random, event_presentation_id_random,
|
||||
person_id, person_profile_id,
|
||||
person_id_random, person_profile_id_random,
|
||||
pronouns, informal_name, title_names, given_name, middle_name, family_name, designations,
|
||||
professional_title, full_name, affiliations, email,
|
||||
biography, agree, comments, passcode,
|
||||
given_name, family_name,
|
||||
full_name, affiliations, email,
|
||||
agree
|
||||
hide_event_launcher,
|
||||
data_json,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on
|
||||
|
||||
Reference in New Issue
Block a user