fix(core): modern Svelte 5 cleanup — Dexie .get() bug, typed API calls, inline confirms
- person_view.svelte: fix liveQuery using .get() (primary key, never set by V3)
→ .where('person_id').equals().first()
- people/[person_id]: same Dexie .get() fix for lq__person_obj
- person_view.svelte: replace 4x generic api.update_ae_obj → core_func.update_ae_obj__person
(removes unused api import)
- Replace all browser confirm()/alert() dialogs (9 occurrences, 6 files) with
inline two-click confirm state pattern (confirm_action = $state<string|null>)
Affected: users, accounts, contacts, addresses, people, sites
- Bootstrap doc: add Dexie .get() trap to Section 5 and Mistake #8
This commit is contained in:
@@ -14,8 +14,6 @@ import { liveQuery } from 'dexie';
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
import Element_ae_obj_field_editor from '$lib/elements/element_ae_obj_field_editor.svelte';
|
||||
import { api } from '$lib/api/api';
|
||||
|
||||
import { core_func } from '$lib/ae_core/ae_core_functions';
|
||||
import {
|
||||
ae_snip,
|
||||
@@ -62,11 +60,9 @@ $effect(() => {
|
||||
}
|
||||
});
|
||||
|
||||
// .get() uses the primary key (id), which V3 never populates — always use .where().equals().first()
|
||||
let lq__person_obj = $derived(
|
||||
liveQuery(async () => {
|
||||
let results = await db_core.person.get(person_id);
|
||||
return results;
|
||||
})
|
||||
liveQuery(() => db_core.person.where('person_id').equals(person_id).first())
|
||||
);
|
||||
|
||||
ae_tmp.value__data_json = null;
|
||||
@@ -304,11 +300,10 @@ $effect(() => {
|
||||
<button
|
||||
type="button"
|
||||
onclick={async () => {
|
||||
await api.update_ae_obj({
|
||||
await core_func.update_ae_obj__person({
|
||||
api_cfg: $ae_api,
|
||||
obj_type: 'person',
|
||||
obj_id: $lq__person_obj?.person_id,
|
||||
fields: { hide: !$lq__person_obj?.hide }
|
||||
person_id: $lq__person_obj?.person_id,
|
||||
data_kv: { hide: !$lq__person_obj?.hide }
|
||||
});
|
||||
core_func.load_ae_obj_id__person({
|
||||
api_cfg: $ae_api,
|
||||
@@ -337,11 +332,10 @@ $effect(() => {
|
||||
<button
|
||||
type="button"
|
||||
onclick={async () => {
|
||||
await api.update_ae_obj({
|
||||
await core_func.update_ae_obj__person({
|
||||
api_cfg: $ae_api,
|
||||
obj_type: 'person',
|
||||
obj_id: $lq__person_obj?.person_id,
|
||||
fields: { enable: !$lq__person_obj?.enable }
|
||||
person_id: $lq__person_obj?.person_id,
|
||||
data_kv: { enable: !$lq__person_obj?.enable }
|
||||
});
|
||||
core_func.load_ae_obj_id__person({
|
||||
api_cfg: $ae_api,
|
||||
@@ -373,11 +367,10 @@ $effect(() => {
|
||||
<button
|
||||
type="button"
|
||||
onclick={async () => {
|
||||
await api.update_ae_obj({
|
||||
await core_func.update_ae_obj__person({
|
||||
api_cfg: $ae_api,
|
||||
obj_type: 'person',
|
||||
obj_id: $lq__person_obj?.person_id,
|
||||
fields: { priority: !$lq__person_obj?.priority }
|
||||
person_id: $lq__person_obj?.person_id,
|
||||
data_kv: { priority: !$lq__person_obj?.priority }
|
||||
});
|
||||
core_func.load_ae_obj_id__person({
|
||||
api_cfg: $ae_api,
|
||||
@@ -404,13 +397,10 @@ $effect(() => {
|
||||
<button
|
||||
type="button"
|
||||
onclick={async () => {
|
||||
await api.update_ae_obj({
|
||||
await core_func.update_ae_obj__person({
|
||||
api_cfg: $ae_api,
|
||||
obj_type: 'person',
|
||||
obj_id: $lq__person_obj?.person_id,
|
||||
fields: {
|
||||
allow_auth_key: !$lq__person_obj?.allow_auth_key
|
||||
}
|
||||
person_id: $lq__person_obj?.person_id,
|
||||
data_kv: { allow_auth_key: !$lq__person_obj?.allow_auth_key }
|
||||
});
|
||||
core_func.load_ae_obj_id__person({
|
||||
api_cfg: $ae_api,
|
||||
|
||||
Reference in New Issue
Block a user