Add code field to archive content edit form and IDB

- Expose archive_content.code in edit form (trusted + edit_mode only)
- Add code to properties_to_save so it persists on every API load/save
- Add code field + index to Archive_Content Dexie interface (schema v2)
- Minor: center "Add" button rows in archive and content list components

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-05-07 18:42:15 -04:00
parent 6e700e7b4d
commit 3553809f27
5 changed files with 42 additions and 5 deletions

View File

@@ -299,6 +299,7 @@ export const properties_to_save = [
'archive_id',
'archive_content_type',
'name',
'code',
'description',
'content_html',
'content_json',

View File

@@ -90,6 +90,7 @@ export interface Archive_Content {
archive_content_type: string;
name: string;
code?: null | string;
description?: null | string;
content_html?: null | string;
@@ -168,7 +169,28 @@ export class MySubClassedDexie extends Dexie {
tmp_sort_1, tmp_sort_2,
enable, hide, priority, sort, group, notes, created_on, updated_on, [group+priority+sort+updated_on]`
});
// v2: add code index to content table
this.version(2).stores({
archive: `
id, archive_id,
code,
account_id,
name,
original_datetime, original_timezone, original_location,
tmp_sort_1, tmp_sort_2,
enable, hide, priority, sort, group, notes, created_on, updated_on`,
content: `
id, archive_content_id,
archive_id,
archive_content_type,
name,
code,
hosted_file_id,
original_datetime, original_timezone, original_location,
[group+original_datetime],
tmp_sort_1, tmp_sort_2,
enable, hide, priority, sort, group, notes, created_on, updated_on, [group+priority+sort+updated_on]`
});
}
}

View File

@@ -117,6 +117,7 @@ if ($idaa_slct.archive_content_id) {
// Initialized AFTER the init block above so new-item defaults are in place.
interface ArchiveContentForm {
name: string;
code: string;
archive_content_type: string;
filename: string;
file_extension: string;
@@ -134,6 +135,7 @@ interface ArchiveContentForm {
function create_archive_content_form(obj: any, current_timezone = ''): ArchiveContentForm {
return {
name: obj?.name ?? '',
code: obj?.code ?? '',
archive_content_type: obj?.archive_content_type ?? 'hosted_file',
filename: obj?.filename ?? '',
file_extension: obj?.file_extension ?? '',
@@ -223,6 +225,7 @@ async function handle_submit_form(event: SubmitEvent) {
}
archive_content_do['name'] = archive_content_di.name;
archive_content_do['code'] = archive_content_di?.code?.trim() || null;
// Check if the description_new_html exists and is a string
if (typeof description_new_html === 'string') {
@@ -888,6 +891,19 @@ $effect(() => {
<div
class="space-y-3"
class:hidden={!$idaa_loc.archives.show__admin_options}>
{#if $ae_loc.edit_mode}
<label class="text-sm font-semibold" for="code">
Code
<input
type="text"
id="code"
name="code"
bind:value={archive_content_form.code}
maxlength="100"
class="input preset-tonal-surface form-control w-48"
placeholder="short-code" />
</label>
{/if}
<span
class="flex w-full flex-col flex-wrap items-center justify-center gap-2 md:flex-row md:justify-stretch">
<span

View File

@@ -67,7 +67,7 @@ file_icons['zip'] = 'file-archive';
class="archive_list flex w-full flex-col items-center justify-center gap-2">
{#if $ae_loc.trusted_access && $ae_loc.edit_mode}
<div
class="mb-2 flex w-full max-w-(--breakpoint-lg) flex-row items-center justify-start px-2">
class="mb-2 flex w-full max-w-(--breakpoint-lg) flex-row items-center justify-center px-2">
<button
type="button"
disabled={creating}

View File

@@ -68,7 +68,7 @@ let sorted_archive_obj_li = $derived.by(() => {
flex w-full flex-col items-center justify-center gap-2
">
<div
class="mb-2 flex w-full max-w-(--breakpoint-lg) flex-row items-center justify-between gap-2 px-2">
class="mb-2 flex w-full max-w-(--breakpoint-lg) flex-row items-center justify-center gap-2 px-2">
{#if $ae_loc.trusted_access && $ae_loc.edit_mode}
<button
type="button"
@@ -114,8 +114,6 @@ let sorted_archive_obj_li = $derived.by(() => {
<span class="fas fa-plus m-1"></span> Create New Archive
{/if}
</button>
{:else}
<span></span>
{/if}
<div class="flex flex-row items-center gap-2">