Not sure... I need to get to a good point tomorrow.

This commit is contained in:
Scott Idem
2025-07-01 16:58:25 -04:00
parent a691e7d22d
commit 50deb79f6b
3 changed files with 71 additions and 59 deletions

View File

@@ -21,6 +21,7 @@ import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$
import { idaa_loc, idaa_sess, idaa_slct, idaa_trig, idaa_prom } from '$lib/ae_idaa_stores';
import { posts_func } from '$lib/ae_posts/ae_posts_functions';
import Comp__post_obj_id_edit from '.././ae_idaa_comp__post_obj_id_edit.svelte';
import Comp__post_obj_id_view from '.././ae_idaa_comp__post_obj_id_view.svelte';
// *** Quickly pull out data from parent(s)
@@ -171,12 +172,13 @@ onDestroy(() => {
</button>
{:else}
<!-- This checks if the currently logged in Novi user has a matching UUID or email address. -->
{#if ($ae_loc.trusted_access && $ae_loc.edit_mode) || $lq__post_obj?.external_person_id === $idaa_loc.novi_uuid || $lq__post_obj?.contact_li_json[0].email === $idaa_loc.novi_email}
{#if ($ae_loc.trusted_access && $ae_loc.edit_mode) || $lq__post_obj?.external_person_id === $idaa_loc.novi_uuid || $lq__post_obj?.email === $idaa_loc.novi_email}
<button
type="button"
class="novi_btn btn btn-warning btn-sm preset-tonal-warning border border-warning-500
hover:preset-filled-warning-500 transition"
onclick={() => {
$idaa_slct.post_obj = $lq__post_obj;
$idaa_sess.bb.edit__post_id = $idaa_slct.post_id;
if (log_lvl) {
console.log(`Toggle edit__post_id: ${$idaa_sess.bb.edit__post_id}`);
@@ -194,12 +196,11 @@ onDestroy(() => {
{#if $idaa_sess.bb.edit__post_id}
<!-- <Comp__post_obj_id_edit
<!-- lq__post_comment_obj_li={lq__post_comment_obj_li} -->
<!-- lq__post_comment_obj={lq__post_comment_obj} -->
<Comp__post_obj_id_edit
lq__post_obj={lq__post_obj}
lq__post_comment_obj_li={lq__post_comment_obj_li}
lq__post_comment_obj={lq__post_comment_obj}
/> -->
EDIT GOES HERE?
/>
{:else}
<Comp__post_obj_id_view
lq__post_obj={lq__post_obj}

View File

@@ -1,8 +1,10 @@
<script lang="ts">
export let log_lvl: number = 0;
// import { run, preventDefault } from 'svelte/legacy';
// import { createEventDispatcher, onDestroy, onMount } from 'svelte';
import { fade } from 'svelte/transition';
// import { browser } from '$app/environment';
import { browser } from '$app/environment';
import type { key_val } from '$lib/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';
@@ -14,18 +16,23 @@ import { posts_func } from '$lib/ae_posts/ae_posts_functions';
import Tiptap_editor from '$lib/element_tiptap_editor.svelte';
import Comp_hosted_files_upload from '$lib/ae_core/ae_comp__hosted_files_upload.svelte';
export let lq__post_obj: any;
interface Props {
log_lvl?: number;
lq__post_obj: any;
}
// if (browser) {
// console.log(`$lq__post_obj = `, $lq__post_obj);
// $idaa_slct.post_obj = $lq__post_obj;
// }
let { log_lvl = $bindable(0), lq__post_obj }: Props = $props();
let ae_promises: key_val = {};
let prom_api__post_obj: any;
if (browser) {
console.log(`$lq__post_obj = `, $lq__post_obj);
$idaa_slct.post_obj = $lq__post_obj;
}
let ae_promises: key_val = $state({});
let prom_api__post_obj: any = $state();
// let prom_api__post_obj__hosted_file: any;
let disable_submit_btn = false;
let disable_submit_btn = $state(false);
async function handle_submit_form(event: any) {
@@ -229,9 +236,6 @@ async function handle_delete_post_obj(
}
$: if ($idaa_slct.post_obj.upload_complete && $idaa_slct.post_obj.hosted_file_id_li?.length && $idaa_slct.post_obj.hosted_file_obj_li?.length) {
handle_hosted_files_uploaded($idaa_slct.post_obj.hosted_file_id_li, $idaa_slct.post_obj.hosted_file_obj_li);
}
async function handle_hosted_files_uploaded(hosted_file_id_li: string[], hosted_file_obj_li: any[]) {
@@ -308,16 +312,21 @@ function send_staff_notification_email() {
});
}
$effect(() => {
if ($idaa_slct.post_obj?.upload_complete && $idaa_slct.post_obj?.hosted_file_id_li?.length && $idaa_slct.post_obj.hosted_file_obj_li?.length) {
handle_hosted_files_uploaded($idaa_slct.post_obj.hosted_file_id_li, $idaa_slct.post_obj.hosted_file_obj_li);
}
});
</script>
<section
class="svelte_component ae_section ae_edit post_obj edit__post_obj space-y-2 p-2 border border rounded bg-blue-100"
class="svelte_component ae_section ae_edit post_obj edit__post_obj space-y-2 p-2 border rounded bg-blue-100"
class:ae_create={!$idaa_slct.post_id}
bind:clientHeight={$ae_loc.iframe_height_modal_body}
>
<form on:submit|preventDefault={handle_submit_form} class="space-y-1">
<form onsubmit={handle_submit_form} class="space-y-1">
{#await prom_api__post_obj}
<div class="awaiting alert_msg_pulse" out:fade={{ duration: 2000 }}>Saving...</div>
@@ -332,7 +341,7 @@ function send_staff_notification_email() {
<section class="text-center"> <!-- BEGIN: section post__options -->
<button
type="button"
on:click={() => {
onclick={() => {
$idaa_sess.bb.show__inline_edit__post_obj = false;
}}
class="novi_btn btn btn-sm preset-tonal-warning border border-warning-500 hover:preset-filled-warning-500 transition"
@@ -405,7 +414,7 @@ function send_staff_notification_email() {
class="novi_btn btn btn-sm"
class:preset-filled-secondary-500={$idaa_sess.bb.show__inline_edit__file_upload}
class:preset-tonal-secondary={!$idaa_sess.bb.show__inline_edit__file_upload}
on:click={() => {
onclick={() => {
$idaa_sess.bb.show__inline_edit__file_upload = !$idaa_sess.bb.show__inline_edit__file_upload;
}}
>
@@ -431,18 +440,20 @@ function send_staff_notification_email() {
bind:upload_complete={$idaa_slct.post_obj.upload_complete}
log_lvl={log_lvl}
>
<span slot="label">
<div>
<span class="fas fa-upload"></span>
<strong class="bg-green-100 p-1">Upload post files</strong>
</div>
<span class="text-sm text-gray-600 dark:text-gray-400 italic">
<!-- <strong>Aether hosted files only</strong><br> -->
Recommended: documents (PDF) and images (png, webp, jpg)
<!-- , audio (mp3, m4a), and video (mp4, mkv) -->
<!-- <br> -->
{#snippet label()}
<span >
<div>
<span class="fas fa-upload"></span>
<strong class="bg-green-100 p-1">Upload post files</strong>
</div>
<span class="text-sm text-gray-600 dark:text-gray-400 italic">
<!-- <strong>Aether hosted files only</strong><br> -->
Recommended: documents (PDF) and images (png, webp, jpg)
<!-- , audio (mp3, m4a), and video (mp4, mkv) -->
<!-- <br> -->
</span>
</span>
</span>
{/snippet}
</Comp_hosted_files_upload>
{/if}
</div>
@@ -468,7 +479,7 @@ function send_staff_notification_email() {
<button
type="button"
disabled={!$ae_loc.trusted_access}
on:click={() => {
onclick={() => {
ae_promises[linked_obj.hosted_file_id_random] = api.download_hosted_file({
api_cfg: $ae_api,
hosted_file_id: linked_obj.hosted_file_id_random,
@@ -504,7 +515,7 @@ function send_staff_notification_email() {
<button
type="button"
disabled={!$ae_loc.trusted_access}
on:click={async () => {
onclick={async () => {
if (!confirm(`Are you sure you want to delete this file?\n${linked_obj.filename} [${linked_obj.hosted_file_id_random}]`)) {return false;}
// ae_promises[linked_obj.event_file_id_random] = handle_delete__event_file({event_file_id: linked_obj.event_file_id_random});
@@ -736,7 +747,7 @@ function send_staff_notification_email() {
class="novi_btn btn btn-sm preset-tonal-warning float-right"
class:preset-filled-secondary-500={$idaa_loc.bb.show__admin_options}
class:preset-tonal-secondary={!$idaa_loc.bb.show__admin_options}
on:click={() => {
onclick={() => {
$idaa_loc.bb.show__admin_options = !$idaa_loc.bb.show__admin_options;
}}
>
@@ -890,7 +901,7 @@ function send_staff_notification_email() {
<button
type="submit"
disabled={(disable_submit_btn)}
on:click={() => {
onclick={() => {
if (!confirm('Are you sure you want to create this post?')) {return false;}
// handle_save_post_obj({post_id: $idaa_slct.post_id, method: 'create'});
}}
@@ -908,7 +919,7 @@ function send_staff_notification_email() {
{#if $ae_loc.administrator_access}
<button
type="button"
on:click={() => {
onclick={() => {
if (!confirm('Are you sure you want to delete this post?')) {return false;}
handle_delete_post_obj({post_id: $idaa_slct.post_id, method: 'delete'});
}}
@@ -920,7 +931,7 @@ function send_staff_notification_email() {
{:else if $ae_loc.trusted_access}
<button
type="button"
on:click={() => {
onclick={() => {
if (!confirm('Are you sure you want to disable this post?')) {return false;}
handle_delete_post_obj({post_id: $idaa_slct.post_id, method: 'disable'});
}}
@@ -932,7 +943,7 @@ function send_staff_notification_email() {
{:else}
<button
type="button"
on:click={() => {
onclick={() => {
if (!confirm('Are you sure you want to hide this post?')) {return false;}
handle_delete_post_obj({post_id: $idaa_slct.post_id, method: 'hide'});
}}
@@ -948,7 +959,7 @@ function send_staff_notification_email() {
<div>
<button
type="button"
on:click={() => {
onclick={() => {
$idaa_sess.bb.show__inline_edit__post_obj = false;
}}
class="novi_btn btn btn-sm preset-tonal-warning border border-warning-500 hover:preset-filled-warning-500 transition"

View File

@@ -10,16 +10,16 @@ import { api } from '$lib/api';
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_trig } from '$lib/ae_idaa_stores';
import Comp__post_obj_id_edit from './ae_idaa_comp__post_obj_id_edit.svelte';
// import Comp__post_obj_id_edit from './ae_idaa_comp__post_obj_id_edit.svelte';
import Comp__post_comment_obj_id_edit from './ae_idaa_comp__post_comment_obj_id_edit.svelte';
interface Props {
lq__post_obj: any;
lq__post_comment_obj_li: any;
lq__post_comment_obj: any;
}
interface Props {
lq__post_obj: any;
lq__post_comment_obj_li: any;
lq__post_comment_obj: any;
}
let { lq__post_obj, lq__post_comment_obj_li, lq__post_comment_obj }: Props = $props();
let { lq__post_obj, lq__post_comment_obj_li, lq__post_comment_obj }: Props = $props();
let ae_promises: key_val = $state({});
@@ -32,7 +32,7 @@ if ($idaa_slct.post_id) {
}
$effect(() => {
if (browser && $lq__post_obj?.post_id) {
if (browser && $lq__post_obj?.post_id) {
document.body.scrollIntoView();
// const url = new URL(location);
@@ -41,13 +41,13 @@ $effect(() => {
}
});
onDestroy(() => {
console.log('** Component Destroyed: ** View - Post Obj');
// onDestroy(() => {
// console.log('** Component Destroyed: ** View - Post Obj');
const url = new URL(location);
url.searchParams.delete('post_id');
history.pushState({}, '', url);
});
// 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() ***');
@@ -98,11 +98,11 @@ onDestroy(() => {
class="svelte_component ae_section ae_view post_obj view__post_obj space-y-2"
>
{#if $idaa_sess.bb.show__inline_edit__post_obj}
<!-- {#if $idaa_sess.bb.show__inline_edit__post_obj}
<Comp__post_obj_id_edit
lq__post_obj={lq__post_obj}
/>
{:else}
{:else} -->
<!-- <div class="post__header">
<h2 class="post__title flex flex-row gap-2 items-center h3">
@@ -285,7 +285,7 @@ onDestroy(() => {
{/if}
</div>
</section>
{/if}
<!-- {/if} -->
{#if $idaa_sess.bb.show__inline_edit__post_comment_id === true}