Trying to improve the sign in and passcode logic. Also related bug fixes with focus. Made Journal Entries marked as public visible to others.

This commit is contained in:
Scott Idem
2025-08-21 13:55:23 -04:00
parent edfe9dee7a
commit 33c6cb862e
7 changed files with 48 additions and 27 deletions

View File

@@ -346,6 +346,8 @@ let ae_app_session_data_defaults: key_val = {
disable_sys_footer: false, disable_sys_footer: false,
sys_menu: { sys_menu: {
expand: false,
focus_passcode_input: false,
}, },
debug_menu: { debug_menu: {

View File

@@ -25,6 +25,7 @@ import { events_loc } from '$lib/ae_events_stores';
interface Props { interface Props {
log_lvl?: number; log_lvl?: number;
hide?: null|boolean; hide?: null|boolean;
focus_input: boolean;
expand?: boolean; expand?: boolean;
show_passcode_input: boolean; show_passcode_input: boolean;
trigger_clear_access: null|boolean; trigger_clear_access: null|boolean;
@@ -33,6 +34,7 @@ interface Props {
let { let {
log_lvl = $bindable(0), log_lvl = $bindable(0),
hide = $bindable(false), hide = $bindable(false),
focus_input = $bindable(false),
expand = $bindable(false), expand = $bindable(false),
show_passcode_input = $bindable(false), show_passcode_input = $bindable(false),
trigger_clear_access = $bindable(null), trigger_clear_access = $bindable(null),
@@ -54,15 +56,16 @@ let trigger: null|string|boolean = $state(null);
// WARNING: There is a bug (I think) around here related to the entered_passcode not being cleared. There seems to be something different about how Svelte handles state in this component compared to the others. This might be related to the `$effect` or `$derived` usage. Maybe there are conflicting things trying to update the $ae_loc store at the same time. // WARNING: There is a bug (I think) around here related to the entered_passcode not being cleared. There seems to be something different about how Svelte handles state in this component compared to the others. This might be related to the `$effect` or `$derived` usage. Maybe there are conflicting things trying to update the $ae_loc store at the same time.
onMount(() => { onMount(() => {
log_lvl = 2;
if (log_lvl > 1) { if (log_lvl > 1) {
console.log('** Element Mounted: ** Element Access Type'); console.log('** Element Mounted: ** Element Access Type');
} }
entered_passcode = ''; entered_passcode = '';
trigger = null; trigger = null;
/** @type {HTMLElement | null} */ // /** @type {HTMLElement | null} */
const to_focus = document.getElementById('access_passcode_input'); // const to_focus = document.getElementById('access_passcode_input');
to_focus?.focus(); // to_focus?.focus();
}); });
onDestroy(() => { onDestroy(() => {
@@ -122,11 +125,15 @@ $effect(() => {
}); });
// This does not seem to work. I feel like it should though...? // This does not seem to work. I feel like it should though...?
$effect(async () => { $effect(() => {
if (show_passcode_input) { if (!hide && focus_input) {
focus_input = false;
log_lvl = 2;
// await tick(); // await tick();
// document.getElementById('access_passcode_input')?.focus(); // document.getElementById('access_passcode_input')?.focus();
console.log('Effect: Setting focus on the passcode input field'); if (log_lvl > 1) {
console.log('Effect: Setting focus on the passcode input field');
}
/** @type {HTMLElement | null} */ /** @type {HTMLElement | null} */
const to_focus = document.getElementById('access_passcode_input'); const to_focus = document.getElementById('access_passcode_input');
to_focus?.focus(); to_focus?.focus();

View File

@@ -30,9 +30,9 @@ interface Props {
} }
let { let {
log_lvl = 0, log_lvl = $bindable(0),
data = null, data = null,
hidden = true, hidden = $bindable(true),
}: Props = $props(); }: Props = $props();

View File

@@ -249,7 +249,7 @@ max-w-max -->
if (!expand) { if (!expand) {
expand = true; expand = true;
$ae_loc.sys_menu.expand = true; $ae_sess.sys_menu.expand = true;
$ae_loc.sys_menu.hide_access_type = false; $ae_loc.sys_menu.hide_access_type = false;
$ae_loc.sys_menu.expand_access_type = true; $ae_loc.sys_menu.expand_access_type = true;
// $ae_loc.sys_menu.expand_btn = false; // $ae_loc.sys_menu.expand_btn = false;
@@ -281,7 +281,7 @@ max-w-max -->
if (expand) { if (expand) {
$ae_loc.sys_menu.hide_access_type = false; $ae_loc.sys_menu.hide_access_type = false;
$ae_loc.sys_menu.expand_access_type = false; // $ae_loc.sys_menu.expand_access_type = false;
expand = false; expand = false;
// $ae_loc.sys_menu.expand = true; // $ae_loc.sys_menu.expand = true;
@@ -322,14 +322,18 @@ max-w-max -->
onclick={async () => { onclick={async () => {
expand = true; expand = true;
$ae_sess.sys_menu.expand = true;
$ae_loc.sys_menu.hide_access_type = false; $ae_loc.sys_menu.hide_access_type = false;
$ae_loc.sys_menu.expand_access_type = true; $ae_loc.sys_menu.expand_access_type = true;
$ae_sess.app_cfg.show_element__passcode_input = true;
$ae_sess.sys_menu.focus_passcode_input = true;
// $ae_loc.sys_menu.expand = true; // $ae_loc.sys_menu.expand = true;
// $ae_loc.sys_menu.expand_btn = false; // $ae_loc.sys_menu.expand_btn = false;
// $ae_loc.app_cfg.show_element__access_type = true; // $ae_loc.app_cfg.show_element__access_type = true;
// $ae_loc.app_cfg.show_element__passcode_input = true; // $ae_loc.app_cfg.show_element__passcode_input = true;
await tick(); // await tick();
console.log('Layout button click: Focus on passcode input!'); console.log('Layout button click: Focus on passcode input!');
/** @type {HTMLElement | null} */ /** @type {HTMLElement | null} */
const to_focus = document.getElementById('access_passcode_input'); const to_focus = document.getElementById('access_passcode_input');
@@ -426,25 +430,29 @@ max-w-max -->
onclick={async () => { onclick={async () => {
if (!expand) { if (!expand) {
expand = true; expand = true;
$ae_sess.sys_menu.expand = true;
// $ae_loc.sys_menu.expand = true; // $ae_loc.sys_menu.expand = true;
// $ae_loc.sys_menu.expand_btn = false; // $ae_loc.sys_menu.expand_btn = false;
$ae_loc.app_cfg.show_element__access_type = true; $ae_loc.app_cfg.show_element__access_type = true;
if ($ae_loc?.access_type == 'anonymous') { if ($ae_loc?.access_type == 'anonymous') {
$ae_sess.app_cfg.show_element__passcode_input = true; $ae_sess.sys_menu.focus_passcode_input = true;
// $ae_sess.app_cfg.show_element__passcode_input = true;
} else { } else {
$ae_sess.app_cfg.show_element__passcode_input = false; // $ae_sess.app_cfg.show_element__passcode_input = false;
$ae_loc.sys_menu.expand_user = false; // Not in use yet $ae_loc.sys_menu.expand_user = false; // Not in use yet
$ae_sess.show__sign_in_out__fields = false; $ae_sess.show__sign_in_out__fields = false;
} }
// $ae_loc.app_cfg.show_element__passcode_input = true; // $ae_loc.app_cfg.show_element__passcode_input = true;
await tick(); // await tick();
console.log('Layout button click: Focus on passcode input!'); // console.log('Layout button click: Focus on passcode input!');
/** @type {HTMLElement | null} */ // /** @type {HTMLElement | null} */
const to_focus = document.getElementById('access_passcode_input'); // const to_focus = document.getElementById('access_passcode_input');
to_focus?.focus(); // to_focus?.focus();
} else { } else {
expand = false; expand = false;
$ae_sess.sys_menu.expand = false;
// $ae_loc.sys_menu.expand = false; // $ae_loc.sys_menu.expand = false;
// $ae_loc.sys_menu.expand_btn = true; // $ae_loc.sys_menu.expand_btn = true;
// $ae_loc.app_cfg.show_element__passcode_input = false; // $ae_loc.app_cfg.show_element__passcode_input = false;
@@ -522,11 +530,14 @@ max-w-max -->
onclick={() => { onclick={() => {
if (!expand) { if (!expand) {
expand = true; expand = true;
$ae_loc.sys_menu.expand = true; $ae_sess.sys_menu.expand = true;
// $ae_loc.sys_menu.expand_btn = false; // $ae_loc.sys_menu.expand_btn = false;
// $ae_loc.sys_menu.expand_access_type = true; // $ae_loc.sys_menu.expand_access_type = true;
// $ae_sess.app_cfg.show_element__passcode_input = true;
$ae_sess.sys_menu.focus_passcode_input = true;
} else { } else {
$ae_loc.sys_menu.expand = false; $ae_sess.sys_menu.expand = false;
$ae_loc.sys_menu.expand_user = false; // Not in use yet $ae_loc.sys_menu.expand_user = false; // Not in use yet
$ae_sess.show__sign_in_out__fields = false; $ae_sess.show__sign_in_out__fields = false;
// $ae_loc.sys_menu.expand_btn = true; // $ae_loc.sys_menu.expand_btn = true;
@@ -570,9 +581,9 @@ max-w-max -->
<!-- {/if} --> <!-- {/if} -->
{#if $ae_loc?.app_cfg?.show_element__sign_in_out} {#if $ae_loc?.app_cfg?.show_element__sign_in_out}
<!-- hide={$ae_loc.sys_menu.hide_user} -->
<!-- expand={$ae_loc.sys_menu.expand_user} -->
<Element_sign_in_out <Element_sign_in_out
hide={$ae_loc.sys_menu.hide_user}
expand={$ae_loc.sys_menu.expand_user}
data={data} data={data}
hidden={$ae_loc.iframe || !$ae_loc.app_cfg?.show_element__sign_in_out} hidden={$ae_loc.iframe || !$ae_loc.app_cfg?.show_element__sign_in_out}
/> />
@@ -582,6 +593,7 @@ max-w-max -->
<!-- hidden={$ae_loc?.iframe && !$ae_loc?.trusted_access && !expand} --> <!-- hidden={$ae_loc?.iframe && !$ae_loc?.trusted_access && !expand} -->
<Element_access_type <Element_access_type
bind:hide={$ae_loc.sys_menu.hide_access_type} bind:hide={$ae_loc.sys_menu.hide_access_type}
bind:focus_input={$ae_sess.sys_menu.focus_passcode_input}
bind:expand={$ae_loc.sys_menu.expand_access_type} bind:expand={$ae_loc.sys_menu.expand_access_type}
bind:show_passcode_input={$ae_sess.app_cfg.show_element__passcode_input} bind:show_passcode_input={$ae_sess.app_cfg.show_element__passcode_input}
bind:trigger_clear_access={trigger_clear_access} bind:trigger_clear_access={trigger_clear_access}

View File

@@ -114,7 +114,7 @@ let flag_denied: boolean = $state(false); // Access Denied
if (!$ae_loc?.sys_menu) { if (!$ae_loc?.sys_menu) {
$ae_loc.sys_menu = { $ae_loc.sys_menu = {
hide: false, hide: false,
expand: false, // expand: false,
hide_access_type: false, hide_access_type: false,
expand_access_type: false, expand_access_type: false,
hide_edit_mode: false, hide_edit_mode: false,
@@ -1136,7 +1136,7 @@ email = ${$ae_loc?.email}
<E_app_sys_menu <E_app_sys_menu
data={data} data={data}
bind:hide={$ae_loc.sys_menu.hide} bind:hide={$ae_loc.sys_menu.hide}
bind:expand={$ae_loc.sys_menu.expand} bind:expand={$ae_sess.sys_menu.expand}
/> />
<!-- The app debug menu --> <!-- The app debug menu -->

View File

@@ -298,7 +298,7 @@ async function handle_update_journal() {
<FilePlus /> <FilePlus />
<!-- <span class="fas fa-plus m-1"></span> --> <!-- <span class="fas fa-plus m-1"></span> -->
<span class="hidden sm:inline"> <span class="hidden sm:inline">
New Journal Entry New Entry
</span> </span>
</button> </button>
@@ -383,7 +383,7 @@ async function handle_update_journal() {
<!-- Give list of categories to base the new entry on --> <!-- Give list of categories to base the new entry on -->
<span class="flex flex-row items-center gap-2"> <span class="flex flex-row items-center gap-2">
<span class="text-sm text-gray-500 hidden sm:inline"> <span class="text-sm text-gray-500 hidden md:inline">
Category: Category:
</span> </span>
<select <select

View File

@@ -141,7 +141,7 @@ let lq__journal_entry_obj = $derived(liveQuery(async () => {
</svelte:head> --> </svelte:head> -->
{#if $ae_loc.person_id == $lq__journal_obj?.person_id} {#if $ae_loc.person_id == $lq__journal_obj?.person_id || $lq__journal_entry_obj?.public}
<section <section
class=" class="
ae_journals__journal_entry ae_journals__journal_entry