Working on ability to change the presentation name and session name... Making progress. Need to figure out why the file list does not reload correctly right after saving.
This commit is contained in:
@@ -196,6 +196,7 @@ async function handle_load_ae_obj_li__event_file(
|
||||
handle_db_save_ae_obj_li__event_file({obj_type: 'event_file', obj_li: event_file_obj_li_get_result});
|
||||
return event_file_obj_li_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return [];
|
||||
}
|
||||
})
|
||||
@@ -269,7 +270,7 @@ async function handle_load_ae_obj_id__event_session(
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: 0
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_session_obj_get_result) {
|
||||
if (event_session_obj_get_result) {
|
||||
@@ -436,6 +437,51 @@ async function handle_search__event_session(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-20
|
||||
async function handle_load_ae_obj_id__event_presentation(
|
||||
{
|
||||
api_cfg,
|
||||
event_presentation_id,
|
||||
try_cache=false,
|
||||
log_lvl=0
|
||||
} : {
|
||||
api_cfg: any,
|
||||
event_presentation_id: string,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_id__event_presentation() *** event_presentation_id=${event_presentation_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
ae_promises.load__event_presentation_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_presentation',
|
||||
obj_id: event_presentation_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_presentation_obj_get_result) {
|
||||
if (event_presentation_obj_get_result) {
|
||||
// This is expecting a list
|
||||
handle_db_save_ae_obj_li__event_presentation({obj_type: 'event_presentation', obj_li: [event_presentation_obj_get_result]});
|
||||
return event_presentation_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
return ae_promises.load__event_presentation_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-10
|
||||
async function handle_load_ae_obj_li__event_presentation(
|
||||
{
|
||||
@@ -1900,6 +1946,7 @@ let export_obj = {
|
||||
handle_load_ae_obj_li__event_session: handle_load_ae_obj_li__event_session,
|
||||
handle_search__event_session: handle_search__event_session,
|
||||
|
||||
handle_load_ae_obj_id__event_presentation: handle_load_ae_obj_id__event_presentation,
|
||||
handle_load_ae_obj_li__event_presentation: handle_load_ae_obj_li__event_presentation,
|
||||
|
||||
handle_load_ae_obj_id__event_presenter: handle_load_ae_obj_id__event_presenter,
|
||||
|
||||
@@ -483,7 +483,7 @@ export class MySubClassedDexie extends Dexie {
|
||||
event_id_random, event_session_id_random, event_presentation_id_random, event_presenter_id_random, event_location_id_random,
|
||||
filename, extension,
|
||||
lu_file_purpose_id, lu_event_file_purpose_name, file_purpose,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
||||
|
||||
presentations: `
|
||||
id, event_presentation_id, event_presentation_id_random,
|
||||
@@ -493,7 +493,7 @@ export class MySubClassedDexie extends Dexie {
|
||||
event_id_random, event_session_id_random, event_abstract_id_random,
|
||||
abstract_code, name, description, start_datetime, end_datetime,
|
||||
hide_event_launcher,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
||||
|
||||
presenters: `
|
||||
id, event_presenter_id, event_presenter_id_random,
|
||||
@@ -506,7 +506,7 @@ export class MySubClassedDexie extends Dexie {
|
||||
full_name, affiliations, email,
|
||||
agree,
|
||||
hide_event_launcher,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
|
||||
// let params = {};
|
||||
|
||||
ae_promises.api_update__ae_obj = core_func.handle_update_ae_obj_id_crud({
|
||||
ae_promises.api_update__ae_obj = await core_func.handle_update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
object_type: object_type,
|
||||
object_id: object_id,
|
||||
@@ -100,7 +100,7 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
log_lvl: 0
|
||||
})
|
||||
.then(function (results) {
|
||||
console.log('PATCH Promise', results);
|
||||
console.log('Field PATCH Promise', results);
|
||||
|
||||
if (results) {
|
||||
console.log(`Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}; Original Field Value: ${original_field_value}`);
|
||||
@@ -110,7 +110,16 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
patch_result = 'PATCH failed';
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('Something went wrong patching the record.');
|
||||
console.log(error);
|
||||
return false;
|
||||
})
|
||||
.finally(function () {
|
||||
console.log('Field PATCH Promise finally');
|
||||
// This dispatch() must be under "finally".
|
||||
dispatch(
|
||||
'ae_crud_updated',
|
||||
{
|
||||
@@ -121,73 +130,8 @@ async function handle_obj_field_patch(new_field_value: any) {
|
||||
'original_value': original_field_value,
|
||||
}
|
||||
);
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('Something went wrong patching the record.');
|
||||
console.log(error);
|
||||
return false;
|
||||
})
|
||||
.finally(function () {
|
||||
console.log('PATCH Promise finally');
|
||||
});
|
||||
|
||||
|
||||
// if (ae_promises.api_update__ae_obj) {
|
||||
// console.log(`Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}; Original Field Value: ${original_field_value}`);
|
||||
// patch_result = 'PATCH complete';
|
||||
// } else {
|
||||
// console.log(`Not Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}; Original Field Value: ${original_field_value}`);
|
||||
// patch_result = 'PATCH failed';
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// ae_promises.api_update__ae_obj = api.update_ae_obj_id_crud({
|
||||
// api_cfg: api_cfg,
|
||||
// obj_type: object_type,
|
||||
// obj_id: object_id,
|
||||
// field_name: field_name,
|
||||
// field_value: new_field_value,
|
||||
// // fields: data,
|
||||
// key: api_crud_super_key,
|
||||
// // jwt: null,
|
||||
// // params: params,
|
||||
// // data: patch_data,
|
||||
// log_lvl: 2
|
||||
// })
|
||||
// .then(function (results) {
|
||||
// console.log('PATCH Promise', results);
|
||||
|
||||
// if (results) {
|
||||
// console.log(`Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}; Original Field Value: ${original_field_value}`);
|
||||
// patch_result = 'PATCH complete';
|
||||
// } else {
|
||||
// console.log(`Not Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}; Original Field Value: ${original_field_value}`);
|
||||
// patch_result = 'PATCH failed';
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// dispatch(
|
||||
// 'ae_crud_updated',
|
||||
// {
|
||||
// 'type': object_type,
|
||||
// 'id': object_id,
|
||||
// 'field_name': field_name,
|
||||
// 'field_value': new_field_value,
|
||||
// 'original_value': original_field_value,
|
||||
// }
|
||||
// );
|
||||
// return true;
|
||||
// })
|
||||
// .catch(function (error) {
|
||||
// console.log('Something went wrong patching the record.');
|
||||
// console.log(error);
|
||||
// return false;
|
||||
// })
|
||||
// .finally(function () {
|
||||
// console.log('PATCH Promise finally');
|
||||
// });
|
||||
|
||||
return ae_promises.api_update__ae_obj;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -447,7 +447,7 @@ function send_sign_in_poc_email(
|
||||
{$lq__event_session_obj.poc_person_full_name ? $lq__event_session_obj.poc_person_full_name : '-- not set --'}
|
||||
</span>
|
||||
|
||||
{#if $ae_loc.trusted_access }
|
||||
{#if $ae_loc.trusted_access}
|
||||
<Element_ae_crud
|
||||
trigger_patch={ae_triggers.update_person_poc}
|
||||
api_cfg={$ae_api}
|
||||
|
||||
@@ -19,11 +19,14 @@ import { ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_st
|
||||
import { db_events } from "$lib/db_events";
|
||||
import { events_loc, events_sess, events_slct, events_trigger } from '$lib/ae_events_stores';
|
||||
import { events_func } from '$lib/ae_events_functions';
|
||||
import ElementAeCrud from '$lib/element_ae_crud.svelte';
|
||||
|
||||
|
||||
let ae_triggers: key_val = {};
|
||||
let ae_promises: key_val = {}; // Promise<any>;
|
||||
let ae_placeholder_li: key_val = {};
|
||||
let ae_promises: key_val = {}; // Promise<any>;
|
||||
let ae_tmp: key_val = {};
|
||||
ae_tmp.show__file_li = true;
|
||||
let ae_triggers: key_val = {};
|
||||
|
||||
let lq__event_session_obj = liveQuery(
|
||||
() => db_events.sessions.get($events_slct.event_session_id)
|
||||
@@ -39,7 +42,7 @@ let lq__event_presenter_obj = liveQuery(
|
||||
);
|
||||
|
||||
let lq__event_file_obj_li = liveQuery(
|
||||
() => db_events.files.where('event_presenter_id_random').equals($events_slct.event_presenter_id).toArray()
|
||||
async () => await db_events.files.where('event_presenter_id_random').equals($events_slct.event_presenter_id).toArray()
|
||||
);
|
||||
|
||||
// $events_slct.event_presenter_obj = $lq__event_presenter_obj;
|
||||
@@ -57,7 +60,9 @@ let lq__event_file_obj_li = liveQuery(
|
||||
onMount(() => {
|
||||
console.log('Events Session [slug]: presenter_view.svelte');
|
||||
console.log(`$events_slct.event_presenter_id:`, $events_slct.event_presenter_id);
|
||||
console.log(`$lq__event_presenter_obj:`, $lq__event_presenter_obj);
|
||||
// console.log(`$lq__event_presenter_obj:`, $lq__event_presenter_obj);
|
||||
|
||||
$slct_trigger = 'load__event_file_obj_li';
|
||||
});
|
||||
|
||||
|
||||
@@ -324,6 +329,68 @@ async function handle_delete__event_file({event_file_id}) {
|
||||
|
||||
<section class="p-2">
|
||||
<h3 class="h4">Title: "{$events_slct.presentation_obj.name}"</h3>
|
||||
<!-- Edit the presentation title -->
|
||||
<Element_ae_crud
|
||||
trigger_patch={ae_triggers.update_event_presentation_name}
|
||||
api_cfg={$ae_api}
|
||||
object_type={'event_presentation'}
|
||||
object_id={$events_slct.presentation_obj.event_presentation_id_random}
|
||||
field_name={'name'}
|
||||
field_type={'input'}
|
||||
field_value={$events_slct.presentation_obj.name}
|
||||
allow_null={false}
|
||||
hide_edit_btn={true}
|
||||
outline_element={false}
|
||||
show_crud={false}
|
||||
display_inline={true}
|
||||
class_li={'m-1'}
|
||||
on:ae_crud_updated={e => {
|
||||
console.log(`ae_crud_updated:`, e.detail);
|
||||
|
||||
events_func.handle_load_ae_obj_id__event_presentation({api_cfg: $ae_api, event_presentation_id: $events_slct.presentation_obj.event_presentation_id_random, log_lvl: 1})
|
||||
.then(function (load_results) {
|
||||
// We need to force reload the Indexed DB - Dexie.js?
|
||||
// Sometimes the changes are not seen. The file disappears when the Save button is pressed.
|
||||
|
||||
// Maybe reload page?
|
||||
// window.location.reload();
|
||||
})
|
||||
.finally(function () {
|
||||
// ae_tmp.show__file_li = false;
|
||||
// Careful with the trigger_patch. It will keep firing if not reset.
|
||||
ae_triggers.update_event_presentation_name = false;
|
||||
});
|
||||
}}
|
||||
>
|
||||
<input
|
||||
bind:value={$events_slct.presentation_obj.name}
|
||||
class="input min-w-96 max-w-96 text-sm"
|
||||
/>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
console.log('*** Save button clicked ***');
|
||||
// if (!confirm('Are you sure you want to save this event_presenter?')) {return false;}
|
||||
|
||||
console.log(`Selected event_presentation_id: ${$events_slct.presentation_obj.event_presentation_id_random}`);
|
||||
|
||||
ae_triggers.update_event_presentation_name = true;
|
||||
// ae_triggers.update_event_presentation_name = $events_slct.presentation_obj.event_presentation_id_random;
|
||||
}}
|
||||
class="btn btn-sm variant-soft-success hover:variant-ghost-success mx-1"
|
||||
>
|
||||
<span class="fas fa-save mx-1"></span>
|
||||
Save
|
||||
</button>
|
||||
</Element_ae_crud>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="h4">Presenter:</h3>
|
||||
<ul
|
||||
class="space-y-2 px-4"
|
||||
@@ -367,7 +434,23 @@ async function handle_delete__event_file({event_file_id}) {
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3 class="h4">Files: {$events_slct.presenter_obj.file_count ? `${$events_slct.presenter_obj.file_count}x` : '-- none --'}</h3>
|
||||
<h3 class="h4">
|
||||
Files: {$events_slct.presenter_obj.file_count ? `${$events_slct.presenter_obj.file_count}x` : '-- none --'}
|
||||
</h3>
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
console.log('*** Refresh button clicked ***');
|
||||
ae_tmp.show__file_li = false;
|
||||
console.log(`$lq__event_file_obj_li:`, $lq__event_file_obj_li);
|
||||
$slct_trigger = 'load__event_file_obj_li';
|
||||
ae_tmp.show__file_li = true;
|
||||
}}
|
||||
class="btn btn-sm variant-soft-secondary hover:variant-ghost-warning float-right transition hover:transition-all"
|
||||
>
|
||||
<span class="fas fa-sync-alt mx-1"></span>
|
||||
Refresh Files
|
||||
</button>
|
||||
|
||||
<div class="text-sm text-center bg-orange-100 rounded-md p-2">
|
||||
WARNING: The file upload and management is a work in progress. You can upload and delete files, but not yet rename them.
|
||||
@@ -422,7 +505,7 @@ WARNING: The file upload and management is a work in progress. You can upload an
|
||||
</form>
|
||||
|
||||
|
||||
{#if $lq__event_file_obj_li}
|
||||
{#if ae_tmp.show__file_li && $lq__event_file_obj_li && $lq__event_file_obj_li.length > 0}
|
||||
<ul
|
||||
class="space-y-2 px-4"
|
||||
>
|
||||
@@ -472,10 +555,103 @@ WARNING: The file upload and management is a work in progress. You can upload an
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<!-- Select from options for the purpose of this file -->
|
||||
{#if ae_tmp[event_file_obj.event_file_id_random] && ae_tmp[event_file_obj.event_file_id_random]?.show__edit_file_purpose === true}
|
||||
<Element_ae_crud
|
||||
trigger_patch={ae_triggers.update_event_file_purpose}
|
||||
api_cfg={$ae_api}
|
||||
object_type={'event_file'}
|
||||
object_id={event_file_obj.event_file_id_random}
|
||||
field_name={'file_purpose'}
|
||||
field_type={'button'}
|
||||
field_value={ae_tmp[event_file_obj.event_file_id_random].file_purpose}
|
||||
allow_null={false}
|
||||
hide_edit_btn={true}
|
||||
outline_element={false}
|
||||
show_crud={false}
|
||||
display_inline={true}
|
||||
class_li={'m-1'}
|
||||
on:ae_crud_updated={e => {
|
||||
console.log(`ae_crud_updated:`, e.detail);
|
||||
|
||||
events_func.handle_load_ae_obj_id__event_file({api_cfg: $ae_api, event_file_id: event_file_obj.event_file_id_random, log_lvl: 1})
|
||||
.then(function (load_results) {
|
||||
// We need to force reload the Indexed DB - Dexie.js?
|
||||
// Sometimes the changes are not seen. The file disappears when the Save button is pressed.
|
||||
|
||||
// Maybe reload page?
|
||||
// window.location.reload();
|
||||
})
|
||||
.finally(function () {
|
||||
// ae_tmp[event_file_obj.event_file_id_random].file_purpose = null;
|
||||
ae_tmp[event_file_obj.event_file_id_random].show__edit_file_purpose = false;
|
||||
// Careful with the trigger_patch. It will keep firing if not reset.
|
||||
ae_triggers.update_event_file_purpose = false;
|
||||
});
|
||||
}}
|
||||
>
|
||||
|
||||
<select
|
||||
bind:value={ae_tmp[event_file_obj.event_file_id_random].file_purpose}
|
||||
class="select min-w-fit max-w-fit text-sm mx-1"
|
||||
>
|
||||
<option value="outline" selected={event_file_obj.file_purpose === 'outline'}>1. Outline</option>
|
||||
<option value="draft" selected={event_file_obj.file_purpose === 'draft'}>2. Draft</option>
|
||||
<option value="final" selected={event_file_obj.file_purpose === 'final'}>3. Final</option>
|
||||
<option value="supporting">X. Supporting File (audio, video, data, etc)</option>
|
||||
<option value="handout">X. Handout</option>
|
||||
<option value="other">X. Other</option>
|
||||
<!-- <option value="poster">Final - Poster</option> -->
|
||||
<!-- <option value="presentation">Final - Presentation</option> -->
|
||||
<!-- Shows in session room -->
|
||||
</select>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
console.log('*** Save button clicked ***');
|
||||
// if (!confirm('Are you sure you want to save this event_presenter?')) {return false;}
|
||||
|
||||
console.log(`Selected event_file_id: ${event_file_obj.event_file_id_random}`);
|
||||
|
||||
ae_triggers.update_event_file_purpose = true;
|
||||
// ae_triggers.update_event_file_purpose = event_file_obj.event_file_id_random;
|
||||
|
||||
|
||||
|
||||
// ae_tmp.show__file_li = false;
|
||||
}}
|
||||
class="btn btn-sm variant-soft-success hover:variant-ghost-success mx-1"
|
||||
>
|
||||
<span class="fas fa-save mx-1"></span>
|
||||
Save
|
||||
</button>
|
||||
</Element_ae_crud>
|
||||
{:else}
|
||||
<button
|
||||
type="button"
|
||||
title="Edit the purpose of this file"
|
||||
on:click={() => {
|
||||
ae_tmp[event_file_obj.event_file_id_random] = {
|
||||
file_purpose: event_file_obj.file_purpose,
|
||||
show__edit_file_purpose: true
|
||||
}
|
||||
|
||||
// ae_tmp[event_file_obj.event_file_id_random].file_purpose = event_file_obj.file_purpose;
|
||||
// ae_tmp[event_file_obj.event_file_id_random].show__edit_file_purpose = true;
|
||||
}}
|
||||
class="btn btn-sm variant-soft-primary hover:variant-ghost-primary mx-1"
|
||||
>
|
||||
<span class="fas fa-edit mx-1"></span>
|
||||
Edit
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
|
||||
<button type="button"
|
||||
title="Delete this file"
|
||||
on:click={async () => {
|
||||
if (!confirm('Are you sure you want to delete this file?')) {return false;}
|
||||
if (!confirm(`Are you sure you want to delete this file?\n${event_file_obj.filename} [${event_file_obj.event_file_id_random}]`)) {return false;}
|
||||
|
||||
ae_promises[event_file_obj.event_file_id_random] = handle_delete__event_file({event_file_id: event_file_obj.event_file_id_random});
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user