Skip to content

Commit ac5de5f

Browse files
committed
Optimized donationsValidation property
1 parent 58f0a63 commit ac5de5f

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

app/components/public/ticket-list.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,14 @@ export default Component.extend(FormMixin, {
4949
donationTickets: computed.filterBy('data', 'type', 'donation'),
5050

5151
isDonationPriceValid: computed('[email protected]', '[email protected]', function() {
52-
let returnValue = false;
53-
this.donationTickets.forEach(donationTicket => {
52+
for (const donationTicket of this.donationTickets) {
5453
if (donationTicket.orderQuantity > 0) {
55-
if (donationTicket.price >= donationTicket.minPrice && donationTicket.price <= donationTicket.maxPrice) {
56-
returnValue = true;
57-
} else {
58-
returnValue = false;
54+
if (donationTicket.price < donationTicket.minPrice || donationTicket.price > donationTicket.maxPrice) {
55+
return false;
5956
}
60-
} else {
61-
returnValue = true;
6257
}
63-
});
64-
return returnValue;
58+
}
59+
return true;
6560
}),
6661

6762
total: computed('[email protected]', '[email protected]', '[email protected]', function() {
@@ -201,7 +196,7 @@ export default Component.extend(FormMixin, {
201196
}
202197
},
203198
donationTicketsValidation: computed('[email protected]', '[email protected]', '[email protected]', function() {
204-
let validationRules = {};
199+
const validationRules = {};
205200
for (let donationTicket of this.donationTickets) {
206201
validationRules[donationTicket.id] = {
207202
identifier : donationTicket.id,
@@ -217,7 +212,7 @@ export default Component.extend(FormMixin, {
217212
return validationRules;
218213
}),
219214
getValidationRules() {
220-
let validationRules = {
215+
const validationRules = {
221216
inline : true,
222217
delay : false,
223218
on : 'blur',

0 commit comments

Comments
 (0)