Now the list of archives shows.
This commit is contained in:
@@ -3,7 +3,7 @@ import { api } from '$lib/api';
|
|||||||
|
|
||||||
import { db_archives } from "$lib/db_archives";
|
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 = {};
|
let ae_promises: key_val = {};
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
update_ae_obj__archive,
|
update_ae_obj__archive,
|
||||||
// qry__archive,
|
// qry__archive,
|
||||||
db_save_ae_obj_li__archive,
|
db_save_ae_obj_li__archive,
|
||||||
} from "$lib/ae_archives__archive";
|
} from "$lib/ae_archives/ae_archives__archive";
|
||||||
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
update_ae_obj__archive_content,
|
update_ae_obj__archive_content,
|
||||||
// qry__archive_content,
|
// qry__archive_content,
|
||||||
db_save_ae_obj_li__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 = {
|
let export_obj = {
|
||||||
|
|||||||
46
src/routes/idaa/(idaa)/archives/+layout.ts
Normal file
46
src/routes/idaa/(idaa)/archives/+layout.ts
Normal 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;
|
||||||
|
}
|
||||||
@@ -1,8 +1,90 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
/** @type {import('./$types').PageData} */
|
/** @type {import('./$types').PageData} */
|
||||||
export let data: any;
|
export let data: any;
|
||||||
let log_lvl = 2;
|
let log_lvl = 1;
|
||||||
// console.log(`ae_events_pres_mgmt event [event_id] +page.svelte data:`, data);
|
// 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>
|
</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>
|
||||||
@@ -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}
|
||||||
|
—
|
||||||
|
<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} -->
|
||||||
@@ -130,7 +130,7 @@ onMount(() => {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
<!-- </ul> -->
|
|
||||||
{:else}
|
{:else}
|
||||||
No posts found at this time
|
No posts found at this time
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user