fix(pres-mgmt): inject event_id into nested presenter/presentation creates
v_event_presenter and v_event_presentation both use INNER JOIN with event on event_id. Without event_id in the payload the view returns 0 rows after INSERT, the API falls back to a minimal response, and Dexie save fails with "Object is missing a valid ID". Pull event_id (and event_session_id for presenters) from events_slct at creation time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
import { get } from 'svelte/store';
|
||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
|
import { events_slct } from '$lib/stores/ae_events_stores';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
|
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
|
||||||
@@ -407,12 +409,19 @@ export async function create_ae_obj__event_presentation({
|
|||||||
try_cache?: boolean;
|
try_cache?: boolean;
|
||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
}): Promise<ae_EventPresentation | null> {
|
}): Promise<ae_EventPresentation | null> {
|
||||||
|
// event_id is required for the v_event_presentation view (INNER JOIN with event on event_id).
|
||||||
|
// Without it the API cannot return the full object after creation and the Dexie save fails.
|
||||||
|
const ev_slct = get(events_slct);
|
||||||
|
const fields_with_ids = {
|
||||||
|
event_id: ev_slct.event_id ?? undefined,
|
||||||
|
...data_kv
|
||||||
|
};
|
||||||
const result = await api.create_nested_obj({
|
const result = await api.create_nested_obj({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
for_obj_type: 'event_session',
|
for_obj_type: 'event_session',
|
||||||
for_obj_id: event_session_id,
|
for_obj_id: event_session_id,
|
||||||
obj_type: 'event_presentation',
|
obj_type: 'event_presentation',
|
||||||
fields: { ...data_kv },
|
fields: fields_with_ids,
|
||||||
log_lvl
|
log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -323,12 +323,21 @@ export async function create_ae_obj__event_presenter({
|
|||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
// event_id and event_session_id are required for the v_event_presenter view
|
||||||
|
// (which uses INNER JOIN with event on event_id). Without them the API cannot
|
||||||
|
// return the full object after creation and the Dexie save fails.
|
||||||
|
const ev_slct = get(events_slct);
|
||||||
|
const fields_with_ids = {
|
||||||
|
event_id: ev_slct.event_id ?? undefined,
|
||||||
|
event_session_id: ev_slct.event_session_id ?? undefined,
|
||||||
|
...data_kv
|
||||||
|
};
|
||||||
const result = await api.create_nested_obj({
|
const result = await api.create_nested_obj({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
for_obj_type: 'event_presentation',
|
for_obj_type: 'event_presentation',
|
||||||
for_obj_id: event_presentation_id,
|
for_obj_id: event_presentation_id,
|
||||||
obj_type: 'event_presenter',
|
obj_type: 'event_presenter',
|
||||||
fields: { ...data_kv },
|
fields: fields_with_ids,
|
||||||
log_lvl
|
log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user