From 0c01eed5c8a92094b98cf30f498c8a1facb8ef98 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Mon, 29 Sep 2025 18:58:54 -0400 Subject: [PATCH] More work on new CRUD element. Now able to update the session location in the list. --- src/lib/ae_events_stores.ts | 1 + src/lib/element_ae_crud_v2.svelte | 116 ++++++--- .../ae_comp__event_session_obj_li.svelte | 222 +++++++++--------- 3 files changed, 194 insertions(+), 145 deletions(-) diff --git a/src/lib/ae_events_stores.ts b/src/lib/ae_events_stores.ts index fd26f5ed..bc93cb1e 100644 --- a/src/lib/ae_events_stores.ts +++ b/src/lib/ae_events_stores.ts @@ -489,6 +489,7 @@ let events_session_data_struct: key_val = { show__session_poc_profile: false, show_modal__session_poc_agree: false, + hide__edit_location: {}, show__edit_location: {}, status_rpt: { diff --git a/src/lib/element_ae_crud_v2.svelte b/src/lib/element_ae_crud_v2.svelte index d7b889d9..e1f46a15 100644 --- a/src/lib/element_ae_crud_v2.svelte +++ b/src/lib/element_ae_crud_v2.svelte @@ -6,7 +6,7 @@ interface Props { trigger_patch?: any; patch_status?: string; // '', processing, complete, error - patch_complete?: boolean|null; // null = not started, true = complete/success, false = error + patch_complete?: boolean|null|string; // null = not started, true = complete/success, false = error patch_result?: boolean|null|key_val; // Result of the patch operation object_type: string; @@ -20,12 +20,14 @@ interface Props { new_field_value?: any; allow_null?: boolean; - select_option_li?: key_val; + select_option_kv?: key_val; val_empty_is_null?: boolean; // This was added to help with a select option list. If the value is empty (''), it will be set to null. edit_label?: string; - display_inline?: boolean; - display_block_edit?: boolean; + display_block?: boolean; // If true, the element will be displayed as a block element. + // display_inline?: boolean; + display_absolute_edit?: boolean; // If true, the edit form will be displayed in the top right corner of the element. + // display_block_edit?: boolean; textarea_cols?: number; textarea_rows?: number; @@ -33,7 +35,8 @@ interface Props { hide_element?: boolean; hide_edit_btn?: boolean; - hide_edit_form?: boolean; + // hide_edit_form?: boolean; + show_edit_form?: boolean; outline_element?: boolean; @@ -49,7 +52,7 @@ let { trigger_patch = null, patch_status = '', - patch_complete = null, + patch_complete = $bindable(null), // null = not started, true = complete/success, false = error patch_result = null, object_type, @@ -60,21 +63,24 @@ let { previous_field_value = $bindable(null), current_field_value = null, - new_field_value = $bindable(null), + new_field_value = current_field_value, allow_null = false, - select_option_li = $bindable({}), + select_option_kv = $bindable({}), val_empty_is_null = false, // If the value is empty (''), it will be set to null. edit_label = 'Edit', - display_inline = false, - display_block_edit = false, + display_block = false, + // display_inline = false, + display_absolute_edit = false, + // display_block_edit = false, textarea_cols = 80, textarea_rows = 5, hide_element = $bindable(false), hide_edit_btn = false, - hide_edit_form = true, + // hide_edit_form = $bindable(true), + show_edit_form = $bindable(), outline_element = $bindable(false), @@ -113,6 +119,12 @@ $effect(() => { // ; Super Key: ${api_crud_super_key} } + + + } + + if (select_option_kv) { + console.log(select_option_kv); } if (trigger_patch === true) { @@ -199,7 +211,8 @@ async function handle_obj_field_patch(new_field_value: any) { patch_complete = false; patch_result = false; } else { - patch_complete = true; + // patch_complete = true; + patch_complete = object_id; // Return the object ID that was patched patch_result = { 'type': object_type, 'id': object_id, @@ -222,10 +235,13 @@ async function handle_obj_field_patch(new_field_value: any) { class="{class_li} ae_crud font-normal transition-all duration-300 ease-in-out + relative + z-20 " class:hidden={hide_element} - class:inline={display_inline} + class:block={display_block} + class:inline-block={!display_block} class:outline_element > @@ -239,7 +255,7 @@ async function handle_obj_field_patch(new_field_value: any) { - + {#if field_type == 'template'} @@ -300,13 +338,18 @@ async function handle_obj_field_patch(new_field_value: any) { {:else if field_type == 'select'} - - {#each location_obj_li as location_obj} - - {/each} - - - - {/if} - {/await} {/if} - {#if ae_tmp?.show__edit_location} + {#if $events_sess.pres_mgmt.show__edit_location[session_obj?.event_session_id_random]} - {#await $slct.event_location_obj_li} - - {:then event_location_obj_li} - - {/await} + --> - $events_sess.pres_mgmt.show__edit_location[session_obj?.event_session_id_random] = false; - }} - class="btn btn-sm preset-tonal-warning hover:preset-tonal-warning border border-warning-500" - > - - Cancel - + {:else if $ae_loc.edit_mode} + + return load_results; + }) + .finally(function () { + console.log(`Finally...`); + ae_tmp.event_location_id = session_obj?.event_location_id_random; + ae_tmp.show__edit_event_location = true; - {/if} + $events_sess.pres_mgmt.show__edit_location[session_obj?.event_session_id_random] = true; + + }); + }} + class=" + btn btn-icon + text-xs + m-0 px-0.5 + preset-tonal-warning hover:preset-tonal-error + preset-outlined-warning-100-900 hover:preset-outlined-warning-600-400 + opacity-50 hover:opacity-100 + transition-all + + " + > + + + + + + {/if}