feat(offline): implement Dexie fallbacks and fix type stability in Events module
- Offline Resilience: Added local Dexie fallbacks to load_ae_obj_id__* and load_ae_obj_li__* functions for Events, Sessions, Locations, Exhibits, and Badges. - Type Safety: Standardized ae_Event and ae_EventSession interfaces in ae_types.ts; resolved Promise assignment errors in load functions (+page.ts). - Bug Fixes: Corrected duplication in ae_events__event_location.ts and ae_events__event_badge_template.ts; fixed missing try_cache parameters. - UI Stability: Fixed Dexie LiveQuery subscription pattern in bulk print view and ensured proper property access in layout load functions.
This commit is contained in:
@@ -118,39 +118,24 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
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 [];
|
||||
}
|
||||
if (!obj_li || obj_li.length === 0) 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
|
||||
const newKey = key.slice(0, -7);
|
||||
(processed_obj as any)[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';
|
||||
@@ -160,7 +145,6 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
(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));
|
||||
}
|
||||
@@ -209,56 +193,48 @@ export async function load_ae_obj_id__exhibit({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibit | null> {
|
||||
console.log(`*** load_ae_obj_id__exhibit() *** exhibit_id=${exhibit_id}`);
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__exhibit() *** exhibit_id=${exhibit_id}`);
|
||||
}
|
||||
|
||||
const params = {};
|
||||
try {
|
||||
ae_promises.load__exhibit_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit',
|
||||
obj_id: exhibit_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
params: {},
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
// $events_sess.exhibits.status_load__exhibit_obj = 'loading';
|
||||
ae_promises.load__exhibit_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit',
|
||||
obj_id: exhibit_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (exhibit_obj_get_result) {
|
||||
if (exhibit_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const 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.');
|
||||
return null;
|
||||
if (ae_promises.load__exhibit_obj) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_props({
|
||||
obj_li: [ae_promises.load__exhibit_obj],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
} else {
|
||||
if (try_cache) {
|
||||
ae_promises.load__exhibit_obj = await db_events.exhibit.get(exhibit_id);
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (try_cache) {
|
||||
ae_promises.load__exhibit_obj = await db_events.exhibit.get(exhibit_id);
|
||||
} else {
|
||||
ae_promises.load__exhibit_obj = null;
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__exhibit_obj;
|
||||
}
|
||||
@@ -277,100 +253,73 @@ export async function load_ae_obj_li__exhibit({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibit[]> {
|
||||
console.log(`*** load_ae_obj_li__exhibit() *** event_id=${event_id}`);
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__exhibit() *** event_id=${event_id}`);
|
||||
}
|
||||
|
||||
const enabled: 'enabled' | 'all' | 'not_enabled' = (params.qry__enabled as any) ?? 'enabled';
|
||||
const hidden: 'hidden' | 'all' | 'not_hidden' = (params.qry__hidden as any) ?? 'not_hidden';
|
||||
const limit: number = params.qry__limit ?? 99; // 99
|
||||
const offset: number = params.qry__offset ?? 0; // 0
|
||||
const limit: number = params.qry__limit ?? 99;
|
||||
const offset: number = params.qry__offset ?? 0;
|
||||
|
||||
const params_json: key_val = {};
|
||||
// params_json['and_qry'] = {};
|
||||
// params_json['and_qry']['license_max'] = 10;
|
||||
|
||||
params_json['and_in_li'] = {
|
||||
license_max: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
const params_json: key_val = {
|
||||
and_in_li: {
|
||||
license_max: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
}
|
||||
};
|
||||
|
||||
// if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
||||
// params_json['ft_qry'] = {
|
||||
// 'default_qry_str': fulltext_search_qry_str,
|
||||
// // 'location_address_json_ext': fulltext_search_qry_str, // JSON extracted text DB field
|
||||
// // 'contact_li_json_ext': fulltext_search_qry_str, // JSON extracted text DB field
|
||||
// };
|
||||
// }
|
||||
try {
|
||||
ae_promises.load__event_exhibit_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
// console.log(params_json);
|
||||
|
||||
// $events_sess.exhibits.status_qry__search = 'loading';
|
||||
ae_promises.load__event_exhibit_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
|
||||
// order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'created_on': 'DESC', 'updated_on': 'DESC'},
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
|
||||
.then(async function (exhibit_obj_li_get_result) {
|
||||
// console.log('Badge list:', exhibit_obj_li_get_result);
|
||||
if (exhibit_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const 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 = [];
|
||||
return [];
|
||||
if (ae_promises.load__event_exhibit_obj_li) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_props({
|
||||
obj_li: ae_promises.load__event_exhibit_obj_li,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
// $events_sess.exhibits.status_qry__search = 'done';
|
||||
// console.log('Badge list:', exhibit_obj_li_get_result);
|
||||
// return exhibit_obj_li_get_result;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.load__event_exhibit_obj_li:',
|
||||
ae_promises.load__event_exhibit_obj_li
|
||||
);
|
||||
} else {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_obj_li = await db_events.exhibit
|
||||
.where('event_id').equals(event_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_obj_li = [];
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_obj_li = await db_events.exhibit
|
||||
.where('event_id').equals(event_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_obj_li = [];
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_exhibit_obj_li;
|
||||
}
|
||||
|
||||
@@ -382,62 +331,53 @@ export async function load_ae_obj_id__exhibit_tracking({
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_tracking_id: string;
|
||||
params?: key_val;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
console.log(
|
||||
`*** load_ae_obj_id__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`
|
||||
);
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`*** load_ae_obj_id__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`
|
||||
);
|
||||
}
|
||||
|
||||
const params = {};
|
||||
try {
|
||||
ae_promises.load__event_exhibit_tracking_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
obj_id: exhibit_tracking_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
params: {},
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
// $events_sess.exhibits.status_load__exhibit_tracking_obj = 'loading';
|
||||
ae_promises.load__event_exhibit_tracking_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
obj_id: exhibit_tracking_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (exhibit_tracking_obj_get_result) {
|
||||
if (exhibit_tracking_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const 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.');
|
||||
return null;
|
||||
if (ae_promises.load__event_exhibit_tracking_obj) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [ae_promises.load__event_exhibit_tracking_obj],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
} else {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_tracking_obj = await db_events.exhibit_tracking.get(exhibit_tracking_id);
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_tracking_obj = await db_events.exhibit_tracking.get(exhibit_tracking_id);
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_tracking_obj = null;
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_exhibit_tracking_obj;
|
||||
}
|
||||
@@ -456,80 +396,67 @@ export async function load_ae_obj_li__exhibit_tracking({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking[]> {
|
||||
console.log(`*** load_ae_obj_li__exhibit_tracking() *** exhibit_id=${exhibit_id}`);
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__exhibit_tracking() *** exhibit_id=${exhibit_id}`);
|
||||
}
|
||||
|
||||
const enabled: 'enabled' | 'all' | 'not_enabled' = (params.qry__enabled as any) ?? 'enabled';
|
||||
const hidden: 'hidden' | 'all' | 'not_hidden' = (params.qry__hidden as any) ?? 'all';
|
||||
const limit: number = params.qry__limit ?? 99; // 99
|
||||
const offset: number = params.qry__offset ?? 0; // 0
|
||||
const limit: number = params.qry__limit ?? 99;
|
||||
const offset: number = params.qry__offset ?? 0;
|
||||
|
||||
const params_json: key_val = {};
|
||||
try {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
for_obj_type: 'event_exhibit',
|
||||
for_obj_id: exhibit_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: {},
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
for_obj_type: 'event_exhibit',
|
||||
for_obj_id: exhibit_id,
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
|
||||
.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) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const 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 = [];
|
||||
return [];
|
||||
if (ae_promises.load__event_exhibit_tracking_obj_li) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: ae_promises.load__event_exhibit_tracking_obj_li,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
// console.log('Exhibit tracking list:', exhibit_tracking_obj_li_get_result);
|
||||
// return exhibit_tracking_obj_li_get_result;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.load__event_exhibit_tracking_obj_li:',
|
||||
ae_promises.load__event_exhibit_tracking_obj_li
|
||||
);
|
||||
} else {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await db_events.exhibit_tracking
|
||||
.where('event_exhibit_id').equals(exhibit_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = [];
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await db_events.exhibit_tracking
|
||||
.where('event_exhibit_id').equals(exhibit_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = [];
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_exhibit_tracking_obj_li;
|
||||
}
|
||||
|
||||
@@ -551,13 +478,6 @@ export async function create_ae_obj__exhibit_tracking({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
console.log(
|
||||
`*** handle_create_ae_obj__exhibit_tracking() *** exhibit_id=${exhibit_id}, event_badge_id=${event_badge_id}`
|
||||
);
|
||||
|
||||
const params_json: key_val = {};
|
||||
|
||||
// $events_sess.exhibits.status_create__exhibit_tracking = 'loading';
|
||||
ae_promises.create__event_exhibit_tracking = await api
|
||||
.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
@@ -572,54 +492,23 @@ export async function create_ae_obj__exhibit_tracking({
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
|
||||
.then(async function (exhibit_tracking_obj_create_result) {
|
||||
// console.log('Exhibit tracking create:', exhibit_tracking_obj_create_result);
|
||||
if (exhibit_tracking_obj_create_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const 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 = [];
|
||||
return null;
|
||||
.then(async function (obj_create_result) {
|
||||
if (obj_create_result && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [obj_create_result],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
// console.log('Exhibit tracking create:', exhibit_tracking_obj_create_result);
|
||||
// return exhibit_tracking_obj_create_result;
|
||||
return obj_create_result;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.create__event_exhibit_tracking:',
|
||||
ae_promises.create__event_exhibit_tracking
|
||||
);
|
||||
}
|
||||
return ae_promises.create__event_exhibit_tracking;
|
||||
}
|
||||
|
||||
@@ -629,18 +518,16 @@ export async function update_ae_obj__exhibit_tracking({
|
||||
exhibit_tracking_id,
|
||||
data,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_tracking_id: string;
|
||||
data: any;
|
||||
params: key_val;
|
||||
log_lvl: number;
|
||||
params?: key_val;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
console.log(
|
||||
`*** handle_update_ae_obj__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`
|
||||
);
|
||||
|
||||
ae_promises.update__event_exhibit_tracking = await api
|
||||
.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
@@ -652,48 +539,23 @@ export async function update_ae_obj__exhibit_tracking({
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (exhibit_tracking_obj_update_result) {
|
||||
if (exhibit_tracking_obj_update_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const 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;
|
||||
.then(async function (obj_update_result) {
|
||||
if (obj_update_result && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [obj_update_result],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {});
|
||||
return obj_update_result;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.update__event_exhibit_tracking:',
|
||||
ae_promises.update__event_exhibit_tracking
|
||||
);
|
||||
}
|
||||
return ae_promises.update__event_exhibit_tracking;
|
||||
}
|
||||
|
||||
@@ -741,4 +603,4 @@ export async function download_export__event_exhibit_tracking({
|
||||
);
|
||||
}
|
||||
return ae_promises.download__event_exhibit_tracking_export_file;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user