Now with ability to sync person record to presenter record. Also some other editing.

This commit is contained in:
Scott Idem
2024-06-28 10:45:37 -04:00
parent a0085723c9
commit 298f87960a
5 changed files with 166 additions and 124 deletions

View File

@@ -222,7 +222,7 @@ export async function handle_update_ae_obj__event_file(
}: {
api_cfg: any,
event_file_id: string,
data_kv: any,
data_kv: key_val,
params?: key_val,
log_lvl?: number
}

View File

@@ -183,7 +183,7 @@ export async function handle_update_ae_obj__event_presenter(
}: {
api_cfg: any,
event_presenter_id: string,
data_kv: any,
data_kv: key_val,
params?: key_val,
log_lvl?: number
}
@@ -299,11 +299,15 @@ export function handle_db_save_ae_obj_li__event_presenter(
created_on: obj.created_on,
updated_on: obj.updated_on,
// From SQL view
file_count: obj.file_count,
person_external_id: obj.person_external_id,
person_given_name: obj.person_given_name,
person_family_name: obj.person_family_name,
person_full_name: obj.person_full_name,
person_professional_title: obj.person_professional_title,
person_affiliations: obj.person_affiliations,
person_primary_email: obj.person_primary_email,
person_passcode: obj.person_passcode,
});

View File

@@ -413,66 +413,69 @@ export interface Presenter {
event_presenter_id: string;
event_presenter_id_random: string;
external_id: string;
code: string;
external_id?: string;
code?: string;
event_id: string;
event_id_random: string;
event_session_id: string;
event_session_id_random: string;
event_person_id: null|string;
event_person_id_random: null|string;
event_person_id?: null|string;
event_person_id_random?: null|string;
event_presentation_id: string;
event_presentation_id_random: string;
person_id: null|string;
person_id_random: null|string;
person_profile_id: null|string;
person_profile_id_random: null|string; // The new table person_profile will be used soon...
person_id?: null|string;
person_id_random?: null|string;
person_profile_id?: null|string;
person_profile_id_random?: null|string; // The new table person_profile will be used soon...
pronouns: null|string;
informal_name: null|string;
title_names: null|string;
pronouns?: null|string;
informal_name?: null|string;
title_names?: null|string;
given_name: string;
middle_name: null|string;
family_name: null|string;
designations: null|string;
middle_name?: null|string;
family_name?: null|string;
designations?: null|string;
professional_title: null|string;
professional_title?: null|string;
full_name: string;
full_name?: string;
affiliations: null|string;
affiliations?: null|string;
email: string;
email?: string;
biography: null|string;
biography?: null|string;
agree: null|boolean;
comments: null|string;
agree?: null|boolean;
comments?: null|string;
passcode: null|string;
passcode?: null|string;
hide_event_launcher: null|boolean;
hide_event_launcher?: null|boolean;
data_json: null|string;
data_json?: null|string;
enable: null|boolean;
hide: null|boolean;
priority: null|boolean
sort: null|number;
group: null|string;
notes: null|string;
created_on: Date;
updated_on: null|Date;
hide?: null|boolean;
priority?: null|boolean
sort?: null|number;
group?: null|string;
notes?: null|string;
created_on?: Date;
updated_on?: null|Date;
// Additional fields for convenience (database views)
file_count: null|number;
file_count?: null|number;
person_given_name: null|string;
person_family_name: null|string;
person_full_name: null|string;
person_primary_email: null|string;
person_passcode: null|string;
person_external_id?: null|string;
person_given_name?: null|string;
person_family_name?: null|string;
person_full_name?: null|string;
person_professional_title?: null|string;
person_affiliations?: null|string;
person_primary_email?: null|string;
person_passcode?: null|string;
}

View File

@@ -57,10 +57,6 @@ onMount(() => {
<section class="svelte_component event_file_uploaded_manage {container_class_li.join(' ')}">
<h3 class="h4">
Manage Files: {$lq__event_file_obj_li ? `${$lq__event_file_obj_li.length}x` : '-- none --'}
</h3>
<button
type="button"
on:click={() => {
@@ -76,6 +72,9 @@ onMount(() => {
Refresh Files
</button>
<h3 class="h4">
Manage Files: {$lq__event_file_obj_li ? `${$lq__event_file_obj_li.length}x` : '-- none --'}
</h3>
{#if $lq__event_file_obj_li && $lq__event_file_obj_li.length}

View File

@@ -1,8 +1,6 @@
<script lang="ts">
console.log(`ae_events_pres_mgmt session [slug] form_agree.svelte`);
export let data: any;
import { createEventDispatcher, onMount } from 'svelte';
import { clipboard, FileDropzone } from '@skeletonlabs/skeleton';
import { liveQuery } from "dexie";
@@ -29,9 +27,9 @@ 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)
);
// let lq__event_session_obj = liveQuery(
// () => db_events.sessions.get($events_slct.event_session_id)
// );
// let lq__event_presentation_obj = liveQuery(
// async () => await db_events.presentations.get($events_slct.event_presentation_id)
@@ -64,86 +62,11 @@ $slct.person_obj_kv = {}; // This is intended for the POC lookup list when gener
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);
$slct_trigger = 'load__event_file_obj_li';
});
// async function handle_submit_form(event) {
// console.log('*** handle_submit_form() ***');
// $events_sess.pres_mgmt.disable_submit__opt_out = true;
// $events_sess.pres_mgmt.submit_status = 'saving';
// // Data in
// let form_data = new FormData(event.target);
// console.log(form_data);
// let opt_out_di: key_val = ae_util.extract_prefixed_form_data({prefix: null, form_data: form_data, trim_values: true, bool_tf_str: true, log_lvl: 0});
// console.log(`opt_out_di:`, opt_out_di);
// // Data out
// let opt_out_do: key_val = {};
// opt_out_do.optout_audio = opt_out_di.optout_audio??false;
// opt_out_do.optout_video = opt_out_di.optout_video??false;
// opt_out_do.optout_transcription_and_publication = opt_out_di.optout_transcription_and_publication??false;
// opt_out_do.optout_publication_in_app = opt_out_di.optout_publication_in_app??false;
// console.log(`opt_out_do:`, opt_out_do);
// let data_out = {
// data_json: opt_out_do,
// }
// ae_promises.update__event_presenter_obj = await handle_update__event_presenter({
// obj_type: 'event_presenter',
// obj_id: $lq__event_presenter_obj?.event_presenter_id_random,
// data: data_out
// });
// console.log(ae_promises.update__event_presenter_obj);
// $events_sess.pres_mgmt.disable_submit__opt_out = false;
// $events_sess.pres_mgmt.submit_status = 'saved';
// }
// async function handle_update__event_presenter({
// obj_type,
// obj_id,
// data
// }) {
// console.log('*** handle_update__event_presenter() ***');
// ae_promises.update__event_presenter_obj = api.update_ae_obj_id_crud({
// api_cfg: $ae_api,
// obj_type: obj_type,
// obj_id: obj_id,
// fields: data,
// key: $ae_api.api_crud_super_key,
// return_obj: true,
// log_lvl: 2
// })
// .then(async function (update__obj_result) {
// if (!update__obj_result) {
// console.log('The result was null or false.');
// return false;
// } else {
// console.log(`update__obj_result = `, update__obj_result);
// }
// $slct_trigger = 'load__event_presenter_obj_li';
// return update__obj_result;
// })
// .catch(function (error) {
// console.log('Something went wrong.');
// console.log(error);
// return false;
// });
// return ae_promises.update__event_presenter_obj;
// }
async function handle_submit_form_files(event) {
console.log('*** handle_submit_form() ***');
@@ -576,6 +499,80 @@ async function handle_delete__event_file({event_file_id}) {
<span class="fas fa-building"></span>
{$lq__event_presenter_obj.affiliations ?? '-- affiliations not set --'}
</Element_ae_crud>
{#if $lq__event_presenter_obj.person_affiliations != $lq__event_presenter_obj.affiliations}
<div>
<Element_ae_crud
api_cfg={$ae_api}
object_type={'person'}
object_id={$lq__event_presenter_obj.person_id_random}
field_name={'affiliations'}
field_type={'text'}
field_value={$lq__event_presenter_obj.person_affiliations}
allow_null={false}
hide_edit_btn={!$ae_loc.trusted_access}
outline_element={false}
show_crud={false}
display_inline={true}
class_li={''}
on:ae_crud_updated={e => {
console.log(`ae_crud_updated:`, e.detail);
events_func.handle_load_ae_obj_id__event_presenter({api_cfg: $ae_api, event_presenter_id: $lq__event_presenter_obj.event_presenter_id_random, log_lvl: 1})
.then(function (load_results) {
// Maybe reload page?
// window.location.reload();
});
}}
>
<span class="fas fa-star-of-life"></span>
<span class="fas fa-building"></span>
{$lq__event_presenter_obj.person_affiliations ?? '-- affiliations not set --'}
</Element_ae_crud>
<Element_ae_crud
trigger_patch={ae_triggers.update_person_affiliations}
api_cfg={$ae_api}
object_type={'person'}
object_id={$lq__event_presenter_obj.person_id_random}
field_name={'affiliations'}
field_type={'text'}
field_value={$lq__event_presenter_obj.affiliations}
allow_null={false}
hide_edit_btn={true}
outline_element={false}
show_crud={false}
display_inline={true}
class_li={''}
on:ae_crud_updated={e => {
console.log(`ae_crud_updated:`, e.detail);
events_func.handle_load_ae_obj_id__event_presenter({api_cfg: $ae_api, event_presenter_id: $lq__event_presenter_obj?.event_presenter_id_random, log_lvl: 1})
.then(function (load_results) {
// Maybe reload page?
// window.location.reload();
});
}}
>
<button
type="button"
on:click={() => {
console.log('*** Sync affiliations button clicked ***');
if (!confirm('Are you sure you want to sync the affiliations?')) {return false;}
ae_triggers.update_person_affiliations = true;
}}
class="btn btn-sm variant-soft-warning hover:variant-ghost-warning"
title="Use the affiliations from this presenter record to overwrite the person record."
>
<span class="fas fa-sync-alt mx-1"></span>
Sync
</button>
</Element_ae_crud>
</div>
{/if}
</li>
<li>
<Element_ae_crud
@@ -756,12 +753,51 @@ async function handle_delete__event_file({event_file_id}) {
</Element_ae_crud>
{/if}
<!-- A sync button to use the person record fields to update the event_presenter fields -->
{#if $ae_loc.administrator_access}
<button
type="button"
on:click={() => {
console.log('*** Sync person button clicked ***');
if (!confirm('Are you sure you want to sync from the person record?')) {return false;}
let event_presenter_data = {
'external_id': $lq__event_presenter_obj.person_external_id,
'given_name': $lq__event_presenter_obj.person_given_name,
'family_name': $lq__event_presenter_obj.person_family_name,
'professional_title': $lq__event_presenter_obj.person_professional_title,
'affiliations': $lq__event_presenter_obj.person_affiliations,
'email': $lq__event_presenter_obj.person_primary_email,
// 'passcode': $lq__event_presenter_obj.person_passcode,
};
let person_update_result = events_func.handle_update_ae_obj__event_presenter({
api_cfg: $ae_api,
event_presenter_id: $lq__event_presenter_obj.event_presenter_id_random,
data_kv: event_presenter_data,
log_lvl: 1,
})
.then(function (update_result) {
console.log(update_result);
return update_result;
});
return person_update_result;
}}
class="btn btn-sm variant-soft-warning hover:variant-ghost-warning"
title="Sync the person record fields to the presenter record. person_id: {$lq__event_presenter_obj.person_id_random}; presenter_id: {$lq__event_presenter_obj.event_presenter_id_random}"
>
<span class="fas fa-sync-alt mx-1"></span>
Sync Person
</button>
{/if}
</li>
</ul>
<h3 class="h4">
Files: {$lq__event_presenter_obj.file_count ? `${$lq__event_presenter_obj.file_count}x` : '-- none --'}
Upload File(s):
</h3>
<button
type="button"