fix(data-stores): sort format, enabled filter, account name display

- order_by_li was sent as an array; backend expects plain object — fixes sort
- pass enabled/hidden directly to search_ae_obj (was defaulting to 'enabled'/'not_hidden')
- account column now shows code/short_name from Dexie cache via SvelteMap

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-06-17 16:15:34 -04:00
parent a6abcd6603
commit 726338cb1f

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { onMount, untrack } from 'svelte';
import { SvelteMap } from 'svelte/reactivity';
import { goto } from '$app/navigation';
import {
ArrowRight,
@@ -26,9 +27,17 @@ import { ae_util } from '$lib/ae_utils/ae_utils';
import type { ae_DataStore } from '$lib/types/ae_types';
import AE_DataStore_Form from '$lib/elements/element_data_store_form.svelte';
onMount(() => {
let account_map = new SvelteMap<string, string>();
onMount(async () => {
if (!$ae_loc.manager_access) {
goto('/core');
return;
}
const accts = await db_core.account.toArray();
account_map.clear();
for (const a of accts) {
if (a.id) account_map.set(a.id, a.code ?? a.short_name ?? a.name ?? a.id.slice(0, 8) + '…');
}
});
@@ -89,17 +98,13 @@ async function do_search(reset = true) {
if (qry_for_id.trim()) {
search_query.and.push({ field: 'for_id_random', op: 'eq', value: qry_for_id.trim() });
}
if (qry_enabled === 'enabled') {
search_query.and.push({ field: 'enable', op: 'eq', value: true });
} else if (qry_enabled === 'not_enabled') {
search_query.and.push({ field: 'enable', op: 'eq', value: false });
}
const result_li = await api.search_ae_obj({
api_cfg: $ae_api,
obj_type: 'data_store',
search_query,
order_by_li: [{ [sort_col]: sort_dir }],
enabled: qry_enabled,
hidden: 'all',
order_by_li: { [sort_col]: sort_dir },
limit: page_limit,
offset: page_offset,
log_lvl: 0
@@ -213,6 +218,11 @@ function type_badge(type: string | null | undefined) {
}
}
function fmt_account(account_id: string | null | undefined): string {
if (!account_id) return 'global';
return account_map.get(account_id) ?? account_id.slice(0, 8) + '…';
}
function fmt_date(val: string | Date | null | undefined) {
if (!val) return '—';
return ae_util.iso_datetime_formatter(val as any, 'datetime_12_short');
@@ -536,9 +546,9 @@ function content_preview(ds: ae_DataStore): string {
<td class="px-3 py-2">
<span class="badge {type_badge(ds.type)} font-mono text-[9px] uppercase">{ds.type ?? '?'}</span>
</td>
<td class="px-3 py-2 font-mono opacity-60">
<td class="px-3 py-2 font-mono opacity-60" title={ds.account_id ?? 'global'}>
{#if ds.account_id}
<span title={ds.account_id}>{ds.account_id.slice(0, 8)}…</span>
{fmt_account(ds.account_id)}
{:else}
<span class="italic opacity-50">global</span>
{/if}