Work on "delete" functions for recovery meetings.
This commit is contained in:
@@ -225,7 +225,7 @@ $: if ($idaa_slct.event_obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($idaa_slct.event_obj == null) {
|
if ($idaa_slct.event_obj == null) {
|
||||||
// $idaa_slct.event_obj = {code: null, name: null, description: null, start_datetime: null, end_datetime: null, notes: null};
|
$idaa_slct.event_obj = {contact_li_json: []};
|
||||||
} else {
|
} else {
|
||||||
disable_submit_btn = false;
|
disable_submit_btn = false;
|
||||||
}
|
}
|
||||||
@@ -481,32 +481,35 @@ async function handle_submit_form(event: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handle_delete_event_obj({event_id, method='disable'}) {
|
async function handle_delete_event_obj(
|
||||||
console.log('*** handle_delete_event_obj() ***');
|
{
|
||||||
|
event_id,
|
||||||
|
method = 'disable'
|
||||||
|
}: {
|
||||||
|
event_id: string,
|
||||||
|
method?: string
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
if (log_lvl) {
|
||||||
|
console.log('*** handle_delete_event_obj() ***');
|
||||||
|
}
|
||||||
|
|
||||||
prom_api__event_obj = api.delete_ae_obj_id_crud({
|
prom_api__event_obj = events_func.delete_ae_obj_id__event({
|
||||||
api_cfg: $ae_api,
|
api_cfg: $ae_api,
|
||||||
obj_type: 'event',
|
event_id: event_id,
|
||||||
obj_id: event_id,
|
|
||||||
method: method,
|
method: method,
|
||||||
// params: params,
|
log_lvl: log_lvl
|
||||||
key: $ae_api.api_crud_super_key,
|
|
||||||
log_lvl: 0
|
|
||||||
})
|
})
|
||||||
.then(function (event_obj_delete_result) {
|
.then(function (event_obj_delete_result) {
|
||||||
if (event_obj_delete_result) {
|
$idaa_sess.recovery_meetings.show__modal_edit = false;
|
||||||
// console.log(`Result:`, event_obj_delete_result);
|
|
||||||
|
|
||||||
dispatch(
|
|
||||||
'deleted__event_obj',
|
|
||||||
{
|
|
||||||
event_id: event_id,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
console.log('The result was null or false when trying to delete.', 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.event_id = null;
|
||||||
|
$idaa_slct.event_obj = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
return prom_api__event_obj;
|
return prom_api__event_obj;
|
||||||
@@ -1009,7 +1012,7 @@ async function handle_delete_event_obj({event_id, method='disable'}) {
|
|||||||
|
|
||||||
<span class="ae_group">
|
<span class="ae_group">
|
||||||
|
|
||||||
{#if !($ae_loc.administrator_access || $idaa_slct.event_obj?.contact_li_json[0]?.unlock)}
|
{#if !($ae_loc.administrator_access || ($idaa_slct.event_obj?.contact_li_json?.length && $idaa_slct.event_obj?.contact_li_json[0]?.unlock))}
|
||||||
<button type="button" class="ae_btn ae_smaller ae_btn_info"
|
<button type="button" class="ae_btn ae_smaller ae_btn_info"
|
||||||
on:click|preventDefault={() => {
|
on:click|preventDefault={() => {
|
||||||
if (confirm('Are you sure you want to lock these fields? The primary contact name and email address are required.')) {
|
if (confirm('Are you sure you want to lock these fields? The primary contact name and email address are required.')) {
|
||||||
@@ -1228,42 +1231,45 @@ async function handle_delete_event_obj({event_id, method='disable'}) {
|
|||||||
{#if $idaa_slct.event_id}
|
{#if $idaa_slct.event_id}
|
||||||
{#if $ae_loc.administrator_access}
|
{#if $ae_loc.administrator_access}
|
||||||
<button
|
<button
|
||||||
|
type="button"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
if (!confirm('Are you sure you want to delete this event?')) {return false;}
|
if (!confirm('Are you sure you want to delete this event?')) {return false;}
|
||||||
handle_delete_event_obj({event_id: $idaa_slct.event_id, method: 'delete'});
|
handle_delete_event_obj({event_id: $idaa_slct.event_id, method: 'delete'});
|
||||||
|
|
||||||
$idaa_slct.event_id = null;
|
// $idaa_slct.event_id = null;
|
||||||
$lq__event_obj = {};
|
// $lq__event_obj = {};
|
||||||
}}
|
}}
|
||||||
class="btn btn-sm variant-soft-warning" type="button"
|
class="btn btn-sm variant-soft-warning"
|
||||||
title="Delete record permanently"
|
title="Delete record permanently"
|
||||||
>
|
>
|
||||||
<span class="fas fa-minus m-1"></span> Delete
|
<span class="fas fa-minus m-1"></span> Delete
|
||||||
</button>
|
</button>
|
||||||
{:else if $ae_loc.trusted_access}
|
{:else if $ae_loc.trusted_access}
|
||||||
<button
|
<button
|
||||||
|
type="button"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
if (!confirm('Are you sure you want to disable this event?')) {return false;}
|
if (!confirm('Are you sure you want to disable this event?')) {return false;}
|
||||||
handle_delete_event_obj({event_id: $idaa_slct.event_id, method: 'disable'});
|
handle_delete_event_obj({event_id: $idaa_slct.event_id, method: 'disable'});
|
||||||
|
|
||||||
$idaa_slct.event_id = null;
|
// $idaa_slct.event_id = null;
|
||||||
$lq__event_obj = {};
|
// $lq__event_obj = {};
|
||||||
}}
|
}}
|
||||||
class="btn btn-sm variant-soft-warning" type="button"
|
class="btn btn-sm variant-soft-warning"
|
||||||
title="Disable record to delete"
|
title="Disable record to delete"
|
||||||
>
|
>
|
||||||
<span class="fas fa-minus m-1"></span> Delete
|
<span class="fas fa-minus m-1"></span> Delete
|
||||||
</button>
|
</button>
|
||||||
{:else}
|
{:else}
|
||||||
<button
|
<button
|
||||||
|
type="button"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
if (!confirm('Are you sure you want to hide this event?')) {return false;}
|
if (!confirm('Are you sure you want to hide this event?')) {return false;}
|
||||||
handle_delete_event_obj({event_id: $idaa_slct.event_id, method: 'hide'});
|
handle_delete_event_obj({event_id: $idaa_slct.event_id, method: 'hide'});
|
||||||
|
|
||||||
$idaa_slct.event_id = null;
|
// $idaa_slct.event_id = null;
|
||||||
$lq__event_obj = {};
|
// $lq__event_obj = {};
|
||||||
}}
|
}}
|
||||||
class="btn btn-sm variant-soft-warning" type="button"
|
class="btn btn-sm variant-soft-warning"
|
||||||
title="Hide record to delete"
|
title="Hide record to delete"
|
||||||
>
|
>
|
||||||
<span class="fas fa-comment-slash m-1"></span> Delete
|
<span class="fas fa-comment-slash m-1"></span> Delete
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ onMount(() => {
|
|||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
{#each $lq__event_obj_li as idaa_event_obj, index}
|
{#each $lq__event_obj_li as idaa_event_obj, index}
|
||||||
|
|
||||||
|
{#if idaa_event_obj}
|
||||||
<div
|
<div
|
||||||
class="container recovery_meeting event_obj border border-1 rounded p-2 mb-2"
|
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}
|
class:hidden={(idaa_event_obj?.hide || !idaa_event_obj?.enable) && !$ae_loc.trusted_access}
|
||||||
@@ -292,7 +294,10 @@ onMount(() => {
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user