Getting the badges up and running again
This commit is contained in:
@@ -75,7 +75,20 @@ async function handle_load_ae_obj_id__badge({api_cfg, badge_id, try_cache=false}
|
|||||||
|
|
||||||
|
|
||||||
// Updated 2024-03-06
|
// Updated 2024-03-06
|
||||||
async function handle_load_ae_obj_li__badge({api_cfg, event_id, params={}, try_cache=true}: {api_cfg: any, event_id: any, params: any, try_cache?: boolean}) {
|
async function handle_load_ae_obj_li__badge(
|
||||||
|
{
|
||||||
|
api_cfg,
|
||||||
|
event_id,
|
||||||
|
params={},
|
||||||
|
try_cache=true,
|
||||||
|
log_lvl=0
|
||||||
|
}: {
|
||||||
|
api_cfg: any,
|
||||||
|
event_id: any,
|
||||||
|
params: any,
|
||||||
|
try_cache?: boolean,
|
||||||
|
log_lvl: number
|
||||||
|
}) {
|
||||||
console.log(`*** handle_load_ae_obj_li__badge() *** event_id=${event_id}`);
|
console.log(`*** handle_load_ae_obj_li__badge() *** event_id=${event_id}`);
|
||||||
|
|
||||||
let fulltext_search_qry_str = ''; // $events_sess.badges.fulltext_search_qry_str;
|
let fulltext_search_qry_str = ''; // $events_sess.badges.fulltext_search_qry_str;
|
||||||
@@ -125,7 +138,7 @@ async function handle_load_ae_obj_li__badge({api_cfg, event_id, params={}, try_c
|
|||||||
offset: offset,
|
offset: offset,
|
||||||
params_json: params_json,
|
params_json: params_json,
|
||||||
params: params,
|
params: params,
|
||||||
log_lvl: 1
|
log_lvl: log_lvl
|
||||||
})
|
})
|
||||||
|
|
||||||
.then(function (badge_obj_li_get_result) {
|
.then(function (badge_obj_li_get_result) {
|
||||||
@@ -149,7 +162,9 @@ async function handle_load_ae_obj_li__badge({api_cfg, event_id, params={}, try_c
|
|||||||
// return badge_obj_li_get_result;
|
// return badge_obj_li_get_result;
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('ae_promises.load__event_badge_obj_li:', ae_promises.load__event_badge_obj_li);
|
if (log_lvl) {
|
||||||
|
console.log('ae_promises.load__event_badge_obj_li:', ae_promises.load__event_badge_obj_li);
|
||||||
|
}
|
||||||
return ae_promises.load__event_badge_obj_li;
|
return ae_promises.load__event_badge_obj_li;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
export let data: any;
|
export let data: any;
|
||||||
|
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
import type { Writable } from 'svelte/store';
|
import type { Writable } from 'svelte/store';
|
||||||
import { localStorageStore } from '@skeletonlabs/skeleton';
|
import { localStorageStore } from '@skeletonlabs/skeleton';
|
||||||
|
|
||||||
@@ -11,7 +12,6 @@ import type { key_val } from '$lib/ae_stores';
|
|||||||
import { api } from '$lib/api';
|
import { api } from '$lib/api';
|
||||||
import { ae_loc, ae_sess, ae_api, slct } from '$lib/ae_stores';
|
import { ae_loc, ae_sess, ae_api, slct } from '$lib/ae_stores';
|
||||||
import { events_loc, events_slct, events_trigger } from '$lib/ae_events_stores';
|
import { events_loc, events_slct, events_trigger } from '$lib/ae_events_stores';
|
||||||
import { onMount } from 'svelte';
|
|
||||||
|
|
||||||
// import Element_data_store from '$lib/element_data_store.svelte';
|
// import Element_data_store from '$lib/element_data_store.svelte';
|
||||||
|
|
||||||
@@ -26,84 +26,86 @@ console.log(`$slct.account_id = `, $slct.account_id);
|
|||||||
let ae_acct = data[$slct.account_id];
|
let ae_acct = data[$slct.account_id];
|
||||||
console.log(`ae_acct = `, ae_acct);
|
console.log(`ae_acct = `, ae_acct);
|
||||||
|
|
||||||
$events_slct.event_id = ae_acct.slct.event_id
|
$events_slct.event_id = ae_acct.slct.event_id;
|
||||||
$events_slct.event_obj = ae_acct.slct.event_obj
|
$events_slct.event_obj = ae_acct.slct.event_obj;
|
||||||
|
|
||||||
let ae_promises: key_val = {};
|
let ae_promises: key_val = {};
|
||||||
|
|
||||||
if (ae_acct.loc.site_cfg_json.slct__event_id) {
|
// if (ae_acct.loc.site_cfg_json.slct__event_id) {
|
||||||
$events_slct.event_id = ae_acct.loc.site_cfg_json.slct__event_id;
|
// $events_slct.event_id = ae_acct.loc.site_cfg_json.slct__event_id;
|
||||||
$events_loc.event_id = ae_acct.loc.site_cfg_json.slct__event_id;
|
// $events_loc.event_id = ae_acct.loc.site_cfg_json.slct__event_id;
|
||||||
} else if ($events_loc.default__event_id) {
|
// } else if ($events_loc.default__event_id) {
|
||||||
$events_slct.event_id = $events_loc.default__event_id;
|
// $events_slct.event_id = $events_loc.default__event_id;
|
||||||
$events_loc.event_id = $events_loc.default__event_id;
|
// $events_loc.event_id = $events_loc.default__event_id;
|
||||||
} else if ($events_slct.event_id) {
|
// } else if ($events_slct.event_id) {
|
||||||
console.log(`Event ID already set:`, $events_slct.event_id);
|
// console.log(`Event ID already set:`, $events_slct.event_id);
|
||||||
$events_loc.event_id = $events_slct.event_id;
|
// $events_loc.event_id = $events_slct.event_id;
|
||||||
} else {
|
// } else {
|
||||||
console.log(`No Event ID set.`);
|
// console.log(`No Event ID set.`);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if ($events_slct.event_id) {
|
// if ($events_slct.event_id) {
|
||||||
$events_trigger = 'load__event_obj';
|
// $events_trigger = 'load__event_obj';
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-03-06
|
// Updated 2024-03-06
|
||||||
$: if ($events_trigger == 'load__event_obj' && $events_slct.event_id) {
|
// $: if ($events_trigger == 'load__event_obj' && $events_slct.event_id) {
|
||||||
console.log(`$events_slct.event_id=${$events_slct.event_id}`);
|
// console.log(`$events_slct.event_id=${$events_slct.event_id}`);
|
||||||
$events_trigger = null;
|
// $events_trigger = null;
|
||||||
|
|
||||||
let load_obj_results = handle_load_ae_obj_id__event({event_id: $events_slct.event_id, try_cache: false})
|
// let load_obj_results = handle_load_ae_obj_id__event({event_id: $events_slct.event_id, try_cache: false})
|
||||||
.then(function (load_obj_results) {
|
// .then(function (load_obj_results) {
|
||||||
if (load_obj_results) {
|
// if (load_obj_results) {
|
||||||
console.log(`load_obj_results=`, load_obj_results);
|
// console.log(`load_obj_results=`, load_obj_results);
|
||||||
} else {
|
// } else {
|
||||||
console.log('No results returned.');
|
// console.log('No results returned.');
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
$events_slct.event_obj = load_obj_results;
|
// $events_slct.event_obj = load_obj_results;
|
||||||
console.log(`load_obj_results=`, load_obj_results);
|
// console.log(`load_obj_results=`, load_obj_results);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (data.url.searchParams.get('event_id')) {
|
console.log('Events Badges: +layout.svelte');
|
||||||
$events_slct.event_id = data.url.searchParams.get('event_id');
|
|
||||||
$events_loc.event_id = data.url.searchParams.get('event_id');
|
// if (data.url.searchParams.get('event_id')) {
|
||||||
}
|
// $events_slct.event_id = data.url.searchParams.get('event_id');
|
||||||
|
// $events_loc.event_id = data.url.searchParams.get('event_id');
|
||||||
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
// Updated 2024-03-06
|
// Updated 2024-03-06
|
||||||
async function handle_load_ae_obj_id__event({event_id, try_cache=false}) {
|
// async function handle_load_ae_obj_id__event({event_id, try_cache=false}) {
|
||||||
console.log(`*** handle_load_ae_obj_id__event() *** event_id=${event_id} api_cfg=`, $ae_api);
|
// console.log(`*** handle_load_ae_obj_id__event() *** event_id=${event_id} api_cfg=`, $ae_api);
|
||||||
|
|
||||||
let params = {};
|
// let params = {};
|
||||||
|
|
||||||
// $events_sess.badges.status_load__event_obj = 'loading';
|
// // $events_sess.badges.status_load__event_obj = 'loading';
|
||||||
ae_promises.load__event_obj = await api.get_ae_obj_id_crud({
|
// ae_promises.load__event_obj = await api.get_ae_obj_id_crud({
|
||||||
api_cfg: $ae_api,
|
// api_cfg: $ae_api,
|
||||||
obj_type: 'event',
|
// obj_type: 'event',
|
||||||
obj_id: event_id, // NOTE: This is the FQDN, not normally the ID.
|
// obj_id: event_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_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.
|
// 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,
|
// params: params,
|
||||||
log_lvl: 0
|
// log_lvl: 0
|
||||||
})
|
// })
|
||||||
.then(function (event_obj_get_result) {
|
// .then(function (event_obj_get_result) {
|
||||||
if (event_obj_get_result) {
|
// if (event_obj_get_result) {
|
||||||
return event_obj_get_result;
|
// return event_obj_get_result;
|
||||||
} else {
|
// } else {
|
||||||
console.log('No results returned.');
|
// console.log('No results returned.');
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
.catch(function (error) {
|
// .catch(function (error) {
|
||||||
console.log('No results returned or failed.', error);
|
// console.log('No results returned or failed.', error);
|
||||||
});
|
// });
|
||||||
|
|
||||||
return ae_promises.load__event_obj;
|
// return ae_promises.load__event_obj;
|
||||||
}
|
// }
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -112,9 +114,11 @@ async function handle_load_ae_obj_id__event({event_id, try_cache=false}) {
|
|||||||
<title>Events Badges - {$events_loc.title ?? 'Æ loading...'}</title>
|
<title>Events Badges - {$events_loc.title ?? 'Æ loading...'}</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<!-- <h1>Events Badges Layout?</h1> -->
|
|
||||||
|
|
||||||
<div class="submenu flex flex-row justify-center">
|
<section
|
||||||
|
class="submenu flex flex-row justify-center"
|
||||||
|
>
|
||||||
|
|
||||||
<span class="btn-group variant-soft-secondary px-4 py-2">
|
<span class="btn-group variant-soft-secondary px-4 py-2">
|
||||||
{#each Object.entries(data.submenu) as [key, item]}
|
{#each Object.entries(data.submenu) as [key, item]}
|
||||||
<!-- <a href="/settings/{item.slug}">{item.title}</a> -->
|
<!-- <a href="/settings/{item.slug}">{item.title}</a> -->
|
||||||
@@ -146,24 +150,10 @@ async function handle_load_ae_obj_id__event({event_id, try_cache=false}) {
|
|||||||
{item.name}
|
{item.name}
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<!-- <button
|
|
||||||
title={item.title}
|
|
||||||
class="hover:variant-ghost-secondary"
|
|
||||||
class:hidden={(!$ae_loc.trusted_access && item.access === 'trusted') || (!$ae_loc.administrator_access && item.access === 'administrator' || item.hide)}
|
|
||||||
disabled={item.disable}
|
|
||||||
|
|
||||||
on:click={() => {
|
|
||||||
// window.location(item.href);
|
|
||||||
// href={item.href}
|
|
||||||
// invalidateAll
|
|
||||||
goto(item.href, { });
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{item.name}
|
|
||||||
</button> -->
|
|
||||||
{/each}
|
{/each}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
|
|||||||
@@ -1,22 +1,14 @@
|
|||||||
/** @type {import('./$types').LayoutLoad} */
|
/** @type {import('./$types').LayoutLoad} */
|
||||||
|
console.log(`ae_events_badges +layout.ts start`);
|
||||||
|
|
||||||
// import { get } from 'svelte/store';
|
import { events_func } from '$lib/ae_events_functions';
|
||||||
|
|
||||||
// import { api } from '$lib/api';
|
|
||||||
// import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
|
|
||||||
// import { ae_events_loc, ae_events_sess, ae_events_triggers, ae_events_badges_loc, ae_events_badges_sess, ae_events_badges_triggers } from '$lib/ae_events_stores';
|
|
||||||
// import { ae_events_loc, ae_events_slct, ae_events_trigger } from '$lib/ae_events_stores';
|
|
||||||
// import type { key_val } from '$lib/ae_stores';
|
|
||||||
|
|
||||||
|
|
||||||
export async function load({ parent }) { // route
|
export async function load({ parent }) {
|
||||||
|
|
||||||
let data = await parent();
|
let data = await parent();
|
||||||
|
// console.log(`ae_events_badges +layout.ts data:`, data);
|
||||||
|
|
||||||
console.log(`ae_events_badges +layout.ts data:`, data);
|
|
||||||
// console.log(`ae_events_badges +layout.ts data.params:`, params);
|
|
||||||
// console.log(`ae_events_badges +layout.ts data.route:`, route);
|
|
||||||
// console.log(`ae_events_badges +layout.ts data.url:`, url);
|
|
||||||
|
|
||||||
let account_id = data.account_id;
|
let account_id = data.account_id;
|
||||||
let ae_acct = data[account_id];
|
let ae_acct = data[account_id];
|
||||||
@@ -33,13 +25,15 @@ export async function load({ parent }) { // route
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.ae_events_badges_layout_ts = true;
|
let load_event_obj = events_func.handle_load_ae_obj_id__event({api_cfg: ae_acct.api, event_id: event_id, try_cache: false});
|
||||||
|
|
||||||
|
ae_acct.slct.event_obj = load_event_obj;
|
||||||
|
|
||||||
let submenu = {
|
let submenu = {
|
||||||
main: {name: 'Main', href: '/events_badges', access: false},
|
main: {name: 'Main', href: '/events_badges', access: false},
|
||||||
manage: {name: 'Manage', href: '/events_badges/manage', access: 'administrator', disable: true, hide: true},
|
// manage: {name: 'Manage', href: '/events_badges/manage', access: 'administrator', disable: true, hide: true},
|
||||||
review: {name: 'Review', href: '/events_badges/review', access: false, disable: true, hide: false},
|
review: {name: 'Review', href: '/events_badges/review', access: false, disable: false, hide: false},
|
||||||
print: {name: 'Print', href: '/events_badges/print', access: 'trusted', disable: true, hide: false},
|
// print: {name: 'Print', href: '/events_badges/print', access: 'trusted', disable: true, hide: false},
|
||||||
// view: {name: 'View', href: '/events_badges/view', access: 'trusted', hide: true}, // event_badge_id
|
// view: {name: 'View', href: '/events_badges/view', access: 'trusted', hide: true}, // event_badge_id
|
||||||
// new: {name: 'New', href: '/events_badges/new'},
|
// new: {name: 'New', href: '/events_badges/new'},
|
||||||
// sponsorships: {name: 'Sponsorships', href: '/sponsorships', disable: true, hide: true},
|
// sponsorships: {name: 'Sponsorships', href: '/sponsorships', disable: true, hide: true},
|
||||||
|
|||||||
@@ -5,17 +5,6 @@ console.log(`ae_events_badges [slug] +page data:`, data);
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
|
|
||||||
// https://github.com/skeletonlabs/skeleton/blob/master/packages/skeleton/src/lib/utilities/Modal/types.ts
|
|
||||||
// To retrieve the store, getModalStore must be invoked at the top level of your component!
|
|
||||||
// import { getDrawerStore, getModalStore } from '@skeletonlabs/skeleton';
|
|
||||||
// import type {
|
|
||||||
// DrawerSettings,
|
|
||||||
// ModalSettings,
|
|
||||||
// ModalComponent,
|
|
||||||
// ModalStore
|
|
||||||
// } from '@skeletonlabs/skeleton';
|
|
||||||
// const modalStore = getModalStore();
|
|
||||||
|
|
||||||
import type { key_val } from '$lib/ae_stores';
|
import type { key_val } from '$lib/ae_stores';
|
||||||
import { ae_util } from '$lib/ae_utils';
|
import { ae_util } from '$lib/ae_utils';
|
||||||
import { api } from '$lib/api';
|
import { api } from '$lib/api';
|
||||||
@@ -25,7 +14,8 @@ import { db_events } from "$lib/db_events";
|
|||||||
import { ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
|
import { ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
|
||||||
import { events_loc, events_sess, events_slct, events_trigger } from '$lib/ae_events_stores';
|
import { events_loc, events_sess, events_slct, events_trigger } from '$lib/ae_events_stores';
|
||||||
|
|
||||||
let event_badge_li = liveQuery(
|
// The lq__ prefix is used to indicate that this is a liveQuery object and it should use the $ prefix when referencing the object.
|
||||||
|
let lq__event_badge_li = liveQuery(
|
||||||
() => db_events.badges.toArray()
|
() => db_events.badges.toArray()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -33,38 +23,7 @@ let event_badge_li = liveQuery(
|
|||||||
|
|
||||||
let ae_promises: key_val = {};
|
let ae_promises: key_val = {};
|
||||||
let load_obj_li_results: Promise<any>|key_val;
|
let load_obj_li_results: Promise<any>|key_val;
|
||||||
|
let search_submit_results: Promise<any>|key_val;
|
||||||
// Editing
|
|
||||||
// const modalComponentEditEventPresenterObj: ModalComponent = { ref: Edit_modal_event_badge, props: {container_class_li: 'w-full p-4 space-y-4 card'} };
|
|
||||||
|
|
||||||
// const modal_edit__event_badge: ModalSettings = {
|
|
||||||
// type: 'component',
|
|
||||||
// component: modalComponentEditEventPresenterObj,
|
|
||||||
// title: 'Edit Badge Submission',
|
|
||||||
// position: '', // default is "items-center"
|
|
||||||
|
|
||||||
// response: (r: boolean | undefined) => handle_modal_close(r)
|
|
||||||
// };
|
|
||||||
|
|
||||||
// This function waits for the response from one of the modals. Do stuff when the modal is closed.
|
|
||||||
function handle_modal_close(response: boolean | undefined) {
|
|
||||||
console.log('Modal closed. Response:', response);
|
|
||||||
|
|
||||||
ae_util.handle_url_and_message('event_badge_id', null);
|
|
||||||
|
|
||||||
// We want to keep these values in case they want to re-open the modal. Do NOT clear.
|
|
||||||
// $events_slct.event_badge_id = null;
|
|
||||||
// $events_slct.event_badge_obj = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($events_trigger == 'msg_parent' && $events_slct.event_id) {
|
|
||||||
console.log(`Message parent with event_id ${$events_slct.event_id}`);
|
|
||||||
$events_trigger = null
|
|
||||||
|
|
||||||
let message = {'event_id': $events_slct.event_id};
|
|
||||||
window.parent.postMessage(message, "*");
|
|
||||||
// console.log('Message sent to parent (iframe):', message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$ae_loc.hostname = data.url.hostname;
|
$ae_loc.hostname = data.url.hostname;
|
||||||
@@ -103,56 +62,6 @@ onMount(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$: if ($events_trigger == 'load__event_obj' && $events_slct.event_id) {
|
|
||||||
console.log('Selected Event ID:', $events_slct.event_id);
|
|
||||||
|
|
||||||
$events_trigger = null;
|
|
||||||
|
|
||||||
handle_load_ae_obj_id__event({event_id: $events_slct.event_id, try_cache: false});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handle_load_ae_obj_id__event({event_id, try_cache=false}) {
|
|
||||||
console.log(`*** handle_load_ae_obj_id__event() *** event_id=${event_id}`);
|
|
||||||
|
|
||||||
let params = {};
|
|
||||||
|
|
||||||
// $events_sess.status_load__event_id = 'loading';
|
|
||||||
ae_event_obj_get_promise = api.get_ae_obj_id_crud({
|
|
||||||
api_cfg: $ae_api,
|
|
||||||
obj_type: 'event',
|
|
||||||
obj_id: event_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 in the API config.
|
|
||||||
params: params,
|
|
||||||
log_lvl: 0
|
|
||||||
})
|
|
||||||
.then(function (event_obj_get_result) {
|
|
||||||
if (event_obj_get_result) {
|
|
||||||
$events_slct.event_obj = event_obj_get_result;
|
|
||||||
console.log(`event object:`, $events_slct.event_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Auto show the selected event_badge ID
|
|
||||||
// Is this pushState needed here?
|
|
||||||
// Set the URL param "event_id" to the current event_badge ID.
|
|
||||||
// const url = new URL(location);
|
|
||||||
// url.searchParams.set('event_id', $events_slct.event_id);
|
|
||||||
// history.pushState({}, '', url);
|
|
||||||
|
|
||||||
// Is this postMessage needed here?
|
|
||||||
// let message = {'event_id': $events_slct.event_id};
|
|
||||||
// window.parent.postMessage(message, "*");
|
|
||||||
|
|
||||||
// modalStore.trigger(modal_view__event_obj);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
console.log('No results returned or failed.', error);
|
|
||||||
});
|
|
||||||
|
|
||||||
return ae_event_obj_get_promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($events_slct.event_badge_id) {
|
if ($events_slct.event_badge_id) {
|
||||||
console.log('Selected Event Presenter ID:', $events_slct.event_badge_id);
|
console.log('Selected Event Presenter ID:', $events_slct.event_badge_id);
|
||||||
$events_trigger = 'load__event_badge';
|
$events_trigger = 'load__event_badge';
|
||||||
@@ -217,6 +126,10 @@ async function handle_load_ae_obj_id__event_badge({event_badge_id, try_cache=fal
|
|||||||
$: if ($events_trigger == 'load__event_badge_obj_li' && $events_slct.event_id) {
|
$: if ($events_trigger == 'load__event_badge_obj_li' && $events_slct.event_id) {
|
||||||
console.log(`handle_load_ae_obj_id__event() $events_slct.event_id=${$events_slct.event_id} api_cfg=`, $ae_api);
|
console.log(`handle_load_ae_obj_id__event() $events_slct.event_id=${$events_slct.event_id} api_cfg=`, $ae_api);
|
||||||
|
|
||||||
|
if (!$events_sess.badges.fulltext_search_qry_str) {
|
||||||
|
$events_sess.badges.fulltext_search_qry_str = '';
|
||||||
|
}
|
||||||
|
|
||||||
if ($events_sess.status_qry__search == 'loading') {
|
if ($events_sess.status_qry__search == 'loading') {
|
||||||
console.log('*** $events_sess.status_qry__search == loading ***');
|
console.log('*** $events_sess.status_qry__search == loading ***');
|
||||||
|
|
||||||
@@ -224,153 +137,35 @@ $: if ($events_trigger == 'load__event_badge_obj_li' && $events_slct.event_id) {
|
|||||||
console.log("Delayed for X second.");
|
console.log("Delayed for X second.");
|
||||||
$events_trigger = null;
|
$events_trigger = null;
|
||||||
|
|
||||||
load_obj_li_results = events_func.handle_load_ae_obj_li__badge({api_cfg: $ae_api, event_id: $events_slct.event_id, try_cache: false})
|
let search_str = $events_sess.badges.fulltext_search_qry_str.trim();
|
||||||
.then(function (load_results) {
|
console.log(search_str);
|
||||||
if (load_results) {
|
|
||||||
console.log(`load_results=`, load_results);
|
search_submit_results = events_func.handle_search__event_badge({api_cfg: $ae_api, event_id: $events_slct.event_id, fulltext_search_qry_str: search_str, external_event_id: $events_loc.badges.default__external_registration_id})
|
||||||
} else {
|
.then(function (search_results) {
|
||||||
console.log('No results returned.');
|
$events_slct.badge_obj_li = search_results;
|
||||||
}
|
console.log(search_results);
|
||||||
// return load_results;
|
$events_sess.status_qry__search = 'done';
|
||||||
console.log(`load_results=`, load_results);
|
|
||||||
// $events_slct.badge_obj_li = load_results;
|
|
||||||
return load_results;
|
|
||||||
});
|
});
|
||||||
}, 250);
|
}, 250);
|
||||||
} else {
|
} else {
|
||||||
console.log('*** $events_sess.status_qry__search != loading ***');
|
console.log('*** $events_sess.status_qry__search != loading ***');
|
||||||
$events_trigger = null;
|
$events_trigger = null;
|
||||||
|
|
||||||
load_obj_li_results = events_func.handle_load_ae_obj_li__badge({api_cfg: $ae_api, event_id: $events_slct.event_id, try_cache: false})
|
$events_sess.status_qry__search = 'loading';
|
||||||
.then(function (load_results) {
|
|
||||||
if (load_results) {
|
let search_str = $events_sess.badges.fulltext_search_qry_str.trim();
|
||||||
console.log(`load_results=`, load_results);
|
console.log(search_str);
|
||||||
} else {
|
|
||||||
console.log('No results returned.');
|
search_submit_results = events_func.handle_search__event_badge({api_cfg: $ae_api, event_id: $events_slct.event_id, fulltext_search_qry_str: search_str, external_event_id: $events_loc.badges.default__external_registration_id})
|
||||||
}
|
.then(function (search_results) {
|
||||||
// return load_results;
|
$events_slct.badge_obj_li = search_results;
|
||||||
console.log(`load_results=`, load_results);
|
console.log(search_results);
|
||||||
// $events_slct.badge_obj_li = load_results;
|
$events_sess.status_qry__search = 'done';
|
||||||
return load_results;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updated 2024-03-06
|
|
||||||
async function handle_load_ae_obj_li__badge({api_cfg: ae_api, event_id, try_cache=true}) {
|
|
||||||
console.log(`*** handle_load_ae_obj_li__badge() *** event_id=${event_id}`);
|
|
||||||
|
|
||||||
let fulltext_search_qry_str = $events_sess.badges.fulltext_search_qry_str;
|
|
||||||
|
|
||||||
let enabled = $events_loc.qry_enabled;
|
|
||||||
let hidden = $events_loc.qry__hidden;
|
|
||||||
let limit = $events_loc.qry__limit;
|
|
||||||
let offset = $events_loc.qry__offset;
|
|
||||||
|
|
||||||
if ($ae_loc.administrator_access) {
|
|
||||||
enabled = 'all';
|
|
||||||
hidden = 'all';
|
|
||||||
limit = 500;
|
|
||||||
} else if ($ae_loc.trusted_access) {
|
|
||||||
// enabled = 'all';
|
|
||||||
hidden = 'all';
|
|
||||||
limit = 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
let params = {};
|
|
||||||
|
|
||||||
let params_json: key_val = {};
|
|
||||||
if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
|
||||||
params_json['ft_qry'] = {
|
|
||||||
'default_qry_str': fulltext_search_qry_str,
|
|
||||||
// 'location_address_json_ext': fulltext_search_qry_str, // JSON extracted text DB field
|
|
||||||
// 'contact_li_json_ext': fulltext_search_qry_str, // JSON extracted text DB field
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// console.log('params_json:', params_json);
|
|
||||||
// console.log(params_json);
|
|
||||||
|
|
||||||
$events_sess.badges.status_qry__search = 'loading';
|
|
||||||
ae_promises.load__event_badge_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
|
||||||
api_cfg: $ae_api,
|
|
||||||
obj_type: 'event_badge',
|
|
||||||
for_obj_type: 'event',
|
|
||||||
for_obj_id: event_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 in the API config.
|
|
||||||
enabled: enabled,
|
|
||||||
hidden: hidden,
|
|
||||||
order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
|
||||||
// order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'created_on': 'DESC', 'updated_on': 'DESC'},
|
|
||||||
limit: limit,
|
|
||||||
offset: offset,
|
|
||||||
params_json: params_json,
|
|
||||||
params: params,
|
|
||||||
log_lvl: 0
|
|
||||||
})
|
|
||||||
|
|
||||||
.then(function (badge_obj_li_get_result) {
|
|
||||||
// console.log('Badge list:', badge_obj_li_get_result);
|
|
||||||
if (badge_obj_li_get_result) {
|
|
||||||
// $slct.badge_obj_li = badge_obj_li_get_result;
|
|
||||||
handle_db_save_ae_obj_li({obj_type: 'event_badge', obj_li: badge_obj_li_get_result});
|
|
||||||
return badge_obj_li_get_result;
|
|
||||||
} else {
|
|
||||||
// $slct.badge_obj_li = [];
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
console.log('No results returned or failed.', error);
|
|
||||||
})
|
|
||||||
.finally(function () {
|
|
||||||
$events_sess.badges.status_qry__search = 'done';
|
|
||||||
|
|
||||||
// console.log('Badge list:', badge_obj_li_get_result);
|
|
||||||
// return badge_obj_li_get_result;
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log('ae_promises.load__event_badge_obj_li:', ae_promises.load__event_badge_obj_li);
|
|
||||||
return ae_promises.load__event_badge_obj_li;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This function will loop through the badge_obj_li and save each one to the DB.
|
|
||||||
function handle_db_save_ae_obj_li({obj_type, obj_li}) {
|
|
||||||
console.log(`*** handle_db_save_ae_obj_li() ***`);
|
|
||||||
|
|
||||||
if (obj_li && obj_li.length) {
|
|
||||||
obj_li.forEach(async function (obj) {
|
|
||||||
// console.log(`ae_obj ${obj_type}:`, obj);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const id_random = await db_events.badges.put({
|
|
||||||
id_random: obj.event_badge_id_random,
|
|
||||||
full_name: obj.full_name,
|
|
||||||
full_name_override: obj.full_name_override,
|
|
||||||
email: obj.email,
|
|
||||||
email_override: obj.email_override,
|
|
||||||
affiliations: obj.affiliations,
|
|
||||||
affiliations_override: obj.affiliations_override,
|
|
||||||
badge_type: obj.badge_type,
|
|
||||||
badge_type_override: obj.badge_type_override,
|
|
||||||
badge_type_code: obj.badge_type_code,
|
|
||||||
badge_type_code_override: obj.badge_type_code_override,
|
|
||||||
external_event_id: obj.external_event_id,
|
|
||||||
external_id: obj.external_id,
|
|
||||||
external_person_id: obj.external_person_id,
|
|
||||||
});
|
|
||||||
// console.log(`Put obj with ID: ${obj.event_badge_id_random} or ${id_random}`);
|
|
||||||
} catch (error) {
|
|
||||||
let status = `Failed to put ${obj.event_badge_id_random}: ${error}`;
|
|
||||||
console.log(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
// const id_random = await db_events.badges.put(obj);
|
|
||||||
// console.log(`Put obj with ID: ${obj.event_badge_id_random}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -387,6 +182,12 @@ function handle_db_save_ae_obj_li({obj_type, obj_li}) {
|
|||||||
</header>
|
</header>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
<form
|
||||||
|
class="form"
|
||||||
|
on:submit|preventDefault={() => {
|
||||||
|
$events_trigger = 'load__event_badge_obj_li';
|
||||||
|
}}
|
||||||
|
>
|
||||||
<!-- <section class="btn btn-group"> -->
|
<!-- <section class="btn btn-group"> -->
|
||||||
<input
|
<input
|
||||||
type="search"
|
type="search"
|
||||||
@@ -398,9 +199,10 @@ function handle_db_save_ae_obj_li({obj_type, obj_li}) {
|
|||||||
>
|
>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
type="submit"
|
||||||
class="btn variant-ghost-primary w-48"
|
class="btn variant-ghost-primary w-48"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
$events_trigger = 'load__event_badge_obj_li';
|
// $events_trigger = 'load__event_badge_obj_li';
|
||||||
// $events_trigger = $events_trigger;
|
// $events_trigger = $events_trigger;
|
||||||
|
|
||||||
// handle_oninput_fulltext_search_qry_str();
|
// handle_oninput_fulltext_search_qry_str();
|
||||||
@@ -418,6 +220,7 @@ function handle_db_save_ae_obj_li({obj_type, obj_li}) {
|
|||||||
<span class="fas fa-search mx-1"></span>
|
<span class="fas fa-search mx-1"></span>
|
||||||
Search
|
Search
|
||||||
</button>
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
{#await load_obj_li_results}
|
{#await load_obj_li_results}
|
||||||
<span class="modal-loading">
|
<span class="modal-loading">
|
||||||
@@ -436,8 +239,8 @@ function handle_db_save_ae_obj_li({obj_type, obj_li}) {
|
|||||||
{/await}
|
{/await}
|
||||||
|
|
||||||
|
|
||||||
<!-- {#if $events_slct.badge_obj_li && $events_slct.badge_obj_li.length} -->
|
{#if $events_slct?.badge_obj_li.length}
|
||||||
{#if $event_badge_li}
|
<!-- {#if $event_badge_li} -->
|
||||||
<section class="ae_h_scrollfix">
|
<section class="ae_h_scrollfix">
|
||||||
<h2 class="h3">Results:</h2>
|
<h2 class="h3">Results:</h2>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
@@ -450,8 +253,8 @@ function handle_db_save_ae_obj_li({obj_type, obj_li}) {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<!-- {#each $events_slct.badge_obj_li as badge_obj} -->
|
{#each $events_slct.badge_obj_li as badge_obj}
|
||||||
{#each $event_badge_li as badge_obj}
|
<!-- {#each $lq__event_badge_li as badge_obj} -->
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -5,20 +5,11 @@ export let data: any;
|
|||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
|
// import type { key_val } from '$lib/ae_stores';
|
||||||
|
// import { ae_util } from '$lib/ae_utils';
|
||||||
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
|
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
|
||||||
import { events_loc, events_slct, events_trigger } from '$lib/ae_events_stores';
|
import { events_loc, events_slct, events_trigger } from '$lib/ae_events_stores';
|
||||||
import { ae_util } from '$lib/ae_utils';
|
|
||||||
|
|
||||||
// if (!$ae_api.account_id || !$ae_api.headers['x-account-id']) {
|
|
||||||
// console.log(`Account ID not set. Redirecting to root if can not fix.`);
|
|
||||||
|
|
||||||
// if ($ae_loc.account_id) {
|
|
||||||
// $ae_api.account_id = $ae_loc.account_id;
|
|
||||||
// $ae_api.headers['x-account-id'] = $ae_loc.account_id;
|
|
||||||
// } else {
|
|
||||||
// console.log(`Account ID not set!!!`);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
$events_loc.qry__enabled = 'enabled';
|
$events_loc.qry__enabled = 'enabled';
|
||||||
$events_loc.qry__hidden = 'not_hidden';
|
$events_loc.qry__hidden = 'not_hidden';
|
||||||
@@ -31,9 +22,9 @@ console.log(`$slct.account_id = `, $slct.account_id);
|
|||||||
let ae_acct = data[$slct.account_id];
|
let ae_acct = data[$slct.account_id];
|
||||||
console.log(`ae_acct = `, ae_acct);
|
console.log(`ae_acct = `, ae_acct);
|
||||||
|
|
||||||
$events_slct.event_id = ae_acct.slct.event_id
|
$events_slct.event_id = ae_acct.slct.event_id;
|
||||||
$events_slct.event_obj = ae_acct.slct.event_obj
|
$events_slct.event_obj = ae_acct.slct.event_obj;
|
||||||
$events_slct.exhibit_obj_li = ae_acct.slct.event_exhibit_obj_li
|
$events_slct.exhibit_obj_li = ae_acct.slct.event_exhibit_obj_li;
|
||||||
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
@@ -55,7 +46,7 @@ onMount(() => {
|
|||||||
|
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>Events Leads - {$events_loc.title}</title>
|
<title>Events Leads - {$events_loc.title ?? 'Æ loading...'}</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user