fix: extend poster session type context to all file list wrapper contexts
element_manage_event_file_li_all.svelte — also derives context_session_type_code via Dexie chain (event_presentation → session, or event_presenter → presentation → session) and passes it to element_manage_event_file_li. Fixes the button not showing when viewing a presenter's files from the session view. element_manage_event_file_li_direct.svelte — extends the Dexie chain to also handle event_session (direct lookup) and event_presentation, not just event_presenter. Both: correct API URL to /v3/hosted_file/ per backend agent's examples. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -98,7 +98,7 @@
|
||||
|| event_file_obj.event_presentation_id
|
||||
|| event_file_obj.event_id;
|
||||
const filename_no_ext = (event_file_obj.filename ?? 'poster_image').replace(/\.pdf$/i, '');
|
||||
const url = `${$ae_api.base_url}/v3/action/hosted_file/${event_file_obj.hosted_file_id}/convert_file`
|
||||
const url = `${$ae_api.base_url}/v3/hosted_file/${event_file_obj.hosted_file_id}/convert_file`
|
||||
+ `?link_to_type=${encodeURIComponent(link_to_type_val)}`
|
||||
+ `&link_to_id=${encodeURIComponent(link_to_id_val)}`
|
||||
+ `&filename_no_ext=${encodeURIComponent(filename_no_ext)}`
|
||||
|
||||
@@ -38,6 +38,31 @@
|
||||
ae_tmp.show__direct_download = false;
|
||||
// let ae_triggers: key_val = {};
|
||||
|
||||
// WHY: v_event_file joins event_session only via event_file.event_session_id.
|
||||
// For files linked to a presentation or presenter, event_session_id is NULL on
|
||||
// the file record itself, so event_session_type_code is always NULL from the API.
|
||||
// Derive the session type from Dexie: presentation → event_session_id → type_code,
|
||||
// or presenter → event_presentation_id → event_session_id → type_code.
|
||||
let lq__context_session_type_code = $derived(
|
||||
liveQuery(async () => {
|
||||
if (link_to_type === 'event_presentation' && link_to_id) {
|
||||
const presentation = await db_events.presentation.get(link_to_id);
|
||||
if (!presentation?.event_session_id) return null;
|
||||
const session = await db_events.session.get(presentation.event_session_id);
|
||||
return session?.type_code ?? null;
|
||||
}
|
||||
if (link_to_type === 'event_presenter' && link_to_id) {
|
||||
const presenter = await db_events.presenter.get(link_to_id);
|
||||
if (!presenter?.event_presentation_id) return null;
|
||||
const presentation = await db_events.presentation.get(presenter.event_presentation_id);
|
||||
if (!presentation?.event_session_id) return null;
|
||||
const session = await db_events.session.get(presentation.event_session_id);
|
||||
return session?.type_code ?? null;
|
||||
}
|
||||
return null;
|
||||
})
|
||||
);
|
||||
|
||||
let dq__where_val = $derived(`${link_to_type}_id`);
|
||||
let dq__where_eq_val = $derived(link_to_id);
|
||||
|
||||
@@ -74,4 +99,5 @@
|
||||
{allow_moderator}
|
||||
{container_class_li}
|
||||
{display_mode}
|
||||
context_session_type_code={$lq__context_session_type_code ?? null}
|
||||
/>
|
||||
|
||||
@@ -49,13 +49,26 @@
|
||||
// Sessions are guaranteed in Dexie because the pres_mgmt layout loads inc_session_li:true.
|
||||
let lq__context_session_type_code = $derived(
|
||||
liveQuery(async () => {
|
||||
if (link_to_type !== 'event_presenter' || !link_to_id) return null;
|
||||
const presenter = await db_events.presenter.get(link_to_id);
|
||||
if (!presenter?.event_presentation_id) return null;
|
||||
const presentation = await db_events.presentation.get(presenter.event_presentation_id);
|
||||
if (!presentation?.event_session_id) return null;
|
||||
const session = await db_events.session.get(presentation.event_session_id);
|
||||
return session?.type_code ?? null;
|
||||
if (!link_to_id) return null;
|
||||
if (link_to_type === 'event_session') {
|
||||
const session = await db_events.session.get(link_to_id);
|
||||
return session?.type_code ?? null;
|
||||
}
|
||||
if (link_to_type === 'event_presentation') {
|
||||
const presentation = await db_events.presentation.get(link_to_id);
|
||||
if (!presentation?.event_session_id) return null;
|
||||
const session = await db_events.session.get(presentation.event_session_id);
|
||||
return session?.type_code ?? null;
|
||||
}
|
||||
if (link_to_type === 'event_presenter') {
|
||||
const presenter = await db_events.presenter.get(link_to_id);
|
||||
if (!presenter?.event_presentation_id) return null;
|
||||
const presentation = await db_events.presentation.get(presenter.event_presentation_id);
|
||||
if (!presentation?.event_session_id) return null;
|
||||
const session = await db_events.session.get(presentation.event_session_id);
|
||||
return session?.type_code ?? null;
|
||||
}
|
||||
return null;
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
|| event_file_obj.event_presentation_id
|
||||
|| event_file_obj.event_id;
|
||||
const filename_no_ext = (event_file_obj.filename ?? 'poster_image').replace(/\.pdf$/i, '');
|
||||
const url = `${$ae_api.base_url}/v3/action/hosted_file/${event_file_obj.hosted_file_id}/convert_file`
|
||||
const url = `${$ae_api.base_url}/v3/hosted_file/${event_file_obj.hosted_file_id}/convert_file`
|
||||
+ `?link_to_type=${encodeURIComponent(link_to_type)}`
|
||||
+ `&link_to_id=${encodeURIComponent(link_to_id)}`
|
||||
+ `&filename_no_ext=${encodeURIComponent(filename_no_ext)}`
|
||||
|
||||
Reference in New Issue
Block a user