From 183d431e1da7ae0cc5fb496bade374e7bdbe1903 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Sat, 15 Mar 2025 21:24:25 -0400 Subject: [PATCH] Doing some more work on the new Notes objects. --- src/lib/ae_notes/ae_notes__note.ts | 13 +- src/routes/(notes)/+layout.svelte | 65 +++++++ src/routes/(notes)/+layout.ts | 34 ++++ src/routes/(notes)/notes/+layout.ts | 82 +++++++++ .../(notes)/notes/+layout@(notes).svelte | 98 +++++++++++ src/routes/{ => (notes)}/notes/+page.svelte | 37 ++-- src/routes/{ => (notes)}/notes/+page.ts | 0 src/routes/+layout.svelte | 2 +- src/routes/notes/+layout.svelte | 163 ------------------ src/routes/notes/+layout.ts | 74 -------- 10 files changed, 305 insertions(+), 263 deletions(-) create mode 100644 src/routes/(notes)/+layout.svelte create mode 100644 src/routes/(notes)/+layout.ts create mode 100644 src/routes/(notes)/notes/+layout.ts create mode 100644 src/routes/(notes)/notes/+layout@(notes).svelte rename src/routes/{ => (notes)}/notes/+page.svelte (84%) rename src/routes/{ => (notes)}/notes/+page.ts (100%) delete mode 100644 src/routes/notes/+layout.svelte delete mode 100644 src/routes/notes/+layout.ts diff --git a/src/lib/ae_notes/ae_notes__note.ts b/src/lib/ae_notes/ae_notes__note.ts index 060cd24d..e40f0a9e 100644 --- a/src/lib/ae_notes/ae_notes__note.ts +++ b/src/lib/ae_notes/ae_notes__note.ts @@ -98,6 +98,10 @@ export async function load_ae_obj_li__note( for_obj_type = 'account', for_obj_id, // inc_other_li = false, + enabled = 'enabled', + hidden = 'not_hidden', + limit = 99, + offset = 0, order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}, params = {}, try_cache = true, @@ -107,6 +111,10 @@ export async function load_ae_obj_li__note( for_obj_type: string, for_obj_id: string, // inc_other_li?: boolean, + enabled?: string, // all, disabled, enabled + hidden?: string, // all, hidden, not_hidden + limit?: number, + offset?: number, order_by_li?: key_val, params?: key_val, try_cache?: boolean, @@ -115,11 +123,6 @@ export async function load_ae_obj_li__note( ) { console.log(`*** load_ae_obj_li__note() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`); - let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled - let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden - let limit: number = (params.qry__limit ?? 99); // 99 - let offset: number = (params.qry__offset ?? 0); // 0 - let params_json: key_val = {}; // console.log('params_json:', params_json); diff --git a/src/routes/(notes)/+layout.svelte b/src/routes/(notes)/+layout.svelte new file mode 100644 index 00000000..1d6db7d5 --- /dev/null +++ b/src/routes/(notes)/+layout.svelte @@ -0,0 +1,65 @@ + + + + Notes - {$notes_loc.title ?? 'Æ loading...'} + + +
+ + + +
+{#if $ae_loc.administrator_access} +

Administrator Access - Technical Support

+

You are accessing the notes system with "administrator" level permissions.

+{:else if $ae_loc.trusted_access} +

Trusted Access - Staff

+

You are accessing the notes system with "trusted" level permissions.

+{:else if !$ae_loc.trusted_access} +

Restricted Access

+

You are accessing to the notes system is limited

+{/if} +
+ +
+ {@render children()} +
+ +
\ No newline at end of file diff --git a/src/routes/(notes)/+layout.ts b/src/routes/(notes)/+layout.ts new file mode 100644 index 00000000..199685f2 --- /dev/null +++ b/src/routes/(notes)/+layout.ts @@ -0,0 +1,34 @@ +/** @type {import('./$types').LayoutLoad} */ + +// import { error } from '@sveltejs/kit'; +import { browser } from '$app/environment'; + +// import { api } from '$lib/api'; +// import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores'; +// import { core_func } from '$lib/ae_core/ae_core_functions'; +// import type { key_val } from '$lib/ae_stores'; + + +export async function load({ fetch, params, parent, route, url }) { + let log_lvl: number = 0; + + let parent_data = await parent(); + + let account_id = parent_data.account_id; + + let ae_acct = parent_data[account_id]; + if (log_lvl) { + console.log(`ae_acct = `, ae_acct); + } + + + // let ae_params = {}; + + if (browser) { + + } + + parent_data[account_id] = ae_acct; + + return parent_data; +} \ No newline at end of file diff --git a/src/routes/(notes)/notes/+layout.ts b/src/routes/(notes)/notes/+layout.ts new file mode 100644 index 00000000..c4078347 --- /dev/null +++ b/src/routes/(notes)/notes/+layout.ts @@ -0,0 +1,82 @@ +/** @type {import('./$types').LayoutLoad} */ +console.log(`ae_notes +layout.ts start`); + +// Imports +import { browser } from '$app/environment'; +import { notes_func } from '$lib/ae_notes/ae_notes_functions'; + + +export async function load({ params, parent }) { + let log_lvl: number = 0; + + let data = await parent(); + // console.log(`ae_notes +layout.ts data:`, data); + + let account_id = data.account_id; + if (!account_id) { + console.log(`notes +layout.ts: The account_id was not found in the data!!!`); + return false; + } + + let ae_acct = data[account_id]; + if (log_lvl) { + console.log(`ae_acct = `, ae_acct); + } + + let note_id = ae_acct.slct.note_id; // From root +layout.ts + if (!note_id) { + console.log(`ERROR: notes +layout.ts: The note_id was not found in the data!!!`); + // return false; + } + + let ae_params = {}; + + if (browser) { + if (note_id) { + let load_note_obj_li = notes_func.load_ae_obj_li__note({ + api_cfg: ae_acct.api, + for_obj_type: 'account', + for_obj_id: account_id, + enabled: 'enabled', + hidden: 'not_hidden', + limit: 20, + // order_by_li: {}, + params: ae_params, + try_cache: true, + log_lvl: log_lvl + }); + ae_acct.slct.note_obj_li = load_note_obj_li; + } + } + + // let load_note_obj = notes_func.load_ae_obj_id__note({ + // api_cfg: ae_acct.api, + // note_id: note_id, + // try_cache: false + // }); + + // ae_acct.slct.note_obj = load_note_obj; + + // if (browser) { + // console.log(`Browser: ${browser}`); + // notes_func.db_save_ae_obj_li__note({ + // obj_type: 'note', + // obj_li: [load_note_obj_li], + // }); + // } + + // let submenu = { + // main: {name: 'Main', href: '/notes', access: false}, + // // manage: {name: 'Manage', href: '/notes/manage', access: 'administrator', disable: true, hide: true}, + // locations: {name: 'Locations', href: `/notes/${note_id}/locations`, access: false, disable: false, hide: false}, + // }; + // data.submenu = submenu + + // WARNING: Precaution against shared data between sites and sessions. + data[account_id] = ae_acct; + + return data; +} + +// export const prerender = false; +// export const prerender = true; diff --git a/src/routes/(notes)/notes/+layout@(notes).svelte b/src/routes/(notes)/notes/+layout@(notes).svelte new file mode 100644 index 00000000..a8566fa1 --- /dev/null +++ b/src/routes/(notes)/notes/+layout@(notes).svelte @@ -0,0 +1,98 @@ + + + +{#if $ae_loc.administrator_access && 1==2} + +{/if} + + +
+{@render children()} +
diff --git a/src/routes/notes/+page.svelte b/src/routes/(notes)/notes/+page.svelte similarity index 84% rename from src/routes/notes/+page.svelte rename to src/routes/(notes)/notes/+page.svelte index 78866380..571e2978 100644 --- a/src/routes/notes/+page.svelte +++ b/src/routes/(notes)/notes/+page.svelte @@ -1,16 +1,20 @@ - - - - Notes - {$notes_loc.title ?? 'Æ loading...'} - - - -{#if $ae_loc.administrator_access && 1==2} - -{/if} - - - -{#if $ae_loc.ver != '2024-08-16_1821' || $ae_loc.ver_idb != '2024-08-16_1826'} - -
- - -

New Version Available

-

- There is a new version of the web app (this website). Please use the button to clear some cached data and settings. The page will then reload. -

- -{#if $ae_loc.ver != '2024-08-07_1504'} -

- You will need to sign in again after clearing the cache. -

-{/if} - - -
- -{:else} - - - -{/if} - - - - diff --git a/src/routes/notes/+layout.ts b/src/routes/notes/+layout.ts deleted file mode 100644 index e8326f11..00000000 --- a/src/routes/notes/+layout.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** @type {import('./$types').LayoutLoad} */ -console.log(`ae_notes +layout.ts start`); - -// Imports -import { browser } from '$app/environment'; -import { events_func } from '$lib/ae_events_functions'; - - -export async function load({ parent }) { - let log_lvl: number = 0; - - let data = await parent(); - // console.log(`ae_events_pres_mgmt +layout.ts data:`, data); - - let account_id = data.account_id; - if (!account_id) { - console.log(`events_pres_mgmt +layout.ts: The account_id was not found in the data!!!`); - return false; - } - - let ae_acct = data[account_id]; - if (log_lvl) { - console.log(`ae_acct = `, ae_acct); - } - - let event_id = ae_acct.slct.event_id; // From root +layout.ts - if (!event_id) { - console.log(`ERROR: events_pres_mgmt +layout.ts: The event_id was not found in the data!!!`); - return false; - } - - if (browser) { - // 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}, - try_cache: true, - log_lvl: log_lvl - }); - ae_acct.slct.event_obj_li = load_event_obj_li; - } - - // let load_event_obj = events_func.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; - - // if (browser) { - // console.log(`Browser: ${browser}`); - // events_func.db_save_ae_obj_li__event({ - // obj_type: 'event', - // obj_li: [load_event_obj_li], - // }); - // } - - let submenu = { - main: {name: 'Main', href: '/events_pres_mgmt', access: false}, - // manage: {name: 'Manage', href: '/events_pres_mgmt/manage', access: 'administrator', disable: true, hide: true}, - locations: {name: 'Locations', href: `/events/${event_id}/locations`, access: false, disable: false, hide: false}, - }; - data.submenu = submenu - - // WARNING: Precaution against shared data between sites and sessions. - data[account_id] = ae_acct; - - return data; -} - -// export const prerender = false; -// export const prerender = true;