parent
fd406eb3e6
commit
63e02492e8
@ -19,7 +19,11 @@
|
|||||||
$: amount_input = 0;
|
$: amount_input = 0;
|
||||||
$: is_amount_valid = amount_input > 0;
|
$: is_amount_valid = amount_input > 0;
|
||||||
$: changes_performed =
|
$: 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;
|
$: save_enabled = changes_performed && is_amount_valid;
|
||||||
const donor_promise = DonorService.donorControllerGetAll().then((val) => {
|
const donor_promise = DonorService.donorControllerGetAll().then((val) => {
|
||||||
current_donors = val;
|
current_donors = val;
|
||||||
@ -33,7 +37,7 @@
|
|||||||
data_loaded = true;
|
data_loaded = true;
|
||||||
original_data = Object.assign(original_data, data);
|
original_data = Object.assign(original_data, data);
|
||||||
editable = Object.assign(editable, original_data);
|
editable = Object.assign(editable, original_data);
|
||||||
editable.donor=data.donor.id;
|
editable.donor = data.donor.id;
|
||||||
if (data.responseType == "DISTANCEDONATION") {
|
if (data.responseType == "DISTANCEDONATION") {
|
||||||
editable.runner = data.runner.id;
|
editable.runner = data.runner.id;
|
||||||
amount_input = data.amountPerDistance / 100;
|
amount_input = data.amountPerDistance / 100;
|
||||||
@ -49,42 +53,41 @@
|
|||||||
text: "Donation is being updated",
|
text: "Donation is being updated",
|
||||||
duration: 2500,
|
duration: 2500,
|
||||||
}).showToast();
|
}).showToast();
|
||||||
if(original_data.responseType === "DISTANCEDONATION"){
|
if (original_data.responseType === "DISTANCEDONATION") {
|
||||||
editable.amountPerDistance = Math.floor(amount_input * 100);
|
editable.amountPerDistance = Math.floor(amount_input * 100);
|
||||||
DonationService.donationControllerPutDistance(original_data.id, editable)
|
DonationService.donationControllerPutDistance(
|
||||||
.then((resp) => {
|
original_data.id,
|
||||||
Object.assign(original_data, editable);
|
editable
|
||||||
original_data=original_data;
|
)
|
||||||
Toastify({
|
.then((resp) => {
|
||||||
text: "updated donation",
|
Object.assign(original_data, resp);
|
||||||
duration: 2500,
|
original_data = original_data;
|
||||||
backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
|
Toastify({
|
||||||
}).showToast();
|
text: "updated donation",
|
||||||
})
|
duration: 2500,
|
||||||
.catch((err) => {});
|
backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
|
||||||
}
|
}).showToast();
|
||||||
else{
|
})
|
||||||
|
.catch((err) => {});
|
||||||
|
} else {
|
||||||
editable.amount = Math.floor(amount_input * 100);
|
editable.amount = Math.floor(amount_input * 100);
|
||||||
DonationService.donationControllerPutFixed(original_data.id, editable)
|
DonationService.donationControllerPutFixed(original_data.id, editable)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
Object.assign(original_data, editable);
|
Object.assign(original_data, editable);
|
||||||
original_data=original_data;
|
original_data = original_data;
|
||||||
Toastify({
|
Toastify({
|
||||||
text: "updated donation",
|
text: "updated donation",
|
||||||
duration: 2500,
|
duration: 2500,
|
||||||
backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
|
backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
|
||||||
}).showToast();
|
}).showToast();
|
||||||
})
|
})
|
||||||
.catch((err) => {});
|
.catch((err) => {});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function deleteDonation() {
|
function deleteDonation() {
|
||||||
DonationService.donationControllerRemove(
|
DonationService.donationControllerRemove(original_data.id, false)
|
||||||
original_data.id,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
Toastify({
|
Toastify({
|
||||||
text: "Donation delete",
|
text: "Donation delete",
|
||||||
@ -154,9 +157,7 @@
|
|||||||
{original_data.runner.lastname}
|
{original_data.runner.lastname}
|
||||||
{:else}
|
{:else}
|
||||||
Fixed:
|
Fixed:
|
||||||
{(amount_input)
|
{amount_input.toFixed(2).toLocaleString('de-DE', { valute: 'EUR' })}€
|
||||||
.toFixed(2)
|
|
||||||
.toLocaleString('de-DE', { valute: 'EUR' })}€
|
|
||||||
{/if}
|
{/if}
|
||||||
<span data-id="donation_actions_${original_data.id}">
|
<span data-id="donation_actions_${original_data.id}">
|
||||||
{#if store.state.jwtinfo.userdetails.permissions.includes('DONATION:DELETE')}
|
{#if store.state.jwtinfo.userdetails.permissions.includes('DONATION:DELETE')}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user