From d1328eb67c5e0a269e8bba421e7007eb2e3e70b2 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Thu, 22 Feb 2024 17:21:22 -0500 Subject: [PATCH] Added the access code component. Improved layout. General clean up and improvements. --- .../10_edit__sponsorship_obj.svelte | 2 +- package-lock.json | 60 +++ package.json | 1 + src/app.postcss | 7 + src/lib/ae_stores.ts | 36 +- src/lib/ae_utils.ts | 171 +++++++ src/lib/element_access_type.svelte | 291 +++++++++++ src/routes/+layout.svelte | 36 +- src/routes/+page.svelte | 2 +- src/routes/sponsorships/+page.svelte | 13 +- .../10_edit_modal__sponsorship_obj.svelte | 482 +++++++++++++----- .../10_list__sponsorship_obj.svelte | 10 +- .../10_view__sponsorship_obj.svelte | 2 +- .../10_view_modal__sponsorship_obj.svelte | 2 +- ...hold 10_edit_modal__sponsorship_obj.svelte | 2 +- tsconfig.json | 8 +- 16 files changed, 973 insertions(+), 152 deletions(-) create mode 100644 src/lib/element_access_type.svelte diff --git a/backups/src/routes/sponsorships/10_edit__sponsorship_obj.svelte b/backups/src/routes/sponsorships/10_edit__sponsorship_obj.svelte index 2dbbcf16..bf133a19 100644 --- a/backups/src/routes/sponsorships/10_edit__sponsorship_obj.svelte +++ b/backups/src/routes/sponsorships/10_edit__sponsorship_obj.svelte @@ -27,7 +27,7 @@ let sponsorship_location_select_option_li = {}; // This is a list (dict) of key if ($slct.sponsorship_id) { // console.log(`Sponsorship ID selected: ${$slct.sponsorship_id}`); - // console.log(`Sponsorship Object selected: ${$slct.sponsorship_obj}`) + // console.log(`Sponsorship object selected:`, $slct.sponsorship_obj); // $slct_trigger = 'load__sponsorship_obj'; disable_submit_btn = false; diff --git a/package-lock.json b/package-lock.json index df297432..9b15c034 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,6 +41,7 @@ "tailwindcss": "3.4.1", "tslib": "^2.4.1", "typescript": "^5.0.0", + "typescript-svelte-plugin": "^0.3.37", "vite": "^5.0.3", "vite-plugin-tailwind-purgecss": "0.2.0", "vitest": "^1.2.0" @@ -2100,6 +2101,12 @@ } } }, + "node_modules/dedent-js": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dedent-js/-/dedent-js-1.0.1.tgz", + "integrity": "sha512-OUepMozQULMLUmhxS95Vudo0jb0UchLimi3+pQ2plj61Fcy8axbP9hbiD4Sz6DPqn6XG3kfmziVfQ1rSys5AJQ==", + "dev": true + }, "node_modules/deep-eql": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", @@ -3289,6 +3296,15 @@ "get-func-name": "^2.0.1" } }, + "node_modules/lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", + "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", + "dev": true, + "dependencies": { + "tslib": "^2.0.3" + } + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -3512,6 +3528,16 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, + "node_modules/no-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", + "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", + "dev": true, + "dependencies": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + } + }, "node_modules/node-releases": { "version": "2.0.14", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", @@ -3664,6 +3690,16 @@ "node": ">=6" } }, + "node_modules/pascal-case": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", + "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", + "dev": true, + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -4910,6 +4946,20 @@ "@types/estree": "*" } }, + "node_modules/svelte2tsx": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/svelte2tsx/-/svelte2tsx-0.7.1.tgz", + "integrity": "sha512-0lKa6LrqJxRan0bDmBd/uFsVzYSXnoFUDaczaH0znke/XI79oy1JjFaF51J9EsOvpn8lXPlrUc3n/MA/ORNxBg==", + "dev": true, + "dependencies": { + "dedent-js": "^1.0.1", + "pascal-case": "^3.1.1" + }, + "peerDependencies": { + "svelte": "^3.55 || ^4.0.0-next.0 || ^4.0 || ^5.0.0-next.0", + "typescript": "^4.9.4 || ^5.0.0" + } + }, "node_modules/tailwindcss": { "version": "3.4.1", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.1.tgz", @@ -5168,6 +5218,16 @@ "node": ">=14.17" } }, + "node_modules/typescript-svelte-plugin": { + "version": "0.3.37", + "resolved": "https://registry.npmjs.org/typescript-svelte-plugin/-/typescript-svelte-plugin-0.3.37.tgz", + "integrity": "sha512-eg+uod/Ao6PEQ606DpexbbKF9Rzm3w8W53DyVFaNnR1CTmQQ4LbKwjcVqFhwFnGeXqrvB+0UK3atTaE+HyK0uA==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.14", + "svelte2tsx": "~0.7.0" + } + }, "node_modules/ufo": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.4.0.tgz", diff --git a/package.json b/package.json index ade9c17d..06db4723 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "tailwindcss": "3.4.1", "tslib": "^2.4.1", "typescript": "^5.0.0", + "typescript-svelte-plugin": "^0.3.37", "vite": "^5.0.3", "vite-plugin-tailwind-purgecss": "0.2.0", "vitest": "^1.2.0" diff --git a/src/app.postcss b/src/app.postcss index 815ae4cc..7c70170f 100644 --- a/src/app.postcss +++ b/src/app.postcss @@ -43,6 +43,13 @@ body { opacity: .5; } +/* Allow content to scroll horizontal if too wide */ +.ae_h_scrollfix { + max-width: 100%; + overflow-x: auto; +} + +/* These helps with the Skeleton Tailwind modal utility. */ .ae_modal_scrollfix { /* Allow modal content to scroll if it's too long */ overflow-y: auto; diff --git a/src/lib/ae_stores.ts b/src/lib/ae_stores.ts index 8a8f3c6b..cc0bf591 100644 --- a/src/lib/ae_stores.ts +++ b/src/lib/ae_stores.ts @@ -3,7 +3,7 @@ import { readable, writable } from 'svelte/store'; import type { 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_ACCOUNT_ID } from '$env/static/public'; +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_ACCOUNT_ID, PUBLIC_AE_SPONSORSHIP_CFG_ID } from '$env/static/public'; console.log(`Aether Config - TESTING:`, PUBLIC_TESTING); const api_base_url = `${PUBLIC_AE_API_PROTOCOL}://${PUBLIC_AE_API_SERVER}:${PUBLIC_AE_API_PORT}${PUBLIC_AE_API_PATH}`; @@ -13,6 +13,7 @@ const api_secret_key = PUBLIC_AE_API_SECRET_KEY; const api_crud_super_key = PUBLIC_AE_API_CRUD_SUPER_KEY; const ae_account_id = PUBLIC_AE_ACCOUNT_ID; +const ae_sponsorship_cfg_id = PUBLIC_AE_SPONSORSHIP_CFG_ID; // import { getStores, navigating, page, updated } from '$app/stores'; @@ -32,13 +33,24 @@ type key_val = { // *** BEGIN *** Longer-term app data. This should be stored to local storage. export let ae_app_local_data_struct: key_val = { - 'ver': '0.0.5', + 'ver': '0.0.7', 'name': 'Aether App Template', 'theme': 'light', + 'account_id': ae_account_id, // OSIT Demo _XY7DXtc9MY 'site_domain': null, // https://example.com, https://dev.example.com, etc. - 'administrator_access': true, - 'trusted_access': true, + + 'page_access_code_li': {'administrator': '11500', 'trusted': '19111', 'authenticated': '00000'}, + 'administrator_passcode': '11500', + 'trusted_passcode': '19111', + + 'access_type': 'anonymous', + 'administrator_access': false, + 'trusted_access': false, + 'public_access': false, + 'authenticated_access': false, + 'anonymous_access': true, + 'ds': {}, 'hub': { 'ds': {}, @@ -46,6 +58,8 @@ export let ae_app_local_data_struct: key_val = { 'mod': { // module 'events': {}, 'sponsorships': { + 'cfg_id': ae_sponsorship_cfg_id, + for_type: null, for_id: null, @@ -60,10 +74,10 @@ export let ae_app_local_data_struct: key_val = { console.log(`Aether Config - App Local Storage Data:`, ae_app_local_data_struct); // This works, but does not uses local storage: -export let ae_loc = writable(ae_app_local_data_struct); +// export let ae_loc = writable(ae_app_local_data_struct); // This works and uses local storage: -// export let ae_loc: Writable = localStorageStore('ae_loc', ae_app_local_data_struct); +export let ae_loc: Writable = localStorageStore('ae_loc', ae_app_local_data_struct); // This does not work yet...? Don't use. @@ -73,10 +87,10 @@ export let ae_loc = writable(ae_app_local_data_struct); // *** BEGIN *** Temporary app data. This should be stored to session storage. export let ae_app_session_data_struct: key_val = { - 'ver': '0.0.1', + 'ver': '0.0.2', // 'name': 'Aether App Template', // 'theme': 'light', - 'account_id': ae_app_local_data_struct.account_id, + 'account_id': ae_account_id, // 'obj': {}, } console.log(`Aether Config - App Session Storage Data:`, ae_app_session_data_struct); @@ -92,7 +106,7 @@ export let ae_api_data_struct: key_val = { 'api_secret_key_bak': api_secret_key, // 'YOUR_API_SECRET_KEY', 'api_crud_super_key': api_crud_super_key, // 'YOUR_SUPER_KEY' 'zp5PtX4zUsI' 'headers': {}, - 'account_id': ae_app_local_data_struct.account_id, + 'account_id': ae_account_id, } let ae_api_headers: key_val = {}; @@ -101,7 +115,7 @@ ae_api_headers['content-type'] = 'application/json'; ae_api_headers['x-aether-api-key'] = ae_api_data_struct.api_secret_key; ae_api_headers['x-aether-api-token'] = 'fake-temp-token'; ae_api_headers['x-aether-api-expire-on'] = ''; -ae_api_headers['x-account-id'] = ae_app_local_data_struct.account_id; +ae_api_headers['x-account-id'] = ae_account_id, ae_api_data_struct['headers'] = ae_api_headers; console.log(`Aether Config - API Data:`, ae_api_data_struct); @@ -114,7 +128,7 @@ export let slct_trigger: any = writable(null); console.log(`Aether Config - Selected Trigger:`, slct_trigger); let slct_obj_template: key_val = { - 'account_id': null, + 'account_id': ae_account_id, 'account_obj': {}, 'event_id': null, 'event_obj': {}, diff --git a/src/lib/ae_utils.ts b/src/lib/ae_utils.ts index 513bbd27..d6726b76 100644 --- a/src/lib/ae_utils.ts +++ b/src/lib/ae_utils.ts @@ -1,5 +1,9 @@ import dayjs from 'dayjs'; +type key_val = { + [key: string]: any; +}; + export let iso_datetime_formatter = function iso_datetime_formatter(raw_datetime: string|Date, named_format: string) { // console.log('*** iso_datetime_formatter() ***'); @@ -234,10 +238,177 @@ export let extract_prefixed_form_data = function extract_prefixed_form_data({pre } +// NOTE: I know there is a better more efficient way to do this, but I don't have time for that right now. +export let process_permission_checks = function process_permission_checks(access_type: string) { + // let access_checks = { 'access_type': null, 'super_check': null }; + let access_checks: key_val = {}; + + if (access_type == 'super') { + access_checks.access_type = 'super'; + + access_checks.super_check = true; + access_checks.manager_check = false; + access_checks.administrator_check = false; + access_checks.support_check = false; + access_checks.assistant_check = false; + access_checks.trusted_check = false; + access_checks.verified_check = false; + access_checks.provisional_check = false; + access_checks.public_check = false; + access_checks.authenticated_check = true; + access_checks.anonymous_check = false; + + access_checks.super_access = true; + access_checks.manager_access = true; + access_checks.administrator_access = true; + access_checks.support_access = true; + access_checks.assistant_access = true; + access_checks.trusted_access = true; + access_checks.verified_access = true; + access_checks.provisional_access = true; + access_checks.public_access = true; + access_checks.authenticated_access = true; + access_checks.anonymous_access = true; + } else if (access_type == 'manager') { + access_checks.access_type = 'manager'; + + access_checks.super_check = false; + access_checks.manager_check = true; + access_checks.administrator_check = false; + access_checks.support_check = false; + access_checks.assistant_check = false; + access_checks.trusted_check = false; + access_checks.verified_check = false; + access_checks.provisional_check = false; + access_checks.public_check = false; + access_checks.authenticated_check = true; + access_checks.anonymous_check = false; + + access_checks.super_access = false; + access_checks.manager_access = true; + access_checks.administrator_access = true; + access_checks.support_access = true; + access_checks.assistant_access = true; + access_checks.trusted_access = true; + access_checks.verified_access = true; + access_checks.provisional_access = true; + access_checks.public_access = true; + access_checks.authenticated_access = true; + access_checks.anonymous_access = true; + } else if (access_type == 'administrator') { + access_checks.access_type = 'administrator'; + + access_checks.super_check = false; + access_checks.manager_check = false; + access_checks.administrator_check = true; + access_checks.support_check = false; + access_checks.assistant_check = false; + access_checks.trusted_check = false; + access_checks.verified_check = false; + access_checks.provisional_check = false; + access_checks.public_check = false; + access_checks.authenticated_check = false; + access_checks.anonymous_check = false; + + access_checks.super_access = false; + access_checks.manager_access = false; + access_checks.administrator_access = true; + access_checks.support_access = true; + access_checks.assistant_access = true; + access_checks.trusted_access = true; + access_checks.verified_access = true; + access_checks.provisional_access = true; + access_checks.public_access = true; + access_checks.authenticated_access = true; + access_checks.anonymous_access = true; + } else if (access_type == 'trusted') { + access_checks.access_type = 'trusted'; + + access_checks.super_check = false; + access_checks.manager_check = false; + access_checks.administrator_check = false; + access_checks.support_check = false; + access_checks.assistant_check = false; + access_checks.trusted_check = true; + access_checks.verified_check = false; + access_checks.provisional_check = false; + access_checks.public_check = false; + access_checks.authenticated_check = true; + access_checks.anonymous_check = false; + + access_checks.super_access = false; + access_checks.manager_access = false; + access_checks.administrator_access = false; + access_checks.support_access = false; + access_checks.assistant_access = false; + access_checks.trusted_access = true; + access_checks.verified_access = true; + access_checks.provisional_access = true; + access_checks.public_access = true; + access_checks.authenticated_access = true; + access_checks.anonymous_access = true; + } else if (access_type == 'authenticated') { + access_checks.access_type = 'authenticated'; + + access_checks.super_check = false; + access_checks.manager_check = false; + access_checks.administrator_check = false; + access_checks.support_check = false; + access_checks.assistant_check = false; + access_checks.trusted_check = false; + access_checks.verified_check = false; + access_checks.provisional_check = false; + access_checks.public_check = false; + access_checks.authenticated_check = true; + access_checks.anonymous_check = false; + + access_checks.super_access = false; + access_checks.manager_access = false; + access_checks.administrator_access = false; + access_checks.support_access = false; + access_checks.assistant_access = false; + access_checks.trusted_access = false; + access_checks.verified_access = false; + access_checks.provisional_access = false; + access_checks.public_access = false; + access_checks.authenticated_access = true; + access_checks.anonymous_access = true; + } else { + access_checks.access_type = 'anonymous'; + + access_checks.super_check = false; + access_checks.manager_check = false; + access_checks.administrator_check = false; + access_checks.support_check = false; + access_checks.assistant_check = false; + access_checks.trusted_check = false; + access_checks.verified_check = false; + access_checks.provisional_check = false; + access_checks.public_check = false; + access_checks.authenticated_check = false; + access_checks.anonymous_check = true; + + access_checks.super_access = false; + access_checks.manager_access = false; + access_checks.administrator_access = false; + access_checks.support_access = false; + access_checks.assistant_access = false; + access_checks.trusted_access = false; + access_checks.verified_access = false; + access_checks.provisional_access = false; + access_checks.public_access = false; + access_checks.authenticated_access = false; + access_checks.anonymous_access = true; + } + + return access_checks; +} + export let ae_util = { iso_datetime_formatter: iso_datetime_formatter, extract_prefixed_form_data: extract_prefixed_form_data, + process_permission_checks: process_permission_checks, }; // export default ae_util; \ No newline at end of file diff --git a/src/lib/element_access_type.svelte b/src/lib/element_access_type.svelte new file mode 100644 index 00000000..7b326d19 --- /dev/null +++ b/src/lib/element_access_type.svelte @@ -0,0 +1,291 @@ + + + +
+ {#if $ae_loc.access_type && $ae_loc.access_type != 'anonymous'} + {#if $ae_loc.access_type == 'super'} + Super Access + {:else if $ae_loc.access_type == 'manager'} + Manager Access + {:else if $ae_loc.access_type == 'administrator'} + Administrator Access + {:else if $ae_loc.access_type == 'trusted'} + Trusted Access + {:else if $ae_loc.access_type == 'authenticated'} + Authenticated Access + {:else if $ae_loc.access_type == 'anonymous'} + Anonymous Access + {:else} + Unknown Access + {/if} + + + {:else} + + + + + {/if} +
+ + + diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 0e52bc65..9308c3e6 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -57,6 +57,8 @@ import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores'; console.log($ae_loc, $ae_sess, $ae_api); +import Element_access_type from '$lib/element_access_type.svelte'; + // const ae_loc_test_store: Writable = localStorageStore('ae_loc_test', {'test': 'This is a test'}); // // Subscribe to the store // ae_loc_test_store.subscribe(() => {}); @@ -74,13 +76,18 @@ console.log($ae_loc, $ae_sess, $ae_api); // $ae_loc_test_store let data_store_obj_get_promises: key_val = {}; +let get_ds_hub_page_access_code_li_json_promise = handle_get_data_store_obj_w_code({code: 'hub__page__access_code_li_json', data_type: 'json', trigger: 'set_access_code_li'}); let get_ds_hub_site_header_promise = handle_get_data_store_obj_w_code({code: 'hub_site_header'}); let get_ds_hub_site_footer_promise = handle_get_data_store_obj_w_code({code: 'hub_site_footer'}); -async function handle_get_data_store_obj_w_code({code, data_type='text'}) { +async function handle_get_data_store_obj_w_code({ code=null, data_type='text', trigger=null }) { console.log(`*** handle_get_data_store_obj_w_code() *** code=${code}`); + if (!code) { + console.log('No code provided.'); + return; + } // let get_item_result = window.localStorage.getItem(code); // localStorage.getItem(code); @@ -109,6 +116,10 @@ async function handle_get_data_store_obj_w_code({code, data_type='text'}) { // console.log(`Code: ${$ae_loc.hub.ds[code]}`); // console.log(`Code:`, $ae_loc.hub.ds[code]); + + if (trigger) { + $slct_trigger = trigger; + } } }) .catch(function (error) { @@ -116,6 +127,15 @@ async function handle_get_data_store_obj_w_code({code, data_type='text'}) { }); } + +$: if ($slct_trigger == 'set_access_code_li' && $ae_loc.hub.ds['hub__page__access_code_li_json']) { + console.log(`$ae_loc.hub.ds['hub__page__access_code_li_json'] = `, $ae_loc.hub.ds['hub__page__access_code_li_json']); + $slct_trigger = null; // Reset the trigger to prevent loops + + $ae_loc.page_access_code_li = $ae_loc.hub.ds['hub__page__access_code_li_json']; + $ae_loc = $ae_loc; // Trigger Svelte just in case + console.log($ae_loc); +} @@ -143,6 +163,7 @@ async function handle_get_data_store_obj_w_code({code, data_type='text'}) { + @@ -151,7 +172,8 @@ async function handle_get_data_store_obj_w_code({code, data_type='text'}) { Æ Home - OSIT's Aether App + + {@html $ae_loc.hub.ds['hub_site_header']} +
{@html $ae_loc.hub.ds['hub_site_footer']}
+
+ + + + + diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 44d50610..021874cc 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -25,7 +25,7 @@ let data_store_obj_get_promises: key_val = {}; let get_ds_hub_site_header_promise = handle_get_data_store_obj_w_code({code: 'hub_site_header'}); let get_ds_hub_site_footer_promise = handle_get_data_store_obj_w_code({code: 'hub_site_footer'}); -async function handle_get_data_store_obj_w_code({code, data_type='text'}) { +async function handle_get_data_store_obj_w_code({code}: {code: string}, data_type='text') { console.log('*** handle_get_data_store_obj_w_code() ***'); // let get_item_result = window.localStorage.getItem(code); diff --git a/src/routes/sponsorships/+page.svelte b/src/routes/sponsorships/+page.svelte index 70f9f047..71015a18 100644 --- a/src/routes/sponsorships/+page.svelte +++ b/src/routes/sponsorships/+page.svelte @@ -79,10 +79,10 @@ onMount(() => { // console.log(`$ae_loc = `, $ae_loc); let href_url = window.location.href; - console.log(href_url); + // console.log(href_url); $ae_loc.href_url = href_url; - console.log(`$ae_loc.href_url = `, $ae_loc.href_url); + // console.log(`$ae_loc.href_url = `, $ae_loc.href_url); }); @@ -205,7 +205,7 @@ async function handle_load_ae_obj_li__sponsorship({account_id, try_cache=true}) }) .finally(function () { $ae_loc.mod.sponsorships.qry_status = 'done'; - console.log('Sponsorship list:', $slct.sponsorship_obj_li); + // console.log('Sponsorship list:', $slct.sponsorship_obj_li); }); return ae_sponsorship_obj_li_get_promise; @@ -213,7 +213,12 @@ async function handle_load_ae_obj_li__sponsorship({account_id, try_cache=true}) // Load the Sponsorship Cfg Obj with ID based on the URL param. -$slct.sponsorship_cfg_id = data.url.searchParams.get('sponsorship_cfg_id'); +if (data.url.searchParams.get('sponsorship_cfg_id')) { + $slct.sponsorship_cfg_id = data.url.searchParams.get('sponsorship_cfg_id'); + $slct_trigger = 'load__sponsorship_cfg_obj'; +} else { + $slct.sponsorship_cfg_id = $ae_loc.mod.sponsorships.cfg_id; +} $slct_trigger = 'load__sponsorship_cfg_obj'; $: if ($slct_trigger == 'load__sponsorship_cfg_obj' && $slct.sponsorship_cfg_id) { diff --git a/src/routes/sponsorships/10_edit_modal__sponsorship_obj.svelte b/src/routes/sponsorships/10_edit_modal__sponsorship_obj.svelte index 27f5e895..879cf1c6 100644 --- a/src/routes/sponsorships/10_edit_modal__sponsorship_obj.svelte +++ b/src/routes/sponsorships/10_edit_modal__sponsorship_obj.svelte @@ -4,11 +4,24 @@ import { createEventDispatcher, onMount } from 'svelte'; // const dispatch = createEventDispatcher(); + +// This works and uses local storage: +// store_current_tab must be prefixed with $ to be reactive. import { clipboard, localStorageStore, ProgressRadial } from '@skeletonlabs/skeleton'; import type { Writable } from 'svelte/store'; -// const store_current_tab: Writable = localStorageStore('store_current_tab', 'start'); -let store_current_tab: string = 'start'; -// console.log(`store_current_tab:`, $store_current_tab); +const store_current_tab: Writable = localStorageStore('store_current_tab', 'start'); +console.log(`store_current_tab:`, $store_current_tab); + + +// This works, but does not uses local storage: +// store_current_tab is not reactive and should not be prefixed with $. +// let store_current_tab: string = 'start'; +// console.log(`store_current_tab:`, store_current_tab); + + +// This does not work: +// let tab_set = $store_current_tab; +// let tab_set = store_current_tab; // Stores import { getModalStore, FileDropzone, TabGroup, Tab, TabAnchor } from '@skeletonlabs/skeleton'; @@ -54,7 +67,8 @@ onMount(() => { // } // Base Classes -const cBase = 'card p-4 w-modal-wide shadow-xl space-y-4 ae_modal_scrollfix'; +const cBase = 'card p-4 shadow-xl space-y-4 ae_modal_scrollfix'; +// w-modal-wide // const cBase = 'bg-surface-100-800-token w-screen h-screen'; // const cBase = 'card h-screen'; // const cBase = 'card p-4 w-modal-wide h-screen shadow-xl space-y-4'; @@ -63,8 +77,6 @@ const cHeader = 'text-2xl font-bold'; const cForm = 'border border-surface-500 p-4 space-y-4 rounded-container-token'; -// let tab_set = $store_current_tab; -let tab_set = store_current_tab; $ae_loc.mod.sponsorships.disable_submit__sponsorship_obj = false; let placeholder_li: key_val = { @@ -78,7 +90,7 @@ let ae_promises: key_val = {}; if ($slct.sponsorship_id) { console.log(`Sponsorship ID selected: ${$slct.sponsorship_id}`); - console.log(`Sponsorship Object selected: ${$slct.sponsorship_obj}`) + console.log(`Sponsorship object selected:`, $slct.sponsorship_obj); // $slct_trigger = 'load__sponsorship_obj'; @@ -158,22 +170,21 @@ async function handle_submit_form(event) { }; } - if (sponsorship_di.name) { - sponsorship_do['name'] = sponsorship_di.name; - } - if (sponsorship_di.description) { - sponsorship_do['description'] = sponsorship_di.description; + if (sponsorship_di.organization_name) { + // Using the organization_name field to store the name of the sponsorship. + sponsorship_do['name'] = sponsorship_di.organization_name; } + // if (sponsorship_di.description) { + // sponsorship_do['description'] = sponsorship_di.description; + // } if (sponsorship_di.level_num) { sponsorship_do['level_num'] = Number(sponsorship_di.level_num); + let level_num = sponsorship_do['level_num']; - if (sponsorship_do['level_num'] == 1) { - sponsorship_do['level_str'] = 'Lowest Level Sponsorship ($5,000)'; - } else if (sponsorship_do['level_num'] == 2) { - sponsorship_do['level_str'] = 'Mid-level Sponsor ($7,500)'; - } else if (sponsorship_do['level_num'] == 3) { - sponsorship_do['level_str'] = 'High Level Sponsor ($15,000)'; + if ($slct.sponsorship_cfg_obj.level_li_json) { + let level_str = `${$slct.sponsorship_cfg_obj.level_li_json[level_num].name} - ${$slct.sponsorship_cfg_obj.level_li_json[level_num].amount}`; + sponsorship_do['level_str'] = level_str; } } @@ -453,8 +464,6 @@ async function handle_update__sponsorship({
{$modalStore[0].title ?? '-- No Title --'} - - {#await ae_promises.update__sponsorship_obj}
+ {#if $ae_loc.mod.sponsorships.link}
+ + +
+ + + {/each} + + {:else} + + {/if} + + + + + + +
+ Additional Information + + + + + +
+ Level of sponsorship? + {#if $slct.sponsorship_cfg_obj} + + {#if $slct.sponsorship_cfg_obj && $slct.sponsorship_cfg_obj.level_li_json} + + {/if} + {:else} + Not found? + {/if} + {#if $slct.sponsorship_obj.paid} + + Yes, marked as paid + {:else} + + + Go Pay Here + + + Not yet marked as paid + {/if} - + Yes, I understand the "Sponsor General Waiver". + + + +
- {:else if store_current_tab === 'options'} + {:else if $store_current_tab === 'options'} { -
+
{#if $slct.sponsorship_obj_li} @@ -67,7 +67,7 @@ onMount(() => { View - {#if $ae_loc.administrator_access} + {#if $ae_loc.trusted_access} - - +
Total Count:{$slct.sponsorship_obj_li.length} + Total Count: + {$slct.sponsorship_obj_li.length} +
diff --git a/src/routes/sponsorships/10_view__sponsorship_obj.svelte b/src/routes/sponsorships/10_view__sponsorship_obj.svelte index 6569bcf0..c8ddc91a 100644 --- a/src/routes/sponsorships/10_view__sponsorship_obj.svelte +++ b/src/routes/sponsorships/10_view__sponsorship_obj.svelte @@ -12,7 +12,7 @@ const dispatch = createEventDispatcher(); if ($slct.sponsorship_id) { console.log(`Sponsorship ID selected: ${$slct.sponsorship_id}`); - console.log(`Sponsorship Object selected: ${$slct.sponsorship_obj}`) + console.log(`Sponsorship object selected:`, $slct.sponsorship_obj); $slct_trigger = 'load__sponsorship_obj'; } diff --git a/src/routes/sponsorships/10_view_modal__sponsorship_obj.svelte b/src/routes/sponsorships/10_view_modal__sponsorship_obj.svelte index 7ad91074..16a9b197 100644 --- a/src/routes/sponsorships/10_view_modal__sponsorship_obj.svelte +++ b/src/routes/sponsorships/10_view_modal__sponsorship_obj.svelte @@ -17,7 +17,7 @@ export let parent: SvelteComponent; if ($slct.sponsorship_id) { console.log(`Sponsorship ID selected: ${$slct.sponsorship_id}`); - console.log(`Sponsorship Object selected: ${$slct.sponsorship_obj}`) + console.log(`Sponsorship object selected:`, $slct.sponsorship_obj); $slct_trigger = 'load__sponsorship_obj'; } diff --git a/src/routes/sponsorships/hold 10_edit_modal__sponsorship_obj.svelte b/src/routes/sponsorships/hold 10_edit_modal__sponsorship_obj.svelte index d22b4889..7d224025 100644 --- a/src/routes/sponsorships/hold 10_edit_modal__sponsorship_obj.svelte +++ b/src/routes/sponsorships/hold 10_edit_modal__sponsorship_obj.svelte @@ -71,7 +71,7 @@ let ae_promises: key_val = {}; if ($slct.sponsorship_id && $slct.sponsorship_obj) { console.log(`Sponsorship ID selected: ${$slct.sponsorship_id}`); - console.log(`Sponsorship Object selected: ${$slct.sponsorship_obj}`) + console.log(`Sponsorship object selected:`, $slct.sponsorship_obj); // $slct_trigger = 'load__sponsorship_obj'; } else { diff --git a/tsconfig.json b/tsconfig.json index 82081abc..2ee98332 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,13 @@ "skipLibCheck": true, "sourceMap": true, "strict": true, - "moduleResolution": "bundler" + "moduleResolution": "bundler", + "plugins": [{ + "name": "typescript-svelte-plugin", + // the following options can be set additionally; they are optional; their default values are listed here + "enabled": true, // enables this plugin + "assumeIsSvelteProject": false // if true, skip detection and always assume it's a Svelte project + }] } // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias //