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:
@@ -299,6 +299,7 @@ export const properties_to_save = [
|
|||||||
'archive_id',
|
'archive_id',
|
||||||
'archive_content_type',
|
'archive_content_type',
|
||||||
'name',
|
'name',
|
||||||
|
'code',
|
||||||
'description',
|
'description',
|
||||||
'content_html',
|
'content_html',
|
||||||
'content_json',
|
'content_json',
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ export interface Archive_Content {
|
|||||||
archive_content_type: string;
|
archive_content_type: string;
|
||||||
|
|
||||||
name: string;
|
name: string;
|
||||||
|
code?: null | string;
|
||||||
description?: null | string;
|
description?: null | string;
|
||||||
|
|
||||||
content_html?: null | string;
|
content_html?: null | string;
|
||||||
@@ -168,7 +169,28 @@ export class MySubClassedDexie extends Dexie {
|
|||||||
tmp_sort_1, tmp_sort_2,
|
tmp_sort_1, tmp_sort_2,
|
||||||
enable, hide, priority, sort, group, notes, created_on, updated_on, [group+priority+sort+updated_on]`
|
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]`
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ if ($idaa_slct.archive_content_id) {
|
|||||||
// Initialized AFTER the init block above so new-item defaults are in place.
|
// Initialized AFTER the init block above so new-item defaults are in place.
|
||||||
interface ArchiveContentForm {
|
interface ArchiveContentForm {
|
||||||
name: string;
|
name: string;
|
||||||
|
code: string;
|
||||||
archive_content_type: string;
|
archive_content_type: string;
|
||||||
filename: string;
|
filename: string;
|
||||||
file_extension: string;
|
file_extension: string;
|
||||||
@@ -134,6 +135,7 @@ interface ArchiveContentForm {
|
|||||||
function create_archive_content_form(obj: any, current_timezone = ''): ArchiveContentForm {
|
function create_archive_content_form(obj: any, current_timezone = ''): ArchiveContentForm {
|
||||||
return {
|
return {
|
||||||
name: obj?.name ?? '',
|
name: obj?.name ?? '',
|
||||||
|
code: obj?.code ?? '',
|
||||||
archive_content_type: obj?.archive_content_type ?? 'hosted_file',
|
archive_content_type: obj?.archive_content_type ?? 'hosted_file',
|
||||||
filename: obj?.filename ?? '',
|
filename: obj?.filename ?? '',
|
||||||
file_extension: obj?.file_extension ?? '',
|
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['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
|
// Check if the description_new_html exists and is a string
|
||||||
if (typeof description_new_html === 'string') {
|
if (typeof description_new_html === 'string') {
|
||||||
@@ -888,6 +891,19 @@ $effect(() => {
|
|||||||
<div
|
<div
|
||||||
class="space-y-3"
|
class="space-y-3"
|
||||||
class:hidden={!$idaa_loc.archives.show__admin_options}>
|
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
|
<span
|
||||||
class="flex w-full flex-col flex-wrap items-center justify-center gap-2 md:flex-row md:justify-stretch">
|
class="flex w-full flex-col flex-wrap items-center justify-center gap-2 md:flex-row md:justify-stretch">
|
||||||
<span
|
<span
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ file_icons['zip'] = 'file-archive';
|
|||||||
class="archive_list flex w-full flex-col items-center justify-center gap-2">
|
class="archive_list flex w-full flex-col items-center justify-center gap-2">
|
||||||
{#if $ae_loc.trusted_access && $ae_loc.edit_mode}
|
{#if $ae_loc.trusted_access && $ae_loc.edit_mode}
|
||||||
<div
|
<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
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
disabled={creating}
|
disabled={creating}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ let sorted_archive_obj_li = $derived.by(() => {
|
|||||||
flex w-full flex-col items-center justify-center gap-2
|
flex w-full flex-col items-center justify-center gap-2
|
||||||
">
|
">
|
||||||
<div
|
<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}
|
{#if $ae_loc.trusted_access && $ae_loc.edit_mode}
|
||||||
<button
|
<button
|
||||||
type="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
|
<span class="fas fa-plus m-1"></span> Create New Archive
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
{:else}
|
|
||||||
<span></span>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="flex flex-row items-center gap-2">
|
<div class="flex flex-row items-center gap-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user