Quick snapshot again as Gemini is working.
This commit is contained in:
@@ -10,10 +10,10 @@ let ae_promises: key_val = {};
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_badge_template_id',
|
||||
'event_badge_template_id_random',
|
||||
// 'event_badge_template_id_random',
|
||||
|
||||
'event_id',
|
||||
'event_id_random',
|
||||
// 'event_id_random',
|
||||
|
||||
'name',
|
||||
'description',
|
||||
@@ -82,82 +82,99 @@ export const properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 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.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.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.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__event_badge_template_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_badge_template_props() ***`, obj_li);
|
||||
}
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
const processed_obj_li = [];
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj event_badge_template:`, obj);
|
||||
let processed_obj = {
|
||||
id: obj.event_badge_template_id_random,
|
||||
event_badge_template_id: obj.event_badge_template_id_random,
|
||||
event_badge_template_id_random: obj.event_badge_template_id_random,
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'event_badge_template',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Event badge template-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}`;
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
logo_filename: obj.logo_filename,
|
||||
logo_path: obj.logo_path,
|
||||
|
||||
header_path: obj.header_path,
|
||||
secondary_header_path: obj.secondary_header_path,
|
||||
footer_path: obj.footer_path,
|
||||
|
||||
header_row_1: obj.header_row_1,
|
||||
header_row_2: obj.header_row_2,
|
||||
|
||||
badge_type_list: obj.badge_type_list,
|
||||
ticket_list: obj.ticket_list,
|
||||
|
||||
ticket_1_text: obj.ticket_1_text,
|
||||
ticket_2_text: obj.ticket_2_text,
|
||||
ticket_3_text: obj.ticket_3_text,
|
||||
ticket_4_text: obj.ticket_4_text,
|
||||
ticket_5_text: obj.ticket_5_text,
|
||||
ticket_6_text: obj.ticket_6_text,
|
||||
ticket_7_text: obj.ticket_7_text,
|
||||
ticket_8_text: obj.ticket_8_text,
|
||||
|
||||
wireless_ssid: obj.wireless_ssid,
|
||||
wireless_password: obj.wireless_password,
|
||||
|
||||
show_qr_front: obj.show_qr_front,
|
||||
show_qr_back: obj.show_qr_back,
|
||||
|
||||
layout: obj.layout,
|
||||
style_filename: obj.style_filename,
|
||||
|
||||
// default: obj.default,
|
||||
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}`,
|
||||
};
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
return processed_obj_li;
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user