Migrate Event Badges to V3 and implement Core Management pages

- Completed V3 migration for Event Badge CRUD operations
- Implemented User module V3 logic and editable fields
- Created management routes for Accounts, Sites, Users, and Lookups
- Updated Site Domain logic to use 'fqdn' and show 'access_key'
- Modernized Core Dashboard with navigation cards
- Restored Dexie User table definition
This commit is contained in:
Scott Idem
2026-01-06 13:38:47 -05:00
parent 1b318eeb8b
commit 00e80af3a1
29 changed files with 3800 additions and 218 deletions

View File

@@ -0,0 +1,149 @@
<script lang="ts">
import { onMount } from 'svelte';
import { page } from '$app/stores';
import { load_ae_obj_id__account, update_ae_obj__account, delete_ae_obj_id__account } from '$lib/ae_core/ae_core__account';
import { editable_fields__account } from '$lib/ae_core/ae_core__account.editable_fields';
import { ae_api, ae_loc } from '$lib/stores/ae_stores';
import { goto } from '$app/navigation';
import { Save, Trash2, ArrowLeft, Building } from 'lucide-svelte';
let account_id = $page.params.account_id;
let account: any = $state(null);
let loading = $state(true);
let saving = $state(false);
async function load_account() {
loading = true;
account = await load_ae_obj_id__account({
api_cfg: $ae_api,
account_id,
log_lvl: 1
});
loading = false;
}
onMount(() => {
if (!$ae_loc.manager_access) {
goto('/core');
return;
}
load_account();
});
async function handle_save() {
saving = true;
// Filter fields to only include editable ones
const data_kv: any = {};
editable_fields__account.forEach(field => {
if (account[field] !== undefined) {
data_kv[field] = account[field];
}
});
const result = await update_ae_obj__account({
api_cfg: $ae_api,
account_id,
data_kv,
log_lvl: 1
});
if (result) {
alert('Account updated successfully');
}
saving = false;
}
async function handle_delete() {
if (!confirm('Are you sure you want to disable this account?')) return;
const result = await delete_ae_obj_id__account({
api_cfg: $ae_api,
account_id,
method: 'disable',
log_lvl: 1
});
if (result) {
goto('/core/accounts');
}
}
</script>
<div class="container mx-auto p-4 space-y-6">
<header class="flex justify-between items-center">
<div class="flex items-center gap-4">
<button class="btn btn-sm variant-soft" onclick={() => goto('/core/accounts')}>
<ArrowLeft size={16} />
</button>
<div class="flex items-center gap-2">
<Building size={24} />
<h1 class="h2">{account?.name ?? 'Loading Account...'}</h1>
</div>
</div>
<div class="flex gap-2">
<button class="btn variant-filled-error" onclick={handle_delete} disabled={loading || saving}>
<Trash2 size={16} class="mr-2" /> Disable
</button>
<button class="btn variant-filled-primary" onclick={handle_save} disabled={loading || saving}>
<Save size={16} class="mr-2" /> Save Changes
</button>
</div>
</header>
{#if loading}
<div class="placeholder animate-pulse w-full h-64"></div>
{:else if account}
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="card p-4 space-y-4">
<h3 class="h4 border-b border-surface-500/30 pb-2">Basic Information</h3>
<label class="label">
<span>Account Name</span>
<input class="input" type="text" bind:value={account.name} />
</label>
<label class="label">
<span>Short Name</span>
<input class="input" type="text" bind:value={account.short_name} />
</label>
<label class="label">
<span>Account Code</span>
<input class="input" type="text" bind:value={account.code} />
</label>
<label class="label">
<span>Description</span>
<textarea class="textarea" rows="3" bind:value={account.description}></textarea>
</label>
</div>
<div class="card p-4 space-y-4">
<h3 class="h4 border-b border-surface-500/30 pb-2">Settings & Status</h3>
<div class="flex flex-col gap-4">
<label class="flex items-center space-x-2">
<input class="checkbox" type="checkbox" bind:checked={account.enable} />
<p>Enabled</p>
</label>
<label class="flex items-center space-x-2">
<input class="checkbox" type="checkbox" bind:checked={account.hide} />
<p>Hidden</p>
</label>
<label class="flex items-center space-x-2">
<input class="checkbox" type="checkbox" bind:checked={account.priority} />
<p>Priority Account</p>
</label>
</div>
<label class="label">
<span>Group</span>
<input class="input" type="text" bind:value={account.group} />
</label>
<label class="label">
<span>Sort Order</span>
<input class="input" type="number" bind:value={account.sort} />
</label>
</div>
<div class="card p-4 space-y-4 md:col-span-2">
<h3 class="h4 border-b border-surface-500/30 pb-2">Internal Notes</h3>
<textarea class="textarea" rows="4" bind:value={account.notes} placeholder="Private notes for staff..."></textarea>
</div>
</div>
{/if}
</div>