Started pulling in the IDAA Bulletin Board code
This commit is contained in:
@@ -19,6 +19,12 @@ let idaa_local_data_struct: key_val = {
|
||||
name: 'Aether - IDAA (SvelteKit 2.x Svelte 4.x)',
|
||||
title: `OSIT's Æ IDAA`, // - Dev SvelteKit`, // Æ
|
||||
|
||||
novi_uuid: null,
|
||||
novi_email: null,
|
||||
novi_full_name: null,
|
||||
novi_admin_li: [],
|
||||
novi_trusted_li: [],
|
||||
|
||||
'ds': {},
|
||||
|
||||
'idaa_cfg_json': {},
|
||||
@@ -34,8 +40,8 @@ let idaa_local_data_struct: key_val = {
|
||||
|
||||
},
|
||||
|
||||
posts: {
|
||||
|
||||
bb: {
|
||||
show_list__post_obj_li: true,
|
||||
},
|
||||
|
||||
recovery_meetings: {
|
||||
@@ -64,7 +70,7 @@ let idaa_session_data_struct: key_val = {
|
||||
|
||||
},
|
||||
|
||||
posts: {
|
||||
bb: {
|
||||
|
||||
},
|
||||
|
||||
@@ -110,4 +116,11 @@ let idaa_slct_obj_template: key_val = {
|
||||
export let idaa_slct = writable(idaa_slct_obj_template);
|
||||
|
||||
// This works and uses *local* storage:
|
||||
// export let idaa_slct: Writable<key_val> = localStorageStore('ae_idaa_slct', idaa_slct_obj_template);
|
||||
// export let idaa_slct: Writable<key_val> = localStorageStore('ae_idaa_slct', idaa_slct_obj_template);
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize idaa_trigger */
|
||||
// Intended for temporary session storage.
|
||||
// Updated 2024-03-06
|
||||
export let idaa_trigger: any = writable(null);
|
||||
// console.log(`AE IDAA Stores - IDAA Trigger:`, idaa_trigger);
|
||||
|
||||
@@ -97,7 +97,7 @@ export async function load_ae_obj_li__post(
|
||||
for_obj_type = 'account',
|
||||
for_obj_id,
|
||||
inc_comment_li = false,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'title': 'ASC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
@@ -591,6 +591,7 @@ export function db_save_ae_obj_li__post(
|
||||
|
||||
topic_id: obj.topic_id,
|
||||
topic: obj.topic,
|
||||
topic_name: obj.topic_name,
|
||||
|
||||
title: obj.title,
|
||||
content: obj.content,
|
||||
|
||||
@@ -21,6 +21,7 @@ export interface Post {
|
||||
|
||||
topic_id?: string;
|
||||
topic?: string; // or topic_name?
|
||||
topic_name?: string;
|
||||
|
||||
// name: null|string;
|
||||
// summary?: null|string;
|
||||
|
||||
21
src/routes/idaa/(idaa)/bb/+layout.svelte
Normal file
21
src/routes/idaa/(idaa)/bb/+layout.svelte
Normal file
@@ -0,0 +1,21 @@
|
||||
<script lang="ts">
|
||||
/** @type {import('./$types').LayoutData} */
|
||||
export let data: any;
|
||||
let log_lvl = 2;
|
||||
console.log(`ae_idaa_bulletin_board +layout.svelte data:`, data);
|
||||
|
||||
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';
|
||||
|
||||
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
|
||||
$slct.account_id = data.account_id;
|
||||
// console.log(`$slct.account_id = `, $slct.account_id);
|
||||
let ae_acct = data[$slct.account_id];
|
||||
console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
$idaa_slct.post_obj_li = ae_acct.slct.post_obj_li;
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<slot />
|
||||
46
src/routes/idaa/(idaa)/bb/+layout.ts
Normal file
46
src/routes/idaa/(idaa)/bb/+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 { posts_func } from '$lib/ae_posts_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 BB - [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 = posts_func.load_ae_obj_li__post({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: account_id,
|
||||
inc_comment_li: true,
|
||||
order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'title': '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;
|
||||
}
|
||||
81
src/routes/idaa/(idaa)/bb/+page.svelte
Normal file
81
src/routes/idaa/(idaa)/bb/+page.svelte
Normal file
@@ -0,0 +1,81 @@
|
||||
<script lang="ts">
|
||||
/** @type {import('./$types').PageData} */
|
||||
export let data: any;
|
||||
let log_lvl = 2;
|
||||
// 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_functions';
|
||||
import { db_posts } from "$lib/db_posts";
|
||||
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 { posts_func } from '$lib/ae_posts_functions';
|
||||
|
||||
import Comp__post_obj_li from './ae_idaa_comp__post_obj_li.svelte';
|
||||
import Comp__post_obj_id_view from './ae_idaa_comp__post_obj_id_view.svelte';
|
||||
|
||||
|
||||
$: lq__post_obj_li = liveQuery(async () => {
|
||||
let results = await db_posts.post
|
||||
.where('account_id')
|
||||
.equals($slct.account_id)
|
||||
.sortBy('name');
|
||||
|
||||
return results;
|
||||
});
|
||||
|
||||
$: lq__post_obj = liveQuery(async () => {
|
||||
let results = await db_posts.post
|
||||
.get($idaa_slct.post_id);
|
||||
|
||||
return results;
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<section
|
||||
class="
|
||||
ae_idaa__recovery_meetings
|
||||
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>Bulletin Board {$lq__post_obj_li?.length}</h1>
|
||||
{#if $lq__post_obj_li && $lq__post_obj_li?.length }
|
||||
<Comp__post_obj_li
|
||||
lq__post_obj_li={lq__post_obj_li}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
<!-- Main modal -->
|
||||
<Modal
|
||||
title="{$lq__post_obj?.title} - {$lq__post_obj?.id}"
|
||||
bind:open={$idaa_slct.post_id}
|
||||
autoclose={false}
|
||||
size="xl"
|
||||
class="bg-white dark:bg-gray-800 text-gray-800 dark:text-gray-200 rounded-lg border-gray-200 dark:border-gray-700 divide-gray-200 dark:divide-gray-700 shadow-md relative flex flex-col mx-auto w-full divide-y"
|
||||
>
|
||||
|
||||
<Comp__post_obj_id_view
|
||||
lq__post_obj={lq__post_obj}
|
||||
/>
|
||||
|
||||
</Modal>
|
||||
@@ -16,7 +16,7 @@ import { slct, slct_trigger, ae_app } from './stores';
|
||||
|
||||
// *** Import Aether module components
|
||||
import Edit_post_obj from './10_edit__post_obj.svelte';
|
||||
import View_post_obj from './10_view__post_obj.svelte';
|
||||
import View_post_obj from './ae_idaa_comp__post_obj_id_view.svelte';
|
||||
|
||||
// *** Export/Exposed variables and functions for component
|
||||
export let account_id: string = $ae_app.account_id;
|
||||
263
src/routes/idaa/(idaa)/bb/ae_idaa_comp__post_obj_id_view.svelte
Normal file
263
src/routes/idaa/(idaa)/bb/ae_idaa_comp__post_obj_id_view.svelte
Normal file
@@ -0,0 +1,263 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher, onMount } from 'svelte';
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
// *** 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, idaa_trigger } from '$lib/ae_idaa_stores';
|
||||
|
||||
// import Edit_post_comment_obj from './10_edit__post_comment_obj.svelte';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
if ($idaa_slct.post_id) {
|
||||
console.log(`Post ID selected: ${$idaa_slct.post_id}`);
|
||||
console.log(`Post Object selected: ${$idaa_slct.post_obj}`)
|
||||
|
||||
$idaa_trigger = 'load__post_obj';
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
console.log('** Component Mounted: ** View - Post Obj');
|
||||
});
|
||||
|
||||
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_trigger = 'load__post_obj_li';
|
||||
$idaa_trigger = 'load__post_obj';
|
||||
$idaa_trigger = 'load__post_comment_obj_li';
|
||||
|
||||
// $idaa_loc.posts.show_post_list = false;
|
||||
// $idaa_loc.posts.show_edit__post_id = false;
|
||||
// $idaa_loc.posts.show_view__post_id = true;
|
||||
$idaa_loc.posts.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_loc.posts.show_post_list = false;
|
||||
// $idaa_loc.posts.show_edit__post_id = false;
|
||||
// $idaa_loc.posts.show_view__post_id = true;
|
||||
$idaa_loc.posts.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_loc.posts.show_post_list = false;
|
||||
// $idaa_loc.posts.show_edit__post_id = false;
|
||||
// $idaa_loc.posts.show_view__post_id = true;
|
||||
$idaa_loc.posts.show_edit__post_comment = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<section
|
||||
bind:clientHeight={$ae_loc.iframe_height_modal_body}
|
||||
class="svelte_component ae_section ae_view post_obj view__post_obj"
|
||||
>
|
||||
|
||||
<div class="post__header">
|
||||
<h2 class="post__title">
|
||||
{@html $idaa_slct.post_obj.title}
|
||||
{#if $idaa_slct.post_obj.topic_id}<span class="badge badge-info bg-info"><span class="fas fa-user-md"></span> {$idaa_slct.post_obj.topic_name}</span>{/if}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="post__content">{@html $idaa_slct.post_obj.content}</div>
|
||||
|
||||
<section class="ae_section ae_meta post__meta">
|
||||
<div class="ae_group">
|
||||
{#if ($idaa_slct.post_obj.anonymous)}
|
||||
<div class="post__posted_by">
|
||||
Posted by: <span class="fas fa-user-secret"></span> <span class="post__full_name">Anonymous</span>
|
||||
</div>
|
||||
{:else if ($idaa_slct.post_obj.full_name)}
|
||||
<div class="post__posted_by">
|
||||
Posted by: <span class="fas fa-user"></span> <span class="post__full_name">{$idaa_slct.post_obj.full_name}
|
||||
{#if $ae_loc.trusted_access && $idaa_slct.post_obj.email}
|
||||
<a href="mailto:{$idaa_slct.post_obj.email}?subject=IDAA BB Post">{$idaa_slct.post_obj.email}</a>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="post__created_on_updated_on">
|
||||
{#if !$idaa_slct.post_obj.updated_on}
|
||||
<span class="ae_label">Created on:</span>
|
||||
<span class="ae_value post__created_on">{ae_util.iso_datetime_formatter($idaa_slct.post_obj.created_on, 'datetime_iso_no_seconds')}</span>
|
||||
{:else}
|
||||
<span class="ae_label">Updated on:</span>
|
||||
<span class="ae_value post__updated_on">
|
||||
{ae_util.iso_datetime_formatter($idaa_slct.post_obj.updated_on, 'datetime_iso_no_seconds')}</span>
|
||||
{/if}
|
||||
<span class="post__archive_on">
|
||||
<span class="ae_label">Archive on:</span>
|
||||
<span class="ae_value">{ae_util.iso_datetime_formatter($idaa_slct.post_obj.archive_on, 'datetime_iso_no_seconds')}</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ae_options">
|
||||
{#if $idaa_slct.post_obj.post_comment_count}
|
||||
<span class="ae_badge ae_info post__post_comment_count">
|
||||
<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}
|
||||
<button
|
||||
on:click={() => {
|
||||
$idaa_loc.posts.show_edit__post_comment = true;
|
||||
}}
|
||||
class="btn btn-primary"
|
||||
title={`New comment on: ${$idaa_slct.post_obj.title}`}
|
||||
>
|
||||
<span class="fas fa-plus m-1"></span> New Comment
|
||||
</button>
|
||||
|
||||
{#if $ae_loc.trusted_access || $idaa_slct.post_obj.external_person_id === $idaa_loc.novi_uuid || $idaa_slct.post_obj.email === $idaa_loc.novi_email}
|
||||
<button
|
||||
on:click={() => {
|
||||
// $idaa_slct.post_id = $idaa_slct.post_obj.post_id_random;
|
||||
// $idaa_slct.post_obj = $idaa_slct.post_obj;
|
||||
|
||||
// const url = new URL(location);
|
||||
// url.searchParams.set('post_id', $idaa_slct.post_obj.post_id_random);
|
||||
// history.pushState({}, '', url);
|
||||
|
||||
// $idaa_loc.posts.show_main__options = false;
|
||||
// $idaa_loc.posts.show_list__post_li = false;
|
||||
$idaa_loc.posts.show_view__post_id = false;
|
||||
$idaa_loc.posts.show_edit__post_id = true;
|
||||
}}
|
||||
class="ae_btn ae_smallest btn btn-xs btn-secondary"
|
||||
title={`Edit post: ${$idaa_slct.post_obj.name}`}
|
||||
>
|
||||
<span class="fas fa-edit m-1"></span> Edit
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
{#if $idaa_loc.posts.show_edit__post_comment}
|
||||
<section class="bb_post_comment_crud">
|
||||
|
||||
<Element_modal_v3
|
||||
show = { true }
|
||||
modal_cover_body = { true }
|
||||
on:close={ () => {
|
||||
$idaa_slct.post_comment_id = null;
|
||||
$idaa_slct.post_comment_obj = {};
|
||||
|
||||
// $idaa_loc.posts.show_post_list = true;
|
||||
// $idaa_loc.posts.show_edit__post_id = false;
|
||||
// $idaa_loc.posts.show_view__post_id = false;
|
||||
$idaa_loc.posts.show_edit__post_comment = false;
|
||||
}}
|
||||
>
|
||||
<span slot="header_title">Comment on: {($idaa_slct.post_obj.title ? $idaa_slct.post_obj.title : '')}</span>
|
||||
|
||||
<span slot="body">
|
||||
<section class="post_comment_obj_view">
|
||||
<Edit_post_comment_obj on:post_comment_obj_created={handle_post_comment_obj_created} on:post_comment_obj_updated={handle_post_comment_obj_updated} on:post_comment_obj_deleted={handle_post_comment_obj_deleted} />
|
||||
</section>
|
||||
</span>
|
||||
</Element_modal_v3>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if $idaa_slct.post_comment_obj_li.length}
|
||||
{#each $idaa_slct.post_comment_obj_li as idaa_post_comment_obj, index}
|
||||
<hr />
|
||||
<div class="post_comment__content">{@html idaa_post_comment_obj.content}</div>
|
||||
|
||||
|
||||
<section class="ae_section ae_meta post_comment__meta">
|
||||
<div class="ae_group">
|
||||
<span class="post_comment__posted_by `comment_by_container">
|
||||
<span class="comment_by_lable">Comment by:</span>
|
||||
{#if idaa_post_comment_obj.anonymous}
|
||||
<span class="fas fa-user-secret"></span>
|
||||
<span class="comment_by_full_name anonymous">Anonymous</span>
|
||||
{:else}
|
||||
<span class="fas fa-user"></span>
|
||||
<span class="comment_by_full_name">{idaa_post_comment_obj.full_name}</span>
|
||||
<!-- {#if idaa_post_comment_obj.email}
|
||||
(<a href="mailto:{idaa_post_comment_obj.email}"><span class="comment_by_email">{idaa_post_comment_obj.email}</span></a>)
|
||||
{/if} -->
|
||||
{/if}
|
||||
<div class="post_comment__created_on_updated_on">
|
||||
Created on:
|
||||
<span class="post_comment__created_on">{ae_util.iso_datetime_formatter(idaa_post_comment_obj.created_on, 'datetime_iso_no_seconds')}
|
||||
{#if idaa_post_comment_obj.updated_on}
|
||||
Updated on:
|
||||
{ae_util.iso_datetime_formatter(idaa_post_comment_obj.updated_on, 'datetime_iso_no_seconds')}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if $ae_loc.trusted_access || idaa_post_comment_obj.external_person_id === $ae_app.novi_uuid}
|
||||
<div class="ae_options">
|
||||
<button on:click={() => {
|
||||
$idaa_slct.post_comment_id = idaa_post_comment_obj.post_comment_id_random;
|
||||
$idaa_slct.post_comment_obj = idaa_post_comment_obj;
|
||||
|
||||
// $idaa_loc.posts.show_post_comment_list = false;
|
||||
$idaa_loc.posts.show_edit__post_comment = true;
|
||||
// $idaa_loc.posts.show_view__post_id = false;
|
||||
}}
|
||||
class="ae_btn ae_smallest btn btn-secondary"
|
||||
>
|
||||
<span class="fas fa-edit"></span> Edit Comment
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
<style>
|
||||
.post_obj .ae_meta {
|
||||
flex-direction: column;
|
||||
/* justify-content: space-between; */
|
||||
}
|
||||
|
||||
.post_obj .ae_meta .ae_group {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.post_obj .ae_meta .ae_options {
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.post__posted_by, .post_comment__posted_by {
|
||||
/* font-size: smaller; */
|
||||
/* background-color: hsla(0,80%,50%,1); */
|
||||
/* color: hsla(0,0%,50%,1); */
|
||||
}
|
||||
|
||||
.post__created_on_updated_on, .post_comment__created_on_updated_on {
|
||||
/* font-size: smaller; */
|
||||
/* background-color: hsla(0,80%,50%,1); */
|
||||
/* color: hsla(0,0%,50%,1); */
|
||||
}
|
||||
</style>
|
||||
154
src/routes/idaa/(idaa)/bb/ae_idaa_comp__post_obj_li.svelte
Normal file
154
src/routes/idaa/(idaa)/bb/ae_idaa_comp__post_obj_li.svelte
Normal file
@@ -0,0 +1,154 @@
|
||||
<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__post_obj_li: any;
|
||||
|
||||
export let container_class_li = [];
|
||||
|
||||
onMount(() => {
|
||||
console.log('** Component Mounted: ** List - Bulletin Board (Post) Obj');
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<!-- {#if $idaa_loc?.bb?.show_list__post_obj_li} -->
|
||||
<section class="bb_post_list">
|
||||
{#if $lq__post_obj_li}
|
||||
<!-- <ul> -->
|
||||
{#each $lq__post_obj_li as idaa_post_obj, index}
|
||||
<div
|
||||
id={`idaa_bb_post_id__${idaa_post_obj.post_id_random}`}
|
||||
class="container bb_post post_obj border border-1 rounded p-2 mb-2"
|
||||
class:post__hide={idaa_post_obj.hide}
|
||||
class:post__priority={idaa_post_obj.priority}
|
||||
class:post__group={idaa_post_obj.group}
|
||||
>
|
||||
<header class="ae_header post__header">
|
||||
<h3 class="post__title">
|
||||
{@html idaa_post_obj.title}
|
||||
{#if idaa_post_obj.topic_id}<span class="badge badge-info bg-info"><span class="fas fa-user-md m-1"></span> {idaa_post_obj.topic_name}</span>{/if}
|
||||
</h3>
|
||||
</header>
|
||||
|
||||
{#if idaa_post_obj.content}<div class="post__content">{@html idaa_post_obj.content}</div>{/if}
|
||||
|
||||
<div class="ae_options post_obj__options">
|
||||
<button
|
||||
on:click={() => {
|
||||
$slct.post_id = idaa_post_obj.post_id_random;
|
||||
$slct.post_obj = idaa_post_obj;
|
||||
|
||||
// handle_load_post_comment_obj_li({post_id: $slct.post_id, try_cache: false});
|
||||
|
||||
const url = new URL(location);
|
||||
url.searchParams.set('post_id', idaa_post_obj.post_id_random);
|
||||
history.pushState({}, '', url);
|
||||
|
||||
let message = {'post_id': idaa_post_obj.post_id_random};
|
||||
window.parent.postMessage(message, "*");
|
||||
|
||||
$idaa_loc.bb.show_main__options = true;
|
||||
$idaa_loc.bb.show_list__post_obj_li = true;
|
||||
// $idaa_loc.bb.show_edit__post_id = false;
|
||||
$idaa_loc.bb.show_view__post_id = true;
|
||||
}}
|
||||
class="btn btn-md variant-ghost-primary hover:variant-filled-primary transition"
|
||||
title={`View: ${idaa_post_obj.title}`}
|
||||
>
|
||||
<span class="fas fa-envelope-open m-1"></span> Open
|
||||
|
||||
{#if idaa_post_obj.post_comment_count}
|
||||
<span class="ae_badge ae_info post__post_comment_count">
|
||||
<span class="fas fa-comment"></span> {(idaa_post_obj.post_comment_count == 1 ? `${idaa_post_obj.post_comment_count} comment` : `${idaa_post_obj.post_comment_count} comments` )}
|
||||
</span>
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
{#if $ae_loc.trusted_access || idaa_post_obj.external_person_id === $idaa_loc.novi_uuid || idaa_post_obj.email === $idaa_loc.novi_email}
|
||||
<button
|
||||
on:click={() => {
|
||||
$slct.post_id = idaa_post_obj.post_id_random;
|
||||
$slct.post_obj = idaa_post_obj;
|
||||
$slct_trigger = 'load__post_obj';
|
||||
|
||||
$idaa_loc.bb.show_main__options = true;
|
||||
$idaa_loc.bb.show_list__post_obj_li = true;
|
||||
$idaa_loc.bb.show_edit__post_id = true;
|
||||
// $idaa_loc.bb.show_view__post_id = false;
|
||||
}}
|
||||
class="btn btn-sm variant-ghost-warning hover:variant-filled-warning transition"
|
||||
title={`Edit post: ${idaa_post_obj.title}`}
|
||||
>
|
||||
<span class="fas fa-edit m-1"></span> Edit Post
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<!-- <button
|
||||
on:click={() => {
|
||||
$slct.post_id = idaa_post_obj.post_id_random;
|
||||
$slct.post_obj = idaa_post_obj;
|
||||
|
||||
$idaa_loc.bb.show_post_comment_crud = true;
|
||||
}}
|
||||
class="ae_btn btn_md btn_outline_warning"
|
||||
title={`New comment on: ${idaa_post_obj.title}`}
|
||||
>
|
||||
<span class="fas fa-plus"></span> New Comment
|
||||
</button> -->
|
||||
|
||||
</div>
|
||||
|
||||
<div class="ae_section ae_footer ae_meta post__meta">
|
||||
{#if (idaa_post_obj.anonymous)}
|
||||
<div class="post__posted_by">
|
||||
Posted by: <span class="fas fa-user-secret"></span> <span class="post__full_name">Anonymous</span>
|
||||
</div>
|
||||
{:else if (idaa_post_obj.full_name)}
|
||||
<div class="post__posted_by">
|
||||
Posted by: <span class="fas fa-user"></span> <span class="post__full_name">{idaa_post_obj.full_name}
|
||||
{#if $ae_loc.trusted_access && idaa_post_obj.email}
|
||||
(<a href="mailto:{idaa_post_obj.email}?subject=IDAA BB Post">{idaa_post_obj.email}</a>)
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if idaa_post_obj.created_on}
|
||||
<div class="post__created_on_updated_on">
|
||||
{#if !idaa_post_obj.updated_on}
|
||||
<span
|
||||
class="post__created_on"
|
||||
>
|
||||
<span class="ae_label">Created on:</span>
|
||||
<span class="ae_value">{ae_util.iso_datetime_formatter(idaa_post_obj.created_on, 'datetime_iso_no_seconds')}</span>
|
||||
</span>
|
||||
{:else}
|
||||
<span
|
||||
class="post__updated_on"
|
||||
>
|
||||
<span class="ae_label">Updated on:</span>
|
||||
<span class="ae_value">{ae_util.iso_datetime_formatter(idaa_post_obj.updated_on, 'datetime_iso_no_seconds')}</span>
|
||||
</span>
|
||||
{/if}
|
||||
{#if idaa_post_obj.archive_on}
|
||||
<span class="post__archive_on">Archive on: {ae_util.iso_datetime_formatter(idaa_post_obj.archive_on, 'datetime_iso_no_seconds')}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
<!-- <div style="font-size: smaller">json={encodeURIComponent(JSON.stringify({idaa_post_obj}))}</div> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{/each}
|
||||
<!-- </ul> -->
|
||||
{:else}
|
||||
No posts found at this time
|
||||
{/if}
|
||||
</section>
|
||||
<!-- {/if} -->
|
||||
@@ -1,261 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher, onMount } from 'svelte';
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
import { ae, Element_modal_v3 } from 'aether_npm_lib';
|
||||
import { slct, slct_trigger, ae_app } from './stores';
|
||||
|
||||
import Edit_post_comment_obj from './10_edit__post_comment_obj.svelte';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
if ($slct.post_id) {
|
||||
console.log(`Post ID selected: ${$slct.post_id}`);
|
||||
console.log(`Post Object selected: ${$slct.post_obj}`)
|
||||
|
||||
$slct_trigger = 'load__post_obj';
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
console.log('** Component Mounted: ** View - Post Obj');
|
||||
});
|
||||
|
||||
function handle_post_comment_obj_created(event) {
|
||||
console.log('*** handle_post_comment_obj_created() ***');
|
||||
console.log(event.detail);
|
||||
|
||||
$slct.post_comment_id = null;
|
||||
$slct.post_comment_obj = {};
|
||||
|
||||
$slct_trigger = 'load__post_obj_li';
|
||||
$slct_trigger = 'load__post_obj';
|
||||
$slct_trigger = 'load__post_comment_obj_li';
|
||||
|
||||
// $ae_app.posts.show_post_list = false;
|
||||
// $ae_app.posts.show_edit__post_id = false;
|
||||
// $ae_app.posts.show_view__post_id = true;
|
||||
$ae_app.posts.show_edit__post_comment = false;
|
||||
}
|
||||
function handle_post_comment_obj_updated(event) {
|
||||
console.log('*** handle_post_comment_obj_updated() ***');
|
||||
console.log(event.detail);
|
||||
|
||||
$slct_trigger = 'load__post_obj';
|
||||
$slct_trigger = 'load__post_comment_obj_li';
|
||||
|
||||
// $ae_app.posts.show_post_list = false;
|
||||
// $ae_app.posts.show_edit__post_id = false;
|
||||
// $ae_app.posts.show_view__post_id = true;
|
||||
$ae_app.posts.show_edit__post_comment = false;
|
||||
}
|
||||
function handle_post_comment_obj_deleted(event) {
|
||||
console.log('*** handle_post_comment_obj_deleted() ***');
|
||||
console.log(event.detail);
|
||||
|
||||
$slct_trigger = 'load__post_obj_li';
|
||||
$slct_trigger = 'load__post_obj';
|
||||
$slct_trigger = 'load__post_comment_obj_li';
|
||||
|
||||
// $ae_app.posts.show_post_list = false;
|
||||
// $ae_app.posts.show_edit__post_id = false;
|
||||
// $ae_app.posts.show_view__post_id = true;
|
||||
$ae_app.posts.show_edit__post_comment = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<section
|
||||
bind:clientHeight={$ae_app.iframe_height_modal_body}
|
||||
class="svelte_component ae_section ae_view post_obj view__post_obj"
|
||||
>
|
||||
|
||||
<div class="post__header">
|
||||
<h2 class="post__title">
|
||||
{@html $slct.post_obj.title}
|
||||
{#if $slct.post_obj.topic_id}<span class="badge badge-info bg-info"><span class="fas fa-user-md"></span> {$slct.post_obj.topic_name}</span>{/if}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="post__content">{@html $slct.post_obj.content}</div>
|
||||
|
||||
<section class="ae_section ae_meta post__meta">
|
||||
<div class="ae_group">
|
||||
{#if ($slct.post_obj.anonymous)}
|
||||
<div class="post__posted_by">
|
||||
Posted by: <span class="fas fa-user-secret"></span> <span class="post__full_name">Anonymous</span>
|
||||
</div>
|
||||
{:else if ($slct.post_obj.full_name)}
|
||||
<div class="post__posted_by">
|
||||
Posted by: <span class="fas fa-user"></span> <span class="post__full_name">{$slct.post_obj.full_name}
|
||||
{#if $ae_app.trusted_access && $slct.post_obj.email}
|
||||
<a href="mailto:{$slct.post_obj.email}?subject=IDAA BB Post">{$slct.post_obj.email}</a>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="post__created_on_updated_on">
|
||||
{#if !$slct.post_obj.updated_on}
|
||||
<span class="ae_label">Created on:</span>
|
||||
<span class="ae_value post__created_on">{ae.util.iso_datetime_formatter($slct.post_obj.created_on, 'datetime_iso_no_seconds')}</span>
|
||||
{:else}
|
||||
<span class="ae_label">Updated on:</span>
|
||||
<span class="ae_value post__updated_on">
|
||||
{ae.util.iso_datetime_formatter($slct.post_obj.updated_on, 'datetime_iso_no_seconds')}</span>
|
||||
{/if}
|
||||
<span class="post__archive_on">
|
||||
<span class="ae_label">Archive on:</span>
|
||||
<span class="ae_value">{ae.util.iso_datetime_formatter($slct.post_obj.archive_on, 'datetime_iso_no_seconds')}</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ae_options">
|
||||
{#if $slct.post_obj.post_comment_count}
|
||||
<span class="ae_badge ae_info post__post_comment_count">
|
||||
<span class="fas fa-comment"></span> {($slct.post_obj.post_comment_count == 1 ? `${$slct.post_obj.post_comment_count} comment` : `${$slct.post_obj.post_comment_count} comments` )}
|
||||
</span>
|
||||
{/if}
|
||||
<button
|
||||
on:click={() => {
|
||||
$ae_app.posts.show_edit__post_comment = true;
|
||||
}}
|
||||
class="btn btn-primary"
|
||||
title={`New comment on: ${$slct.post_obj.title}`}
|
||||
>
|
||||
<span class="fas fa-plus"></span> New Comment
|
||||
</button>
|
||||
|
||||
{#if $ae_app.trusted_access || $slct.post_obj.external_person_id === $ae_app.novi_uuid || $slct.post_obj.email === $ae_app.novi_email}
|
||||
<button
|
||||
on:click={() => {
|
||||
// $slct.post_id = $slct.post_obj.post_id_random;
|
||||
// $slct.post_obj = $slct.post_obj;
|
||||
|
||||
// const url = new URL(location);
|
||||
// url.searchParams.set('post_id', $slct.post_obj.post_id_random);
|
||||
// history.pushState({}, '', url);
|
||||
|
||||
// $ae_app.posts.show_main__options = false;
|
||||
// $ae_app.posts.show_list__post_li = false;
|
||||
$ae_app.posts.show_view__post_id = false;
|
||||
$ae_app.posts.show_edit__post_id = true;
|
||||
}}
|
||||
class="ae_btn ae_smallest btn btn-xs btn-secondary"
|
||||
title={`Edit post: ${$slct.post_obj.name}`}
|
||||
>
|
||||
<span class="fas fa-edit"></span> Edit
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
{#if $ae_app.posts.show_edit__post_comment}
|
||||
<section class="bb_post_comment_crud">
|
||||
|
||||
<Element_modal_v3
|
||||
show = { true }
|
||||
modal_cover_body = { true }
|
||||
on:close={ () => {
|
||||
$slct.post_comment_id = null;
|
||||
$slct.post_comment_obj = {};
|
||||
|
||||
// $ae_app.posts.show_post_list = true;
|
||||
// $ae_app.posts.show_edit__post_id = false;
|
||||
// $ae_app.posts.show_view__post_id = false;
|
||||
$ae_app.posts.show_edit__post_comment = false;
|
||||
}}
|
||||
>
|
||||
<span slot="header_title">Comment on: {($slct.post_obj.title ? $slct.post_obj.title : '')}</span>
|
||||
|
||||
<span slot="body">
|
||||
<section class="post_comment_obj_view">
|
||||
<Edit_post_comment_obj on:post_comment_obj_created={handle_post_comment_obj_created} on:post_comment_obj_updated={handle_post_comment_obj_updated} on:post_comment_obj_deleted={handle_post_comment_obj_deleted} />
|
||||
</section>
|
||||
</span>
|
||||
</Element_modal_v3>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if $slct.post_comment_obj_li.length}
|
||||
{#each $slct.post_comment_obj_li as idaa_post_comment_obj, index}
|
||||
<hr />
|
||||
<div class="post_comment__content">{@html idaa_post_comment_obj.content}</div>
|
||||
|
||||
|
||||
<section class="ae_section ae_meta post_comment__meta">
|
||||
<div class="ae_group">
|
||||
<span class="post_comment__posted_by `comment_by_container">
|
||||
<span class="comment_by_lable">Comment by:</span>
|
||||
{#if idaa_post_comment_obj.anonymous}
|
||||
<span class="fas fa-user-secret"></span>
|
||||
<span class="comment_by_full_name anonymous">Anonymous</span>
|
||||
{:else}
|
||||
<span class="fas fa-user"></span>
|
||||
<span class="comment_by_full_name">{idaa_post_comment_obj.full_name}</span>
|
||||
<!-- {#if idaa_post_comment_obj.email}
|
||||
(<a href="mailto:{idaa_post_comment_obj.email}"><span class="comment_by_email">{idaa_post_comment_obj.email}</span></a>)
|
||||
{/if} -->
|
||||
{/if}
|
||||
<div class="post_comment__created_on_updated_on">
|
||||
Created on:
|
||||
<span class="post_comment__created_on">{ae.util.iso_datetime_formatter(idaa_post_comment_obj.created_on, 'datetime_iso_no_seconds')}
|
||||
{#if idaa_post_comment_obj.updated_on}
|
||||
Updated on:
|
||||
{ae.util.iso_datetime_formatter(idaa_post_comment_obj.updated_on, 'datetime_iso_no_seconds')}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if $ae_app.trusted_access || idaa_post_comment_obj.external_person_id === $ae_app.novi_uuid}
|
||||
<div class="ae_options">
|
||||
<button on:click={() => {
|
||||
$slct.post_comment_id = idaa_post_comment_obj.post_comment_id_random;
|
||||
$slct.post_comment_obj = idaa_post_comment_obj;
|
||||
|
||||
// $ae_app.posts.show_post_comment_list = false;
|
||||
$ae_app.posts.show_edit__post_comment = true;
|
||||
// $ae_app.posts.show_view__post_id = false;
|
||||
}}
|
||||
class="ae_btn ae_smallest btn btn-secondary"
|
||||
>
|
||||
<span class="fas fa-edit"></span> Edit Comment
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
<style>
|
||||
.post_obj .ae_meta {
|
||||
flex-direction: column;
|
||||
/* justify-content: space-between; */
|
||||
}
|
||||
|
||||
.post_obj .ae_meta .ae_group {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.post_obj .ae_meta .ae_options {
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.post__posted_by, .post_comment__posted_by {
|
||||
/* font-size: smaller; */
|
||||
/* background-color: hsla(0,80%,50%,1); */
|
||||
/* color: hsla(0,0%,50%,1); */
|
||||
}
|
||||
|
||||
.post__created_on_updated_on, .post_comment__created_on_updated_on {
|
||||
/* font-size: smaller; */
|
||||
/* background-color: hsla(0,80%,50%,1); */
|
||||
/* color: hsla(0,0%,50%,1); */
|
||||
}
|
||||
</style>
|
||||
@@ -348,7 +348,7 @@ onMount(() => {
|
||||
$idaa_loc.recovery_meetings.show_view__event_obj = false;
|
||||
$idaa_loc.recovery_meetings.show_edit__event_obj = true;
|
||||
}}
|
||||
class="btn btn-md variant-ghost-warning hover:variant-filled-warning transition"
|
||||
class="btn btn-sm variant-ghost-warning hover:variant-filled-warning transition"
|
||||
title={`Edit meeting: ${$lq__event_obj?.name}`}
|
||||
>
|
||||
<span class="fas fa-edit"></span> Edit
|
||||
|
||||
@@ -99,7 +99,7 @@ onMount(() => {
|
||||
$idaa_loc.recovery_meetings.show_view__event_obj = false;
|
||||
$idaa_loc.recovery_meetings.show_edit__event_obj = true;
|
||||
}}
|
||||
class="btn btn-md variant-ghost-warning hover:variant-filled-warning transition"
|
||||
class="btn btn-sm variant-ghost-warning hover:variant-filled-warning transition"
|
||||
title={`Edit meeting: ${idaa_event_obj.name}`}
|
||||
>
|
||||
<span class="fas fa-edit m-1"></span>
|
||||
|
||||
Reference in New Issue
Block a user