From bed4f4a0f2b1cc7899bf87925eb73f90b11f56c7 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 5 Mar 2024 17:01:37 -0500 Subject: [PATCH] Work on the new Data Store element --- src/lib/ae_stores.ts | 8 +- src/lib/api.js | 10 + src/lib/element_data_store.svelte | 675 ++++++++++++++++++ src/routes/events_badges/+page.svelte | 35 +- .../10_edit_modal__event_presenter_obj.svelte | 70 +- .../10_edit_modal__sponsorship_obj.svelte | 27 +- 6 files changed, 777 insertions(+), 48 deletions(-) create mode 100644 src/lib/element_data_store.svelte diff --git a/src/lib/ae_stores.ts b/src/lib/ae_stores.ts index 983b0d72..23af8aef 100644 --- a/src/lib/ae_stores.ts +++ b/src/lib/ae_stores.ts @@ -1,10 +1,10 @@ -import { localStorageStore } from '@skeletonlabs/skeleton' +import { localStorageStore } from '@skeletonlabs/skeleton'; import { get, readable, writable } from 'svelte/store'; import type { get, Writable } from 'svelte/store'; import { PUBLIC_TESTING, PUBLIC_AE_API_PROTOCOL, PUBLIC_AE_API_SERVER, PUBLIC_AE_API_BAK_SERVER, PUBLIC_AE_API_PORT, PUBLIC_AE_API_PATH, PUBLIC_AE_API_SECRET_KEY, PUBLIC_AE_API_CRUD_SUPER_KEY, PUBLIC_AE_NO_ACCOUNT_ID, PUBLIC_AE_NO_ACCOUNT_ID_TOKEN, PUBLIC_AE_ACCOUNT_ID, PUBLIC_AE_EVENT_ID, PUBLIC_AE_SPONSORSHIP_CFG_ID } from '$env/static/public'; -console.log(`AE Stores - PUBLIC_TESTING:`, PUBLIC_TESTING); +// console.log(`AE Stores - PUBLIC_TESTING:`, PUBLIC_TESTING); const api_base_url = `${PUBLIC_AE_API_PROTOCOL}://${PUBLIC_AE_API_SERVER}:${PUBLIC_AE_API_PORT}${PUBLIC_AE_API_PATH}`; const api_base_url_bak = `${PUBLIC_AE_API_PROTOCOL}://${PUBLIC_AE_API_BAK_SERVER}:${PUBLIC_AE_API_PORT}${PUBLIC_AE_API_PATH}`; @@ -136,7 +136,9 @@ export let ae_app_session_data_struct: key_val = { // 'name': 'Aether App Template', // 'theme': 'light', // 'account_id': ae_account_id, - 'ds': {}, + 'ds': { + 'submit_status': null, + }, 'hub': { 'show_xyz': null, }, diff --git a/src/lib/api.js b/src/lib/api.js index b94e249c..3b516c93 100644 --- a/src/lib/api.js +++ b/src/lib/api.js @@ -531,6 +531,8 @@ export let get_ae_obj_id_crud = async function get_ae_obj_id_crud({ endpoint = `/crud/archive/content/${obj_id}`; } else if (obj_type == 'contact') { endpoint = `/crud/contact/${obj_id}`; + } else if (obj_type == 'data_store') { + endpoint = `/crud/data_store/${obj_id}`; } else if (obj_type == 'event') { endpoint = `/crud/event/${obj_id}`; } else if (obj_type == 'event_abstract') { @@ -668,6 +670,8 @@ export let get_ae_obj_li_for_obj_id_crud = async function get_ae_obj_li_for_obj_ endpoint = `/crud/archive/content/list`; } else if (obj_type == 'contact') { endpoint = `/crud/contact/list`; + } else if (obj_type == 'data_store') { + endpoint = `/crud/data_store/list`; } else if (obj_type == 'event') { endpoint = `/crud/event/list`; } else if (obj_type == 'event_abstract') { @@ -838,6 +842,8 @@ export let create_ae_obj_crud = async function create_ae_obj_crud({api_cfg, obj_ endpoint = `/crud/archive/content`; } else if (obj_type == 'contact') { endpoint = `/crud/contact`; + } else if (obj_type == 'data_store') { + endpoint = `/crud/data_store`; } else if (obj_type == 'event') { endpoint = `/crud/event`; } else if (obj_type == 'event_abstract') { @@ -969,6 +975,8 @@ export let update_ae_obj_id_crud = async function update_ae_obj_id_crud({api_cfg endpoint = `/crud/archive/content/${obj_id}`; } else if (obj_type == 'contact') { endpoint = `/crud/contact/${obj_id}`; + } else if (obj_type == 'data_store') { + endpoint = `/crud/data_store/${obj_id}`; } else if (obj_type == 'event') { endpoint = `/crud/event/${obj_id}`; } else if (obj_type == 'event_abstract') { @@ -1126,6 +1134,8 @@ export let delete_ae_obj_id_crud = async function delete_ae_obj_id_crud({api_cfg endpoint = `/crud/archive/content/${obj_id}`; } else if (obj_type == 'contact') { endpoint = `/crud/contact/${obj_id}`; + } else if (obj_type == 'data_store') { + endpoint = `/crud/data_store/${obj_id}`; } else if (obj_type == 'event') { endpoint = `/crud/event/${obj_id}`; } else if (obj_type == 'event_abstract') { diff --git a/src/lib/element_data_store.svelte b/src/lib/element_data_store.svelte new file mode 100644 index 00000000..0797e567 --- /dev/null +++ b/src/lib/element_data_store.svelte @@ -0,0 +1,675 @@ + + + +
+{#if $ae_ds_loc} + + +{#if debug || $ae_loc.debug == 'debug'} + +
+    id: {$ae_ds_loc.id},
+    code: {$ae_ds_loc.code},
+    type: {$ae_ds_loc.type},
+    for_type: {$ae_ds_loc.for_type},
+    for_id: {$ae_ds_loc.for_id},
+    access_read: {$ae_ds_loc.access_read},
+    access_write: {$ae_ds_loc.access_write},
+    access_delete: {$ae_ds_loc.access_delete},
+    name: {$ae_ds_loc.name},
+    html: {$ae_ds_loc.html},
+    json: {$ae_ds_loc.json},
+    md: {$ae_ds_loc.md},
+    text: {$ae_ds_loc.text},
+    updated_on: {$ae_ds_loc.updated_on},
+    
+{/if} + +{#if show_edit} +
+
+ + + + {#if $ae_loc.administrator_access} + + + + + + + + + + + + + {/if} + + {#if $ae_ds_loc.type == 'html' || $ae_ds_loc.type == null} + + {:else if $ae_ds_loc.type == 'text'} + + {/if} +
+ + + + + + + + {#await data_store_results} + + {:then data_store_results} + {#if data_store_results} + + + Saved + + {/if} + {/await} + +
+ submit: {$ae_sess.ds.submit_status} + create: {$ae_sess.ds.create_status} + update: {$ae_sess.ds.update_status} +
+ +
+ +
+
+{/if} + + + + {#if !$ae_ds_loc.type && !$ae_ds_loc.html && !$ae_ds_loc.json && !$ae_ds_loc.md && !$ae_ds_loc.text} + No data found! Is the data store correct or new? + {/if} + + {#if $ae_ds_loc.type == 'html' && $ae_ds_loc.html} + {@html $ae_ds_loc.html} + {:else if $ae_ds_loc.type == 'html'} + No HTML found! Is the data store type correct? + {/if} + + {#if $ae_ds_loc.type == 'text' && $ae_ds_loc.text} + {$ae_ds_loc.text} + {:else if $ae_ds_loc.type == 'text'} + No text found! Is the data store type correct? + {/if} + + + + + + +{/if} + + + + + +
+ + + diff --git a/src/routes/events_badges/+page.svelte b/src/routes/events_badges/+page.svelte index e8c40c25..b2e35091 100644 --- a/src/routes/events_badges/+page.svelte +++ b/src/routes/events_badges/+page.svelte @@ -4,10 +4,10 @@ export let data; import { onMount } from 'svelte'; -import { api } from '$lib/api'; import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores'; import { ae_util } from '$lib/ae_utils'; -import type { key_val } from '$lib/ae_stores'; + +import Element_data_store from '$lib/element_data_store.svelte'; onMount(() => { @@ -22,16 +22,39 @@ onMount(() => { // $slct_trigger = 'msg_parent'; ae_util.handle_url_and_message('event_id', $slct.event_id); ae_util.handle_url_and_message('event_badge_id', $slct.event_badge_id); - if ($slct.event_badge_id) { - console.log(`Got an ID. Let's show the modal!`); - modalStore.trigger(modal_edit__event_badge_obj); - } + // if ($slct.event_badge_id) { + // console.log(`Got an ID. Let's show the modal!`); + // modalStore.trigger(modal_edit__event_badge_obj); + // } });
+

New Events - Badges

+ + + + +
diff --git a/src/routes/events_speakers/10_edit_modal__event_presenter_obj.svelte b/src/routes/events_speakers/10_edit_modal__event_presenter_obj.svelte index 10336d9f..362ce58d 100644 --- a/src/routes/events_speakers/10_edit_modal__event_presenter_obj.svelte +++ b/src/routes/events_speakers/10_edit_modal__event_presenter_obj.svelte @@ -369,26 +369,26 @@ async function handle_create__event_presenter({ console.log('*** handle_create__event_presenter() ***'); ae_promises.api_create__event_presenter_obj = api.create_ae_obj_crud({ - api_cfg: $ae_api, - obj_type: obj_type, - fields: data, - key: $ae_api.api_crud_super_key, - log_lvl: 2 - }) - .then(async function (create__obj_result) { - if (!create__obj_result) { - console.log('The result was null or false.'); - return false; - } - return create__obj_result; + api_cfg: $ae_api, + obj_type: obj_type, + fields: data, + key: $ae_api.api_crud_super_key, + log_lvl: 2 }) - .catch(function (error) { - console.log('Something went wrong.'); - console.log(error); + .then(async function (create__obj_result) { + if (!create__obj_result) { + console.log('The result was null or false.'); return false; - }); + } + return create__obj_result; + }) + .catch(function (error) { + console.log('Something went wrong.'); + console.log(error); + return false; + }); - return ae_promises.api_create__event_presenter_obj; + return ae_promises.api_create__event_presenter_obj; } @@ -400,27 +400,27 @@ async function handle_update__event_presenter({ 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, - log_lvl: 2 - }) - .then(async function (update__obj_result) { - if (!update__obj_result) { - console.log('The result was null or false.'); - return false; - } - return update__obj_result; + api_cfg: $ae_api, + obj_type: obj_type, + obj_id: obj_id, + fields: data, + key: $ae_api.api_crud_super_key, + log_lvl: 2 }) - .catch(function (error) { - console.log('Something went wrong.'); - console.log(error); + .then(async function (update__obj_result) { + if (!update__obj_result) { + console.log('The result was null or false.'); return false; - }); + } + return update__obj_result; + }) + .catch(function (error) { + console.log('Something went wrong.'); + console.log(error); + return false; + }); - return ae_promises.update__event_presenter_obj; + return ae_promises.update__event_presenter_obj; } diff --git a/src/routes/sponsorships/10_edit_modal__sponsorship_obj.svelte b/src/routes/sponsorships/10_edit_modal__sponsorship_obj.svelte index 04c1f3fe..ac0355e2 100644 --- a/src/routes/sponsorships/10_edit_modal__sponsorship_obj.svelte +++ b/src/routes/sponsorships/10_edit_modal__sponsorship_obj.svelte @@ -8,6 +8,9 @@ import { fade } from 'svelte/transition'; // store_current_tab must be prefixed with $ to be reactive. import { clipboard, FileDropzone, getModalStore, localStorageStore, ProgressRadial, RadioGroup, RadioItem, TabGroup, Tab, TabAnchor } from '@skeletonlabs/skeleton'; import type { Writable } from 'svelte/store'; + +import Element_data_store from '$lib/element_data_store.svelte'; + const store_current_tab: Writable = localStorageStore('ae_sponsorships_current_tab', 'start'); console.log(`store_current_tab:`, $store_current_tab); @@ -1215,8 +1218,16 @@ async function handle_update__sponsorship({ {$ae_loc.ds['sponsorships__agree_li'][1].code} {/if} --> -

Sponsor General Waiver

-

Proceeds from your sponsorship benefit the National Marine Sanctuary Foundation, a 501c3 nonprofit organization. Your contribution may be tax-deductible. For more information, please consult with a tax professional. All sales are final, and contributions, purchases, tickets, and sponsorships are non-refundable. As the host of CHOW, the Foundation is committed to the safety and well-being of all participants. If CHOW moves entirely to a virtual platform due to external circumstances, the Foundation will work with you to ensure that we meet your sponsor benefit needs. In the event of cancellation, your purchase becomes a tax-deductible gift.

+ +