151 lines
4.6 KiB
TypeScript
151 lines
4.6 KiB
TypeScript
import { persisted } from 'svelte-persisted-store';
|
|
|
|
import { writable } from 'svelte/store';
|
|
import type { Writable } from 'svelte/store';
|
|
|
|
import type { key_val } from '$lib/ae_stores';
|
|
|
|
|
|
/* *** BEGIN *** Initialize journals_local_data_struct */
|
|
// This is for longer term or sticky app data. This should be stored to *local* storage.
|
|
// Updated 2025-03-20
|
|
let journals_local_data_struct: key_val = {
|
|
ver: '2024-08-20_19',
|
|
// Shared
|
|
name: 'Aether - Journals (SvelteKit 2.x Svelte 4.x)',
|
|
title: `OSIT's Æ Journals`, // Æ
|
|
|
|
mode__edit: false,
|
|
mode__debug: false,
|
|
|
|
qry__enabled: 'enabled', // all, disabled, enabled
|
|
qry__hidden: 'not_hidden', // all, hidden, not_hidden
|
|
qry__limit: 20,
|
|
qry__order_by_li: {
|
|
// 'created_on': 'desc',
|
|
// 'updated_on': 'desc',
|
|
},
|
|
qry__offset: 0,
|
|
qry__journal_id: null,
|
|
|
|
journal: {
|
|
edit: false,
|
|
edit_kv: {},
|
|
|
|
type_code_li: [
|
|
{ code: 'diary', name: 'Diary' },
|
|
{ code: 'log', name: 'Log' },
|
|
{ code: 'journal', name: 'Journal' },
|
|
{ code: 'notebook', name: 'Notebook' },
|
|
{ code: 'personal', name: 'Personal' },
|
|
{ code: 'professional', name: 'Professional' },
|
|
{ code: 'tracking', name: 'Tracking' },
|
|
{ code: 'other', name: 'Other' },
|
|
{ code: 'test', name: 'Test' },
|
|
// { code: 'notepad', name: 'Notepad' },
|
|
],
|
|
},
|
|
entry: {
|
|
edit: false,
|
|
edit_kv: {},
|
|
},
|
|
|
|
};
|
|
// console.log(`AE Stores - App Journals Local Storage Data:`, journals_local_data_struct);
|
|
|
|
// This works and uses *local* storage:
|
|
export let journals_loc: Writable<key_val> = persisted('ae_journals_loc', journals_local_data_struct);
|
|
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
|
|
|
|
|
|
/* *** BEGIN *** Initialize journals_session_data_struct */
|
|
// Temporary app data. This is lost if the page is refreshed or using different tabs/windows. This should be stored to *session* storage.
|
|
// Updated 2025-03-20
|
|
let journals_session_data_struct: key_val = {
|
|
ver: '2024-08-20_19',
|
|
log_lvl: 1,
|
|
|
|
// Shared Triggers
|
|
trigger: null,
|
|
trigger__journal_id: null,
|
|
// trigger__journal_li: null,
|
|
|
|
show__modal_edit__journal_obj: false,
|
|
show__modal_new__journal_obj: false,
|
|
show__modal_view__journal_id: null,
|
|
show_list__journal_entry_li_group: true,
|
|
show__modal_view__journal_entry_id: null,
|
|
show__modal_edit__journal_entry_id: null,
|
|
|
|
show__modal_edit__journal_obj: false,
|
|
|
|
show__content__journal_entry_history: false,
|
|
|
|
journal: {
|
|
edit: false,
|
|
edit_kv: {},
|
|
|
|
new_journal_name: '',
|
|
new_journal_type_code: '',
|
|
|
|
tmp_obj: {},
|
|
},
|
|
entry: {
|
|
decrypt_kv: {}, // Essentially flag that the entry (content and history) can be decrypted.
|
|
edit: false,
|
|
edit_kv: {},
|
|
|
|
tmp_obj: {},
|
|
},
|
|
|
|
journal_kv: {
|
|
// journal_id: {},
|
|
},
|
|
};
|
|
// console.log(`AE Stores - App Journals Session Storage Data:`, journals_session_data_struct);
|
|
export let journals_sess = writable(journals_session_data_struct);
|
|
|
|
|
|
|
|
/* *** BEGIN *** Initialize journals_slct and journals_trig */
|
|
/* 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 journals, badges, exhibits, etc. */
|
|
|
|
// Intended for temporary session storage.
|
|
// Updated 2024-08-20
|
|
let journals_slct_obj_template: key_val = {
|
|
// Top level
|
|
'journal_id': null,
|
|
'journal_obj': {},
|
|
'journal_obj_li': [],
|
|
|
|
'tmp_journal_obj': {}, // Temporary object for new journal
|
|
'tmp_journal_entry_obj': {}, // Temporary object for new journal entry
|
|
|
|
'lq__journal_obj': {}, // Testing passing a LiveQuery object around...
|
|
};
|
|
// console.log(`AE Stores - Selected Journals Objects:`, journals_slct_obj_template);
|
|
|
|
// This works, and uses *session* (not local) storage:
|
|
export let journals_slct = writable(journals_slct_obj_template);
|
|
|
|
|
|
/* *** BEGIN *** Initialize journals_trig */
|
|
// Intended for temporary session storage.
|
|
// Updated 2025-03-16
|
|
let journals_trig_template: key_val = {
|
|
journal_id: false,
|
|
journal_entry_li: false,
|
|
};
|
|
export let journals_trig: any = writable(journals_trig_template);
|
|
// console.log(`AE Journals Stores - Journals Trigger:`, journals_trig);
|
|
|
|
|
|
/* *** BEGIN *** Initialize journals_prom */
|
|
// Intended for temporary session storage.
|
|
// Updated 2025-03-16
|
|
let journals_prom_template: key_val = {
|
|
journal_id: false,
|
|
journal_entry_li: false,};
|
|
export let journals_prom: any = writable(journals_prom_template);
|
|
// console.log(`AE Journals Stores - Journals Trigger:`, journals_prom);
|