refactor: Standardize data processing and update to Svelte 5 runes

This commit introduces a major refactoring of the data processing logic across multiple modules (events, archives, posts, sponsorships) to use a standardized pattern with . This improves consistency and maintainability.

Key changes:
- Replaced module-specific data processing with a generic helper.
- Removed deprecated  functions.
- Updated Svelte components to leverage the new Svelte 5 runes, simplifying state management.
- Fixed linting errors and updated test configurations.
- Added .
This commit is contained in:
Scott Idem
2025-11-17 16:38:54 -05:00
parent c4fa35e86e
commit a3b37a5df4
31 changed files with 979 additions and 1491 deletions

View File

@@ -576,13 +576,31 @@ export async function qry__archive(
params: params,
log_lvl: log_lvl
})
.then(function (archive_obj_li_get_result) {
.then(async function (archive_obj_li_get_result) {
if (archive_obj_li_get_result) {
if (try_cache) {
db_save_ae_obj_li__archive({
obj_type: 'archive',
obj_li: archive_obj_li_get_result
// Process the results first
let processed_obj_li = await process_ae_obj__archive_props({
obj_li: archive_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...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_archives,
table_name: 'archive',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return archive_obj_li_get_result;
} else {
@@ -734,82 +752,7 @@ export async function qry__archive(
// }
// This function will loop through the archive_obj_li and save each one to the DB.
// Updated 2024-09-25
export function db_save_ae_obj_li__archive(
{
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__archive() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_archives.archive.put({
id: obj.archive_id_random,
archive_id: obj.archive_id_random,
code: obj.code,
account_id: obj.account_id_random,
name: obj.name,
description: obj.description,
original_datetime: obj.original_datetime,
original_timezone: obj.original_timezone,
original_location: obj.original_location,
original_url: obj.original_url,
original_url_text: obj.original_url_text,
sort_by: obj.sort_by,
sort_by_desc: obj.sort_by_desc,
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,
// From SQL view
// archive_content_count: obj.archive_content_count,
// A key value list of the contents
// archive_content_kv: obj.archive_content_kv,
// archive_content_li: obj.archive_content_li,
});
// console.log(`Put obj with ID: ${obj.archive_id_random} or ${id_random}`);
} catch (error) {
let status = `Failed to put ${obj.archive_id_random}: ${error}`;
console.log(status);
}
// const id_random = await db_archives.archive.put(obj);
// console.log(`Put obj with ID: ${obj.archive_id_random}`);
});
return true;
}
}
// Updated 2025-06-04

View File

@@ -406,96 +406,7 @@ export async function update_ae_obj__archive_content(
}
// This function will loop through the archive_content_obj_li and save each one to the DB.
// Updated 2024-09-25
export async function db_save_ae_obj_li__archive_content(
{
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__archive_content() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_archives.content.put({
id: obj.archive_content_id_random,
archive_content_id: obj.archive_content_id_random,
archive_id: obj.archive_id_random,
archive_content_type: obj.archive_content_type,
name: obj.name,
description: obj.description,
content_html: obj.content_html,
content_json: obj.content_json,
url: obj.url,
url_text: obj.url_text,
hosted_file_id: obj.hosted_file_id_random,
file_path: obj.file_path,
filename: obj.filename,
file_extension: obj.file_extension,
original_datetime: obj.original_datetime,
original_timezone: obj.original_timezone,
original_location: obj.original_location,
original_url: obj.original_url,
original_url_text: obj.original_url_text,
enable_for_public: obj.enable_for_public,
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,
// Generated fields for sorting locally only
tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`,
tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`,
// From SQL view
archive_code: obj.archive_code,
archive_name: obj.archive_name,
hash_sha256: obj.hosted_file_hash_sha256 ?? ''
});
// console.log(`Put obj with ID: ${obj.archive_content_id_random} or ${id_random}`);
} catch (error) {
let status = `Failed to put ${obj.archive_content_id_random}: ${error}`;
console.log(status);
}
// const id_random = await db_archives.content.put(obj);
// console.log(`Put obj with ID: ${obj.archive_content_id_random}`);
});
return true;
}
}
// Updated 2025-06-04

View File

@@ -6,8 +6,7 @@ import {
create_ae_obj__archive,
delete_ae_obj_id__archive,
update_ae_obj__archive,
// qry__archive,
db_save_ae_obj_li__archive,
} from "$lib/ae_archives/ae_archives__archive";
@@ -17,8 +16,7 @@ import {
create_ae_obj__archive_content,
delete_ae_obj_id__archive_content,
update_ae_obj__archive_content,
// qry__archive_content,
db_save_ae_obj_li__archive_content,
} from "$lib/ae_archives/ae_archives__archive_content";
@@ -28,13 +26,13 @@ let export_obj = {
create_ae_obj__archive: create_ae_obj__archive,
delete_ae_obj_id__archive: delete_ae_obj_id__archive,
update_ae_obj__archive: update_ae_obj__archive,
db_save_ae_obj_li__archive: db_save_ae_obj_li__archive,
load_ae_obj_id__archive_content: load_ae_obj_id__archive_content,
load_ae_obj_li__archive_content: load_ae_obj_li__archive_content,
create_ae_obj__archive_content: create_ae_obj__archive_content,
delete_ae_obj_id__archive_content: delete_ae_obj_id__archive_content,
update_ae_obj__archive_content: update_ae_obj__archive_content,
db_save_ae_obj_li__archive_content: db_save_ae_obj_li__archive_content,
};
export let archives_func = export_obj;

View File

@@ -1,6 +1,6 @@
import Dexie, { type Table } from 'dexie';
import type { key_val } from '../ae_stores';
import type { key_val } from '$lib/stores/ae_stores';
// li = list
// kv = key value list

View File

@@ -510,31 +510,7 @@ export async function search__event_badge({
}
// Updated 2025-10-06
export async function db_save_ae_obj_li__event_badge({
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any[],
log_lvl?: number
}) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__event_badge() *** obj_type=${obj_type}`, obj_li);
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl) console.log('No objects to save.');
return [];
}
return await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'badge',
obj_li,
properties_to_save,
log_lvl,
});
}
// Updated 2025-10-06

View File

@@ -178,31 +178,7 @@ export async function process_ae_obj__event_badge_template_props({
}
// --- DB SAVE FUNCTION ---
export async function db_save_ae_obj_li__event_badge_template({
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any[],
log_lvl?: number
}) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__event_badge_template() *** obj_type=${obj_type}`, obj_li);
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl) console.log('No objects to save.');
return [];
}
return await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'badge_template',
obj_li,
properties_to_save,
log_lvl,
});
}
// --- CRUD FUNCTIONS ---

View File

@@ -557,10 +557,31 @@ export async function search__event_device(
params: params,
log_lvl: log_lvl
})
.then(function (event_device_obj_li_get_result) {
.then(async function (event_device_obj_li_get_result) {
if (event_device_obj_li_get_result) {
if (try_cache) {
db_save_ae_obj_li__event_device({obj_type: 'event_device', obj_li: event_device_obj_li_get_result});
// Process the results first
let processed_obj_li = await process_ae_obj__event_device_props({
obj_li: event_device_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...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'device',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return event_device_obj_li_get_result;
} else {
@@ -580,106 +601,7 @@ export async function search__event_device(
}
// This function will loop through the event_device_obj_li and save each one to the DB.
// Updated 2024-10-16
export function db_save_ae_obj_li__event_device(
{
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__event_device() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_events.device.put({
id: obj.event_device_id_random,
event_device_id: obj.event_device_id_random,
// event_device_id_random: obj.event_device_id_random,
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,
code: obj.code,
name: obj.name,
description: obj.description,
passcode: obj.passcode,
local_file_cache_path: obj.local_file_cache_path,
host_file_temp_path: obj.host_file_temp_path,
recording_path: obj.recording_path,
record_audio: obj.record_audio,
record_video: obj.record_video,
trigger_open_file_id: obj.trigger_open_file_id,
trigger_open_session_id: obj.trigger_open_session_id,
trigger_recording_start: obj.trigger_recording_start,
trigger_recording_stop: obj.trigger_recording_stop,
trigger_reset: obj.trigger_reset,
trigger_show_admin: obj.trigger_show_admin,
trigger_show_hidden: obj.trigger_show_hidden,
alert: obj.alert,
alert_msg: obj.alert_msg,
alert_on: obj.alert_on,
status: obj.status,
status_msg: obj.status_msg,
status_on: obj.status_on,
record_status: obj.record_status,
record_status_msg: obj.record_status_msg,
record_status_on: obj.record_status_on,
// These are timestamps that are in UTC but missing the 'Z' at the end
heartbeat: obj.heartbeat ? obj.heartbeat+'Z' : null,
info_hostname: obj.info_hostname,
info_ip_list: obj.info_ip_list,
meta_json: obj.meta_json,
other_json: obj.other_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,
// From SQL view
event_name: obj.event_name,
event_location_code: obj.event_location_code,
event_location_name: obj.event_location_name,
});
// console.log(`Put obj with ID: ${obj.event_device_id_random} or ${id_random}`);
} catch (error) {
let status = `Failed to put ${obj.event_device_id_random}: ${error}`;
console.log(status);
}
// const id_random = await db_events.device.put(obj);
// console.log(`Put obj with ID: ${obj.event_device_id_random}`);
});
return true;
}
}
// Updated 2025-05-23

View File

@@ -675,193 +675,9 @@ export async function search__event_file(
}
// This function will loop through the event_file_obj_li and save each one to the DB.
// Updated 2024-10-04
export function db_save_ae_obj_li__event_file(
{
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__event_file() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_events.file.put({
id: obj.event_file_id_random,
id_random: obj.event_file_id_random,
event_file_id: obj.event_file_id_random,
event_file_id_random: obj.event_file_id_random,
hosted_file_id: obj.hosted_file_id_random,
hosted_file_id_random: obj.hosted_file_id_random,
hash_sha256: obj.hash_sha256, // Renamed with alias in FastAPI model
for_type: obj.for_type,
for_id: obj.for_id_id_random,
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_presentation_id: obj.event_presentation_id_random,
event_presentation_id_random: obj.event_presentation_id_random,
event_presenter_id: obj.event_presenter_id_random,
event_presenter_id_random: obj.event_presenter_id_random,
event_location_id: obj.event_location_id_random,
event_location_id_random: obj.event_location_id_random,
filename: obj.filename,
extension: obj.extension,
open_in_os: obj.open_in_os,
lu_file_purpose_id: obj.lu_file_purpose_id, // Not id_random in this case?
lu_event_file_purpose_name: obj.lu_event_file_purpose_name,
file_purpose: obj.file_purpose,
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,
filename_no_ext: obj.filename_no_ext,
filename_w_ext: obj.filename_w_ext,
hosted_file_content_type: obj.hosted_file_content_type,
file_size: obj.file_size,
hosted_file_size: obj.hosted_file_size,
event_location_code: obj.event_location_code,
event_location_name: obj.event_location_name,
event_session_code: obj.event_session_code,
event_session_type_code: obj.event_session_type_code,
event_session_name: obj.event_session_name,
event_session_start_datetime: obj.event_session_start_datetime,
event_session_end_datetime: obj.event_session_end_datetime,
event_presentation_code: obj.event_presentation_code,
event_presentation_type_code: obj.event_presentation_type_code,
event_presentation_name: obj.event_presentation_name,
event_presentation_start_datetime: obj.event_presentation_start_datetime,
event_presentation_end_datetime: obj.event_presentation_end_datetime,
event_presenter_given_name: obj.event_presenter_given_name,
event_presenter_family_name: obj.event_presenter_family_name,
event_presenter_full_name: obj.event_presenter_full_name,
event_presenter_email: obj.event_presenter_email,
});
// console.log(`Put obj with ID: ${obj.event_file_id_random} or ${id_random}`);
} catch (error) {
let status = `Failed to put ${obj.event_file_id_random}: ${error}`;
console.log(status);
}
// const id_random = await db_events.file.put(obj);
// console.log(`Put obj with ID: ${obj.event_file_id_random}`);
});
return true;
}
return false;
}
export function db_update_ae_obj_id__event_file(
{
obj_type,
obj_id,
data_kv,
}: {
obj_type: string,
obj_id: string,
data_kv: key_val
}
) {
console.log(`*** db_update_ae_obj_id__event_file() ***`);
if (obj_id) {
console.log(`ae_obj ${obj_type}:`, obj_id);
try {
// db_events.file.update(obj_id, data_kv);
db_events.file.update(obj_id,
{
// for_type: data_kv.for_type,
// for_id: data_kv.for_id_id_random,
// for_id_random: data_kv.for_id_random,
// event_id_random: data_kv.event_id_random,
// event_session_id_random: data_kv.event_session_id_random,
// event_presentation_id_random: data_kv.event_presentation_id_random,
// event_presenter_id_random: data_kv.event_presenter_id_random,
// event_location_id_random: data_kv.event_location_id_random,
filename: data_kv.filename,
extension: data_kv.extension,
open_in_os: data_kv.open_in_os,
// lu_file_purpose_id: data_kv.lu_file_purpose_id, // Not id_random in this case?
// lu_event_file_purpose_name: data_kv.lu_event_file_purpose_name,
file_purpose: data_kv.file_purpose,
// enable: data_kv.enable,
// hide: data_kv.hide,
// priority: data_kv.priority,
// sort: data_kv.sort,
// group: data_kv.group,
// notes: data_kv.notes,
// created_on: data_kv.created_on,
// updated_on: data_kv.updated_on,
filename_no_ext: data_kv.filename_no_ext,
filename_w_ext: data_kv.filename_w_ext,
// hosted_file_content_type: data_kv.hosted_file_content_type,
// file_size: data_kv.file_size,
// hosted_file_size: data_kv.hosted_file_size,
// event_location_code: data_kv.event_location_code,
// event_location_name: data_kv.event_location_name,
// event_session_code: data_kv.event_session_code,
// event_session_name: data_kv.event_session_name,
// event_session_start_datetime: data_kv.event_session_start_datetime,
// event_presentation_code: data_kv.event_presentation_code,
// event_presentation_name: data_kv.event_presentation_name,
// event_presentation_start_datetime: data_kv.event_presentation_start_datetime,
// event_presenter_given_name: data_kv.event_presenter_given_name,
// event_presenter_family_name: data_kv.event_presenter_family_name,
// event_presenter_full_name: data_kv.event_presenter_full_name,
// event_presenter_email: data_kv.event_presenter_email,
}
);
console.log(`Update obj with ID: ${obj_id}`);
} catch (error) {
let status = `Failed to update ${obj_id}: ${error}`;
console.log(status);
}
// const id_random = await db_events.file.put(obj);
// console.log(`Put obj with ID: ${data_kv.event_file_id_random}`);
return true;
}
return false;
}
// Updated 2025-05-23

View File

@@ -659,10 +659,31 @@ export async function search__event_location(
params: params,
log_lvl: log_lvl
})
.then(function (event_location_obj_li_get_result) {
.then(async function (event_location_obj_li_get_result) {
if (event_location_obj_li_get_result) {
if (try_cache) {
db_save_ae_obj_li__event_location({obj_type: 'event_location', obj_li: event_location_obj_li_get_result});
// Process the results first
let processed_obj_li = await process_ae_obj__event_location_props({
obj_li: event_location_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...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'location',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return event_location_obj_li_get_result;
} else {
@@ -682,92 +703,7 @@ export async function search__event_location(
}
// This function will loop through the event_location_obj_li and save each one to the DB.
// Updated 2024-06-25
export function db_save_ae_obj_li__event_location(
{
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__event_location() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_events.location.put({
id: obj.event_location_id_random,
event_location_id: obj.event_location_id_random,
event_location_id_random: obj.event_location_id_random,
external_id: obj.external_id,
code: obj.code,
type_code: obj.type_code,
event_id: obj.event_id_random,
event_id_random: obj.event_id_random,
name: obj.name,
description: obj.description,
passcode: obj.passcode,
hide_event_launcher: obj.hide_event_launcher,
alert: obj.alert,
alert_msg: obj.alert_msg,
data_json: obj.data_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,
// 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,
// poc_kv_json: obj.poc_kv_json,
event_name: obj.event_name,
});
// console.log(`Put obj with ID: ${obj.event_location_id_random} or ${id_random}`);
} catch (error) {
let status = `Failed to put ${obj.event_location_id_random}: ${error}`;
console.log(status);
}
// const id_random = await db_events.location.put(obj);
// console.log(`Put obj with ID: ${obj.event_location_id_random}`);
});
return true;
}
}
// Updated 2025-05-23

View File

@@ -563,93 +563,7 @@ export async function update_ae_obj__event_presentation(
}
// This function will loop through the event_presentation_obj_li and save each one to the DB.
// Updated 2024-06-10
export function db_save_ae_obj_li__event_presentation(
{
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__event_presentation() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_events.presentation.put({
id: obj.event_presentation_id_random,
// id_random: obj.event_presentation_id_random,
event_presentation_id: obj.event_presentation_id_random,
event_presentation_id_random: obj.event_presentation_id_random,
external_id: obj.external_id,
code: obj.code,
for_type: obj.for_type,
for_id: obj.for_id_random,
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_session_id: obj.event_session_id_random,
event_session_id_random: obj.event_session_id_random,
event_abstract_id: obj.event_abstract_id_random,
event_abstract_id_random: obj.event_abstract_id_random,
abstract_code: obj.abstract_code,
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,
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
event_session_code: obj.event_session_code,
event_session_name: obj.event_session_name,
// A key value list of the presenters
// event_presenter_kv: obj.event_presenter_kv,
});
// console.log(`Put obj with ID: ${obj.event_presentation_id_random} or ${id_random}`);
} catch (error) {
let status = `Failed to put ${obj.event_presentation_id_random}: ${error}`;
console.log(status);
}
// const id_random = await db_events.presentation.put(obj);
// console.log(`Put obj with ID: ${obj.event_presentation_id_random}`);
});
return true;
}
}
// Updated 2025-05-22

View File

@@ -607,15 +607,32 @@ export async function search__event_presenter(
params: params,
log_lvl: log_lvl
})
.then(function (event_presenter_obj_li_get_result) {
.then(async function (event_presenter_obj_li_get_result) {
if (event_presenter_obj_li_get_result) {
if (try_cache) {
db_save_ae_obj_li__event_presenter({
obj_type: 'event_presenter',
obj_li: event_presenter_obj_li_get_result
// Process the results first
let processed_obj_li = await process_ae_obj__event_presenter_props({
obj_li: event_presenter_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...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'presenter',
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_presenter({obj_type: 'event_presenter', obj_li: event_presenter_obj_li_get_result});
return event_presenter_obj_li_get_result;
} else {
return [];
@@ -634,124 +651,7 @@ export async function search__event_presenter(
}
// Updated 2024-06-10
export function db_save_ae_obj_li__event_presenter(
{
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__event_presenter() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_events.presenter.put({
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_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,
informal_name: obj.informal_name,
title_names: obj.title_names,
given_name: obj.given_name,
middle_name: obj.middle_name,
family_name: obj.family_name,
designations: obj.designations,
professional_title: obj.professional_title,
full_name: obj.full_name,
affiliations: obj.affiliations,
email: obj.email,
biography: obj.biography,
agree: obj.agree,
comments: obj.comments,
passcode: obj.passcode,
hide_event_launcher: obj.hide_event_launcher,
data_json: obj.data_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,
// From SQL view
file_count: obj.file_count,
event_session_code: obj.event_session_code,
event_session_name: obj.event_session_name,
event_session_start_datetime: obj.event_session_start_datetime,
event_presentation_code: obj.event_presentation_code,
event_presentation_name: obj.event_presentation_name,
event_presentation_start_datetime: obj.event_presentation_start_datetime,
person_external_id: obj.person_external_id,
person_external_sys_id: obj.person_external_sys_id,
person_given_name: obj.person_given_name,
person_family_name: obj.person_family_name,
person_full_name: obj.person_full_name,
person_professional_title: obj.person_professional_title,
person_affiliations: obj.person_affiliations,
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) {
let status = `Failed to put ${obj.event_presenter_id_random}: ${error}`;
console.log(status);
}
// const id_random = await db_events.presenter.put(obj);
// console.log(`Put obj with ID: ${obj.event_presenter_id_random}`);
});
return true;
}
return false;
}
// Updated 2024-08-07

View File

@@ -3,11 +3,203 @@ import { api } from '$lib/api/api';
import { db_events } from "$lib/ae_events/db_events";
let ae_promises: key_val = {};
// --- PROPERTIES TO SAVE ---
export const properties_to_save_exhibit_tracking = [
'id',
'event_exhibit_tracking_id',
'event_exhibit_id',
'event_badge_id',
'event_person_id',
'external_person_id',
'exhibitor_notes',
'responses_json',
'data_json',
'event_exhibit_name',
'event_badge_title_names',
'event_badge_given_name',
'event_badge_family_name',
'event_badge_designations',
'event_badge_full_name',
'event_badge_full_name_override',
'event_badge_professional_title',
'event_badge_professional_title_override',
'event_badge_affiliations',
'event_badge_affiliations_override',
'event_badge_email',
'event_badge_email_override',
'event_badge_location',
'event_badge_location_override',
'event_badge_country',
'enable',
'hide',
'priority',
'sort',
'group',
'notes',
'created_on',
'updated_on',
// Generated fields for sorting locally only
'tmp_sort_1',
'tmp_sort_2',
];
// --- PROCESS FUNCTION ---
export async function process_ae_obj__exhibit_tracking_props({
obj_li,
log_lvl = 0
}: {
obj_li: any[];
log_lvl?: number;
}) {
return _process_generic_props({
obj_li,
obj_type: 'event_exhibit_tracking',
log_lvl,
specific_processor: (obj) => {
// Event exhibit tracking-specific computed sort fields, overriding generic ones if needed
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on ?? obj.created_on}`;
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on}_${obj.created_on}`;
return obj;
}
});
}
// --- PROPERTIES TO SAVE ---
export const properties_to_save = [
'id',
'event_exhibit_id',
'event_id',
'code',
'name',
'description',
'staff_passcode',
'data_json',
'leads_api_access',
'leads_custom_questions_json',
'leads_device_sm_qty',
'leads_device_lg_qty',
'license_max',
'license_li_json',
'cfg_json',
'enable',
'hide',
'priority',
'sort',
'group',
'notes',
'created_on',
'updated_on',
// Generated fields for sorting locally only
'tmp_sort_1',
'tmp_sort_2',
];
/**
* NON-EXPORTED LOCAL HELPER
* Processes a list of Aether objects by applying common and specific transformations.
*/
async function _process_generic_props<T extends Record<string, any>>({
obj_li,
obj_type,
log_lvl = 0,
specific_processor
}: {
obj_li: T[];
obj_type: string;
log_lvl?: number;
specific_processor?: (obj: T) => Promise<T> | T;
}): Promise<T[]> {
if (log_lvl > 0) {
console.log(
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
);
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl > 0) console.log('No objects to process.');
return [];
}
const processed_obj_li: T[] = [];
for (const original_obj of obj_li) {
let processed_obj = { ...original_obj };
// --- Common Transformations ---
// 1. Standardize ID and other '_random' fields
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
for (const key in processed_obj) {
if (key.endsWith('_random')) {
const newKey = key.slice(0, -7); // Remove '_random' suffix
processed_obj[newKey] = processed_obj[key];
}
}
// Ensure 'id' is set from '[obj_type]_id_random'
const randomIdKey = `${obj_type}_id_random`;
if (processed_obj[randomIdKey]) {
(processed_obj as any).id = processed_obj[randomIdKey];
}
// 2. Create common computed properties for client-side sorting.
const group = processed_obj.group ?? '0';
const priority = processed_obj.priority ? 1 : 0;
const sort = processed_obj.sort ?? '0';
const updated = processed_obj.updated_on ?? processed_obj.created_on;
const name = processed_obj.name ?? '';
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
// --- Specific Transformations ---
if (specific_processor) {
processed_obj = await Promise.resolve(specific_processor(processed_obj));
}
processed_obj_li.push(processed_obj as T);
}
return processed_obj_li;
}
// --- PROCESS FUNCTION ---
export async function process_ae_obj__exhibit_props({
obj_li,
log_lvl = 0
}: {
obj_li: any[];
log_lvl?: number;
}) {
return _process_generic_props({
obj_li,
obj_type: 'event_exhibit',
log_lvl,
specific_processor: (obj) => {
// Event exhibit-specific computed sort fields, overriding generic ones if needed
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on ?? obj.created_on}`;
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on}_${obj.created_on}`;
return obj;
}
});
}
// Updated 2024-03
export async function handle_load_ae_obj_id__exhibit(
export async function load_ae_obj_id__exhibit(
{
api_cfg,
exhibit_id,
@@ -20,7 +212,7 @@ export async function handle_load_ae_obj_id__exhibit(
log_lvl?: number
}
) {
console.log(`*** handle_load_ae_obj_id__exhibit() *** exhibit_id=${exhibit_id}`);
console.log(`*** load_ae_obj_id__exhibit() *** exhibit_id=${exhibit_id}`);
let params = {};
@@ -34,10 +226,32 @@ export async function handle_load_ae_obj_id__exhibit(
params: params,
log_lvl: log_lvl
})
.then(function (exhibit_obj_get_result) {
.then(async function (exhibit_obj_get_result) {
if (exhibit_obj_get_result) {
// This is expecting a list
handle_db_save_ae_obj_li__exhibitor({obj_type: 'event_exhibit', obj_li: [exhibit_obj_get_result]});
if (try_cache) {
// Process the results first
let processed_obj_li = await process_ae_obj__exhibit_props({
obj_li: [exhibit_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: 'exhibit',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return exhibit_obj_get_result;
} else {
console.log('No results returned.');
@@ -53,7 +267,7 @@ export async function handle_load_ae_obj_id__exhibit(
// Updated 2024-03-06
export async function handle_load_ae_obj_li__exhibit(
export async function load_ae_obj_li__exhibit(
{
api_cfg,
event_id,
@@ -68,7 +282,7 @@ export async function handle_load_ae_obj_li__exhibit(
log_lvl?: number
}
) {
console.log(`*** handle_load_ae_obj_li__exhibit() *** event_id=${event_id}`);
console.log(`*** load_ae_obj_li__exhibit() *** event_id=${event_id}`);
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
@@ -113,11 +327,33 @@ export async function handle_load_ae_obj_li__exhibit(
log_lvl: log_lvl
})
.then(function (exhibit_obj_li_get_result) {
.then(async function (exhibit_obj_li_get_result) {
// console.log('Badge list:', exhibit_obj_li_get_result);
if (exhibit_obj_li_get_result) {
// $slct.exhibit_obj_li = exhibit_obj_li_get_result;
handle_db_save_ae_obj_li__exhibitor({obj_type: 'event_exhibit', obj_li: exhibit_obj_li_get_result});
if (try_cache) {
// Process the results first
let processed_obj_li = await process_ae_obj__exhibit_props({
obj_li: exhibit_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...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'exhibit',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return exhibit_obj_li_get_result;
} else {
// $slct.exhibit_obj_li = [];
@@ -141,7 +377,7 @@ export async function handle_load_ae_obj_li__exhibit(
}
export async function handle_load_ae_obj_id__exhibit_tracking(
export async function load_ae_obj_id__exhibit_tracking(
{
api_cfg,
exhibit_tracking_id,
@@ -154,7 +390,7 @@ export async function handle_load_ae_obj_id__exhibit_tracking(
log_lvl?: number
}
) {
console.log(`*** handle_load_ae_obj_id__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`);
console.log(`*** load_ae_obj_id__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`);
let params = {};
@@ -168,10 +404,32 @@ export async function handle_load_ae_obj_id__exhibit_tracking(
params: params,
log_lvl: log_lvl
})
.then(function (exhibit_tracking_obj_get_result) {
.then(async function (exhibit_tracking_obj_get_result) {
if (exhibit_tracking_obj_get_result) {
// This is expecting a list
handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: [exhibit_tracking_obj_get_result]});
if (try_cache) {
// Process the results first
let processed_obj_li = await process_ae_obj__exhibit_tracking_props({
obj_li: [exhibit_tracking_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: 'exhibit_tracking',
obj_li: processed_obj_li,
properties_to_save: properties_to_save_exhibit_tracking,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return exhibit_tracking_obj_get_result;
} else {
console.log('No results returned.');
@@ -187,7 +445,7 @@ export async function handle_load_ae_obj_id__exhibit_tracking(
// Updated 2024-03-19
export async function handle_load_ae_obj_li__exhibit_tracking(
export async function load_ae_obj_li__exhibit_tracking(
{
api_cfg,
exhibit_id,
@@ -202,7 +460,7 @@ export async function handle_load_ae_obj_li__exhibit_tracking(
log_lvl?: number
}
) {
console.log(`*** handle_load_ae_obj_li__exhibit_tracking() *** exhibit_id=${exhibit_id}`);
console.log(`*** load_ae_obj_li__exhibit_tracking() *** exhibit_id=${exhibit_id}`);
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden
@@ -228,11 +486,33 @@ export async function handle_load_ae_obj_li__exhibit_tracking(
log_lvl: log_lvl
})
.then(function (exhibit_tracking_obj_li_get_result) {
.then(async function (exhibit_tracking_obj_li_get_result) {
// console.log('Exhibit tracking list:', exhibit_tracking_obj_li_get_result);
if (exhibit_tracking_obj_li_get_result) {
// $slct.exhibit_tracking_obj_li = exhibit_tracking_obj_li_get_result;
handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: exhibit_tracking_obj_li_get_result});
if (try_cache) {
// Process the results first
let processed_obj_li = await process_ae_obj__exhibit_tracking_props({
obj_li: exhibit_tracking_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...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'exhibit_tracking',
obj_li: processed_obj_li,
properties_to_save: properties_to_save_exhibit_tracking,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return exhibit_tracking_obj_li_get_result;
} else {
// $slct.exhibit_tracking_obj_li = [];
@@ -255,7 +535,7 @@ export async function handle_load_ae_obj_li__exhibit_tracking(
// Updated 2024-03-22
export async function handle_create_ae_obj__exhibit_tracking(
export async function create_ae_obj__exhibit_tracking(
{
api_cfg,
exhibit_id,
@@ -291,11 +571,33 @@ export async function handle_create_ae_obj__exhibit_tracking(
log_lvl: log_lvl
})
.then(function (exhibit_tracking_obj_create_result) {
.then(async function (exhibit_tracking_obj_create_result) {
// console.log('Exhibit tracking create:', exhibit_tracking_obj_create_result);
if (exhibit_tracking_obj_create_result) {
// $slct.exhibit_tracking_obj = exhibit_tracking_obj_create_result;
handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: [exhibit_tracking_obj_create_result]});
if (try_cache) {
// Process the results first
let processed_obj_li = await process_ae_obj__exhibit_tracking_props({
obj_li: [exhibit_tracking_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: 'exhibit_tracking',
obj_li: processed_obj_li,
properties_to_save: properties_to_save_exhibit_tracking,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return exhibit_tracking_obj_create_result;
} else {
// $slct.exhibit_tracking_obj = [];
@@ -318,7 +620,7 @@ export async function handle_create_ae_obj__exhibit_tracking(
// Updated 2024-03-28
export async function handle_update_ae_obj__exhibit_tracking(
export async function update_ae_obj__exhibit_tracking(
{
api_cfg,
exhibit_tracking_id,
@@ -345,9 +647,32 @@ export async function handle_update_ae_obj__exhibit_tracking(
return_obj: true,
log_lvl: log_lvl
})
.then(function (exhibit_tracking_obj_update_result) {
.then(async function (exhibit_tracking_obj_update_result) {
if (exhibit_tracking_obj_update_result) {
handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: [exhibit_tracking_obj_update_result]});
if (try_cache) {
// Process the results first
let processed_obj_li = await process_ae_obj__exhibit_tracking_props({
obj_li: [exhibit_tracking_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: 'exhibit_tracking',
obj_li: processed_obj_li,
properties_to_save: properties_to_save_exhibit_tracking,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return exhibit_tracking_obj_update_result;
} else {
return null;
@@ -366,7 +691,7 @@ export async function handle_update_ae_obj__exhibit_tracking(
}
export async function handle_download_export__event_exhibit_tracking(
export async function download_export__event_exhibit_tracking(
{
api_cfg,
exhibit_id,
@@ -412,153 +737,7 @@ export async function handle_download_export__event_exhibit_tracking(
}
// This function will loop through the event_exhibit_obj_li and save each one to the DB.
export function handle_db_save_ae_obj_li__exhibitor(
{
obj_type,
obj_li=[],
log_lvl=0
}: {
obj_type: string,
obj_li: any[],
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** handle_db_save_ae_obj_li__exhibitor() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_events.exhibit.put({
id_random: obj.event_exhibit_id_random,
event_exhibit_id_random: obj.event_exhibit_id_random,
event_id_random: obj.event_id_random,
code: obj.code,
name: obj.name,
description: obj.description,
staff_passcode: obj.staff_passcode,
data_json: obj.data_json,
leads_api_access: obj.leads_api_access,
leads_custom_questions_json: obj.leads_custom_questions_json,
leads_device_sm_qty: obj.leads_device_sm_qty,
leads_device_lg_qty: obj.leads_device_lg_qty,
license_max: obj.license_max,
license_li_json: obj.license_li_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,
});
// console.log(`Put obj with ID: ${obj.event_exhibit_id_random} or ${id_random}`);
} catch (error) {
let status = `Failed to put ${obj.event_exhibit_id_random}: ${error}`;
console.log(status);
}
// const id_random = await db_events.exhibit.put(obj);
// console.log(`Put obj with ID: ${obj.event_exhibit_id_random}`);
});
return true;
}
}
// This function will loop through the event_exhibit_tracking_obj_li and save each one to the DB.
export function handle_db_save_ae_obj_li__exhibitor_tracking(
{
obj_type,
obj_li,
log_lvl=0
}: {
obj_type: string,
obj_li: any,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** handle_db_save_ae_obj_li__exhibitor_tracking() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_events.exhibit_tracking.put({
id_random: obj.event_exhibit_tracking_id_random,
event_exhibit_tracking_id_random: obj.event_exhibit_tracking_id_random,
event_exhibit_id_random: obj.event_exhibit_id_random,
event_badge_id_random: obj.event_badge_id_random,
event_person_id_random: obj.event_person_id_random,
external_person_id: obj.external_person_id,
exhibitor_notes: obj.exhibitor_notes,
responses_json: obj.responses_json,
data_json: obj.data_json,
event_exhibit_name: obj.event_exhibit_name,
event_badge_title_names: obj.event_badge_title_names,
event_badge_given_name: obj.event_badge_given_name,
event_badge_family_name: obj.event_badge_family_name,
event_badge_designations: obj.event_badge_designations,
event_badge_full_name: obj.event_badge_full_name,
event_badge_full_name_override: obj.event_badge_full_name_override,
event_badge_professional_title: obj.event_badge_professional_title,
event_badge_professional_title_override: obj.event_badge_professional_title_override,
event_badge_affiliations: obj.event_badge_affiliations,
event_badge_affiliations_override: obj.event_badge_affiliations_override,
event_badge_email: obj.event_badge_email,
event_badge_email_override: obj.event_badge_email_override,
event_badge_location: obj.event_badge_location,
event_badge_location_override: obj.event_badge_location_override,
event_badge_country: obj.event_badge_country,
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,
});
// console.log(`Put obj with ID: ${obj.event_exhibit_tracking_id_random} or ${id_random}`);
} catch (error) {
let status = `Failed to put ${obj.event_exhibit_tracking_id_random}: ${error}`;
console.log(status);
}
// const id_random = await db_events.exhibit_tracking.put(obj);
// console.log(`Put obj with ID: ${obj.event_exhibit_tracking_id_random}`);
});
return true;
}
}

View File

@@ -1,6 +1,6 @@
import Dexie, { type Table } from 'dexie';
import type { key_val } from '../ae_stores';
import type { key_val } from '$lib/stores/ae_stores';
// li = list
// kv = key value list

View File

@@ -7,14 +7,14 @@ import * as event_device from "$lib/ae_events/ae_events__event_device";
import * as event_file from "$lib/ae_events/ae_events__event_file";
import {
handle_load_ae_obj_id__exhibit,
handle_load_ae_obj_li__exhibit,
handle_load_ae_obj_id__exhibit_tracking,
handle_load_ae_obj_li__exhibit_tracking,
handle_create_ae_obj__exhibit_tracking,
handle_update_ae_obj__exhibit_tracking,
handle_download_export__event_exhibit_tracking,
handle_db_save_ae_obj_li__exhibitor,
load_ae_obj_id__exhibit,
load_ae_obj_li__exhibit,
load_ae_obj_id__exhibit_tracking,
load_ae_obj_li__exhibit_tracking,
create_ae_obj__exhibit_tracking,
update_ae_obj__exhibit_tracking,
download_export__event_exhibit_tracking,
// db_save_ae_obj_li__exhibitor,
} from "$lib/ae_events/ae_events__exhibit";
import * as event_location from "$lib/ae_events/ae_events__event_location";
@@ -71,14 +71,14 @@ let export_obj = {
// db_save_ae_obj_li__event_device: event_device.db_save_ae_obj_li__event_device,
// Event Exhibits
handle_load_ae_obj_id__exhibit: handle_load_ae_obj_id__exhibit,
handle_load_ae_obj_li__exhibit: handle_load_ae_obj_li__exhibit,
handle_load_ae_obj_id__exhibit_tracking: handle_load_ae_obj_id__exhibit_tracking,
handle_load_ae_obj_li__exhibit_tracking: handle_load_ae_obj_li__exhibit_tracking,
handle_create_ae_obj__exhibit_tracking: handle_create_ae_obj__exhibit_tracking,
handle_update_ae_obj__exhibit_tracking: handle_update_ae_obj__exhibit_tracking,
handle_download_export__event_exhibit_tracking: handle_download_export__event_exhibit_tracking,
// handle_db_save_ae_obj_li__exhibitor: handle_db_save_ae_obj_li__exhibitor,
handle_load_ae_obj_id__exhibit: load_ae_obj_id__exhibit,
handle_load_ae_obj_li__exhibit: load_ae_obj_li__exhibit,
handle_load_ae_obj_id__exhibit_tracking: load_ae_obj_id__exhibit_tracking,
handle_load_ae_obj_li__exhibit_tracking: load_ae_obj_li__exhibit_tracking,
handle_create_ae_obj__exhibit_tracking: create_ae_obj__exhibit_tracking,
handle_update_ae_obj__exhibit_tracking: update_ae_obj__exhibit_tracking,
handle_download_export__event_exhibit_tracking: download_export__event_exhibit_tracking,
// handle_db_save_ae_obj_li__exhibitor: db_save_ae_obj_li__exhibitor,
// Event Files
load_ae_obj_id__event_file: event_file.load_ae_obj_id__event_file,

View File

@@ -1,6 +1,6 @@
import Dexie, { type Table } from 'dexie';
import type { key_val } from '../ae_stores';
import type { key_val } from '$lib/stores/ae_stores';
// li = list
// kv = key value list

View File

@@ -627,13 +627,32 @@ export async function qry__post(
params: params,
log_lvl: log_lvl
})
.then(function (post_obj_li_get_result) {
.then(async function (post_obj_li_get_result) {
if (post_obj_li_get_result) {
db_save_ae_obj_li__post({
obj_type: 'post',
obj_li: post_obj_li_get_result,
log_lvl: log_lvl
});
if (try_cache) {
// Process the results first
let processed_obj_li = await process_ae_obj__post_props({
obj_li: post_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...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'post',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return post_obj_li_get_result;
} else {
return [];
@@ -784,92 +803,7 @@ export async function qry__post(
// }
// This function will loop through the post_obj_li and save each one to the DB.
// Updated 2024-09-25
export function db_save_ae_obj_li__post(
{
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__post() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_posts.post.put({
id: obj.post_id_random,
post_id: obj.post_id_random,
account_id: obj.account_id_random,
external_person_id: obj.external_person_id,
topic_id: obj.topic_id,
topic: obj.topic,
topic_name: obj.topic_name,
name: obj.title,
title: obj.title, // Switching to name instead of title
// summary: obj.summary,
content: obj.content,
anonymous: obj.anonymous,
full_name: obj.full_name,
email: obj.email,
notify: obj.notify,
enable_comments: obj.enable_comments,
archive: obj.archive,
archive_on: obj.archive_on,
linked_li_json: obj.linked_li_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,
tmp_sort_1: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on ?? obj.created_on}`,
tmp_sort_2: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on}_${obj.created_on}`,
// From SQL view
post_comment_count: obj.post_comment_count,
// A key value list of the comments
// post_comment_kv: obj.post_comment_kv,
// post_comment_li: obj.post_comment_li,
});
if (log_lvl) {
console.log(`Put obj with ID: ${obj.post_id_random} or ${id_random}`);
}
} catch (error) {
let status = `Failed to put ${obj.post_id_random}: ${error}`;
console.log(status);
return false;
}
});
return true;
}
}
// Updated 2025-06-04

View File

@@ -412,78 +412,7 @@ export async function update_ae_obj__post_comment(
}
// This function will loop through the post_comment_obj_li and save each one to the DB.
// Updated 2024-09-25
export function db_save_ae_obj_li__post_comment(
{
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__post_comment() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_posts.comment.put({
id: obj.post_comment_id_random,
post_comment_id: obj.post_comment_id_random,
post_id: obj.post_id_random,
external_person_id: obj.external_person_id,
name: obj.name,
title: obj.title, // Switching to name instead of title
// summary: obj.summary,
content: obj.content,
anonymous: obj.anonymous,
full_name: obj.full_name,
email: obj.email,
notify: obj.notify,
linked_li_json: obj.linked_li_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,
tmp_sort_1: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on ?? obj.created_on}`,
tmp_sort_2: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(2, '0') ?? ''}_${obj.updated_on}_${obj.created_on}`,
// From SQL view
});
if (log_lvl) {
console.log(`Put obj with ID: ${obj.post_comment_id_random} or ${id_random}`);
}
} catch (error) {
let status = `Failed to put ${obj.post_comment_id_random}: ${error}`;
console.log(status);
return false;
}
});
return true;
}
}
// Updated 2025-06-04

View File

@@ -6,8 +6,7 @@ import {
create_ae_obj__post,
delete_ae_obj_id__post,
update_ae_obj__post,
// qry__post,
db_save_ae_obj_li__post,
} from "$lib/ae_posts/ae_posts__post";
@@ -17,8 +16,7 @@ import {
create_ae_obj__post_comment,
delete_ae_obj_id__post_comment,
update_ae_obj__post_comment,
// qry__post_comment,
db_save_ae_obj_li__post_comment,
} from "$lib/ae_posts/ae_posts__post_comment";
@@ -28,13 +26,13 @@ let export_obj = {
create_ae_obj__post: create_ae_obj__post,
delete_ae_obj_id__post: delete_ae_obj_id__post,
update_ae_obj__post: update_ae_obj__post,
db_save_ae_obj_li__post: db_save_ae_obj_li__post,
load_ae_obj_id__post_comment: load_ae_obj_id__post_comment,
load_ae_obj_li__post_comment: load_ae_obj_li__post_comment,
create_ae_obj__post_comment: create_ae_obj__post_comment,
delete_ae_obj_id__post_comment: delete_ae_obj_id__post_comment,
update_ae_obj__post_comment: update_ae_obj__post_comment,
db_save_ae_obj_li__post_comment: db_save_ae_obj_li__post_comment,
};
export let posts_func = export_obj;

View File

@@ -1,6 +1,6 @@
import Dexie, { type Table } from 'dexie';
import type { key_val } from '../ae_stores';
import type { key_val } from '$lib/stores/ae_stores';
// li = list
// kv = key value list

View File

@@ -6,7 +6,193 @@ import { db_sponsorships } from "$lib/ae_sponsorships/db_sponsorships";
// import { liveQuery } from "dexie";
// import { db_core } from "$lib/db_core";
let ae_promises: key_val = {}; // Promise<any>;
// --- PROPERTIES TO SAVE ---
export const properties_to_save_sponsorship_cfg = [
'id',
'sponsorship_cfg_id',
'account_id',
'for_type',
'for_id',
'level_li_json',
'option_li_json',
'schedule_li_json',
'cfg_json',
'enable',
'hide',
'priority',
'sort',
'group',
'notes',
'created_on',
'updated_on',
// Generated fields for sorting locally only
'tmp_sort_1',
'tmp_sort_2',
];
// --- PROCESS FUNCTION ---
export async function process_ae_obj__sponsorship_cfg_props({
obj_li,
log_lvl = 0
}: {
obj_li: any[];
log_lvl?: number;
}) {
return _process_generic_props({
obj_li,
obj_type: 'sponsorship_cfg',
log_lvl,
specific_processor: (obj) => {
// Sponsorship Cfg-specific computed sort fields, overriding generic ones if needed
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on ?? obj.created_on}`;
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on}_${obj.created_on}`;
return obj;
}
});
}
// --- PROPERTIES TO SAVE ---
export const properties_to_save_sponsorship = [
'id',
'sponsorship_id',
'account_id',
'organization_id',
'person_id',
'poc_person_id',
'poc_json',
'name',
'name_override',
'description',
'email',
'website_url',
'logo_li_json',
'media_li_json',
'social_li_json',
'address_li_json',
'contact_li_json',
'guest_li_json',
'level_num',
'level_str',
'amount',
'questions_li_json',
'agree',
'comments',
'staff_notes',
'enable',
'hide',
'priority',
'sort',
'group',
'notes',
'created_on',
'updated_on',
// Generated fields for sorting locally only
'tmp_sort_1',
'tmp_sort_2',
];
// --- PROCESS FUNCTION ---
export async function process_ae_obj__sponsorship_props({
obj_li,
log_lvl = 0
}: {
obj_li: any[];
log_lvl?: number;
}) {
return _process_generic_props({
obj_li,
obj_type: 'sponsorship',
log_lvl,
specific_processor: (obj) => {
// Sponsorship-specific computed sort fields, overriding generic ones if needed
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on ?? obj.created_on}`;
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on}_${obj.created_on}`;
return obj;
}
});
}
/**
* NON-EXPORTED LOCAL HELPER
* Processes a list of Aether objects by applying common and specific transformations.
*/
async function _process_generic_props<T extends Record<string, any>>({
obj_li,
obj_type,
log_lvl = 0,
specific_processor
}: {
obj_li: T[];
obj_type: string;
log_lvl?: number;
specific_processor?: (obj: T) => Promise<T> | T;
}): Promise<T[]> {
if (log_lvl > 0) {
console.log(
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
);
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl > 0) console.log('No objects to process.');
return [];
}
const processed_obj_li: T[] = [];
for (const original_obj of obj_li) {
let processed_obj = { ...original_obj };
// --- Common Transformations ---
// 1. Standardize ID and other '_random' fields
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
for (const key in processed_obj) {
if (key.endsWith('_random')) {
const newKey = key.slice(0, -7); // Remove '_random' suffix
processed_obj[newKey] = processed_obj[key];
}
}
// Ensure 'id' is set from '[obj_type]_id_random'
const randomIdKey = `${obj_type}_id_random`;
if (processed_obj[randomIdKey]) {
(processed_obj as any).id = processed_obj[randomIdKey];
}
// 2. Create common computed properties for client-side sorting.
const group = processed_obj.group ?? '0';
const priority = processed_obj.priority ? 1 : 0;
const sort = processed_obj.sort ?? '0';
const updated = processed_obj.updated_on ?? processed_obj.created_on;
const name = processed_obj.name ?? '';
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
// --- Specific Transformations ---
if (specific_processor) {
processed_obj = await Promise.resolve(specific_processor(processed_obj));
}
processed_obj_li.push(processed_obj as T);
}
return processed_obj_li;
}
// Updated 2024-03-29
@@ -38,7 +224,7 @@ async function load_ae_obj_id__sponsorship_cfg(
params: params,
log_lvl: log_lvl
})
.then(function (sponsorship_cfg_obj_get_result) {
.then(async function (sponsorship_cfg_obj_get_result) {
if (sponsorship_cfg_obj_get_result) {
if (log_lvl) {
console.log(`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}`);
@@ -46,11 +232,28 @@ async function load_ae_obj_id__sponsorship_cfg(
console.log(`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}:`, sponsorship_cfg_obj_get_result);
}
if (try_cache) {
// This is expecting a list
db_save_ae_obj_li__sponsorship_cfg({
obj_type: 'sponsorship_cfg',
obj_li: [sponsorship_cfg_obj_get_result]
// Process the results first
let processed_obj_li = await process_ae_obj__sponsorship_cfg_props({
obj_li: [sponsorship_cfg_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_sponsorships,
table_name: 'cfg',
obj_li: processed_obj_li,
properties_to_save: properties_to_save_sponsorship_cfg,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return sponsorship_cfg_obj_get_result;
} else {
@@ -99,7 +302,7 @@ async function load_ae_obj_id__sponsorship(
params: params,
log_lvl: log_lvl
})
.then(function (sponsorship_obj_get_result) {
.then(async function (sponsorship_obj_get_result) {
if (sponsorship_obj_get_result) {
if (log_lvl) {
console.log(`*spons_func* Got a result for sponsorship_id ${sponsorship_id}`);
@@ -107,11 +310,28 @@ async function load_ae_obj_id__sponsorship(
console.log(`*spons_func* Got a result for sponsorship_id ${sponsorship_id}:`, sponsorship_obj_get_result);
}
if (try_cache) {
// This is expecting a list
db_save_ae_obj_li__sponsorship({
obj_type: 'sponsorship',
obj_li: [sponsorship_obj_get_result]
// Process the results first
let processed_obj_li = await process_ae_obj__sponsorship_props({
obj_li: [sponsorship_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_sponsorships,
table_name: 'sponsorship',
obj_li: processed_obj_li,
properties_to_save: properties_to_save_sponsorship,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return sponsorship_obj_get_result;
} else {
@@ -182,13 +402,31 @@ async function load_ae_obj_li__sponsorship(
params: params,
log_lvl: log_lvl
})
.then(function (sponsorship_obj_li_get_result) {
.then(async function (sponsorship_obj_li_get_result) {
if (sponsorship_obj_li_get_result) {
if (try_cache) {
db_save_ae_obj_li__sponsorship({
obj_type: 'sponsorship',
obj_li: sponsorship_obj_li_get_result
// Process the results first
let processed_obj_li = await process_ae_obj__sponsorship_props({
obj_li: sponsorship_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...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_sponsorships,
table_name: 'sponsorship',
obj_li: processed_obj_li,
properties_to_save: properties_to_save_sponsorship,
log_lvl: log_lvl,
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return sponsorship_obj_li_get_result;
} else {
@@ -205,7 +443,7 @@ async function load_ae_obj_li__sponsorship(
async function handle_download_export__sponsorship(
export async function download_export__sponsorship(
{
api_cfg,
account_id,
@@ -252,91 +490,7 @@ return ae_promises.download__sponsorship_export_file;
}
// Updated 2025-01-15
export function db_save_ae_obj_li__sponsorship(
{
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__sponsorship() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_sponsorships.sponsorship.put({
id: obj.sponsorship_id_random,
sponsorship_id: obj.sponsorship_id_random,
account_id: obj.account_id_random,
external_person_id: obj.external_person_id,
topic_id: obj.topic_id,
topic: obj.topic,
topic_name: obj.topic_name,
name: obj.title,
title: obj.title, // Switching to name instead of title
// summary: obj.summary,
content: obj.content,
anonymous: obj.anonymous,
full_name: obj.full_name,
email: obj.email,
notify: obj.notify,
enable_comments: obj.enable_comments,
archive: obj.archive,
archive_on: obj.archive_on,
linked_li_json: obj.linked_li_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,
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
// From SQL view
sponsorship_comment_count: obj.sponsorship_comment_count,
// A key value list of the comments
// sponsorship_comment_kv: obj.sponsorship_comment_kv,
// sponsorship_comment_li: obj.sponsorship_comment_li,
});
if (log_lvl) {
console.log(`Put obj with ID: ${obj.sponsorship_id_random} or ${id_random}`);
}
} catch (error) {
let status = `Failed to put ${obj.sponsorship_id_random}: ${error}`;
console.log(status);
return false;
}
});
return true;
}
}
@@ -344,7 +498,6 @@ let export_obj = {
load_ae_obj_id__sponsorship_cfg: load_ae_obj_id__sponsorship_cfg,
load_ae_obj_id__sponsorship: load_ae_obj_id__sponsorship,
load_ae_obj_li__sponsorship: load_ae_obj_li__sponsorship,
handle_download_export__sponsorship: handle_download_export__sponsorship,
db_save_ae_obj_li__sponsorship: db_save_ae_obj_li__sponsorship
download_export__sponsorship: download_export__sponsorship,
};
export let spons_func = export_obj;

View File

@@ -1,6 +1,6 @@
import Dexie, { type Table } from 'dexie';
import type { key_val } from '../ae_stores';
import type { key_val } from '$lib/stores/ae_stores';
// li = list
// kv = key value list

View File

@@ -340,7 +340,7 @@ async function get_url_cfg(cfg) {
}
return return_data;
})
.catch(function (error: any) {
.catch(function (error) {
console.log(`Base URL: ${base_url} | Endpoint: ${endpoint}`);
console.log('Error Message:', error.message); // Is this needed here or below in the in the else portion???

View File

@@ -1,27 +1,21 @@
<script lang="ts">
/** @type {import('./$types').LayoutProps} */
let log_lvl: number = 0;
let log_lvl = $state(0);
// *** Import Svelte specific
// import { browser } from '$app/environment';
import { goto } from '$app/navigation';
// *** Import other supporting libraries
// import * as icons from '@lucide/svelte';
import {
Brain,
House, Library,
House,
RefreshCw,
Satellite
} from '@lucide/svelte';
// *** Import Aether specific variables and functions
import type { key_val } from '$lib/stores/ae_stores';
// import { ae_util } from '$lib/ae_utils/ae_utils';
// import { api } from '$lib/api';
import { ae_loc, ae_sess, ae_api, slct } from '$lib/stores/ae_stores';
import { journals_loc, journals_slct, journals_trig } from '$lib/ae_journals/ae_journals_stores';
// import { journals_func } from '$lib/ae_journals/ae_journals_functions';
import Element_data_store from '$lib/elements/element_data_store_v2.svelte';
import Help_tech from '$lib/app_components/e_app_help_tech.svelte';
@@ -39,26 +33,16 @@ $journals_loc.qry__offset = 0;
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
$slct.account_id = data.account_id;
$effect(() => {
if (log_lvl) {
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}`);
// journals_func.handle_db_save_ae_obj_li__journal({
// obj_type: 'journal',
// obj_li: [ae_acct.slct.journal_obj_li],
// });
// }
$journals_slct.journal_id = ae_acct.slct.journal_id;
// $journals_slct.journal_obj = ae_acct.slct.journal_obj;
$journals_slct.journal_obj_li = ae_acct.slct.journal_obj_li;
// let ae_promises: key_val = {};
let nav_y_height = $state(0);
@@ -70,17 +54,17 @@ let yTop = $state(0);
let yScroll = $state(0);
let yHeight = $state(0);
let scroll_y = $state(0);
function parse_scroll() {
// console.log(`parse_scroll() called`);
xLeft = box.scrollLeft;
xScroll = box.scrollWidth;
xWidth = box.clientWidth;
yTop = box.scrollTop;
yHeight = box.clientHeight;
yScroll = box.scrollHeight;
// console.log(`parse_scroll() called: ${yTop}`);
function handle_scroll() {
// console.log(`handle_scroll() called`);
if (box) {
xLeft = box.scrollLeft;
xScroll = box.scrollWidth;
xWidth = box.clientWidth;
yTop = box.scrollTop;
yHeight = box.clientHeight;
yScroll = box.scrollHeight;
// console.log(`handle_scroll() called: ${yTop}`);
}
}
function scroll_container() {
@@ -101,7 +85,7 @@ function scroll_container() {
id="ae_main_content"
bind:clientHeight={$ae_loc.iframe_height}
bind:this={box}
onscroll={parse_scroll}
onscroll={handle_scroll}
class:iframe={$ae_loc?.iframe}
class="
ae_journals
@@ -286,6 +270,7 @@ function scroll_container() {
class:ae_btn_warning_filled={yTop > 1500}
onclick={() => {
log_lvl = 1;
$effect(() => {
if (log_lvl) {
console.log(`Scroll to top button clicked. scroll_y: ${scroll_y} scrollTop: ${scroll_container().scrollTop}`, scroll_container());
// document.getElementById('ae_idaa')?.scrollTo(0, 0);
@@ -293,6 +278,7 @@ function scroll_container() {
// document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
// document.body.scrollTop = 0; // For Safari
}
});
console.log('Not Safari, using smooth scroll to top');
document.getElementById('ae_main_content')?.scrollTo({
@@ -356,6 +342,7 @@ function scroll_container() {
class:ae_btn_warning_filled={yTop > 1500}
onclick={() => {
log_lvl = 1;
$effect(() => {
if (log_lvl) {
console.log(`Scroll to bottom button clicked. scroll_y: ${scroll_y} scrollTop: ${scroll_container().scrollTop}`, scroll_container());
// document.getElementById('ae_idaa')?.scrollTo(0, 0);
@@ -363,6 +350,7 @@ function scroll_container() {
// document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
// document.body.scrollTop = 0; // For Safari
}
});
console.log('Not Safari, using smooth scroll to bottom');
document.getElementById('ae_main_content')?.scrollTo({

View File

@@ -9,143 +9,134 @@ import { goto } from '$app/navigation';
// *** Import other supporting libraries
import {
ArrowDown01, ArrowDown10, ArrowDownUp,
BetweenVerticalEnd, BetweenVerticalStart,
BookHeart, BookImage, Bookmark, BookOpenText, BriefcaseBusiness,
Check, Copy,
Expand, Eye, EyeOff,
Flag, FlagOff, FilePlus, Fingerprint,
Globe,
Library,
MessageSquareWarning, Minus,
FilePlus,
Notebook,
Pencil, Plus,
RemoveFormatting,
SquareLibrary,
Shapes, Share2, ShieldCheck, ShieldMinus, Siren, Skull,
Tags, Target, ToggleLeft, ToggleRight, Trash2, TypeOutline,
X
} from '@lucide/svelte';
import { liveQuery } from "dexie";
// import { Modal } from 'flowbite-svelte';
// import { ae_util } from '$lib/ae_utils/ae_utils';
import { db_journals } from "$lib/ae_journals/db_journals";
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/stores/ae_stores';
import { journals_loc, journals_sess, journals_slct, journals_prom, journals_trig } from '$lib/ae_journals/ae_journals_stores';
import { ae_loc, ae_api, slct } from '$lib/stores/ae_stores';
import { journals_loc, journals_sess, journals_slct } from '$lib/ae_journals/ae_journals_stores';
import { journals_func } from '$lib/ae_journals/ae_journals_functions';
// import Journal_obj_id_edit from '../ae_comp__journal_obj_id_edit.svelte';
import Journal_entry_obj_qry from './../ae_comp__journal_entry_obj_qry.svelte';
// interface Props {
// data: any;
// }
// let { data }: Props = $props();
// let tmp_journal_obj_changed: boolean = $state(false);
// let tmp_journal_obj: key_val = $state({});
let ae_acct = data[$slct.account_id];
$effect(() => {
if (log_lvl) {
console.log(`ae_acct = `, ae_acct);
}
// $journals_sess.entry_li = [];
// $journals_slct.journal_id = ae_acct.slct.journal_id;
});
let show_menu__all_journals: boolean = $state(false);
let lq__journal_obj = $derived(liveQuery(async () => {
if (log_lvl) {
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`);
}
let results = await db_journals.journal
.get($journals_slct?.journal_id ?? ''); // null or undefined does not reset things like '' does
if (log_lvl) {
console.log(`lq__journal_obj: results = `, results);
}
// tmp_journal_obj = { ...results };
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_obj && results) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(results)) {
$journals_slct.journal_obj = { ...results };
if (log_lvl) {
console.log(`Session slct stored version has changed for ID = ${$journals_slct.journal_id}`, $journals_slct.journal_obj);
}
} else {
if (log_lvl) {
console.log(`Session slct stored version has not changed for ID = ${$journals_slct.journal_id}`);
}
}
}
return results;
}));
// $effect(() => {
// if ($lq__journal_obj) {
// tmp_journal_obj = { ...$lq__journal_obj };
// console.log('tmp_journal_obj:', tmp_journal_obj);
// }
// });
$effect(() => {
if (log_lvl) {
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`);
console.log(`lq__journal_obj: results = `, lq__journal_obj);
if ($journals_slct.journal_obj && lq__journal_obj) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(lq__journal_obj)) {
console.log(`Session slct stored version has changed for ID = ${$journals_slct.journal_id}`, $journals_slct.journal_obj);
} else {
console.log(`Session slct stored version has not changed for ID = ${$journals_slct.journal_id}`);
}
}
}
});
// $effect(() => {
// if (tmp_journal_obj) {
// tmp_journal_obj_changed = JSON.stringify(tmp_journal_obj) != JSON.stringify($lq__journal_obj);
// }
// });
let lq__journal_entry_obj_li = $derived(liveQuery(async () => {
let results;
// async function handle_update_journal() {
// if (tmp_journal_obj.name && tmp_journal_obj.type_code) {
// try {
// let data_kv = {
// // account: $slct.account_id,
// name: tmp_journal_obj.name,
// description: tmp_journal_obj.description ?? '', // Ensure description is at least an empty string
// type_code: tmp_journal_obj.type_code,
// passcode: tmp_journal_obj.passcode,
// private_passcode: tmp_journal_obj.private_passcode,
// passcode_timeout: tmp_journal_obj.passcode_timeout,
// auth_key: tmp_journal_obj.auth_key, // The Journal Entry encryption password
if ($journals_sess?.entry_li && $journals_sess?.entry_li?.length) {
// $journals_sess.entry_li_trigger = false;
let journal_entry_id_random_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
// cfg_json: tmp_journal_obj.cfg_json
for (let i = 0; i < $journals_sess?.entry_li.length; i++) {
let journal_entry_obj = $journals_sess?.entry_li[i];
let journal_entry_id_random = journal_entry_obj.journal_entry_id_random;
journal_entry_id_random_li.push(journal_entry_id_random);
}
// let journal_entry_id_random_li = tmp_li;
// };
// journals_func.update_ae_obj__journal({
// api_cfg: $ae_api,
// journal_id: $lq__journal_obj?.journal_id ?? '',
// data_kv: data_kv,
// log_lvl: log_lvl
// }).then((results) => {
// if (log_lvl) {
// console.log('Journal updated:', results);
// }
// // $journals_slct.journal_id = results?.journal_id_random;
// }).catch((error) => {
// console.error('Error updating journal:', error);
// alert('Failed to update journal.');
// }).finally(() => {
// if ($journals_slct.journal_id) {
// $journals_sess.show__modal_new__journal_obj = false;
// // goto(`/journals/${$journals_slct.journal_id}`);
// }
// });
// // console.log('New journal updated:', result);
// // $journals_sess.show__modal_new__journal_obj = false;
// // goto(`/journals/${result.journal_id_random}`);
// } catch (error) {
// console.error('Error updating journal:', error);
// alert('Failed to update journal.');
// }
// } else {
// alert('Please provide both name and type for the journal.');
// }
// }
results = await db_journals.journal_entry
.bulkGet(journal_entry_id_random_li);
} else if ($lq__journal_obj?.cfg_json?.entry_group_sort === 'DESC') {
results = await db_journals.journal_entry
// .orderBy('updated_on')
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.reverse()
// .sortBy('tmp_sort_2');
.sortBy('updated_on');
// .sortBy('title');
} else if ($journals_loc.filter__category_code && $journals_loc.filter__category_code.length > 0) {
results = await db_journals.journal_entry
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.and(entry => entry.category_code === $journals_loc.filter__category_code)
.reverse()
.sortBy('tmp_sort_1');
} else {
results = await db_journals.journal_entry
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.reverse()
.sortBy('tmp_sort_1');
// .sortBy('updated_on');
}
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_entry_obj_li && JSON.stringify($journals_slct.journal_entry_obj_li) !== JSON.stringify(results)) {
$journals_slct.journal_entry_obj_li = [...results];
}
return results;
}));
$effect(() => {
if (log_lvl) {
console.log(`LQ - $lq__journal_obj.cfg_json = `, $lq__journal_obj?.cfg_json);
console.log(`LQ - $journals_loc.filter__category_code = `, $journals_loc.filter__category_code);
if ($journals_sess?.entry_li && $journals_sess?.entry_li?.length) {
console.log(`LQ - Using $journals_sess.entry_li to get journal entries.`);
} else if ($lq__journal_obj?.cfg_json?.entry_group_sort === 'DESC') {
console.log(`LQ - Using DESC sort for Journal Entry list journal_id: ${$journals_slct?.journal_id}`);
} else if ($journals_loc.filter__category_code && $journals_loc.filter__category_code.length > 0) {
console.log(`LQ - Using category filter: ${$journals_loc.filter__category_code}`);
} else {
console.log(`LQ - Using default sort for Journal Entry list journal_id: ${$journals_slct?.journal_id}`);
}
if ($journals_slct.journal_entry_obj_li && JSON.stringify($journals_slct.journal_entry_obj_li) !== JSON.stringify(lq__journal_entry_obj_li)) {
console.log(`Session slct li stored version has changed for ID = ${$journals_slct.journal_id}`, $journals_slct.journal_entry_obj_li);
} else {
if (log_lvl > 1) {
console.log(`Session slct li stored version has not changed for ID = ${$journals_slct.journal_id}`);
}
}
}
});
</script>
@@ -368,18 +359,22 @@ let lq__journal_obj = $derived(liveQuery(async () => {
if ($journals_loc.qry__category_code) {
data_kv.category_code = $journals_loc.qry__category_code;
}
$effect(() => {
if (log_lvl) {
console.log('Creating new journal entry with data_kv:', data_kv);
}
});
journals_func.create_ae_obj__journal_entry({
api_cfg: $ae_api,
journal_id: $lq__journal_obj.journal_id,
data_kv: data_kv,
log_lvl: log_lvl
}).then((results) => {
$effect(() => {
if (log_lvl) {
console.log('New journal entry created:', results);
}
});
$journals_slct.journal_entry_id = results?.journal_entry_id_random;
// $journals_loc.entry.edit = true;
$journals_loc.entry.edit_kv[$journals_slct.journal_entry_id] = 'current';

View File

@@ -62,10 +62,12 @@ import Journal_obj_id_edit from '../ae_comp__journal_obj_id_edit.svelte';
// Variables
// *** Quickly pull out data from parent(s)
let ae_acct = data[$slct.account_id];
$effect(() => {
if (log_lvl > 1) {
console.log(`ae_acct = `, ae_acct);
}
});
$inspect(log_lvl, `log_lvl = ${log_lvl}`);
$inspect($journals_slct.journal_id, `$journals_slct.journal_id = ${$journals_slct.journal_id}`);
@@ -88,55 +90,42 @@ $journals_sess.entry_li = [];
$journals_slct.journal_entry_id = null;
let lq__journal_obj = $derived(liveQuery(async () => {
if (log_lvl) {
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`);
}
let results = await db_journals.journal
.get($journals_slct?.journal_id ?? ''); // null or undefined does not reset things like '' does
if (log_lvl) {
console.log(`lq__journal_obj: results = `, results);
}
// tmp_journal_obj = { ...results };
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_obj && results) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(results)) {
$journals_slct.journal_obj = { ...results};
if (log_lvl) {
console.log(`Session slct stored version has changed for ID = ${$journals_slct.journal_id}`, $journals_slct.journal_obj);
}
} else {
if (log_lvl) {
console.log(`Session slct stored version has not changed for ID = ${$journals_slct.journal_id}`);
}
}
}
return results;
}));
$effect(() => {
if (log_lvl) {
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`);
console.log(`lq__journal_obj: results = `, lq__journal_obj);
if ($journals_slct.journal_obj && lq__journal_obj) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(lq__journal_obj)) {
console.log(`Session slct stored version has changed for ID = ${$journals_slct.journal_id}`, $journals_slct.journal_obj);
} else {
console.log(`Session slct stored version has not changed for ID = ${$journals_slct.journal_id}`);
}
}
}
});
let lq__journal_entry_obj_li = $derived(liveQuery(async () => {
log_lvl = 1;
if (log_lvl) {
console.log(`LQ - $lq__journal_obj.cfg_json = `, $lq__journal_obj?.cfg_json);
console.log(`LQ - $journals_loc.filter__category_code = `, $journals_loc.filter__category_code);
}
let results;
if ($journals_sess.entry_li_trigger && !$journals_sess?.entry_li) {
$journals_sess.entry_li = null;
$journals_sess.entry_li_trigger = false;
}
let results;
if ($journals_sess?.entry_li && $journals_sess?.entry_li?.length) {
if (log_lvl) {
console.log(`LQ - Using $journals_sess.entry_li to get journal entries.`);
}
// $journals_sess.entry_li_trigger = false;
let journal_entry_id_random_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
for (let i = 0; i < $journals_sess?.entry_li.length; i++) {
@@ -150,9 +139,6 @@ let lq__journal_entry_obj_li = $derived(liveQuery(async () => {
.bulkGet(journal_entry_id_random_li);
} else if ($lq__journal_obj?.cfg_json?.entry_group_sort === 'DESC') {
if (log_lvl) {
console.log(`LQ - Using DESC sort for Journal Entry list journal_id: ${$journals_slct?.journal_id}`);
}
results = await db_journals.journal_entry
// .orderBy('updated_on')
.where('journal_id')
@@ -163,9 +149,6 @@ let lq__journal_entry_obj_li = $derived(liveQuery(async () => {
// .sortBy('title');
} else if ($journals_loc.filter__category_code && $journals_loc.filter__category_code.length > 0) {
if (log_lvl) {
console.log(`LQ - Using category filter: ${$journals_loc.filter__category_code}`);
}
results = await db_journals.journal_entry
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
@@ -174,10 +157,6 @@ let lq__journal_entry_obj_li = $derived(liveQuery(async () => {
.sortBy('tmp_sort_1');
} else {
if (log_lvl) {
// console.log(`$lq__journal_obj.cfg_json = `, $lq__journal_obj?.cfg_json);
console.log(`LQ - Using default sort for Journal Entry list journal_id: ${$journals_slct?.journal_id}`);
}
results = await db_journals.journal_entry
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
@@ -190,19 +169,35 @@ let lq__journal_entry_obj_li = $derived(liveQuery(async () => {
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_entry_obj_li && JSON.stringify($journals_slct.journal_entry_obj_li) !== JSON.stringify(results)) {
$journals_slct.journal_entry_obj_li = [...results];
if (log_lvl) {
console.log(`Session slct li stored version has changed for ID = ${$journals_slct.journal_id}`, $journals_slct.journal_entry_obj_li);
}
} else {
if (log_lvl > 1) {
console.log(`Session slct li stored version has not changed for ID = ${$journals_slct.journal_id}`);
}
}
return results;
}));
$effect(() => {
if (log_lvl) {
console.log(`LQ - $lq__journal_obj.cfg_json = `, $lq__journal_obj?.cfg_json);
console.log(`LQ - $journals_loc.filter__category_code = `, $journals_loc.filter__category_code);
if ($journals_sess?.entry_li && $journals_sess?.entry_li?.length) {
console.log(`LQ - Using $journals_sess.entry_li to get journal entries.`);
} else if ($lq__journal_obj?.cfg_json?.entry_group_sort === 'DESC') {
console.log(`LQ - Using DESC sort for Journal Entry list journal_id: ${$journals_slct?.journal_id}`);
} else if ($journals_loc.filter__category_code && $journals_loc.filter__category_code.length > 0) {
console.log(`LQ - Using category filter: ${$journals_loc.filter__category_code}`);
} else {
console.log(`LQ - Using default sort for Journal Entry list journal_id: ${$journals_slct?.journal_id}`);
}
if ($journals_slct.journal_entry_obj_li && JSON.stringify($journals_slct.journal_entry_obj_li) !== JSON.stringify(lq__journal_entry_obj_li)) {
console.log(`Session slct li stored version has changed for ID = ${$journals_slct.journal_id}`, $journals_slct.journal_entry_obj_li);
} else {
if (log_lvl > 1) {
console.log(`Session slct li stored version has not changed for ID = ${$journals_slct.journal_id}`);
}
}
}
});
// Trigger doing a basic load of journal entries
// NOTE: Categories are (currently) filtered at the CSS style level.

View File

@@ -36,47 +36,42 @@ let { data }: Props = $props();
// Variables
// *** Quickly pull out data from parent(s)
let ae_acct = data[$slct.account_id];
$effect(() => {
if (log_lvl) {
console.log(`ae_acct = `, ae_acct);
}
});
$journals_slct.journal_id = ae_acct.slct.journal_id;
let lq__journal_obj = $derived(liveQuery(async () => {
if (log_lvl) {
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`);
}
let results = await db_journals.journal
.get($journals_slct?.journal_id ?? ''); // null or undefined does not reset things like '' does
// .where('id')
// .equals($journals_slct.journal_id)
// .first();
if (log_lvl) {
console.log(`lq__journal_obj: results = `, results);
}
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_obj && results) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(results)) {
$journals_slct.journal_obj = { ...results };
if (log_lvl) {
console.log(`Session slct stored version has changed for ID = ${$journals_slct.journal_id}`, $journals_slct.journal_obj);
}
} else {
if (log_lvl) {
console.log(`Session slct stored version has not changed for ID = ${$journals_slct.journal_id}`);
}
}
}
return results;
}));
let lq__journal_obj_li = $derived(liveQuery(async () => {
$effect(() => {
if (log_lvl) {
console.log(`lq__journal_obj_li: person_id = ${$ae_loc.person_id}`);
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`);
console.log(`lq__journal_obj: results = `, lq__journal_obj);
if ($journals_slct.journal_obj && lq__journal_obj) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(lq__journal_obj)) {
console.log(`Session slct stored version has changed for ID = ${$journals_slct.journal_id}`, $journals_slct.journal_obj);
} else {
console.log(`Session slct stored version has not changed for ID = ${$journals_slct.journal_id}`);
}
}
}
});
let lq__journal_obj_li = $derived(liveQuery(async () => {
let results = await db_journals.journal
.where('person_id')
.equals($ae_loc.person_id)
@@ -86,49 +81,57 @@ let lq__journal_obj_li = $derived(liveQuery(async () => {
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_obj_li && JSON.stringify($journals_slct.journal_obj_li) !== JSON.stringify(results)) {
$journals_slct.journal_obj_li = [...results];
if (log_lvl) {
console.log(`Session slct li stored version has changed for ID = ${$ae_loc.person_id}`, $journals_slct.journal_obj_li);
}
} else {
if (log_lvl > 1) {
console.log(`Session slct li stored version has not changed for ID = ${$ae_loc.person_id}`);
}
}
return results;
}));
$effect(() => {
if (log_lvl) {
console.log(`lq__journal_obj_li: person_id = ${$ae_loc.person_id}`);
console.log(`lq__journal_obj_li: results = `, lq__journal_obj_li);
if ($journals_slct.journal_obj_li && JSON.stringify($journals_slct.journal_obj_li) !== JSON.stringify(lq__journal_obj_li)) {
console.log(`Session slct li stored version has changed for ID = ${$ae_loc.person_id}`, $journals_slct.journal_obj_li);
} else {
if (log_lvl > 1) {
console.log(`Session slct li stored version has not changed for ID = ${$ae_loc.person_id}`);
}
}
}
});
// For some reason data.params.journal_entry_id (or whatever param) is not being passed to this page when loaded by a link from another page. This seems to be a bug with Svelte or SvelteKit. Hopefully fixed in a future version 5? 2024-11-06
$journals_slct.journal_entry_id = ae_acct.slct.journal_entry_id;
// $journals_slct.journal_entry_obj = ae_acct.slct.journal_entry_obj;
let lq__journal_entry_obj = $derived(liveQuery(async () => {
if (log_lvl) {
console.log(`lq__journal_entry_obj: journal_entry_id = ${$journals_slct?.journal_entry_id}`);
}
let results = await db_journals.journal_entry
.get($journals_slct.journal_entry_id ?? ''); // null or undefined does not reset things like '' does
if (log_lvl) {
console.log(`lq__journal_entry_obj: results = `, results);
}
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_entry_obj && results) {
if (JSON.stringify($journals_slct.journal_entry_obj) !== JSON.stringify(results)) {
$journals_slct.journal_entry_obj = { ...results};
if (log_lvl) {
console.log(`Session slct stored version has changed for ID = ${$journals_slct.journal_entry_id}`, $journals_slct.journal_entry_obj);
}
} else {
if (log_lvl) {
console.log(`Session slct stored version has not changed for ID = ${$journals_slct.journal_entry_id}`);
}
}
}
return results;
}));
$effect(() => {
if (log_lvl) {
console.log(`lq__journal_entry_obj: journal_entry_id = ${$journals_slct?.journal_entry_id}`);
console.log(`lq__journal_entry_obj: results = `, lq__journal_entry_obj);
if ($journals_slct.journal_entry_obj && lq__journal_entry_obj) {
if (JSON.stringify($journals_slct.journal_entry_obj) !== JSON.stringify(lq__journal_entry_obj)) {
console.log(`Session slct stored version has changed for ID = ${$journals_slct.journal_entry_id}`, $journals_slct.journal_entry_obj);
} else {
console.log(`Session slct stored version has not changed for ID = ${$journals_slct.journal_entry_id}`);
}
}
}
});
// $effect(() => {
// if (browser && $lq__journal_entry_obj?.journal_entry_id) {