Made the closing of the modals cleaner

This commit is contained in:
Scott Idem
2024-02-27 17:04:03 -05:00
parent c93d84f3c3
commit 22efa3fd96
5 changed files with 27 additions and 219 deletions

View File

@@ -34,6 +34,8 @@ const modal_edit__event_presenter_obj: ModalSettings = {
component: modalComponentEditEventPresenterObj,
title: 'Edit Event Presenter',
position: '', // default is "items-center"
response: (r: boolean | undefined) => handle_modal_close(r)
};
// Viewing
@@ -55,8 +57,19 @@ const modal_view__event_presenter_obj: ModalSettings = {
// component_root_classes: 'w-full',
// fn: do_something_function
// },
response: (r: boolean | undefined) => handle_modal_close(r)
};
function handle_modal_close(response: boolean | undefined) {
console.log('Modal closed. Response:', response);
let location = window.location.href;
const url = new URL(location);
url.searchParams.delete('event_presenter_id');
history.pushState({}, '', url);
}
// We don't want the edit or view to show up by default. Maybe if we see an object ID param in the URL, we can show the view modal.
$ae_loc.mod.events.show_edit__event_presenter_obj = false;
$ae_loc.mod.sponsorships.show_view__event_presenter_obj = false;

View File

@@ -125,15 +125,7 @@ onMount(() => {
{/if}
<button
class="btn {parent.buttonNeutral}"
on:click={() => {
let location = window.location.href;
const url = new URL(location);
url.searchParams.delete('event_presenter_id');
history.pushState({}, '', url);
parent.onClose();
}}
on:click={() => {parent.onClose();}}
>
{parent.buttonTextCancel}
</button>