Files
OSIT-AE-App-Svelte/src/lib/ae_idaa_stores.ts
2024-11-08 16:37:42 -05:00

153 lines
4.4 KiB
TypeScript

import { localStorageStore } from '@skeletonlabs/skeleton';
import { writable } from 'svelte/store';
import type { Writable } from 'svelte/store';
import type { key_val } from '$lib/ae_stores';
import { offset } from '@floating-ui/dom';
// Set the version for the app data. Changing this should force a notification and ask the user to clear and reload the page.
let ver = '2024-08-21_1646';
let ver_idb = '2024-08-21_1645';
/* *** BEGIN *** Initialize idaa_local_data_struct */
// Longer-term app data. This should be stored to *local* storage.
// Updated 2024-03-06
let idaa_local_data_struct: key_val = {
ver: ver,
ver_idb: ver_idb,
// Shared
name: 'Aether - IDAA (SvelteKit 2.x Svelte 4.x)',
title: `OSIT's Æ IDAA`, // - Dev SvelteKit`, // Æ
novi_uuid: null,
novi_email: null,
novi_full_name: null,
novi_admin_li: [],
novi_trusted_li: [],
'ds': {},
'idaa_cfg_json': {},
// all, disabled, enabled
'qry__enabled': 'enabled',
// all, hidden, not_hidden
'qry__hidden': 'not_hidden',
'qry__limit': 20,
'qry__offset': 0,
archives: {
enabled: 'enabled', // all, disabled, enabled
hidden: 'not_hidden', // all, hidden, not_hidden
limit: 150,
offset: 0,
},
bb: {
enabled: 'enabled', // all, disabled, enabled
hidden: 'not_hidden', // all, hidden, not_hidden
limit: 150,
offset: 0,
show_list__post_obj_li: true,
qry__enabled: 'enabled', // all, disabled, enabled
qry__hidden: 'not_hidden', // all, hidden, not_hidden
qry__limit: 150,
qry__offset: 0,
qry__order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'title': 'ASC'},
},
recovery_meetings: {
qry__enabled: 'enabled', // all, disabled, enabled
qry__hidden: 'not_hidden', // all, hidden, not_hidden
qry__limit: 150,
qry__offset: 0,
qry__fulltext_str: null,
qry__physical: null,
qry__type: null,
qry__virtual: null,
},
};
// console.log(`AE Stores - App IDAA Local Storage Data:`, idaa_local_data_struct);
// This works, but does not uses local storage:
// export let ae_loc = writable(idaa_local_data_struct);
// This works and uses *local* storage:
export let idaa_loc: Writable<key_val> = localStorageStore('ae_idaa_loc', idaa_local_data_struct);
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
/* *** BEGIN *** Initialize idaa_session_data_struct */
// Temporary app data. This should be stored to session storage.
// Updated 2024-03-06
let idaa_session_data_struct: key_val = {
ver: ver,
ver_idb: ver_idb,
log_lvl: 1,
archives: {
qry__status: null,
},
bb: {
qry__status: null,
},
recovery_meetings: {
qry__status: null,
// qry__fulltext_str: null,
show__modal_edit: false,
show__modal_view: false,
},
};
// console.log(`AE Stores - App IDAA Session Storage Data:`, idaa_session_data_struct);
export let idaa_sess = writable(idaa_session_data_struct);
/* *** BEGIN *** Initialize idaa_slct and idaa_trigger */
/* The slct and slct_trigger variable should not be stored in local storage. Only use session storage because browser tabs can be open to different idaa, badges, exhibits, etc. */
// Intended for temporary session storage.
// Updated 2024-03-06
let idaa_slct_obj_template: key_val = {
// Top level
'event_id': null,
'event_obj': {},
'event_obj_li': [],
'archive_id': null,
'archive_obj': {},
'archive_obj_li': [],
'archive_content_id': null,
'archive_content_obj': {},
'archive_content_obj_li': [],
'post_id': null,
'post_obj': {},
'post_obj_li': [],
'post_comment_id': null,
'post_comment_obj': {},
'post_comment_obj_li': [],
};
// console.log(`AE Stores - Selected IDAA Objects:`, idaa_slct_obj_template);
// This works, and uses *session* (not local) storage:
export let idaa_slct = writable(idaa_slct_obj_template);
// This works and uses *local* storage:
// export let idaa_slct: Writable<key_val> = localStorageStore('ae_idaa_slct', idaa_slct_obj_template);
/* *** BEGIN *** Initialize idaa_trigger */
// Intended for temporary session storage.
// Updated 2024-03-06
export let idaa_trigger: any = writable(null);
// console.log(`AE IDAA Stores - IDAA Trigger:`, idaa_trigger);