General clean up. Better sorting for the IDAA Archives and BB Posts and Comments

This commit is contained in:
Scott Idem
2025-08-12 13:24:03 -04:00
parent 2f19422c72
commit 0ecb9d15b0
8 changed files with 24 additions and 24 deletions

View File

@@ -938,8 +938,8 @@ export async function process_ae_obj__archive_props({
updated_on: obj.updated_on,
// Generated fields for sorting locally only
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
tmp_sort_1: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on ?? obj.created_on}`,
tmp_sort_2: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on}_${obj.created_on}`,
// From SQL view
// archive_content_count: obj.archive_content_count,

View File

@@ -625,8 +625,9 @@ export async function process_ae_obj__archive_content_props({
updated_on: obj.updated_on,
// Generated fields for sorting locally only
tmp_sort_1: `${obj.original_datetime ?? ''}_${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(2, '0') ?? ''}`,
tmp_sort_2: `${obj.group ?? ''}_${obj.original_datetime ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(2, '0') ?? ''}`,
tmp_sort_1: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.original_datetime ?? ''}`,
tmp_sort_2: `${obj.group ?? ''}_${obj.original_datetime ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}`,
tmp_sort_3: `${obj.original_datetime ?? ''}_${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}`,
// tmp_sort_a: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
// tmp_sort_b: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,

View File

@@ -847,8 +847,8 @@ export function db_save_ae_obj_li__post(
created_on: obj.created_on,
updated_on: obj.updated_on,
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
tmp_sort_1: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on ?? obj.created_on}`,
tmp_sort_2: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on}_${obj.created_on}`,
// From SQL view
post_comment_count: obj.post_comment_count,

View File

@@ -466,6 +466,9 @@ export function db_save_ae_obj_li__post_comment(
created_on: obj.created_on,
updated_on: obj.updated_on,
tmp_sort_1: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on ?? obj.created_on}`,
tmp_sort_2: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(2, '0') ?? ''}_${obj.updated_on}_${obj.created_on}`,
// From SQL view
});
if (log_lvl) {

View File

@@ -93,14 +93,13 @@ let lq__archive_content_obj_li = $derived(liveQuery(async () => {
console.log(`$lq__archive_obj.cfg_json = `, $lq__archive_obj?.cfg_json);
}
if ($lq__archive_obj?.cfg_json?.content_group_sort === 'DESC') {
// Really this should be called sort by original datetime with the newest being first
let results = await db_archives.content
// .orderBy('updated_on')
.where('archive_id')
.equals($idaa_slct?.archive_id ?? '') // null or undefined does not reset things like '' does
.reverse()
.sortBy('tmp_sort_2');
// .sortBy('updated_on');
// .sortBy('title');
return results;
} else {
@@ -108,7 +107,7 @@ let lq__archive_content_obj_li = $derived(liveQuery(async () => {
.where('archive_id')
.equals($idaa_slct?.archive_id ?? '') // null or undefined does not reset things like '' does
// .reverse()
.sortBy('tmp_sort_2');
.sortBy('tmp_sort_1');
return results;
}

View File

@@ -67,7 +67,10 @@ let lq__post_comment_obj_li = $derived(liveQuery(async () => {
.where('post_id')
.equals($idaa_slct.post_id ?? '') // null or undefined does not reset things like '' does
.reverse()
.sortBy('updated_on');
.limit($idaa_loc.bb.qry__limit)
.sortBy('tmp_sort_1');
// .sortBy('created_on');
// .sortBy('updated_on');
// .sortBy('title');
if ($idaa_slct.post_comment_obj_li && JSON.stringify($idaa_slct.post_comment_obj_li) !== JSON.stringify(results)) {

View File

@@ -2,19 +2,18 @@
interface Props {
log_lvl?: number;
lq__post_obj: any;
lq__post_comment_obj: any;
lq__post_comment_obj_li?: any;
// lq__post_comment_obj: any;
// lq__post_comment_obj_li?: any;
}
let {
log_lvl = $bindable(1),
lq__post_obj,
lq__post_comment_obj,
lq__post_comment_obj_li
// lq__post_comment_obj,
// lq__post_comment_obj_li
}: Props = $props();
// *** Import Svelte specific
// import { createEventDispatcher, onDestroy, onMount } from 'svelte';
import { fade } from 'svelte/transition';
// *** Import other supporting libraries
@@ -48,8 +47,6 @@ function preventDefault(fn) {
async function handle_submit_form(event: any) {
if (log_lvl > 1) {
console.log('*** handle_submit_form() ***', event.target);
console.log($lq__post_obj);
console.log($lq__post_comment_obj);
}
disable_submit_btn = true;
@@ -454,11 +451,7 @@ function send_poster_commenters_notification_email(
<input type="hidden" value={$idaa_slct.post_comment_id} />
<div class="ae_section post__general_information border border-gray-200 rounded p-1 space-y-1"> <!-- BEGIN: section post__general_information -->
<!-- <label for="title">Title of BB Post:
<input type="text" id="title" name="title" required max="200" value={$lq__post_comment_obj?.title} placeholder="Title of Post" autocomplete="off" class="input w-96" />
</label> -->
<div class="ae_section post_comment__general_information border border-gray-200 rounded p-1 space-y-1"> <!-- BEGIN: section post_comment__general_information -->
<label for="content" class="ae_label post__content w-full">
<span class="legend text-sm font-semibold text-gray-600 dark:text-gray-400">

View File

@@ -345,10 +345,11 @@ $effect(() => {
{/if}
</span>
<span class="post_comment__created_on_updated_on">
{#if !post_comment_obj.updated_on}
{#if !post_comment_obj.updated_on || $ae_loc.edit_mode }
<span class="ae_label">Created on:</span>
<span class="ae_value post_comment__created_on">{ae_util.iso_datetime_formatter(post_comment_obj.created_on, 'datetime_12_short')}</span>
{:else}
{/if}
{#if post_comment_obj.updated_on }
<span class="ae_label">Updated on:</span>
<span class="ae_value post_comment__updated_on">{ae_util.iso_datetime_formatter(post_comment_obj.updated_on, 'datetime_12_short')}</span>
{/if}