Wrapping up for the day. Finally working on IDAA related events some more.

This commit is contained in:
Scott Idem
2024-10-28 18:07:06 -04:00
parent 2ebb411905
commit a211570af9
8 changed files with 332 additions and 140 deletions

View File

@@ -1,4 +1,5 @@
<script lang="ts">
export let log_lvl = 1;
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
import { fade } from 'svelte/transition';
// import Editor from '@tinymce/tinymce-svelte';
@@ -8,6 +9,7 @@ import { core_func } from '$lib/ae_core_functions';
import { api } from '$lib/api';
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { idaa_loc, idaa_sess, idaa_slct } from '$lib/ae_idaa_stores';
import { events_func } from '$lib/ae_events_functions';
import Tiptap_editor from '$lib/element_tiptap_editor.svelte';
export let lq__event_obj: any;
@@ -301,7 +303,7 @@ $: if ($idaa_slct.event_obj) {
}
async function handle_submit_form(event){
async function handle_submit_form(event: any) {
console.log('*** handle_submit_form() ***');
disable_submit_btn = true;
@@ -318,6 +320,12 @@ async function handle_submit_form(event){
event_data['name'] = event_meeting_data.name;
if (event_meeting_data.description) {
event_data['description'] = event_meeting_data.description;
} else {
event_data['description'] = null;
}
// if (tinyMCE.get('description')) {
// event_data['description'] = tinyMCE.get('description').getContent();
// } else {
@@ -337,7 +345,7 @@ async function handle_submit_form(event){
if (event_meeting_data.address_country_subdivision_code) {
address['country_subdivision_code'] = event_meeting_data.address_country_subdivision_code;
let country_subdivision_data = ae_util.get_obj_li_with_matching_prop({'obj_li': $ae_loc.lu_country_subdivision_list, 'property': 'code', 'value': event_meeting_data.address_country_subdivision_code});
let country_subdivision_data = ae_util.get_obj_li_w_match_prop({'obj_li': $ae_loc.lu_country_subdivision_list, 'property': 'code', 'value': event_meeting_data.address_country_subdivision_code});
address['state_province'] = country_subdivision_data[0].name; // Assume there is only one match
// address['country_subdivision_name'] = country_subdivision_data[0].name;
}
@@ -345,12 +353,12 @@ async function handle_submit_form(event){
if (event_meeting_data.address_country_alpha_2_code) {
address['country_alpha_2_code'] = event_meeting_data.address_country_alpha_2_code;
let country_data = ae_util.get_obj_li_with_matching_prop({'obj_li': $ae_loc.lu_country_list, 'property': 'alpha_2_code', 'value': event_meeting_data.address_country_alpha_2_code});
let country_data = ae_util.get_obj_li_w_match_prop({'obj_li': $ae_loc.lu_country_list, 'property': 'alpha_2_code', 'value': event_meeting_data.address_country_alpha_2_code});
console.log(country_data);
address['country'] = country_data[0].english_short_name; // Assume there is only one match
// address['country_name'] = country_data[0].english_short_name;
}
event_data['location_address_json'] = address;
// event_data['location_address_json'] = address;
// if (tinyMCE.get('location_text')) {
// event_data['location_text'] = tinyMCE.get('location_text').getContent();
@@ -453,7 +461,7 @@ async function handle_submit_form(event){
if (event_meeting_data.contact_1_phone_office) {
contact_1['phone_office'] = event_meeting_data.contact_1_phone_office;
}
event_data['contact_li_json'].push(contact_1);
// event_data['contact_li_json'].push(contact_1);
let contact_2: key_val = {};
contact_2['full_name'] = event_meeting_data.contact_2_full_name;
@@ -467,7 +475,7 @@ async function handle_submit_form(event){
if (event_meeting_data.contact_2_phone_office) {
contact_2['phone_office'] = event_meeting_data.contact_2_phone_office;
}
event_data['contact_li_json'].push(contact_2);
// event_data['contact_li_json'].push(contact_2);
event_data['hide'] = !!event_meeting_data.hide;
event_data['priority'] = !!event_meeting_data.priority;
@@ -475,7 +483,7 @@ async function handle_submit_form(event){
event_data['sort'] = Number(event_meeting_data.sort);
}
if (event_data['group']) {
event_data['group'] = form_event_data.group;
event_data['group'] = event_meeting_data.group;
} else {
event_data['group'] = null;
}
@@ -526,14 +534,24 @@ async function handle_submit_form(event){
return create_event_obj_promise;
} else {
update_event_obj_promise = api.update_ae_obj_id_crud({
events_func.update_ae_obj__event({
api_cfg: $ae_api,
obj_type: 'event',
obj_id: $idaa_slct.event_id,
fields: event_data,
key: $ae_api.api_crud_super_key,
log_lvl: 1
})
event_id: $idaa_slct.event_id,
data_kv: event_data,
log_lvl: log_lvl
})
// update_event_obj_promise = api.update_ae_obj_id_crud({
// api_cfg: $ae_api,
// obj_type: 'event',
// obj_id: $idaa_slct.event_id,
// fields: event_data,
// key: $ae_api.api_crud_super_key,
// return_obj: true,
// log_lvl: 2
// })
.then(function (event_obj_update_result) {
if (!event_obj_update_result) {
console.log('The result was null or false.');
@@ -661,8 +679,30 @@ async function handle_delete_event_obj({event_id, method='disable'}) {
<!-- <textarea name="description" id="description" class="ae_value event__description tinymce_editor editor_basic textarea" rows="5" cols="70" bind:value={$idaa_slct.event_obj.description} placeholder="A short description or overview of this recovery meeting"></textarea> -->
<Tiptap_editor
html_text={$idaa_slct.event_obj.description}
default_minimal={true}
bind:html_text={$idaa_slct.event_obj.description}
show_button_kv={{'heading__h1': false, 'heading__h2': false, 'heading__h3': false}}
bind:new_html={$idaa_slct.event_obj.description_new_html}
/>
<!-- {@html $idaa_slct.event_obj?.description_new_html ?? 'not sure?'} -->
<!-- If changed then show Save button -->
{#if
$idaa_slct.event_obj.description_new_html &&
$idaa_slct.event_obj?.description_new_html != '<p></p>' &&
$idaa_slct.event_obj.description != $idaa_slct.event_obj.description_new_html}
<button
type="button"
class="btn btn-md btn-primary variant-ghost-secondary"
on:click={() => $idaa_slct.event_obj.description = $idaa_slct.event_obj.description_new_html}
>
<!-- <span class="icon">💾</span> -->
<span class="fas fa-save m-1"></span>
Save?
</button>
{/if}
</label>
@@ -700,7 +740,7 @@ async function handle_delete_event_obj({event_id, method='disable'}) {
<fieldset class="event__physical_virtual">
<legend class="legend">Face-to-Face or Virtual</legend>
<p>Is this a face-to-face/in person meeting, a virtual/online meeting, or both?</p>
<div class="ae_group">
<div class="ae_group border border-gray-200 rounded-md p-2 space-y-1">
<label for="physical" class="">Face-to-Face/In person
<input
type="checkbox"
@@ -796,9 +836,26 @@ async function handle_delete_event_obj({event_id, method='disable'}) {
<label for="location_text" class="">Additional information the meeting location
<!-- <textarea class="ae_value event__location_text tinymce_editor editor_less_100 textarea" id="location_text" name="location_text" placeholder="Additional information about the meeting location" rows="2" cols="70" bind:value={$idaa_slct.event_obj.location_text}></textarea> -->
<Tiptap_editor
html_text={$idaa_slct.event_obj.location_text}
default_minimal={true}
bind:html_text={$idaa_slct.event_obj.location_text}
show_button_kv={{'heading__h1': false, 'heading__h2': false, 'heading__h3': false}}
bind:new_html={$idaa_slct.event_obj.location_text_new_html}
/>
<!-- If changed then show Save button -->
{#if
$idaa_slct.event_obj?.location_text_new_html &&
$idaa_slct.event_obj?.location_text_new_html != '<p></p>' &&
$idaa_slct.event_obj.location_text != $idaa_slct.event_obj.location_text_new_html}
<button
type="button"
class="btn btn-md btn-primary variant-ghost-secondary"
on:click={() => $idaa_slct.event_obj.location_text = $idaa_slct.event_obj.location_text_new_html}
>
<span class="fas fa-save m-1"></span>
Save?
</button>
{/if}
</label>
<fieldset
@@ -826,9 +883,26 @@ async function handle_delete_event_obj({event_id, method='disable'}) {
<label for="attend_text" class="">Additional information on how to attend
<!-- <textarea class="ae_value event__attend_text tinymce_editor editor_less_100 textarea" id="attend_text" name="attend_text" placeholder="Additional information on how to attend or join the meeting" rows="2" cols="70" value={$lq__event_obj?.attend_text ?? ''}></textarea> -->
<Tiptap_editor
html_text={$idaa_slct.event_obj.attend_text}
default_minimal={true}
bind:html_text={$idaa_slct.event_obj.attend_text}
show_button_kv={{'heading__h1': false, 'heading__h2': false, 'heading__h3': false}}
bind:new_html={$idaa_slct.event_obj.attend_text_new_html}
/>
<!-- If changed then show Save button -->
{#if
$idaa_slct.event_obj?.attend_text_new_html &&
$idaa_slct.event_obj?.attend_text_new_html != '<p></p>' &&
$idaa_slct.event_obj.attend_text != $idaa_slct.event_obj.attend_text_new_html}
<button
type="button"
class="btn btn-md btn-primary variant-ghost-secondary"
on:click={() => $idaa_slct.event_obj.attend_text = $idaa_slct.event_obj.attend_text_new_html}
>
<span class="fas fa-save m-1"></span>
Save?
</button>
{/if}
</label>
</section> <!-- END: section event__how_to_attend -->
@@ -1174,9 +1248,27 @@ async function handle_delete_event_obj({event_id, method='disable'}) {
Internal Staff Notes
<!-- <textarea id="notes" name="notes" class="ae_value event__notes tinymce_editor editor_basic_200 textarea" rows="2" cols="70" value={$lq__event_obj?.notes}></textarea> -->
<Tiptap_editor
html_text={$idaa_slct.event_obj.notes}
default_minimal={true}
bind:html_text={$idaa_slct.event_obj.notes}
show_button_kv={{'heading__h1': false, 'heading__h2': false, 'heading__h3': false}}
bind:new_html={$idaa_slct.event_obj.notes_new_html}
/>
<!-- If changed then show Save button -->
{#if
$idaa_slct.event_obj?.notes_new_html &&
$idaa_slct.event_obj?.notes_new_html != '<p></p>' &&
$idaa_slct.event_obj.notes != $idaa_slct.event_obj.notes_new_html}
<button
type="button"
class="btn btn-md btn-primary variant-ghost-secondary"
on:click={() => $idaa_slct.event_obj.notes = $idaa_slct.event_obj.notes_new_html}
>
<span class="fas fa-save m-1"></span>
Save?
</button>
{/if}
<!-- {$idaa_slct.event_obj?.notes_new_html} -->
</label>
{/if}