The Event and Event Session should now be using the new IDB save method and related updates. Need to TEST TEST TEST more now.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
import { db_events } from "$lib/ae_events/db_events";
|
||||
|
||||
import { load_ae_obj_li__event_device } from './ae_events__event_device';
|
||||
@@ -49,14 +50,36 @@ export async function load_ae_obj_id__event(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_get_result) {
|
||||
.then(async function (event_obj_get_result) {
|
||||
if (event_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__event({
|
||||
obj_type: 'event',
|
||||
obj_li: [event_obj_get_result]
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_props({
|
||||
obj_li: [event_obj_get_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'events',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__event({
|
||||
// obj_type: 'event',
|
||||
// obj_li: [event_obj_get_result]
|
||||
// });
|
||||
}
|
||||
return event_obj_get_result;
|
||||
} else {
|
||||
@@ -195,10 +218,32 @@ export async function load_ae_obj_li__event(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_li_get_result) {
|
||||
.then(async function (event_obj_li_get_result) {
|
||||
if (event_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event({obj_type: 'event', obj_li: event_obj_li_get_result});
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_props({
|
||||
obj_li: event_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'events',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
// db_save_ae_obj_li__event({obj_type: 'event', obj_li: event_obj_li_get_result});
|
||||
}
|
||||
return event_obj_li_get_result;
|
||||
} else {
|
||||
@@ -369,15 +414,37 @@ export async function create_ae_obj__event(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_create_result) {
|
||||
.then(async function (event_obj_create_result) {
|
||||
if (event_obj_create_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event(
|
||||
{
|
||||
obj_type: 'event',
|
||||
obj_li: [event_obj_create_result],
|
||||
log_lvl: log_lvl
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_props({
|
||||
obj_li: [event_obj_create_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'events',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
// db_save_ae_obj_li__event(
|
||||
// {
|
||||
// obj_type: 'event',
|
||||
// obj_li: [event_obj_create_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return event_obj_create_result;
|
||||
} else {
|
||||
@@ -480,12 +547,34 @@ export async function update_ae_obj__event(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_update_result) {
|
||||
.then(async function (event_obj_update_result) {
|
||||
if (event_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event({
|
||||
obj_type: 'event', obj_li: [event_obj_update_result]
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_props({
|
||||
obj_li: [event_obj_update_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'events',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
// db_save_ae_obj_li__event({
|
||||
// obj_type: 'event', obj_li: [event_obj_update_result]
|
||||
// });
|
||||
}
|
||||
return event_obj_update_result;
|
||||
} else {
|
||||
@@ -747,4 +836,219 @@ export function sync_config__event_pres_mgmt(
|
||||
console.log(`pres_mgmt_cfg_local:`, pres_mgmt_cfg_local);
|
||||
}
|
||||
return pres_mgmt_cfg_local;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-09
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_id',
|
||||
'event_id_random',
|
||||
|
||||
'code',
|
||||
|
||||
'account_id',
|
||||
'account_id_random',
|
||||
|
||||
'conference',
|
||||
'type',
|
||||
'name',
|
||||
'summary',
|
||||
'description',
|
||||
|
||||
'start_datetime',
|
||||
'end_datetime',
|
||||
'timezone',
|
||||
|
||||
'location_address_json',
|
||||
'location_text',
|
||||
|
||||
'attend_json',
|
||||
'attend_text',
|
||||
|
||||
'status', // draft, active, inactive, archived, unknown; currently only used with IDAA
|
||||
// review
|
||||
// approve
|
||||
// ready
|
||||
// ready_on
|
||||
// archive
|
||||
// archive_on
|
||||
|
||||
'mod_abstracts_json',
|
||||
'mod_badges_json',
|
||||
'mod_exhibits_json',
|
||||
'mod_pres_mgmt_json',
|
||||
'cfg_json',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// IDAA Recovery Meetings:
|
||||
// Currently only really used for IDAA
|
||||
'contact_li_json',
|
||||
'external_person_id',
|
||||
|
||||
'physical',
|
||||
'virtual',
|
||||
|
||||
'recurring',
|
||||
'recurring_pattern',
|
||||
'recurring_start_time',
|
||||
'recurring_end_time',
|
||||
'recurring_text',
|
||||
|
||||
'weekday_sunday',
|
||||
'weekday_monday',
|
||||
'weekday_tuesday',
|
||||
'weekday_wednesday',
|
||||
'weekday_thursday',
|
||||
'weekday_friday',
|
||||
'weekday_saturday',
|
||||
|
||||
'attend_url',
|
||||
'attend_url_text',
|
||||
'attend_url_passcode',
|
||||
'attend_phone',
|
||||
'attend_phone_passcode',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
// 'tmp_sort_1',
|
||||
// 'tmp_sort_2',
|
||||
// 'tmp_sort_3',
|
||||
|
||||
// From SQL view
|
||||
'file_count',
|
||||
'file_count_all',
|
||||
'internal_use_count',
|
||||
'event_file_id_li_json',
|
||||
// 'event_session_count',
|
||||
// 'event_presenter_count',
|
||||
// 'event_file_count',
|
||||
|
||||
// A key value list of the others
|
||||
// 'event_other_kv',
|
||||
// 'event_other_li',
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-05-09
|
||||
export async function process_ae_obj__event_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) {
|
||||
console.log('No objects to process.');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) {
|
||||
console.log(`Processing ae_obj event:`, obj);
|
||||
}
|
||||
|
||||
// Create the processed object
|
||||
let processed_obj = {
|
||||
id: obj.event_id_random,
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
|
||||
code: obj.event_code,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
account_id_random: obj.account_id_random,
|
||||
|
||||
conference: obj.conference,
|
||||
type: obj.type,
|
||||
name: obj.name,
|
||||
summary: obj.summary,
|
||||
description: obj.description,
|
||||
|
||||
start_datetime: obj.start_datetime,
|
||||
end_datetime: obj.end_datetime,
|
||||
timezone: obj.timezone,
|
||||
location_address_json: obj.location_address_json,
|
||||
location_text: obj.location_text,
|
||||
|
||||
attend_json: obj.attend_json,
|
||||
attend_text: obj.attend_text,
|
||||
|
||||
status: obj.status, // draft, active, inactive, archived, unknown; currently only used with IDAA
|
||||
// review: obj.review,
|
||||
// approve: obj.approve,
|
||||
// ready: obj.ready,
|
||||
// ready_on: obj.ready_on,
|
||||
// archive: obj.archive,
|
||||
// archive_on: obj.archive_on,
|
||||
|
||||
mod_abstracts_json: obj.mod_abstracts_json,
|
||||
mod_badges_json: obj.mod_badges_json,
|
||||
mod_exhibits_json: obj.mod_exhibits_json,
|
||||
mod_pres_mgmt_json: obj.mod_pres_mgmt_json,
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// IDAA Recovery Meetings:
|
||||
// Currently only really used for IDAA
|
||||
contact_li_json: obj.contact_li_json,
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
physical: obj.physical,
|
||||
virtual: obj.virtual,
|
||||
|
||||
recurring: obj.recurring,
|
||||
recurring_pattern: obj.recurring_pattern,
|
||||
recurring_start_time: obj.recurring_start_time,
|
||||
recurring_end_time: obj.recurring_end_time,
|
||||
recurring_text: obj.recurring_text,
|
||||
|
||||
weekday_sunday: obj.weekday_sunday,
|
||||
weekday_monday: obj.weekday_monday,
|
||||
weekday_tuesday: obj.weekday_tuesday,
|
||||
weekday_wednesday: obj.weekday_wednesday,
|
||||
weekday_thursday: obj.weekday_thursday,
|
||||
weekday_friday: obj.weekday_friday,
|
||||
weekday_saturday: obj.weekday_saturday,
|
||||
|
||||
attend_url: obj.attend_url,
|
||||
attend_url_text: obj.attend_url_text,
|
||||
attend_url_passcode: obj.attend_url_passcode,
|
||||
attend_phone: obj.attend_phone,
|
||||
attend_phone_passcode: obj.attend_phone_passcode,
|
||||
|
||||
// From SQL view
|
||||
file_count: obj.file_count,
|
||||
file_count_all: obj.file_count_all,
|
||||
internal_use_count: obj.internal_use_count,
|
||||
event_file_id_li_json: obj.event_file_id_li_json,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
@@ -877,7 +877,7 @@ export async function db_save_ae_obj_li__event_session(
|
||||
let id_random = null;
|
||||
|
||||
try {
|
||||
id_random = await db_events.event_sessions.update(obj_record.id, obj_record);
|
||||
id_random = await db_events.sessions.update(obj_record.id, obj_record);
|
||||
} catch (error) {
|
||||
console.error(`Error: Failed to update ${obj_record.id}: ${error}`);
|
||||
}
|
||||
@@ -887,7 +887,7 @@ export async function db_save_ae_obj_li__event_session(
|
||||
console.log(`Failed to update record with ID: ${obj_record.id}. Trying put...`);
|
||||
}
|
||||
try {
|
||||
id_random = await db_events.event_sessions.put(obj_record);
|
||||
id_random = await db_events.sessions.put(obj_record);
|
||||
} catch (error) {
|
||||
console.error(`Error: Failed to put ${obj.event_session_id_random}: ${error}`);
|
||||
}
|
||||
@@ -969,4 +969,184 @@ export async function email_sign_in__event_session (
|
||||
subject: subject,
|
||||
body_html: body_html,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-09
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_session_id',
|
||||
'event_session_id_random',
|
||||
|
||||
'external_id',
|
||||
'code',
|
||||
|
||||
'for_type',
|
||||
'for_id',
|
||||
'for_id_random',
|
||||
|
||||
'type_code',
|
||||
|
||||
'event_id',
|
||||
'event_id_random',
|
||||
'event_location_id',
|
||||
'event_location_id_random',
|
||||
|
||||
'poc_person_id',
|
||||
'poc_person_id_random',
|
||||
'poc_agree',
|
||||
'poc_kv_json',
|
||||
|
||||
'name',
|
||||
'description',
|
||||
|
||||
'start_datetime',
|
||||
'end_datetime',
|
||||
|
||||
'passcode',
|
||||
|
||||
'hide_event_launcher',
|
||||
|
||||
'alert',
|
||||
'alert_msg',
|
||||
|
||||
'data_json',
|
||||
|
||||
'ux_mode',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// From SQL view
|
||||
'file_count',
|
||||
'file_count_all',
|
||||
'internal_use_count',
|
||||
'event_file_id_li_json',
|
||||
|
||||
'poc_person_given_name',
|
||||
'poc_person_family_name',
|
||||
'poc_person_full_name',
|
||||
'poc_person_primary_email',
|
||||
'poc_person_passcode',
|
||||
|
||||
'event_name',
|
||||
|
||||
'event_location_code',
|
||||
'event_location_name',
|
||||
|
||||
// A key value list of the presentations
|
||||
'event_presentation_kv',
|
||||
'event_presentation_li',
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-05-09
|
||||
export async function process_ae_obj__event_session_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_session_props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) {
|
||||
console.log('No objects to process.');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) {
|
||||
console.log(`Processing ae_obj event_session:`, obj);
|
||||
}
|
||||
|
||||
// Create the processed object
|
||||
let processed_obj = {
|
||||
id: 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,
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id: obj.for_id,
|
||||
for_id_random: obj.for_id_random,
|
||||
|
||||
type_code: obj.type_code,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
poc_person_id: obj.poc_person_id_random,
|
||||
poc_person_id_random: obj.poc_person_id_random,
|
||||
poc_agree: obj.poc_agree,
|
||||
poc_kv_json: obj.poc_kv_json ?? {},
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
start_datetime: obj.start_datetime,
|
||||
end_datetime: obj.end_datetime,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
|
||||
data_json: obj.data_json,
|
||||
|
||||
ux_mode: obj.ux_mode,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// From SQL view
|
||||
file_count: obj.file_count,
|
||||
file_count_all: obj.file_count_all,
|
||||
internal_use_count: obj.internal_use_count,
|
||||
event_file_id_li_json: obj.event_file_id_li_json,
|
||||
|
||||
poc_person_given_name: obj.poc_person_given_name,
|
||||
poc_person_family_name: obj.poc_person_family_name,
|
||||
poc_person_full_name: obj.poc_person_full_name,
|
||||
poc_person_primary_email: obj.poc_person_primary_email,
|
||||
poc_person_passcode: obj.poc_person_passcode,
|
||||
|
||||
event_name: obj.event_name,
|
||||
|
||||
event_location_code: obj.event_location_code,
|
||||
event_location_name: obj.event_location_name,
|
||||
|
||||
// A key value list of the presentations
|
||||
event_presentation_kv: obj.event_presentation_kv,
|
||||
event_presentation_li: obj.event_presentation_li,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
@@ -45,13 +45,6 @@ console.log(`$slct.account_id = `, $slct.account_id);
|
||||
let ae_acct = data[$slct.account_id];
|
||||
// console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
// if (browser) {
|
||||
// console.log(`Browser: ${browser}`);
|
||||
// events_func.handle_db_save_ae_obj_li__event({
|
||||
// obj_type: 'event',
|
||||
// obj_li: [ae_acct.slct.event_obj_li],
|
||||
// });
|
||||
// }
|
||||
|
||||
$events_slct.event_id = ae_acct.slct.event_id;
|
||||
// $events_slct.event_obj = ae_acct.slct.event_obj;
|
||||
|
||||
@@ -54,13 +54,6 @@ export async function load({ parent }) {
|
||||
|
||||
// ae_acct.slct.event_obj = load_event_obj;
|
||||
|
||||
// if (browser) {
|
||||
// console.log(`Browser: ${browser}`);
|
||||
// events_func.db_save_ae_obj_li__event({
|
||||
// obj_type: 'event',
|
||||
// obj_li: [load_event_obj_li],
|
||||
// });
|
||||
// }
|
||||
|
||||
let submenu = {
|
||||
main: {name: 'Main', href: '/events_pres_mgmt', access: false},
|
||||
|
||||
Reference in New Issue
Block a user