Now the list of archives shows.

This commit is contained in:
Scott Idem
2024-11-05 17:05:46 -05:00
parent 4d667d57a4
commit b9698615be
6 changed files with 257 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ import { api } from '$lib/api';
import { db_archives } from "$lib/db_archives";
import { load_ae_obj_li__archive_content } from "$lib/ae_archives__archive_content";
import { load_ae_obj_li__archive_content } from "$lib/ae_archives/ae_archives__archive_content";
let ae_promises: key_val = {};

View File

@@ -7,7 +7,7 @@ import {
update_ae_obj__archive,
// qry__archive,
db_save_ae_obj_li__archive,
} from "$lib/ae_archives__archive";
} from "$lib/ae_archives/ae_archives__archive";
import {
@@ -17,7 +17,7 @@ import {
update_ae_obj__archive_content,
// qry__archive_content,
db_save_ae_obj_li__archive_content,
} from "$lib/ae_archives__archive_content";
} from "$lib/ae_archives/ae_archives__archive_content";
let export_obj = {

View File

@@ -0,0 +1,46 @@
/** @type {import('./$types').LayoutLoad} */
console.log(`IDAA BB - [account_id] +layout.ts start`);
import { error } from '@sveltejs/kit';
import { browser } from '$app/environment';
import { archives_func } from '$lib/ae_archives/ae_archives_functions';
export async function load({ params, parent }) { // route
let log_lvl = 0;
let data = await parent();
data.log_lvl = log_lvl;
let account_id = data.account_id;
let ae_acct = data[account_id];
// console.log(`ae_acct = `, ae_acct);
if (!account_id) {
console.log(`ae IDAA Archives - [account_id] +page.ts: The account_id was not found!!!`);
error(404, {
message: 'Account ID not found'
});
}
ae_acct.slct.account_id = account_id;
if (browser) {
let load_event_obj_li = archives_func.load_ae_obj_li__archive({
api_cfg: ae_acct.api,
for_obj_type: 'account',
for_obj_id: account_id,
inc_content_li: true,
order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'name': 'ASC'},
params: {qry__enabled: 'enabled', qry__hidden: 'all', qry__limit: 200},
try_cache: true,
log_lvl: log_lvl
});
console.log(`load_event_obj_li = `, load_event_obj_li);
ae_acct.slct.event_obj_li = load_event_obj_li;
}
// WARNING: Precaution against shared data between sites and sessions.
data[account_id] = ae_acct;
return data;
}

View File

@@ -1,8 +1,90 @@
<script lang="ts">
/** @type {import('./$types').PageData} */
export let data: any;
let log_lvl = 2;
// console.log(`ae_events_pres_mgmt event [event_id] +page.svelte data:`, data);
let log_lvl = 1;
// console.log(`ae_idaa_bb +page.svelte data:`, data);
import { browser } from '$app/environment';
import { Modal } from 'flowbite-svelte';
import type { key_val } from '$lib/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';
import { liveQuery } from "dexie";
import { core_func } from '$lib/ae_core/ae_core_functions';
import { db_archives } from "$lib/db_archives";
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { idaa_loc, idaa_sess, idaa_slct, idaa_trigger } from '$lib/ae_idaa_stores';
import { archives_func } from '$lib/ae_archives/ae_archives_functions';
import Comp__archive_obj_li from './ae_idaa_comp__archive_obj_li.svelte';
$: lq__archive_obj_li = liveQuery(async () => {
let results = await db_archives.archive
.where('account_id')
.equals($slct.account_id)
// .orderBy('updated_on')
// .toArray()
.reverse()
.sortBy('updated_on');
// .sortBy('updated_on, created_on');
// .sortBy('[updated_on+created_on]');
// .sortBy('[created_on+updated_on]');
return results;
});
$: lq__archive_obj = liveQuery(async () => {
let results = await db_archives.archive
.get($idaa_slct.archive_id);
return results;
});
$: lq__archive_content_obj_li = liveQuery(async () => {
let results = await db_posts.comment
.where('post_id')
.equals($idaa_slct.post_id)
.reverse()
.sortBy('updated_on');
// .sortBy('title');
return results;
});
$: lq__archive_content_obj = liveQuery(async () => {
let results = await db_posts.comment
.get($idaa_slct.archive_content_id);
return results;
});
</script>
<section
class="
ae_idaa__bb
container h-full mx-auto
flex flex-col gap-1
py-1 px-2 pb-16
items-center
min-w-full
max-w-max
"
>
<!-- <h1>Archives {$lq__archive_obj_li?.length}</h1> -->
{#if $lq__archive_obj_li && $lq__archive_obj_li?.length }
<Comp__archive_obj_li
lq__archive_obj_li={lq__archive_obj_li}
/>
{:else}
<p>No archives available to show.</p>
{/if}
</section>

View File

@@ -0,0 +1,123 @@
<script lang="ts">
// *** Import Svelte core
import { onMount } from 'svelte';
import { Spinner } from 'flowbite-svelte';
// *** Import Aether core variables and functions
import { ae_util } from '$lib/ae_utils/ae_utils';
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { idaa_loc, idaa_sess, idaa_slct } from '$lib/ae_idaa_stores';
export let lq__archive_obj_li: any;
onMount(() => {
console.log('** Component Mounted: ** List - Archive Obj');
});
</script>
<section class="archive_list">
{#if $lq__archive_obj_li && $lq__archive_obj_li.length}
{#each $lq__archive_obj_li as idaa_archive_obj, index}
<div
class="container archive archive_obj border border-1 rounded p-2 mb-2 space-y-2"
class:dim={idaa_archive_obj.hide}
class:bg-warning-100={!idaa_archive_obj?.enable}
>
<header class="ae_header flex flex-row gap-2 items-center">
<h3 class="archive__name h3">
<span class="archive__name">{@html idaa_archive_obj.name}</span>
</h3>
{#if idaa_archive_obj.original_location}
&mdash;
<h4 class="h4">
<!-- <span class="ae_label">Location:</span> -->
<span class="ae_value">{idaa_archive_obj.original_location}</span>
</h4>
{/if}
</header>
{#if idaa_archive_obj.description}<pre class="archive__description p-2 bg-white shadow-md rounded-lg text-wrap text-sm font-normal whitespace-pre-wrap">{@html idaa_archive_obj.description}</pre>{/if}
<div class="ae_options flex flex-row gap-2 items-center justify-center">
<button
on:click={() => {
$idaa_slct.archive_id = idaa_archive_obj?.archive_id;
$idaa_slct.archive_obj = idaa_archive_obj;
// handle_load_post_comment_obj_li({archive_id: $idaa_slct.archive_id, try_cache: false});
const url = new URL(location);
url.searchParams.set('archive_id', idaa_archive_obj?.archive_id);
history.pushState({}, '', url);
let message = {'archive_id': idaa_archive_obj?.archive_id};
window.parent.postMessage(message, "*");
// $idaa_sess.archives.show_main__options = true;
// $idaa_sess.archives.show_list__archive_obj_li = true;
// $idaa_sess.archives.show_edit__archive_id = false;
$idaa_sess.archives.show__modal_view = true;
$idaa_sess.archives.show__modal_edit = false;
}}
class="btn btn-md variant-ghost-primary hover:variant-filled-primary transition"
title={`View: ${idaa_archive_obj?.title}`}
>
<span class="fas fa-envelope-open m-1"></span> Open
{#if idaa_archive_obj?.archive_content_count}
<span class="ae_badge ae_info archive__archive_content_count">
<span class="fas fa-content"></span> {(idaa_archive_obj?.archive_content_count == 1 ? `${idaa_archive_obj?.archive_content_count} content` : `${idaa_archive_obj?.archive_content_count} contents` )}
</span>
{/if}
</button>
{#if $ae_loc.administrator_access}
<button
on:click={() => {
$idaa_slct.archive_id = idaa_archive_obj.archive_id;
$idaa_slct.archive_obj = idaa_archive_obj;
$idaa_sess.archives.show__modal_view = false;
$idaa_sess.archives.show__modal_edit__archive_obj = true;
}}
class="btn btn-sm variant-ghost-warning hover:variant-filled-warning transition"
title={`Edit archive: ${idaa_archive_obj.title}`}
>
<span class="fas fa-edit m-1"></span> Edit Archive
</button>
{/if}
</div>
<section class="ae_section ae_footer ae_meta archive__meta">
<div class="ae_group">
{#if !idaa_archive_obj.updated_on}
<span
class="archive__created_on"
>
<span class="ae_label">Created on:</span>
<span class="ae_value">{ae_util.iso_datetime_formatter(idaa_archive_obj.created_on, 'datetime_short')}</span>
</span>
{:else}
<span
class="archive__updated_on"
>
<span class="ae_label">Updated on:</span>
<span class="ae_value">{ae_util.iso_datetime_formatter(idaa_archive_obj.updated_on, 'datetime_short')}</span>
</span>
{/if}
</div>
</section>
</div>
{/each}
{:else}
No archives found at this time
{/if}
</section>
<!-- {/if} -->

View File

@@ -130,7 +130,7 @@ onMount(() => {
</div>
{/each}
<!-- </ul> -->
{:else}
No posts found at this time
{/if}