feat(donations): Implemented donation deletion via confirm modal
This commit is contained in:
parent
e5c9265588
commit
505fb8cb08
122
src/components/donations/DeleteDonationModal.svelte
Normal file
122
src/components/donations/DeleteDonationModal.svelte
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
<script>
|
||||||
|
import { _ } from "svelte-i18n";
|
||||||
|
import { clickOutside } from "../base/outsideclick";
|
||||||
|
import { createEventDispatcher, onMount } from "svelte";
|
||||||
|
export let modal_open;
|
||||||
|
export let delete_donation = {
|
||||||
|
id: 0,
|
||||||
|
runner: {
|
||||||
|
firstname: "",
|
||||||
|
lastname: "",
|
||||||
|
},
|
||||||
|
donor: {
|
||||||
|
firstname: "",
|
||||||
|
lastname: "",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const dispatch = createEventDispatcher();
|
||||||
|
onMount(() => {
|
||||||
|
document.onkeydown = (e) => {
|
||||||
|
e = e || window.event;
|
||||||
|
if (e.key === "Escape") {
|
||||||
|
modal_open = false;
|
||||||
|
}
|
||||||
|
if (e.keyCode === 13) {
|
||||||
|
if (createbtnenabled === true) {
|
||||||
|
createbtnenabled = false;
|
||||||
|
submit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
async function submit() {
|
||||||
|
dispatch("delete", { id: delete_donation.id });
|
||||||
|
modal_open = false;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if modal_open}
|
||||||
|
<div
|
||||||
|
class="fixed z-10 inset-0 overflow-y-auto"
|
||||||
|
use:clickOutside
|
||||||
|
on:click_outside={() => {
|
||||||
|
modal_open = false;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"
|
||||||
|
>
|
||||||
|
<div class="fixed inset-0 transition-opacity" aria-hidden="true">
|
||||||
|
<div
|
||||||
|
class="absolute inset-0 bg-gray-500 opacity-75"
|
||||||
|
data-id="modal_backdrop"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<span
|
||||||
|
class="hidden sm:inline-block sm:align-middle sm:h-screen"
|
||||||
|
aria-hidden="true">​</span
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="inline-block align-bottom bg-white rounded-lg text-left shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="modal-headline"
|
||||||
|
>
|
||||||
|
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
|
||||||
|
<div class="sm:flex sm:items-start">
|
||||||
|
<div
|
||||||
|
class="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-blue-100 sm:mx-0 sm:h-10 sm:w-10"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="h-6 w-6 text-blue-600"
|
||||||
|
fill="currentColor"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
><path fill="none" d="M0 0h24v24H0z" />
|
||||||
|
<path
|
||||||
|
d="M14 2a8 8 0 013.3 15.3A8 8 0 116.7 6.7 8 8 0 0114 2zm-3 7H9v1a2.5 2.5 0 00-.16 5h2.25a.5.5 0 010 1H7v2h2v1h2v-1a2.5 2.5 0 00.16-5H8.91a.5.5 0 010-1H13v-2h-2V9zm3-5a5.99 5.99 0 00-4.48 2.01 8 8 0 018.47 8.47A6 6 0 0014 4z"
|
||||||
|
/></svg
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">
|
||||||
|
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
||||||
|
{$_("confirm-delete")}
|
||||||
|
</h3>
|
||||||
|
<div class="mt-2 mb-6">
|
||||||
|
<p class="text-sm text-gray-500">
|
||||||
|
{$_("please-confirm-the-deletion-of-donation")}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="w-full">
|
||||||
|
<span class="inline-block"
|
||||||
|
><b>{$_("donor")}</b>: {delete_donation.donor.firstname}
|
||||||
|
{delete_donation.donor.lastname}</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
|
||||||
|
<button
|
||||||
|
on:click={submit}
|
||||||
|
type="button"
|
||||||
|
class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm"
|
||||||
|
>
|
||||||
|
{$_("delete")}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
on:click={() => {
|
||||||
|
modal_open = false;
|
||||||
|
}}
|
||||||
|
type="button"
|
||||||
|
class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"
|
||||||
|
>
|
||||||
|
{$_("cancel")}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
@ -22,6 +22,7 @@
|
|||||||
import DonationRunner from "./DonationRunner.svelte";
|
import DonationRunner from "./DonationRunner.svelte";
|
||||||
import DonationStatus from "./DonationStatus.svelte";
|
import DonationStatus from "./DonationStatus.svelte";
|
||||||
import DonationTableAction from "./DonationTableAction.svelte";
|
import DonationTableAction from "./DonationTableAction.svelte";
|
||||||
|
import DeleteDonationModal from "./DeleteDonationModal.svelte";
|
||||||
$: searchvalue = "";
|
$: searchvalue = "";
|
||||||
$: active_deletes = [];
|
$: active_deletes = [];
|
||||||
$: active_edits = [];
|
$: active_edits = [];
|
||||||
@ -32,10 +33,6 @@
|
|||||||
$: dataLoaded = false;
|
$: dataLoaded = false;
|
||||||
|
|
||||||
export let current_donations = [];
|
export let current_donations = [];
|
||||||
export let payment_modal_open = false;
|
|
||||||
export let editable = {};
|
|
||||||
export let original_data = {};
|
|
||||||
export let paid_amount_input = 0;
|
|
||||||
export const addDonations = (donations) => {
|
export const addDonations = (donations) => {
|
||||||
current_donations = current_donations.concat(...donations);
|
current_donations = current_donations.concat(...donations);
|
||||||
options.update((options) => ({
|
options.update((options) => ({
|
||||||
@ -150,6 +147,22 @@
|
|||||||
});
|
});
|
||||||
const table = createSvelteTable(options);
|
const table = createSvelteTable(options);
|
||||||
|
|
||||||
|
async function deleteDonation(delete_donation_id) {
|
||||||
|
await DonationService.donationControllerRemove(delete_donation_id, true);
|
||||||
|
current_donations = current_donations.filter(
|
||||||
|
(r) => r.id !== delete_donation_id
|
||||||
|
);
|
||||||
|
options.update((options) => ({
|
||||||
|
...options,
|
||||||
|
data: current_donations,
|
||||||
|
}));
|
||||||
|
Toastify({
|
||||||
|
text: $_("donation-deleted"),
|
||||||
|
duration: 3500,
|
||||||
|
backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
|
||||||
|
}).showToast();
|
||||||
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
let page = 0;
|
let page = 0;
|
||||||
while (page >= 0) {
|
while (page >= 0) {
|
||||||
@ -188,6 +201,13 @@
|
|||||||
}));
|
}));
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<DeleteDonationModal
|
||||||
|
delete_donation={active_deletes[0]}
|
||||||
|
modal_open={active_deletes.length > 0}
|
||||||
|
on:delete={(event) => {
|
||||||
|
deleteDonation(event.detail.id);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
{#if store.state.jwtinfo.userdetails.permissions.includes("DONATION:GET")}
|
{#if store.state.jwtinfo.userdetails.permissions.includes("DONATION:GET")}
|
||||||
{#if !dataLoaded}
|
{#if !dataLoaded}
|
||||||
<div
|
<div
|
||||||
|
@ -495,5 +495,6 @@
|
|||||||
"you-have-to-provide-an-organization": "Du musst eine Organisation angeben",
|
"you-have-to-provide-an-organization": "Du musst eine Organisation angeben",
|
||||||
"you-have-to-save-your-changes-to-generate-a-link": "Du musst deine Änderungen speichern, um einen Link zu generieren.",
|
"you-have-to-save-your-changes-to-generate-a-link": "Du musst deine Änderungen speichern, um einen Link zu generieren.",
|
||||||
"you-must-create-at-least-one-card-or-cancel": "Du musst mindestens eine Blankokarte erstellen (oder abbrechen).",
|
"you-must-create-at-least-one-card-or-cancel": "Du musst mindestens eine Blankokarte erstellen (oder abbrechen).",
|
||||||
"zip-postal-code": "Postleitzahl"
|
"zip-postal-code": "Postleitzahl",
|
||||||
|
"please-confirm-the-deletion-of-donation": "Bitte bestätige die Löschung des Sponsorings"
|
||||||
}
|
}
|
@ -495,5 +495,6 @@
|
|||||||
"you-have-to-provide-an-organization": "You have to provide an organization",
|
"you-have-to-provide-an-organization": "You have to provide an organization",
|
||||||
"you-have-to-save-your-changes-to-generate-a-link": "You have to save your changes to generate a link.",
|
"you-have-to-save-your-changes-to-generate-a-link": "You have to save your changes to generate a link.",
|
||||||
"you-must-create-at-least-one-card-or-cancel": "You must create at least one card (or cancel).",
|
"you-must-create-at-least-one-card-or-cancel": "You must create at least one card (or cancel).",
|
||||||
"zip-postal-code": "ZIP/ postal code"
|
"zip-postal-code": "ZIP/ postal code",
|
||||||
|
"please-confirm-the-deletion-of-donation": "Please confirm the deletion of this donation"
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user