From d7284d501060faac964b6312ef045a83bd4f15be Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 1 Oct 2024 11:28:50 -0400 Subject: [PATCH] Improvement and updates to the event list loading and showing. --- src/lib/ae_events__event.ts | 30 +++- src/lib/api_get__crud_obj_li_v2.ts | 32 ++-- src/routes/events_pres_mgmt/+layout.svelte | 47 ------ src/routes/events_pres_mgmt/+layout.ts | 11 +- src/routes/events_pres_mgmt/+page.svelte | 178 +++++++++------------ src/routes/events_pres_mgmt/+page.ts | 4 - 6 files changed, 124 insertions(+), 178 deletions(-) diff --git a/src/lib/ae_events__event.ts b/src/lib/ae_events__event.ts index faa8a35a..2eff7d41 100644 --- a/src/lib/ae_events__event.ts +++ b/src/lib/ae_events__event.ts @@ -73,6 +73,7 @@ export async function load_ae_obj_li__event( api_cfg, for_obj_type = 'account', for_obj_id, + qry_conference = true, inc_file_li = false, inc_location_li = false, inc_presentation_li = false, @@ -86,6 +87,7 @@ export async function load_ae_obj_li__event( api_cfg: any, for_obj_type: string, for_obj_id: string, + qry_conference?: boolean, inc_file_li?: boolean, inc_location_li?: boolean, inc_presentation_li?: boolean, @@ -107,15 +109,37 @@ export async function load_ae_obj_li__event( let params_json: key_val = {}; + params_json['and_qry'] = {}; + + if (qry_conference) { + params_json['and_qry']['conference'] = qry_conference; + } + // console.log('params_json:', params_json); - ae_promises.load__event_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ + // ae_promises.load__event_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ + // api_cfg: api_cfg, + // obj_type: 'event', + // for_obj_type: for_obj_type, + // for_obj_id: for_obj_id, + // use_alt_table: true, // 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 + // enabled: enabled, + // hidden: hidden, + // order_by_li: order_by_li, + // limit: limit, + // offset: offset, + // params_json: params_json, + // params: params, + // log_lvl: log_lvl + // }) + ae_promises.load__event_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({ api_cfg: api_cfg, obj_type: 'event', for_obj_type: for_obj_type, for_obj_id: for_obj_id, - use_alt_table: true, // 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 + use_alt_tbl: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config. + // use_alt_mdl: false, // NOTE: This will use the base_name_alt value instead of the base_name value enabled: enabled, hidden: hidden, order_by_li: order_by_li, diff --git a/src/lib/api_get__crud_obj_li_v2.ts b/src/lib/api_get__crud_obj_li_v2.ts index f8ff36d5..4cd5002c 100644 --- a/src/lib/api_get__crud_obj_li_v2.ts +++ b/src/lib/api_get__crud_obj_li_v2.ts @@ -9,23 +9,23 @@ export async function get_ae_obj_li_for_obj_id_crud_v2( obj_type, for_obj_type, for_obj_id, // NOTE: Changed 2023-12-06 to no longer required - use_alt_tbl=false, - use_alt_mdl=false, - use_alt_exp=false, - inc={}, - enabled='enabled', - hidden='not_hidden', - order_by_li=null, - limit=999999, - offset=0, + use_alt_tbl = false, // Alternate table or view name + use_alt_mdl = false, // Alternate model name + use_alt_exp = false, // Alternate export table or view name + inc = {}, + enabled = 'enabled', + hidden = 'not_hidden', + order_by_li = null, + limit = 999999, + offset = 0, // key, - // jwt=null, - headers={}, - params_json=null, // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the API endpoint. Example: { "fulltext_search": { "default_qry_str": "Search string for default", "address_default_qry_str": "Search string for address", "contact_1_default_qry_str": "Search string for contact_1" } } - // json_obj=null, // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint. - params={}, - return_meta=false, - log_lvl=1 + // jwt = null, + headers = {}, + params_json = null, // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the API endpoint. Example: { "fulltext_search": { "default_qry_str": "Search string for default", "address_default_qry_str": "Search string for address", "contact_1_default_qry_str": "Search string for contact_1" } } + // json_obj = null, // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint. + params = {}, + return_meta = false, + log_lvl = 1 }: { api_cfg: any, obj_type: string, diff --git a/src/routes/events_pres_mgmt/+layout.svelte b/src/routes/events_pres_mgmt/+layout.svelte index 62716615..edca1751 100644 --- a/src/routes/events_pres_mgmt/+layout.svelte +++ b/src/routes/events_pres_mgmt/+layout.svelte @@ -102,51 +102,4 @@ if (browser) { Presentation Management - {$events_loc.title ?? 'Æ loading...'} - -{#if $ae_loc.administrator_access && 1==2} - -{/if} - - - - diff --git a/src/routes/events_pres_mgmt/+layout.ts b/src/routes/events_pres_mgmt/+layout.ts index e061c9e5..05b1e2c4 100644 --- a/src/routes/events_pres_mgmt/+layout.ts +++ b/src/routes/events_pres_mgmt/+layout.ts @@ -7,7 +7,7 @@ import { events_func } from '$lib/ae_events_functions'; export async function load({ parent }) { - let log_lvl = 0; + let log_lvl = 1; let data = await parent(); // console.log(`ae_events_pres_mgmt +layout.ts data:`, data); @@ -30,11 +30,16 @@ export async function load({ parent }) { } if (browser) { + if (log_lvl) { + console.log(`ae_events_pres_mgmt +layout.ts data:`, data); + } + // Should we limit these to event.conference = true? let load_event_obj_li = events_func.load_ae_obj_li__event({ api_cfg: ae_acct.api, - account_id: account_id, - params: {enabled: 'enabled', qry__limit: 25}, + for_obj_type: 'account', + for_obj_id: account_id, + params: {qry__enabled: 'enabled', qry__limit: 25}, try_cache: true, log_lvl: log_lvl }); diff --git a/src/routes/events_pres_mgmt/+page.svelte b/src/routes/events_pres_mgmt/+page.svelte index 03c776a3..1827cd43 100644 --- a/src/routes/events_pres_mgmt/+page.svelte +++ b/src/routes/events_pres_mgmt/+page.svelte @@ -5,7 +5,6 @@ export let data: any; import { onMount } from 'svelte'; -import { api } from '$lib/api'; import { liveQuery } from "dexie"; import { db_events } from "$lib/db_events"; import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores'; @@ -14,53 +13,20 @@ import { ae_util } from '$lib/ae_utils/ae_utils'; // import Element_data_store from '$lib/element_data_store_v2.svelte'; - let ae_acct = data[$slct.account_id]; -// $events_slct.event_obj = ae_acct.slct.event_obj; -// $events_slct.event_obj_li = ae_acct.slct.event_obj_li; - -let lq__event_obj_li = liveQuery( - () => db_events.events - .orderBy('start_datetime') +$: lq__event_obj_li = liveQuery(async () => { + let results = await db_events.events + .where('account_id') + .equals(ae_acct.slct.account_id) .reverse() - .toArray() - // .sortBy('start_datetime') - // () => db_events.events - // .where('conference') - // // .aboveOrEqual(0) - // .equals('true') - // // .above(0) - // .sortBy('name') // Use sortBy() instead of orderBy(). toArray() is also not needed??? - // // .sortBy('[priority+name]') - // // .orderBy('name') - // // .offset(10).limit(5) - // // .toArray() -); -// console.log(`lq__event_obj_li:`, $lq__event_obj_li); + .sortBy('start_datetime') + return results; +}); -let lq__event_obj = liveQuery( - async () => db_events.events - .where('id') - .equals(ae_acct.slct.event_id) - .toArray() - // .first() - // .get($events_slct.event_id) -); onMount(() => { - console.log('Events - Presentation Management: +page.svelte'); - - console.log('ae_ slct:', $slct); - - let href_url = window.location.href; - // console.log(href_url); - - $ae_loc.href_url = href_url; - // console.log(`$ae_loc.href_url = `, $ae_loc.href_url); - console.log(`lq__event_obj = `, $lq__event_obj); - // $events_slct.event_obj = db_events.events.get($events_slct.event_id); - // console.log(`$events_slct.event_obj = `, $events_slct.event_obj?.name); + // console.log('Events - Presentation Management: +page.svelte'); }); @@ -69,9 +35,6 @@ onMount(() => {

Presentation Management for {$ae_loc.account_name ?? 'Æ loading...'}

- - - {#if $ae_loc.administrator_access}

Administrator Access - Technical Support

You are accessing the presentation management system with "administrator" level permissions.

@@ -80,7 +43,7 @@ onMount(() => {

You are accessing the presentation management system with "trusted" level permissions.

{:else if !$ae_loc.trusted_access}

Restricted Access

-

You are accessing to the presentation management system is limited

+

You access to the presentation management system is limited.

{/if} -{#await ae_acct.slct.event_obj_li} -
- - Loading... -
-{:then} -
+{#if $lq__event_obj_li} + - -{#if ae_acct.slct.event_obj_li && $lq__event_obj_li} - + {:else} +
+ + No events available to display. + +
+ {/if} + +{:else} +
+ + Loading... +
+ {/if} -{:catch error} + diff --git a/src/routes/events_pres_mgmt/+page.ts b/src/routes/events_pres_mgmt/+page.ts index d0ab9297..acc56585 100644 --- a/src/routes/events_pres_mgmt/+page.ts +++ b/src/routes/events_pres_mgmt/+page.ts @@ -31,8 +31,4 @@ export async function load({ parent }) { // data[account_id] = ae_acct; return data; - - // return { - // ae_events_pres_mgmt_page_ts: true, - // }; }