Making the URL update when viewing and closing specific content. Other clean up.

This commit is contained in:
Scott Idem
2024-11-08 13:57:16 -05:00
parent 13d906428b
commit e6a9a5ceab
10 changed files with 108 additions and 63 deletions

View File

@@ -1,7 +1,6 @@
<script lang="ts">
import { onMount } from 'svelte';
import { fade } from 'svelte/transition';
import { Modal } from 'flowbite-svelte';
import { onDestroy } from 'svelte';
import { browser } from '$app/environment';
// *** Import Aether core variables and functions
import { ae_util } from '$lib/ae_utils/ae_utils';
@@ -15,7 +14,6 @@ export let lq__post_obj: any;
export let lq__post_comment_obj_li: any;
export let lq__post_comment_obj: any;
// import Edit_post_comment_obj from './10_edit__post_comment_obj.svelte';
if ($idaa_slct.post_id) {
console.log(`Post ID selected: ${$idaa_slct.post_id}`);
@@ -24,51 +22,63 @@ if ($idaa_slct.post_id) {
$idaa_trigger = 'load__post_obj';
}
onMount(() => {
$: if (browser && $lq__post_obj?.post_id) {
console.log('** Component Mounted: ** View - Post Obj');
const url = new URL(location);
url.searchParams.set('post_id', $lq__post_obj?.post_id);
history.pushState({}, '', url);
}
onDestroy(() => {
console.log('** Component Destroyed: ** View - Post Obj');
const url = new URL(location);
url.searchParams.delete('post_id');
history.pushState({}, '', url);
});
function handle_post_comment_obj_created(event) {
console.log('*** handle_post_comment_obj_created() ***');
console.log(event.detail);
// function handle_post_comment_obj_created(event) {
// console.log('*** handle_post_comment_obj_created() ***');
// console.log(event.detail);
$idaa_slct.post_comment_id = null;
$idaa_slct.post_comment_obj = {};
// $idaa_slct.post_comment_id = null;
// $idaa_slct.post_comment_obj = {};
$idaa_trigger = 'load__post_obj_li';
$idaa_trigger = 'load__post_obj';
$idaa_trigger = 'load__post_comment_obj_li';
// $idaa_trigger = 'load__post_obj_li';
// $idaa_trigger = 'load__post_obj';
// $idaa_trigger = 'load__post_comment_obj_li';
// $idaa_sess.bb.show_post_list = false;
// $idaa_sess.bb.show_edit__post_id = false;
// $idaa_sess.bb.show_view__post_id = true;
$idaa_sess.bb.show_edit__post_comment = false;
}
function handle_post_comment_obj_updated(event) {
console.log('*** handle_post_comment_obj_updated() ***');
console.log(event.detail);
// // $idaa_sess.bb.show_post_list = false;
// // $idaa_sess.bb.show_edit__post_id = false;
// // $idaa_sess.bb.show_view__post_id = true;
// $idaa_sess.bb.show_edit__post_comment = false;
// }
// function handle_post_comment_obj_updated(event) {
// console.log('*** handle_post_comment_obj_updated() ***');
// console.log(event.detail);
$idaa_trigger = 'load__post_obj';
$idaa_trigger = 'load__post_comment_obj_li';
// $idaa_trigger = 'load__post_obj';
// $idaa_trigger = 'load__post_comment_obj_li';
// $idaa_sess.bb.show_post_list = false;
// $idaa_sess.bb.show_edit__post_id = false;
// $idaa_sess.bb.show_view__post_id = true;
$idaa_sess.bb.show_edit__post_comment = false;
}
function handle_post_comment_obj_deleted(event) {
console.log('*** handle_post_comment_obj_deleted() ***');
console.log(event.detail);
// // $idaa_sess.bb.show_post_list = false;
// // $idaa_sess.bb.show_edit__post_id = false;
// // $idaa_sess.bb.show_view__post_id = true;
// $idaa_sess.bb.show_edit__post_comment = false;
// }
// function handle_post_comment_obj_deleted(event) {
// console.log('*** handle_post_comment_obj_deleted() ***');
// console.log(event.detail);
$idaa_trigger = 'load__post_obj_li';
$idaa_trigger = 'load__post_obj';
$idaa_trigger = 'load__post_comment_obj_li';
// $idaa_trigger = 'load__post_obj_li';
// $idaa_trigger = 'load__post_obj';
// $idaa_trigger = 'load__post_comment_obj_li';
// $idaa_sess.bb.show_post_list = false;
// $idaa_sess.bb.show_edit__post_id = false;
// $idaa_sess.bb.show_view__post_id = true;
$idaa_sess.bb.show_edit__post_comment = false;
}
// // $idaa_sess.bb.show_post_list = false;
// // $idaa_sess.bb.show_edit__post_id = false;
// // $idaa_sess.bb.show_view__post_id = true;
// $idaa_sess.bb.show_edit__post_comment = false;
// }
</script>
@@ -134,6 +144,7 @@ function handle_post_comment_obj_deleted(event) {
<span class="fas fa-comment"></span> {($idaa_slct.post_obj.post_comment_count == 1 ? `${$idaa_slct.post_obj.post_comment_count} comment` : `${$idaa_slct.post_obj.post_comment_count} comments` )}
</span>
{/if}
{#if ($ae_loc.trusted_access && $ae_loc.edit_mode) || $idaa_loc.novi_uuid}
<button
on:click={() => {
if (confirm('Are you sure you want to add a new comment?')) {
@@ -145,8 +156,9 @@ function handle_post_comment_obj_deleted(event) {
>
<span class="fas fa-plus m-1"></span> New Comment
</button>
{/if}
{#if $ae_loc.trusted_access || $idaa_slct.post_obj.external_person_id === $idaa_loc.novi_uuid}
{#if ($ae_loc.trusted_access && $ae_loc.edit_mode) || $idaa_slct.post_obj.external_person_id === $idaa_loc.novi_uuid}
<button
on:click={() => {
// $idaa_slct.post_id = $idaa_slct.post_obj.post_id_random;
@@ -172,8 +184,6 @@ function handle_post_comment_obj_deleted(event) {
{/if}
{#if $lq__post_comment_obj_li?.length}
<section class="post_comment_obj_li space-y-2 border border-1 rounded p-2 border-y-4">
{#each $lq__post_comment_obj_li as post_comment_obj, index}
@@ -213,7 +223,7 @@ function handle_post_comment_obj_deleted(event) {
</span>
</div>
{#if $ae_loc.trusted_access || post_comment_obj.external_person_id === $idaa_loc.novi_uuid}
{#if ($ae_loc.trusted_access && $ae_loc.edit_mode) || post_comment_obj.external_person_id === $idaa_loc.novi_uuid}
<div class="ae_options">
<button on:click={() => {
$idaa_slct.post_comment_id = post_comment_obj.post_comment_id;

View File

@@ -68,7 +68,7 @@ onMount(() => {
{/if}
</button>
{#if $ae_loc.trusted_access || idaa_post_obj.external_person_id === $idaa_loc.novi_uuid}
{#if ($ae_loc.trusted_access && $ae_loc.edit_mode) || idaa_post_obj.external_person_id === $idaa_loc.novi_uuid}
<button
on:click={() => {
$idaa_slct.post_id = idaa_post_obj.post_id;