More work on the delete related functions.
This commit is contained in:
@@ -173,7 +173,7 @@ export async function load_ae_obj_li__archive(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'archive',
|
||||
for_obj_id: archive_id,
|
||||
params: {qry__enabled: enabled, qry__limit: limit},
|
||||
params: params,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
|
||||
@@ -173,7 +173,7 @@ export async function load_ae_obj_li__post(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'post',
|
||||
for_obj_id: post_id,
|
||||
params: {qry__enabled: enabled, qry__limit: limit},
|
||||
params: params,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
|
||||
@@ -31,7 +31,7 @@ export async function load({ params, parent }) { // route
|
||||
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},
|
||||
params: {qry__enabled: 'enabled', qry__hidden: 'not_hidden', qry__limit: 200},
|
||||
try_cache: true,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ import Tiptap_editor from '$lib/element_tiptap_editor.svelte';
|
||||
|
||||
export let lq__post_comment_obj: any;
|
||||
|
||||
let prom_api__post_comment_obj_v2: any;
|
||||
let prom_api__post_comment_obj: any;
|
||||
|
||||
let disable_submit_btn = false;
|
||||
|
||||
@@ -92,7 +92,7 @@ async function handle_submit_form(event: any) {
|
||||
console.log(post_comment_do);
|
||||
|
||||
if (!$idaa_slct.post_comment_id) {
|
||||
prom_api__post_comment_obj_v2 = posts_func.create_ae_obj__post_comment({
|
||||
prom_api__post_comment_obj = posts_func.create_ae_obj__post_comment({
|
||||
api_cfg: $ae_api,
|
||||
post_id: $idaa_slct.post_id,
|
||||
data_kv: post_comment_do,
|
||||
@@ -119,9 +119,9 @@ async function handle_submit_form(event: any) {
|
||||
$idaa_sess.bb.show__inline_edit__post_comment_id = false;
|
||||
});
|
||||
|
||||
return prom_api__post_comment_obj_v2;
|
||||
return prom_api__post_comment_obj;
|
||||
} else {
|
||||
prom_api__post_comment_obj_v2 = posts_func.update_ae_obj__post_comment({
|
||||
prom_api__post_comment_obj = posts_func.update_ae_obj__post_comment({
|
||||
api_cfg: $ae_api,
|
||||
post_comment_id: $idaa_slct.post_comment_id,
|
||||
data_kv: post_comment_do,
|
||||
@@ -147,16 +147,44 @@ async function handle_submit_form(event: any) {
|
||||
$idaa_sess.bb.show__inline_edit__post_comment_id = false;
|
||||
});
|
||||
|
||||
return prom_api__post_comment_obj_v2;
|
||||
return prom_api__post_comment_obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function handle_delete_post_comment_obj({post_comment_id, method}: key_val) {
|
||||
console.log('*** handle_delete_post_comment_obj() ***');
|
||||
// Updated 2024-11-15
|
||||
async function handle_delete_post_comment_obj(
|
||||
{
|
||||
post_comment_id,
|
||||
method = 'disable'
|
||||
}: {
|
||||
post_comment_id: string,
|
||||
method?: string
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log('*** handle_delete_post_comment_obj() ***');
|
||||
}
|
||||
|
||||
prom_api__post_comment_obj = posts_func.delete_ae_obj_id__post_comment({
|
||||
api_cfg: $ae_api,
|
||||
post_comment_id: post_comment_id,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (post_comment_obj_delete_result) {
|
||||
$idaa_sess.bb.show__inline_edit__post_comment_id = false;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('The result was null or false when trying to delete.', error);
|
||||
})
|
||||
.finally(() => {
|
||||
// $idaa_sess.recovery_meetings.show__modal_edit = false;
|
||||
$idaa_slct.post_comment_id = null;
|
||||
$idaa_slct.post_comment_obj = null;
|
||||
});
|
||||
|
||||
return true;
|
||||
return prom_api__post_comment_obj;
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -170,10 +198,10 @@ async function handle_delete_post_comment_obj({post_comment_id, method}: key_val
|
||||
|
||||
<form on:submit|preventDefault={handle_submit_form} class="space-y-1">
|
||||
|
||||
{#await prom_api__post_comment_obj_v2}
|
||||
{#await prom_api__post_comment_obj}
|
||||
<div class="awaiting alert_msg_pulse" out:fade={{ duration: 2000 }}>Saving...</div>
|
||||
{:then}
|
||||
{#if prom_api__post_comment_obj_v2}
|
||||
{#if prom_api__post_comment_obj}
|
||||
<!-- <div class="awaiting" out:fade={{ duration: 2000 }}>Finished saving</div> -->
|
||||
{:else}
|
||||
<!-- <div class="awaiting" out:fade={{ duration: 2000 }}>Nothing here yet</div> -->
|
||||
@@ -182,6 +210,7 @@ async function handle_delete_post_comment_obj({post_comment_id, method}: key_val
|
||||
|
||||
<section class="text-center"> <!-- BEGIN: section post__options -->
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
$idaa_sess.bb.show__inline_edit__post_comment_id = false;
|
||||
}}
|
||||
@@ -451,7 +480,7 @@ async function handle_delete_post_comment_obj({post_comment_id, method}: key_val
|
||||
disabled={(disable_submit_btn)}
|
||||
class="ae_btn btn_primary btn btn-primary variant-ghost-primary hover:variant-filled-primary transition"
|
||||
>
|
||||
{#await prom_api__post_comment_obj_v2}
|
||||
{#await prom_api__post_comment_obj}
|
||||
<span class="fas fa-spinner fa-spin m-1"></span> Saving
|
||||
{:then}
|
||||
<span class="fas fa-save m-1"></span> Save
|
||||
@@ -467,7 +496,7 @@ async function handle_delete_post_comment_obj({post_comment_id, method}: key_val
|
||||
}}
|
||||
class="ae_btn btn_primary btn btn-primary variant-ghost-primary hover:variant-filled-primary transition"
|
||||
>
|
||||
{#await prom_api__post_comment_obj_v2}
|
||||
{#await prom_api__post_comment_obj}
|
||||
<span class="fas fa-spinner fa-spin m-1"></span> Saving
|
||||
{:then}
|
||||
<span class="fas fa-plus m-1"></span> Save New Event
|
||||
@@ -475,45 +504,39 @@ async function handle_delete_post_comment_obj({post_comment_id, method}: key_val
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#if $idaa_slct.post_id}
|
||||
{#if $idaa_slct.post_comment_id}
|
||||
{#if $ae_loc.administrator_access}
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
if (!confirm('Are you sure you want to delete this post?')) {return false;}
|
||||
handle_delete_post_comment_obj({post_id: $idaa_slct.post_id, method: 'delete'});
|
||||
|
||||
$idaa_slct.post_id = null;
|
||||
// $lq__post_comment_obj = {};
|
||||
if (!confirm('Are you sure you want to delete this post comment?')) {return false;}
|
||||
handle_delete_post_comment_obj({post_comment_id: $idaa_slct.post_comment_id, method: 'delete'});
|
||||
}}
|
||||
class="btn btn-sm variant-soft-warning" type="button"
|
||||
class="btn btn-sm variant-soft-warning"
|
||||
title="Delete record permanently"
|
||||
>
|
||||
<span class="fas fa-minus m-1"></span> Delete
|
||||
</button>
|
||||
{:else if $ae_loc.trusted_access}
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
if (!confirm('Are you sure you want to disable this post?')) {return false;}
|
||||
handle_delete_post_comment_obj({post_id: $idaa_slct.post_id, method: 'disable'});
|
||||
|
||||
$idaa_slct.post_id = null;
|
||||
// $lq__post_comment_obj = {};
|
||||
if (!confirm('Are you sure you want to disable this post comment?')) {return false;}
|
||||
handle_delete_post_comment_obj({post_comment_id: $idaa_slct.post_comment_id, method: 'disable'});
|
||||
}}
|
||||
class="btn btn-sm variant-soft-warning" type="button"
|
||||
class="btn btn-sm variant-soft-warning"
|
||||
title="Disable record to delete"
|
||||
>
|
||||
<span class="fas fa-minus m-1"></span> Delete
|
||||
</button>
|
||||
{:else}
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
if (!confirm('Are you sure you want to hide this post?')) {return false;}
|
||||
handle_delete_post_comment_obj({post_id: $idaa_slct.post_id, method: 'hide'});
|
||||
|
||||
$idaa_slct.post_id = null;
|
||||
// $lq__post_comment_obj = {};
|
||||
if (!confirm('Are you sure you want to hide this post comment?')) {return false;}
|
||||
handle_delete_post_comment_obj({post_comment_id: $idaa_slct.post_comment_id, method: 'hide'});
|
||||
}}
|
||||
class="btn btn-sm variant-soft-warning" type="button"
|
||||
class="btn btn-sm variant-soft-warning"
|
||||
title="Hide record to delete"
|
||||
>
|
||||
<span class="fas fa-comment-slash m-1"></span> Delete
|
||||
@@ -524,11 +547,12 @@ async function handle_delete_post_comment_obj({post_comment_id, method}: key_val
|
||||
|
||||
<div>
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
$idaa_sess.bb.show__inline_edit__post_comment_id = false;
|
||||
}}
|
||||
class="btn btn-sm variant-ghost-warning hover:variant-filled-warning transition"
|
||||
title="Cancel editing of post for {$idaa_slct.post_comment_obj.full_name} (ID: {$idaa_slct.post_comment_obj.post_id}"
|
||||
title="Cancel editing of post for {$idaa_slct.post_comment_obj.full_name} (ID: {$idaa_slct.post_comment_obj.post_comment_id}"
|
||||
>
|
||||
<span class="fas fa-edit m-1"></span> Cancel Edit
|
||||
</button>
|
||||
|
||||
@@ -171,16 +171,43 @@ async function handle_submit_form(event: any) {
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-11-15
|
||||
async function handle_delete_post_obj(
|
||||
{
|
||||
post_id,
|
||||
method = 'disable'
|
||||
}: {
|
||||
post_id: string,
|
||||
method?: string
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log('*** handle_delete_post_obj() ***');
|
||||
}
|
||||
|
||||
async function handle_delete_post_obj({post_id, method}: key_val) {
|
||||
console.log('*** handle_delete_post_obj() ***');
|
||||
prom_api__post_obj = posts_func.delete_ae_obj_id__post({
|
||||
api_cfg: $ae_api,
|
||||
post_id: post_id,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (post_obj_delete_result) {
|
||||
$idaa_sess.bb.show__modal_view__post_id = false;
|
||||
$idaa_sess.bb.show__inline_edit__post_obj = false;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('The result was null or false when trying to delete.', error);
|
||||
})
|
||||
.finally(() => {
|
||||
// $idaa_sess.recovery_meetings.show__modal_edit = false;
|
||||
$idaa_slct.post_id = null;
|
||||
$idaa_slct.post_obj = null;
|
||||
});
|
||||
|
||||
|
||||
return true;
|
||||
return prom_api__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);
|
||||
}
|
||||
@@ -275,6 +302,7 @@ function send_staff_notification_email() {
|
||||
|
||||
<section class="text-center"> <!-- BEGIN: section post__options -->
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
$idaa_sess.bb.show__inline_edit__post_obj = false;
|
||||
}}
|
||||
@@ -815,42 +843,36 @@ function send_staff_notification_email() {
|
||||
{#if $idaa_slct.post_id}
|
||||
{#if $ae_loc.administrator_access}
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
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'});
|
||||
|
||||
$idaa_slct.post_id = null;
|
||||
// $idaa_slct.post_obj = {};
|
||||
}}
|
||||
class="btn btn-sm variant-soft-warning" type="button"
|
||||
class="btn btn-sm variant-soft-warning"
|
||||
title="Delete record permanently"
|
||||
>
|
||||
<span class="fas fa-minus m-1"></span> Delete
|
||||
</button>
|
||||
{:else if $ae_loc.trusted_access}
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
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'});
|
||||
|
||||
$idaa_slct.post_id = null;
|
||||
// $idaa_slct.post_obj = {};
|
||||
}}
|
||||
class="btn btn-sm variant-soft-warning" type="button"
|
||||
class="btn btn-sm variant-soft-warning"
|
||||
title="Disable record to delete"
|
||||
>
|
||||
<span class="fas fa-minus m-1"></span> Delete
|
||||
</button>
|
||||
{:else}
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
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'});
|
||||
|
||||
$idaa_slct.post_id = null;
|
||||
// $idaa_slct.post_obj = {};
|
||||
}}
|
||||
class="btn btn-sm variant-soft-warning" type="button"
|
||||
class="btn btn-sm variant-soft-warning"
|
||||
title="Hide record to delete"
|
||||
>
|
||||
<span class="fas fa-comment-slash m-1"></span> Delete
|
||||
@@ -861,6 +883,7 @@ function send_staff_notification_email() {
|
||||
|
||||
<div>
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
$idaa_sess.bb.show__inline_edit__post_obj = false;
|
||||
}}
|
||||
|
||||
@@ -255,7 +255,10 @@ onDestroy(() => {
|
||||
<section class="post_comment_obj_li space-y-2 border border-1 p-0 border-y-0">
|
||||
{#each $lq__post_comment_obj_li as post_comment_obj, index}
|
||||
|
||||
<div class="p-4 space-y-1 border-b border-b-2">
|
||||
<div
|
||||
class="p-4 space-y-1 border-b border-b-2"
|
||||
class:dim={post_comment_obj?.hide}
|
||||
>
|
||||
|
||||
{#if $idaa_sess.bb.show__inline_edit__post_comment_id == post_comment_obj.post_comment_id}
|
||||
<Comp__post_comment_obj_id_edit
|
||||
|
||||
@@ -20,6 +20,8 @@ onMount(() => {
|
||||
{#if $lq__post_obj_li && $lq__post_obj_li.length}
|
||||
|
||||
{#each $lq__post_obj_li as idaa_post_obj, index}
|
||||
|
||||
{#if idaa_post_obj} <!-- This check for the idaa_post_obj is here in case the IDB entry is deleted. -->
|
||||
<div
|
||||
class="container bb_post post_obj border border-1 rounded p-2 mb-2 space-y-2"
|
||||
class:dim={idaa_post_obj?.hide}
|
||||
@@ -140,6 +142,8 @@ onMount(() => {
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{/each}
|
||||
|
||||
{:else}
|
||||
|
||||
@@ -481,6 +481,8 @@ async function handle_submit_form(event: any) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-11-15
|
||||
async function handle_delete_event_obj(
|
||||
{
|
||||
event_id,
|
||||
|
||||
@@ -38,7 +38,7 @@ onMount(() => {
|
||||
|
||||
{#each $lq__event_obj_li as idaa_event_obj, index}
|
||||
|
||||
{#if idaa_event_obj}
|
||||
{#if idaa_event_obj} <!-- This check for the idaa_event_obj is here in case the IDB entry is deleted. -->
|
||||
<div
|
||||
class="container recovery_meeting event_obj border border-1 rounded p-2 mb-2"
|
||||
class:hidden={(idaa_event_obj?.hide || !idaa_event_obj?.enable) && !$ae_loc.trusted_access}
|
||||
|
||||
Reference in New Issue
Block a user