parent
e1bd364278
commit
8b95b300e2
@ -13,14 +13,13 @@
|
|||||||
export let params;
|
export let params;
|
||||||
$: delete_triggered = false;
|
$: delete_triggered = false;
|
||||||
$: original_data = {};
|
$: original_data = {};
|
||||||
$: original_comparison_string = "";
|
|
||||||
$: editable = {};
|
$: editable = {};
|
||||||
$: current_donors = [];
|
$: current_donors = [];
|
||||||
$: current_runners = [];
|
$: current_runners = [];
|
||||||
$: 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)) ||
|
!(JSON.stringify(original_data) === JSON.stringify(editable)) ||
|
||||||
(original_data.responseType == "DISTANCEDONATION" &&
|
(original_data.responseType == "DISTANCEDONATION" &&
|
||||||
!(Math.floor(amount_input * 100) === original_data.amountPerDistance)) ||
|
!(Math.floor(amount_input * 100) === original_data.amountPerDistance)) ||
|
||||||
(original_data.responseType !== "DISTANCEDONATION" &&
|
(original_data.responseType !== "DISTANCEDONATION" &&
|
||||||
@ -38,14 +37,11 @@
|
|||||||
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;
|
|
||||||
if (data.responseType == "DISTANCEDONATION") {
|
if (data.responseType == "DISTANCEDONATION") {
|
||||||
editable.runner = data.runner.id;
|
|
||||||
amount_input = data.amountPerDistance / 100;
|
amount_input = data.amountPerDistance / 100;
|
||||||
} else {
|
} else {
|
||||||
amount_input = data.amount / 100;
|
amount_input = data.amount / 100;
|
||||||
}
|
}
|
||||||
original_comparison_string = JSON.stringify(editable);
|
|
||||||
});
|
});
|
||||||
const getDonorLabel = (option) =>
|
const getDonorLabel = (option) =>
|
||||||
option.firstname + " " + (option.middlename || "") + " " + option.lastname;
|
option.firstname + " " + (option.middlename || "") + " " + option.lastname;
|
||||||
@ -59,16 +55,19 @@
|
|||||||
text: "Donation is being updated",
|
text: "Donation is being updated",
|
||||||
duration: 2500,
|
duration: 2500,
|
||||||
}).showToast();
|
}).showToast();
|
||||||
|
let postdata = {};
|
||||||
if (original_data.responseType === "DISTANCEDONATION") {
|
if (original_data.responseType === "DISTANCEDONATION") {
|
||||||
editable.amountPerDistance = Math.floor(amount_input * 100);
|
editable.amountPerDistance = Math.floor(amount_input * 100);
|
||||||
|
postdata = Object.assign(postdata, editable);
|
||||||
|
postdata.runner = postdata.runner.id;
|
||||||
|
postdata.donor = postdata.donor.id;
|
||||||
DonationService.donationControllerPutDistance(
|
DonationService.donationControllerPutDistance(
|
||||||
original_data.id,
|
original_data.id,
|
||||||
editable
|
postdata
|
||||||
)
|
)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
Object.assign(original_data, resp);
|
Object.assign(original_data, editable);
|
||||||
original_data = original_data;
|
original_data = original_data;
|
||||||
original_comparison_string = JSON.stringify(editable);
|
|
||||||
Toastify({
|
Toastify({
|
||||||
text: "updated donation",
|
text: "updated donation",
|
||||||
duration: 2500,
|
duration: 2500,
|
||||||
@ -78,7 +77,10 @@
|
|||||||
.catch((err) => {});
|
.catch((err) => {});
|
||||||
} else {
|
} else {
|
||||||
editable.amount = Math.floor(amount_input * 100);
|
editable.amount = Math.floor(amount_input * 100);
|
||||||
DonationService.donationControllerPutFixed(original_data.id, editable)
|
postdata = Object.assign(postdata, editable);
|
||||||
|
postdata.runner = postdata.runner.id;
|
||||||
|
postdata.donor = postdata.donor.id;
|
||||||
|
DonationService.donationControllerPutFixed(original_data.id, postdata)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
Object.assign(original_data, editable);
|
Object.assign(original_data, editable);
|
||||||
original_data = original_data;
|
original_data = original_data;
|
||||||
@ -218,9 +220,8 @@
|
|||||||
showChevron={true}
|
showChevron={true}
|
||||||
placeholder={$_('search-for-donor-name-or-id')}
|
placeholder={$_('search-for-donor-name-or-id')}
|
||||||
noOptionsMessage={$_('no-donors-found')}
|
noOptionsMessage={$_('no-donors-found')}
|
||||||
selectedValue={current_donors.find((d) => (d.id == editable.donor))}
|
bind:selectedValue={editable.donor}
|
||||||
on:select={(selectedValue) => (editable.donor = selectedValue.detail.id)}
|
on:clear={() => (editable.donor = null)} />
|
||||||
on:clear={()=>(editable.donor = null)}/>
|
|
||||||
</div>
|
</div>
|
||||||
{#if original_data.responseType == 'DISTANCEDONATION'}
|
{#if original_data.responseType == 'DISTANCEDONATION'}
|
||||||
<div class=" w-full">
|
<div class=" w-full">
|
||||||
@ -236,9 +237,8 @@
|
|||||||
showChevron={true}
|
showChevron={true}
|
||||||
placeholder={$_('search-for-runner-by-name-or-id')}
|
placeholder={$_('search-for-runner-by-name-or-id')}
|
||||||
noOptionsMessage={$_('no-runners-found')}
|
noOptionsMessage={$_('no-runners-found')}
|
||||||
selectedValue={undefined || current_runners.find((r) => (r.id = original_data.runner.id))}
|
bind:selectedValue={editable.runner}
|
||||||
on:select={(selectedValue) => (editable.runner == selectedValue.detail.id)}
|
on:clear={() => (editable.runner = null)} />
|
||||||
on:clear={()=>(editable.runner = null)} />
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class=" w-full">
|
<div class=" w-full">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user