diff --git a/src/lib/ae_api/api_post__crud_obj_v3.ts b/src/lib/ae_api/api_post__crud_obj_v3.ts index e9b9be28..a48bfa01 100644 --- a/src/lib/ae_api/api_post__crud_obj_v3.ts +++ b/src/lib/ae_api/api_post__crud_obj_v3.ts @@ -54,9 +54,14 @@ export async function create_ae_obj_v3({ interface CreateNestedObjV3Params { api_cfg: any; - parent_type: string; - parent_id: string; - child_type: string; + parent_type?: string; + parent_id?: string; + child_type?: string; + // Aliases for migration + for_obj_type?: string; + for_obj_id?: string; + obj_type?: string; + fields: key_val; params?: key_val; log_lvl?: number; @@ -67,11 +72,18 @@ export async function create_nested_obj_v3({ parent_type, parent_id, child_type, + for_obj_type, + for_obj_id, + obj_type, fields, params = {}, log_lvl = 0 }: CreateNestedObjV3Params) { - const endpoint = `/v3/crud/${parent_type}/${parent_id}/${child_type}/`; + const p_type = parent_type || for_obj_type; + const p_id = parent_id || for_obj_id; + const c_type = child_type || obj_type; + + const endpoint = `/v3/crud/${p_type}/${p_id}/${c_type}/`; if (log_lvl) { console.log('*** create_nested_obj_v3 ***'); @@ -145,10 +157,16 @@ export async function update_ae_obj_v3({ interface UpdateNestedObjV3Params { api_cfg: any; - parent_type: string; - parent_id: string; - child_type: string; - child_id: string; + parent_type?: string; + parent_id?: string; + child_type?: string; + child_id?: string; + // Aliases for migration + for_obj_type?: string; + for_obj_id?: string; + obj_type?: string; + obj_id?: string; + fields: key_val; params?: key_val; log_lvl?: number; @@ -160,11 +178,20 @@ export async function update_nested_obj_v3({ parent_id, child_type, child_id, + for_obj_type, + for_obj_id, + obj_type, + obj_id, fields, params = {}, log_lvl = 0 }: UpdateNestedObjV3Params) { - const endpoint = `/v3/crud/${parent_type}/${parent_id}/${child_type}/${child_id}`; + const p_type = parent_type || for_obj_type; + const p_id = parent_id || for_obj_id; + const c_type = child_type || obj_type; + const c_id = child_id || obj_id; + + const endpoint = `/v3/crud/${p_type}/${p_id}/${c_type}/${c_id}`; if (log_lvl) { console.log('*** update_nested_obj_v3 ***'); @@ -233,10 +260,16 @@ export async function delete_ae_obj_v3({ interface DeleteNestedAeObjV3Params { api_cfg: any; - parent_type: string; - parent_id: string; - child_type: string; - child_id: string; + parent_type?: string; + parent_id?: string; + child_type?: string; + child_id?: string; + // Aliases for migration + for_obj_type?: string; + for_obj_id?: string; + obj_type?: string; + obj_id?: string; + method?: 'delete' | 'soft_delete' | 'disable' | 'hide'; params?: key_val; log_lvl?: number; @@ -251,11 +284,20 @@ export async function delete_nested_ae_obj_v3({ parent_id, child_type, child_id, + for_obj_type, + for_obj_id, + obj_type, + obj_id, method = 'delete', params = {}, log_lvl = 0 }: DeleteNestedAeObjV3Params) { - const endpoint = `/v3/crud/${parent_type}/${parent_id}/${child_type}/${child_id}`; + const p_type = parent_type || for_obj_type; + const p_id = parent_id || for_obj_id; + const c_type = child_type || obj_type; + const c_id = child_id || obj_id; + + const endpoint = `/v3/crud/${p_type}/${p_id}/${c_type}/${c_id}`; const query_params = { ...params, method }; if (log_lvl) { diff --git a/src/lib/ae_events/ae_events__event_badge.spec.ts b/src/lib/ae_events/ae_events__event_badge.test.ts similarity index 82% rename from src/lib/ae_events/ae_events__event_badge.spec.ts rename to src/lib/ae_events/ae_events__event_badge.test.ts index d310b397..c238bcca 100644 --- a/src/lib/ae_events/ae_events__event_badge.spec.ts +++ b/src/lib/ae_events/ae_events__event_badge.test.ts @@ -18,7 +18,7 @@ import { create_ae_obj__event_badge } from './ae_events__event_badge'; describe('create_ae_obj__event_badge', () => { it('calls api.create_nested_obj_v3 with the correct params and returns the result', async () => { const mocked = await import('$lib/api/api'); - const mockCreateNested = mocked.api.create_nested_obj_v3 as jest.MockedFunction; + const mockCreateNested = mocked.api.create_nested_obj_v3 as any; const fakeResult = { event_badge_id: 'eb123', full_name: 'Test User' }; mockCreateNested.mockResolvedValue(fakeResult); @@ -30,11 +30,15 @@ describe('create_ae_obj__event_badge', () => { const result = await create_ae_obj__event_badge({ api_cfg, event_id, data_kv, try_cache: false }); expect(mockCreateNested).toHaveBeenCalled(); - const calledWith = mockCreateNested.mock.calls[0][0]; - expect(calledWith.parent_type).toBe('event'); - expect(calledWith.parent_id).toBe(event_id); - expect(calledWith.child_type).toBe('event_badge'); - expect(calledWith.fields).toEqual(data_kv); + expect(mockCreateNested).toHaveBeenCalledWith({ + api_cfg, + parent_type: 'event', + parent_id: event_id, + child_type: 'event_badge', + fields: data_kv, + return_obj: true, + log_lvl: 0 + }); expect(result).toEqual(fakeResult); }); @@ -43,7 +47,7 @@ describe('create_ae_obj__event_badge', () => { describe('update_ae_obj__event_badge', () => { it('calls api.update_nested_obj_v3 with correct params and returns result', async () => { const mocked = await import('$lib/api/api'); - const mockUpdate = mocked.api.update_nested_obj_v3 as jest.MockedFunction; + const mockUpdate = mocked.api.update_nested_obj_v3 as any; const fakeResult = { event_badge_id: 'eb999', full_name: 'Updated' }; mockUpdate.mockResolvedValue(fakeResult); @@ -52,9 +56,16 @@ describe('update_ae_obj__event_badge', () => { const res = await update_ae_obj__event_badge({ api_cfg, event_id: 'evt1', event_badge_id: 'eb999', data_kv: { full_name_override: 'Updated' }, try_cache: false }); expect(mockUpdate).toHaveBeenCalled(); - const called = mockUpdate.mock.calls[0][0]; - expect(called.child_id).toBe('eb999'); - expect(called.fields).toEqual({ full_name_override: 'Updated' }); + expect(mockUpdate).toHaveBeenCalledWith({ + api_cfg, + parent_type: 'event', + parent_id: 'evt1', + child_type: 'event_badge', + child_id: 'eb999', + fields: { full_name_override: 'Updated' }, + return_obj: true, + log_lvl: 0 + }); expect(res).toEqual(fakeResult); }); }); @@ -62,11 +73,11 @@ describe('update_ae_obj__event_badge', () => { describe('delete_ae_obj_id__event_badge', () => { it('calls api.delete_nested_ae_obj_v3 and deletes from local DB when try_cache true', async () => { const mocked = await import('$lib/api/api'); - const mockDelete = mocked.api.delete_nested_ae_obj_v3 as jest.MockedFunction; + const mockDelete = mocked.api.delete_nested_ae_obj_v3 as any; mockDelete.mockResolvedValue({ success: true }); const db = await import('$lib/ae_events/db_events'); - const dbDelete = db.db_events.badge.delete as jest.MockedFunction; + const dbDelete = db.db_events.badge.delete as any; const { delete_ae_obj_id__event_badge } = await import('./ae_events__event_badge'); @@ -82,7 +93,7 @@ describe('delete_ae_obj_id__event_badge', () => { describe('search__event_badge', () => { it('calls api.search_ae_obj_v3 and returns list (handles data envelope)', async () => { const mocked = await import('$lib/api/api'); - const mockSearch = mocked.api.search_ae_obj_v3 as jest.MockedFunction; + const mockSearch = mocked.api.search_ae_obj_v3 as any; const fakeList = [{ event_badge_id: 'eb1' }, { event_badge_id: 'eb2' }]; mockSearch.mockResolvedValue({ data: fakeList }); diff --git a/src/lib/ae_events/ae_events__event_device.ts b/src/lib/ae_events/ae_events__event_device.ts index 986ee16b..0720901e 100644 --- a/src/lib/ae_events/ae_events__event_device.ts +++ b/src/lib/ae_events/ae_events__event_device.ts @@ -1,3 +1,5 @@ +import { get } from 'svelte/store'; +import { slct } from '$lib/stores/ae_stores'; import type { key_val } from '$lib/stores/ae_stores'; import { api } from '$lib/api/api'; @@ -185,11 +187,16 @@ export async function create_ae_obj__event_device({ log_lvl = 0 }: { api_cfg: any; - event_id: string; + event_id?: string; data_kv: key_val; try_cache?: boolean; log_lvl?: number; }): Promise { + if (!event_id) event_id = get(slct).event_id; + if (!event_id) { + console.error('create_ae_obj__event_device: event_id is required'); + return null; + } if (log_lvl) { console.log(`*** create_ae_obj__event_device() *** [V3] event_id=${event_id}`); } @@ -235,12 +242,17 @@ export async function delete_ae_obj_id__event_device({ log_lvl = 0 }: { api_cfg: any; - event_id: string; + event_id?: string; event_device_id: string; method?: 'delete' | 'soft_delete' | 'disable' | 'hide'; try_cache?: boolean; log_lvl?: number; }) { + if (!event_id) event_id = get(slct).event_id; + if (!event_id) { + console.error('delete_ae_obj_id__event_device: event_id is required'); + return null; + } if (log_lvl) { console.log(`*** delete_ae_obj_id__event_device() *** [V3] id=${event_device_id}`); } @@ -272,12 +284,17 @@ export async function update_ae_obj__event_device({ log_lvl = 0 }: { api_cfg: any; - event_id: string; + event_id?: string; event_device_id: string; data_kv: key_val; try_cache?: boolean; log_lvl?: number; }): Promise { + if (!event_id) event_id = get(slct).event_id; + if (!event_id) { + console.error('update_ae_obj__event_device: event_id is required'); + return null; + } if (log_lvl) { console.log(`*** update_ae_obj__event_device() *** [V3] id=${event_device_id}`); } @@ -512,4 +529,4 @@ export async function process_ae_obj__event_device_props({ return obj; } }); -} \ No newline at end of file +} diff --git a/src/lib/ae_events/ae_events__event_presenter.ts b/src/lib/ae_events/ae_events__event_presenter.ts index eaa1d002..b1364684 100644 --- a/src/lib/ae_events/ae_events__event_presenter.ts +++ b/src/lib/ae_events/ae_events__event_presenter.ts @@ -1,3 +1,6 @@ +import { get } from 'svelte/store'; +import { slct } from '$lib/stores/ae_stores'; +import { events_slct } from '$lib/stores/ae_events_stores'; import type { key_val } from '$lib/stores/ae_stores'; import { api } from '$lib/api/api'; @@ -184,11 +187,16 @@ export async function create_ae_obj__event_presenter({ log_lvl = 0 }: { api_cfg: any; - event_presentation_id: string; + event_presentation_id?: string; data_kv: key_val; try_cache?: boolean; log_lvl?: number; }): Promise { + if (!event_presentation_id) event_presentation_id = get(events_slct).event_presentation_id; + if (!event_presentation_id) { + console.error('create_ae_obj__event_presenter: event_presentation_id is required'); + return null; + } const result = await api.create_nested_obj_v3({ api_cfg, for_obj_type: 'event_presentation', @@ -225,12 +233,17 @@ export async function delete_ae_obj_id__event_presenter({ log_lvl = 0 }: { api_cfg: any; - event_presentation_id: string; + event_presentation_id?: string; event_presenter_id: string; method?: 'delete' | 'soft_delete' | 'disable' | 'hide'; try_cache?: boolean; log_lvl?: number; }) { + if (!event_presentation_id) event_presentation_id = get(events_slct).event_presentation_id; + if (!event_presentation_id) { + console.error('delete_ae_obj_id__event_presenter: event_presentation_id is required'); + return null; + } const result = await api.delete_nested_ae_obj_v3({ api_cfg, for_obj_type: 'event_presentation', @@ -254,12 +267,17 @@ export async function update_ae_obj__event_presenter({ log_lvl = 0 }: { api_cfg: any; - event_presentation_id: string; + event_presentation_id?: string; event_presenter_id: string; data_kv: key_val; try_cache?: boolean; log_lvl?: number; }): Promise { + if (!event_presentation_id) event_presentation_id = get(events_slct).event_presentation_id; + if (!event_presentation_id) { + console.error('update_ae_obj__event_presenter: event_presentation_id is required'); + return null; + } const result = await api.update_nested_obj_v3({ api_cfg, for_obj_type: 'event_presentation', diff --git a/src/lib/ae_events/ae_events__event_session.ts b/src/lib/ae_events/ae_events__event_session.ts index 3f3c82d0..87de585f 100644 --- a/src/lib/ae_events/ae_events__event_session.ts +++ b/src/lib/ae_events/ae_events__event_session.ts @@ -1,3 +1,5 @@ +import { get } from 'svelte/store'; +import { slct } from '$lib/stores/ae_stores'; import type { key_val } from '$lib/stores/ae_stores'; import { api } from '$lib/api/api'; @@ -270,11 +272,16 @@ export async function create_ae_obj__event_session({ log_lvl = 0 }: { api_cfg: any; - event_id: string; + event_id?: string; data_kv: key_val; try_cache?: boolean; log_lvl?: number; }): Promise { + if (!event_id) event_id = get(slct).event_id; + if (!event_id) { + console.error('create_ae_obj__event_session: event_id is required'); + return null; + } const result = await api.create_nested_obj_v3({ api_cfg, for_obj_type: 'event', @@ -309,12 +316,17 @@ export async function delete_ae_obj_id__event_session({ log_lvl = 0 }: { api_cfg: any; - event_id: string; + event_id?: string; event_session_id: string; method?: 'delete' | 'soft_delete' | 'disable' | 'hide'; try_cache?: boolean; log_lvl?: number; }) { + if (!event_id) event_id = get(slct).event_id; + if (!event_id) { + console.error('delete_ae_obj_id__event_session: event_id is required'); + return null; + } const result = await api.delete_nested_ae_obj_v3({ api_cfg, for_obj_type: 'event', @@ -337,12 +349,17 @@ export async function update_ae_obj__event_session({ log_lvl = 0 }: { api_cfg: any; - event_id: string; + event_id?: string; event_session_id: string; data_kv: key_val; try_cache?: boolean; log_lvl?: number; }): Promise { + if (!event_id) event_id = get(slct).event_id; + if (!event_id) { + console.error('update_ae_obj__event_session: event_id is required'); + return null; + } const result = await api.update_nested_obj_v3({ api_cfg, for_obj_type: 'event', diff --git a/src/lib/elements/element_ae_obj_field_editor_v3.svelte b/src/lib/elements/element_ae_obj_field_editor_v3.svelte index e8a3ce2d..a6eeaedb 100644 --- a/src/lib/elements/element_ae_obj_field_editor_v3.svelte +++ b/src/lib/elements/element_ae_obj_field_editor_v3.svelte @@ -1,6 +1,7 @@
diff --git a/src/routes/events/[event_id]/(pres_mgmt)/device/device/ae_comp__event_device_obj_li_wrapper.svelte b/src/routes/events/[event_id]/(pres_mgmt)/device/device/ae_comp__event_device_obj_li_wrapper.svelte index 47a48f34..52c28cf9 100644 --- a/src/routes/events/[event_id]/(pres_mgmt)/device/device/ae_comp__event_device_obj_li_wrapper.svelte +++ b/src/routes/events/[event_id]/(pres_mgmt)/device/device/ae_comp__event_device_obj_li_wrapper.svelte @@ -1,5 +1,6 @@ @@ -152,204 +99,58 @@ Location: {ae_util.shorten_string({ string: $lq__event_location_obj?.name ?? 'Loading...', max_length: 12 - })} ({$lq__event_location_obj?.event_location_id ?? ''}) - Pres Mgmt - {$events_loc?.title} + })} - Pres Mgmt -
- +
+ {#if !$lq__event_location_obj} -
- - Loading location information... +
+ + Loading location...
- {:else if $lq__event_location_obj?.enable || $ae_loc.trusted_access} -
-

- - - - - + {:else} + {#if !$lq__event_location_obj.enable && !$ae_loc.trusted_access} +
+

+ + Location Disabled +

+

This location is currently disabled. Please contact the event organizer for more information.

+
+ {:else} +
+ +
- {@html $lq__event_location_obj?.name ?? ae_snip.html__not_set} -

-
+
+

Sessions at this Location

+ +
- {#if !$events_loc.pres_mgmt.show_content__location_view || $events_loc.pres_mgmt.show_content__location_view == 'default'} - - - - -
- {#if $lq__event_session_obj_li && $lq__event_session_obj_li?.length > 0 && event_session_id_random_li && event_session_id_random_li?.length > 0} - - {:else if $lq__event_session_obj_li && $lq__event_session_obj_li?.length == 0} -
-

- - No Sessions Found -

-

There are no sessions found for this location.

-
- {:else if event_session_id_random_li?.length > 0} -
- - Loading session list... -
- {/if} -
- {:else if $events_loc.pres_mgmt.show_content__location_view == 'manage_files' && $ae_loc.trusted_access} -
-

- - - Manage and Upload Location Files: -

- - - {#snippet label()} - -
- - Upload location (room) specific files only! -
-
- Location (room) files only
- Recommended: PowerPoint (pptx) or Keynote (key)
- Media: Audio and videos files should be directly embedded - in PowerPoint (PPTX) files
- Supplemental files: mp4, PDF, Word Doc, Excel, txt, - etc -
-
- {/snippet} -
- -
+ {#if $ae_loc.trusted_access} +
+

Location Files

+
-
+ {/if} {/if} - {:else} -
-

- - Location Disabled -

-

- This location is currently disabled. Please contact the event - organizer for more information. -

-
{/if}
diff --git a/src/routes/events/[event_id]/(pres_mgmt)/location/[event_location_id]/location_page_menu.svelte b/src/routes/events/[event_id]/(pres_mgmt)/location/[event_location_id]/location_page_menu.svelte index 3f97fdc4..b243def7 100644 --- a/src/routes/events/[event_id]/(pres_mgmt)/location/[event_location_id]/location_page_menu.svelte +++ b/src/routes/events/[event_id]/(pres_mgmt)/location/[event_location_id]/location_page_menu.svelte @@ -1,6 +1,6 @@