Compare commits

..

No commits in common. "8b95b300e283b25a9e25acbd6ffd5c003e30e59c" and "7edc3427e10166d2a5e1b911cc459b26b37f984b" have entirely different histories.

2 changed files with 22 additions and 30 deletions

View File

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

View File

@ -148,26 +148,18 @@
class="block text-sm font-medium text-gray-700">{$_('organization')}</label>
<Select
containerClasses="rounded-l-md mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm rounded-l-md sm:text-sm border-gray-300 border bg-gray-50 text-gray-500 rounded-md p-2"
getSelectionLabel={(option) => {
return option.name;
}}
getOptionLabel={(option) => {
return option.name;
}}
itemFilter={(label, filterText, option) => label
.toLowerCase()
.includes(
filterText.toLowerCase()
) || option.id
.toString()
.startsWith(filterText.toLowerCase())}
getSelectionLabel={(option) => {return option.name}}
getOptionLabel={(option) => {return option.name}}
itemFilter={(label, filterText, option) =>
label.toLowerCase().includes(filterText.toLowerCase()) ||
option.id.toString().startsWith(filterText.toLowerCase())}
items={orgs}
showChevron={true}
placeholder={$_('search-for-an-organization-by-name-or-id')}
noOptionsMessage={$_('no-organizations-found')}
on:select={(selectedValue) => (parentGroup = selectedValue.detail.id)}
on:clear={() => (parentGroup = null)} />
{#if !parentGroup}
on:clear={()=>(parentGroup = null)} />
{#if !parentGroup}
<span
class="flex items-center font-medium tracking-wide text-red-500 text-xs mt-1 ml-1">
{$_('you-have-to-provide-an-organization')}