More work on the BB and related notifications.
This commit is contained in:
@@ -105,6 +105,10 @@ $: lq__post_comment_obj = liveQuery(async () => {
|
||||
placement="top-center"
|
||||
size="lg"
|
||||
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"
|
||||
on:close={() => {
|
||||
// We want to cancel the inline edit if the modal is closed
|
||||
$idaa_sess.bb.show__inline_edit__post_obj = false;
|
||||
}}
|
||||
>
|
||||
|
||||
<svelte:fragment slot="header">
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script lang="ts">
|
||||
export let log_lvl = 1;
|
||||
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
||||
export let log_lvl = 0;
|
||||
// import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
||||
import { fade } from 'svelte/transition';
|
||||
// import { browser } from '$app/environment';
|
||||
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
@@ -15,9 +16,14 @@ import Comp_hosted_files_upload from '$lib/ae_core/ae_comp__hosted_files_upload.
|
||||
|
||||
export let lq__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 = {};
|
||||
let prom_api__post_obj: any;
|
||||
let prom_api__post_obj__hosted_file: any;
|
||||
// let prom_api__post_obj__hosted_file: any;
|
||||
|
||||
let disable_submit_btn = false;
|
||||
|
||||
@@ -36,7 +42,7 @@ async function handle_submit_form(event: any) {
|
||||
}
|
||||
|
||||
// Form Post object data incoming
|
||||
let post_di = ae_util.extract_prefixed_form_data({prefix: null, form_data: form_data, trim_values: true, bool_tf_str: true, log_lvl: 2});
|
||||
let post_di = ae_util.extract_prefixed_form_data({prefix: null, form_data: form_data, trim_values: true, bool_tf_str: true, log_lvl: log_lvl});
|
||||
// console.log(post_di);
|
||||
|
||||
// Form Post object data outgoing
|
||||
@@ -70,6 +76,7 @@ async function handle_submit_form(event: any) {
|
||||
post_do['external_person_id'] = post_di.external_person_id;
|
||||
post_do['full_name'] = post_di.full_name;
|
||||
post_do['email'] = post_di.email;
|
||||
post_do['notify'] = post_di.notify;
|
||||
|
||||
post_do['hide'] = !!post_di.hide;
|
||||
post_do['priority'] = !!post_di.priority;
|
||||
@@ -123,6 +130,9 @@ async function handle_submit_form(event: any) {
|
||||
.finally(() => {
|
||||
disable_submit_btn = false;
|
||||
$idaa_sess.bb.show__inline_edit__post_obj = false;
|
||||
if (!$ae_loc.trusted_access) {
|
||||
send_staff_notification_email();
|
||||
}
|
||||
});
|
||||
|
||||
return prom_api__post_obj;
|
||||
@@ -151,6 +161,9 @@ async function handle_submit_form(event: any) {
|
||||
$idaa_slct.post_obj = $lq__post_obj;
|
||||
disable_submit_btn = false;
|
||||
$idaa_sess.bb.show__inline_edit__post_obj = false;
|
||||
if (!$ae_loc.trusted_access) {
|
||||
send_staff_notification_email();
|
||||
}
|
||||
});
|
||||
|
||||
return prom_api__post_obj;
|
||||
@@ -206,6 +219,39 @@ async function handle_hosted_files_uploaded(hosted_file_id_li: string[], hosted_
|
||||
}
|
||||
|
||||
|
||||
function send_staff_notification_email() {
|
||||
let subject = `IDAA BB Post: ${$idaa_slct.post_obj.title} (ID: ${$idaa_slct.post_id})`;
|
||||
|
||||
let body_html = `
|
||||
<div>${$idaa_slct.post_obj.full_name},
|
||||
<p>A BB post has been created or updated.</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
Poster's Novi ID: ${$idaa_slct.post_obj.external_person_id}<br>
|
||||
Poster's Name: ${$idaa_slct.post_obj.full_name}<br>
|
||||
Poster's Email: ${$idaa_slct.post_obj.email}
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
IDAA BB Post ID: ${$idaa_slct.post_id}<br>
|
||||
<p>Use this link to view the post.<br>
|
||||
Copy and paste link: <a href="${$ae_loc.url_origin}/idaa/bb?post_id=${$idaa_slct.post_id}">${$ae_loc.url_origin}/idaa/bb?post_id=${$idaa_slct.post_id}</a></p>
|
||||
</div>`;
|
||||
|
||||
api.send_email({
|
||||
api_cfg: $ae_api,
|
||||
from_email: $ae_loc.site_cfg_json?.noreply_email ?? 'noreply+idaabb@oneskyit.com',
|
||||
from_name: $ae_loc.site_cfg_json?.noreply_name ?? 'IDAA BB NoReply',
|
||||
to_email: $ae_loc.site_cfg_json?.admin_email ?? 'admin+bb@oneskyit.com', // 'scott+idaabb@oneskyit.com', // $idaa_slct.post_obj.email,
|
||||
to_name: $ae_loc.site_cfg_json?.admin_name ?? 'IDAA BB Admin',
|
||||
subject: subject,
|
||||
body_html: body_html,
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -381,7 +427,7 @@ async function handle_hosted_files_uploaded(hosted_file_id_li: string[], hosted_
|
||||
link_to_id: $idaa_slct.post_id,
|
||||
rm_orphan: true,
|
||||
fake_delete: false,
|
||||
log_lvl: 1
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (delete_result) {
|
||||
// Second - If deleted, then update the post_obj
|
||||
|
||||
@@ -229,7 +229,7 @@ onDestroy(() => {
|
||||
<button
|
||||
on:click={() => {
|
||||
// $idaa_slct.post_id = $idaa_slct.post_obj.post_id_random;
|
||||
// $idaa_slct.post_obj = $idaa_slct.post_obj;
|
||||
$idaa_slct.post_obj = $lq__post_obj; // In case things changed
|
||||
|
||||
// const url = new URL(location);
|
||||
// url.searchParams.set('post_id', $idaa_slct.post_obj.post_id_random);
|
||||
|
||||
Reference in New Issue
Block a user