refactor(leads): modularize exhibitor leads logic and stub v3 UI
This commit is contained in:
@@ -17,16 +17,4 @@ export const editable_fields__event_exhibit = [
|
||||
'sort',
|
||||
'group',
|
||||
'notes'
|
||||
];
|
||||
|
||||
export const editable_fields__event_exhibit_tracking = [
|
||||
'exhibitor_notes',
|
||||
'responses_json',
|
||||
'data_json',
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes'
|
||||
];
|
||||
];
|
||||
@@ -3,49 +3,10 @@ import { api } from '$lib/api/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
|
||||
import { db_events } from '$lib/ae_events/db_events';
|
||||
import type { ae_EventExhibit, ae_EventExhibitTracking } from '$lib/types/ae_types';
|
||||
import type { ae_EventExhibit } from '$lib/types/ae_types';
|
||||
|
||||
const 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',
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2'
|
||||
];
|
||||
|
||||
// --- PROPERTIES TO SAVE ---
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
@@ -126,20 +87,6 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
|
||||
export async function process_ae_obj__exhibit_props({
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
@@ -287,334 +234,6 @@ export async function load_ae_obj_li__exhibit({
|
||||
return ae_promises.load__event_exhibit_obj_li || [];
|
||||
}
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function load_ae_obj_id__exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_tracking_id,
|
||||
view = 'default',
|
||||
try_cache = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_tracking_id: string;
|
||||
view?: string;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
try {
|
||||
ae_promises.load__event_exhibit_tracking_obj = await api.get_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
obj_id: exhibit_tracking_id,
|
||||
view,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
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
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_exhibit_tracking_obj || null;
|
||||
}
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function load_ae_obj_li__exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_id,
|
||||
enabled = 'enabled',
|
||||
hidden = 'all',
|
||||
view = 'default',
|
||||
limit = 100,
|
||||
offset = 0,
|
||||
order_by_li = [
|
||||
{ priority: 'DESC' },
|
||||
{ sort: 'DESC' },
|
||||
{ updated_on: 'DESC' }
|
||||
],
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_id: string;
|
||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||
view?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
order_by_li?: any;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking[]> {
|
||||
try {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await api.get_ae_obj_li_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
for_obj_type: 'event_exhibit',
|
||||
for_obj_id: exhibit_id,
|
||||
enabled,
|
||||
hidden,
|
||||
view,
|
||||
limit,
|
||||
offset,
|
||||
order_by_li,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
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
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
} 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();
|
||||
}
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_exhibit_tracking_obj_li || [];
|
||||
}
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function create_ae_obj__exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_id,
|
||||
event_badge_id,
|
||||
external_person_id,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_id: string;
|
||||
event_badge_id: string;
|
||||
external_person_id: string;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
const result = await api.create_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
fields: {
|
||||
event_exhibit_id_random: exhibit_id,
|
||||
event_badge_id_random: event_badge_id,
|
||||
external_person_id
|
||||
},
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (result && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [result],
|
||||
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
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function update_ae_obj__exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_tracking_id,
|
||||
data,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_tracking_id: string;
|
||||
data: any;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
const result = await api.update_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
obj_id: exhibit_tracking_id,
|
||||
fields: data,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (result && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [result],
|
||||
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
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function download_export__event_exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_id,
|
||||
file_type = 'CSV',
|
||||
filename = 'exhibit_tracking_export.csv',
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_id: string;
|
||||
file_type?: string;
|
||||
filename?: string;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
const endpoint = `/event/exhibit/${exhibit_id}/tracking/export`;
|
||||
const params = {
|
||||
file_type,
|
||||
return_file: true
|
||||
};
|
||||
|
||||
return await api.get_object({
|
||||
api_cfg,
|
||||
endpoint,
|
||||
params,
|
||||
return_blob: true,
|
||||
filename,
|
||||
auto_download: true,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
// Updated 2026-01-28 to V3
|
||||
export async function search__exhibit_tracking({
|
||||
api_cfg,
|
||||
event_exhibit_id,
|
||||
fulltext_search_qry_str = null,
|
||||
enabled = 'enabled',
|
||||
hidden = 'all',
|
||||
view = 'default',
|
||||
order_by_li = { created_on: 'DESC' },
|
||||
limit = 100,
|
||||
offset = 0,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
event_exhibit_id: string;
|
||||
fulltext_search_qry_str?: string | null;
|
||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||
view?: string;
|
||||
order_by_li?: any;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking[]> {
|
||||
if (log_lvl) {
|
||||
console.log(`*** search__exhibit_tracking() *** exhibit_id=${event_exhibit_id} ft=${fulltext_search_qry_str}`);
|
||||
}
|
||||
|
||||
const search_query: any = {
|
||||
q: '',
|
||||
and: []
|
||||
};
|
||||
|
||||
const params: key_val = {};
|
||||
|
||||
if (fulltext_search_qry_str && fulltext_search_qry_str.trim().length > 0) {
|
||||
const qry = fulltext_search_qry_str.trim();
|
||||
// Search across badge name and notes
|
||||
search_query.and.push({ field: 'event_badge_full_name', op: 'like', value: `%${qry}%` });
|
||||
params['lk_qry'] = { event_badge_full_name: qry };
|
||||
}
|
||||
|
||||
if (enabled === 'enabled') search_query.and.push({ field: 'enable', op: 'eq', value: 1 });
|
||||
else if (enabled === 'not_enabled') search_query.and.push({ field: 'enable', op: 'eq', value: 0 });
|
||||
|
||||
if (hidden === 'hidden') search_query.and.push({ field: 'hide', op: 'eq', value: 1 });
|
||||
else if (hidden === 'not_hidden') search_query.and.push({ field: 'hide', op: 'eq', value: 0 });
|
||||
|
||||
try {
|
||||
const result_get = await api.search_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
for_obj_type: 'event_exhibit',
|
||||
for_obj_id: event_exhibit_id,
|
||||
search_query,
|
||||
params,
|
||||
enabled,
|
||||
hidden,
|
||||
view,
|
||||
order_by_li,
|
||||
limit,
|
||||
offset,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
let result_li: ae_EventExhibitTracking[] = [];
|
||||
if (Array.isArray(result_get)) {
|
||||
result_li = result_get;
|
||||
} else if (result_get?.data && Array.isArray(result_get.data)) {
|
||||
result_li = result_get.data;
|
||||
}
|
||||
|
||||
if (result_li.length > 0) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: result_li,
|
||||
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
|
||||
});
|
||||
return processed_obj_li;
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('search__exhibit_tracking V3 Request failed.', error);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
// Updated 2026-01-28 to V3
|
||||
export async function search__exhibit({
|
||||
api_cfg,
|
||||
@@ -705,4 +324,4 @@ export async function search__exhibit({
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
export const editable_fields__event_exhibit_tracking = [
|
||||
'exhibitor_notes',
|
||||
'responses_json',
|
||||
'data_json',
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes'
|
||||
];
|
||||
440
src/lib/ae_events/ae_events__exhibit_tracking.ts
Normal file
440
src/lib/ae_events/ae_events__exhibit_tracking.ts
Normal file
@@ -0,0 +1,440 @@
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
import { api } from '$lib/api/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
|
||||
import { db_events } from '$lib/ae_events/db_events';
|
||||
import type { ae_EventExhibitTracking } from '$lib/types/ae_types';
|
||||
|
||||
const 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',
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2'
|
||||
];
|
||||
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
*/
|
||||
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 (!obj_li || obj_li.length === 0) return [];
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7);
|
||||
(processed_obj as any)[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
(processed_obj as any).id = String(processed_obj[randomIdKey]);
|
||||
}
|
||||
|
||||
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}`;
|
||||
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function load_ae_obj_id__exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_tracking_id,
|
||||
view = 'default',
|
||||
try_cache = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_tracking_id: string;
|
||||
view?: string;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
try {
|
||||
ae_promises.load__event_exhibit_tracking_obj = await api.get_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
obj_id: exhibit_tracking_id,
|
||||
view,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
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
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_exhibit_tracking_obj || null;
|
||||
}
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function load_ae_obj_li__exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_id,
|
||||
enabled = 'enabled',
|
||||
hidden = 'all',
|
||||
view = 'default',
|
||||
limit = 100,
|
||||
offset = 0,
|
||||
order_by_li = [
|
||||
{ priority: 'DESC' },
|
||||
{ sort: 'DESC' },
|
||||
{ updated_on: 'DESC' }
|
||||
],
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_id: string;
|
||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||
view?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
order_by_li?: any;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking[]> {
|
||||
try {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await api.get_ae_obj_li_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
for_obj_type: 'event_exhibit',
|
||||
for_obj_id: exhibit_id,
|
||||
enabled,
|
||||
hidden,
|
||||
view,
|
||||
limit,
|
||||
offset,
|
||||
order_by_li,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
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
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
} 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();
|
||||
}
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_exhibit_tracking_obj_li || [];
|
||||
}
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function create_ae_obj__exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_id,
|
||||
event_badge_id,
|
||||
external_person_id,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_id: string;
|
||||
event_badge_id: string;
|
||||
external_person_id: string;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
const result = await api.create_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
fields: {
|
||||
event_exhibit_id_random: exhibit_id,
|
||||
event_badge_id_random: event_badge_id,
|
||||
external_person_id
|
||||
},
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (result && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [result],
|
||||
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
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function update_ae_obj__exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_tracking_id,
|
||||
data,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_tracking_id: string;
|
||||
data: any;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
const result = await api.update_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
obj_id: exhibit_tracking_id,
|
||||
fields: data,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (result && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [result],
|
||||
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
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function download_export__event_exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_id,
|
||||
file_type = 'CSV',
|
||||
filename = 'exhibit_tracking_export.csv',
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_id: string;
|
||||
file_type?: string;
|
||||
filename?: string;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
const endpoint = `/event/exhibit/${exhibit_id}/tracking/export`;
|
||||
const params = {
|
||||
file_type,
|
||||
return_file: true
|
||||
};
|
||||
|
||||
return await api.get_object({
|
||||
api_cfg,
|
||||
endpoint,
|
||||
params,
|
||||
return_blob: true,
|
||||
filename,
|
||||
auto_download: true,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
// Updated 2026-01-28 to V3
|
||||
export async function search__exhibit_tracking({
|
||||
api_cfg,
|
||||
event_exhibit_id,
|
||||
fulltext_search_qry_str = null,
|
||||
enabled = 'enabled',
|
||||
hidden = 'all',
|
||||
view = 'default',
|
||||
order_by_li = { created_on: 'DESC' },
|
||||
limit = 100,
|
||||
offset = 0,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
event_exhibit_id: string;
|
||||
fulltext_search_qry_str?: string | null;
|
||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||
view?: string;
|
||||
order_by_li?: any;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking[]> {
|
||||
if (log_lvl) {
|
||||
console.log(`*** search__exhibit_tracking() *** exhibit_id=${event_exhibit_id} ft=${fulltext_search_qry_str}`);
|
||||
}
|
||||
|
||||
const search_query: any = {
|
||||
q: '',
|
||||
and: []
|
||||
};
|
||||
|
||||
const params: key_val = {};
|
||||
|
||||
if (fulltext_search_qry_str && fulltext_search_qry_str.trim().length > 0) {
|
||||
const qry = fulltext_search_qry_str.trim();
|
||||
// Search across badge name and notes
|
||||
search_query.and.push({ field: 'event_badge_full_name', op: 'like', value: `%${qry}%` });
|
||||
params['lk_qry'] = { event_badge_full_name: qry };
|
||||
}
|
||||
|
||||
if (enabled === 'enabled') search_query.and.push({ field: 'enable', op: 'eq', value: 1 });
|
||||
else if (enabled === 'not_enabled') search_query.and.push({ field: 'enable', op: 'eq', value: 0 });
|
||||
|
||||
if (hidden === 'hidden') search_query.and.push({ field: 'hide', op: 'eq', value: 1 });
|
||||
else if (hidden === 'not_hidden') search_query.and.push({ field: 'hide', op: 'eq', value: 0 });
|
||||
|
||||
try {
|
||||
const result_get = await api.search_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
for_obj_type: 'event_exhibit',
|
||||
for_obj_id: event_exhibit_id,
|
||||
search_query,
|
||||
params,
|
||||
enabled,
|
||||
hidden,
|
||||
view,
|
||||
order_by_li,
|
||||
limit,
|
||||
offset,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
let result_li: ae_EventExhibitTracking[] = [];
|
||||
if (Array.isArray(result_get)) {
|
||||
result_li = result_get;
|
||||
} else if (result_get?.data && Array.isArray(result_get.data)) {
|
||||
result_li = result_get.data;
|
||||
}
|
||||
|
||||
if (result_li.length > 0) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: result_li,
|
||||
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
|
||||
});
|
||||
return processed_obj_li;
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('search__exhibit_tracking V3 Request failed.', error);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
@@ -9,14 +9,17 @@ import * as event_file from '$lib/ae_events/ae_events__event_file';
|
||||
import {
|
||||
load_ae_obj_id__exhibit,
|
||||
load_ae_obj_li__exhibit,
|
||||
search__exhibit,
|
||||
search__exhibit
|
||||
} from '$lib/ae_events/ae_events__exhibit';
|
||||
|
||||
import {
|
||||
search__exhibit_tracking,
|
||||
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
|
||||
} from '$lib/ae_events/ae_events__exhibit';
|
||||
} from '$lib/ae_events/ae_events__exhibit_tracking';
|
||||
|
||||
import * as event_location from '$lib/ae_events/ae_events__event_location';
|
||||
|
||||
@@ -68,15 +71,15 @@ const export_obj = {
|
||||
update_ae_obj__event_device: event_device.update_ae_obj__event_device,
|
||||
|
||||
// Event Exhibits
|
||||
handle_load_ae_obj_id__exhibit: load_ae_obj_id__exhibit,
|
||||
handle_load_ae_obj_li__exhibit: load_ae_obj_li__exhibit,
|
||||
load_ae_obj_id__exhibit: load_ae_obj_id__exhibit,
|
||||
load_ae_obj_li__exhibit: load_ae_obj_li__exhibit,
|
||||
search__exhibit: search__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,
|
||||
load_ae_obj_id__exhibit_tracking: load_ae_obj_id__exhibit_tracking,
|
||||
load_ae_obj_li__exhibit_tracking: load_ae_obj_li__exhibit_tracking,
|
||||
search__exhibit_tracking: search__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,
|
||||
create_ae_obj__exhibit_tracking: create_ae_obj__exhibit_tracking,
|
||||
update_ae_obj__exhibit_tracking: update_ae_obj__exhibit_tracking,
|
||||
download_export__event_exhibit_tracking: download_export__event_exhibit_tracking,
|
||||
|
||||
// Event Files
|
||||
load_ae_obj_id__event_file: event_file.load_ae_obj_id__event_file,
|
||||
|
||||
Reference in New Issue
Block a user