Now the saveing button even worx :O

ref #79
This commit is contained in:
Nicolai Ort 2021-02-25 15:04:19 +01:00
parent fd406eb3e6
commit 63e02492e8

View File

@ -19,7 +19,11 @@
$: amount_input = 0;
$: is_amount_valid = amount_input > 0;
$: changes_performed =
!(original_comparison_string === JSON.stringify(editable));
!(original_comparison_string === JSON.stringify(editable)) ||
(original_data.responseType == "DISTANCEDONATION" &&
!(Math.floor(amount_input * 100) === original_data.amountPerDistance)) ||
(original_data.responseType !== "DISTANCEDONATION" &&
!(Math.floor(amount_input * 100) === original_data.amount));
$: save_enabled = changes_performed && is_amount_valid;
const donor_promise = DonorService.donorControllerGetAll().then((val) => {
current_donors = val;
@ -51,9 +55,12 @@
}).showToast();
if (original_data.responseType === "DISTANCEDONATION") {
editable.amountPerDistance = Math.floor(amount_input * 100);
DonationService.donationControllerPutDistance(original_data.id, editable)
DonationService.donationControllerPutDistance(
original_data.id,
editable
)
.then((resp) => {
Object.assign(original_data, editable);
Object.assign(original_data, resp);
original_data = original_data;
Toastify({
text: "updated donation",
@ -62,8 +69,7 @@
}).showToast();
})
.catch((err) => {});
}
else{
} else {
editable.amount = Math.floor(amount_input * 100);
DonationService.donationControllerPutFixed(original_data.id, editable)
.then((resp) => {
@ -81,10 +87,7 @@
}
}
function deleteDonation() {
DonationService.donationControllerRemove(
original_data.id,
false
)
DonationService.donationControllerRemove(original_data.id, false)
.then((resp) => {
Toastify({
text: "Donation delete",
@ -154,9 +157,7 @@
{original_data.runner.lastname}
{:else}
Fixed:
{(amount_input)
.toFixed(2)
.toLocaleString('de-DE', { valute: 'EUR' })}€
{amount_input.toFixed(2).toLocaleString('de-DE', { valute: 'EUR' })}
{/if}
<span data-id="donation_actions_${original_data.id}">
{#if store.state.jwtinfo.userdetails.permissions.includes('DONATION:DELETE')}