Skip to content

Commit 656563f

Browse files
committed
Added quantity support for donations & fixed bugs
Added watched properties and fixed totalling error Add min/max validation Added check for zero Added semantic validation Added dynamic popup for ticket buyers Modified validation rules
1 parent 1a63370 commit 656563f

File tree

5 files changed

+90
-35
lines changed

5 files changed

+90
-35
lines changed

app/components/forms/wizard/basic-details-step.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ export default Component.extend(FormMixin, EventWizardMixin, {
121121
},
122122

123123
getValidationRules() {
124+
window.$.fn.form.settings.rules.checkMaxMin = () => {
125+
let returnValue = false;
126+
if (this.$('.ui.form').form('get value', 'min_price')[0] < this.$('.ui.form').form('get value', 'max_price')[0]) {
127+
returnValue = true;
128+
}
129+
return returnValue;
130+
};
124131
let validationRules = {
125132
inline : true,
126133
delay : false,
@@ -269,6 +276,40 @@ export default Component.extend(FormMixin, EventWizardMixin, {
269276
}
270277
]
271278
},
279+
ticketMinPrice: {
280+
identifier : 'min_price',
281+
rules : [
282+
{
283+
type : 'empty',
284+
prompt : this.l10n.t('Minimum price for donation tickets required')
285+
},
286+
{
287+
type : 'integer[1..]',
288+
prompt : this.l10n.t('Ticket price needs to be greater than zero')
289+
},
290+
{
291+
type : 'checkMaxMin',
292+
prompt : this.l10n.t('Ticket min price should be lesser than max price')
293+
}
294+
]
295+
},
296+
ticketMaxPrice: {
297+
identifier : 'max_price',
298+
rules : [
299+
{
300+
type : 'empty',
301+
prompt : this.l10n.t('Maximum price for donation tickets required')
302+
},
303+
{
304+
type : 'integer[1..]',
305+
prompt : this.l10n.t('Ticket max price should be greater than 0')
306+
},
307+
{
308+
type : 'checkMaxMin',
309+
prompt : this.l10n.t('Ticket max price should be greater than min price')
310+
}
311+
]
312+
},
272313
paypalEmail: {
273314
identifier : 'paypal_email',
274315
rules : [

app/components/public/ticket-list.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export default Component.extend(FormMixin, {
1515
&& !this.get('authManager.currentUser.isVerified');
1616
}),
1717

18-
shouldDisableOrderButton: computed('isUnverified', 'hasTicketsInOrder', function() {
19-
return !this.hasTicketsInOrder;
18+
shouldDisableOrderButton: computed('hasTicketsInOrder', 'isDonationPriceValid', function() {
19+
return !(this.hasTicketsInOrder && this.isDonationPriceValid);
2020
}),
2121

2222
showTaxIncludedMessage: computed('taxInfo.isTaxIncludedInPrice', function() {
@@ -40,7 +40,23 @@ export default Component.extend(FormMixin, {
4040
) > 0;
4141
}),
4242

43-
total: computed('[email protected]', '[email protected]', function() {
43+
donationTickets: computed.filterBy('data', 'type', 'donation'),
44+
45+
isDonationPriceValid: computed('[email protected]', '[email protected]', function() {
46+
let returnValue = false;
47+
this.donationTickets.forEach(donationTicket => {
48+
if (donationTicket.orderQuantity >= 0) {
49+
if (donationTicket.price >= donationTicket.minPrice) {
50+
returnValue = true;
51+
} else {
52+
returnValue = false;
53+
}
54+
}
55+
});
56+
return returnValue;
57+
}),
58+
59+
total: computed('[email protected]', '[email protected]', '[email protected]', function() {
4460
if (this.taxInfo !== null) {
4561
return sumBy(this.tickets.toArray(),
4662
ticket => (ticket.ticketPriceWithTax || 0) * (ticket.orderQuantity || 0)
@@ -190,6 +206,19 @@ export default Component.extend(FormMixin, {
190206
prompt : this.l10n.t('Please enter the promotional Code')
191207
}
192208
]
209+
},
210+
price: {
211+
identifier : 'price',
212+
rules : [
213+
{
214+
type : 'number',
215+
prompt : this.l10n.t('Invalid number')
216+
},
217+
{
218+
type : 'integer[1..]',
219+
prompt : this.l10n.t('Donation should be greater than 0')
220+
}
221+
]
193222
}
194223
}
195224
};

app/models/ticket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default ModelBase.extend({
2121
salesEndsAt : attr('moment', { defaultValue: () => moment().add(10, 'days').startOf('day') }),
2222
minOrder : attr('number', { defaultValue: 1 }),
2323
maxOrder : attr('number', { defaultValue: 10 }),
24-
minPrice : attr('number'),
24+
minPrice : attr('number', { defaultValue: 1 }),
2525
maxPrice : attr('number'),
2626
isFeeAbsorbed : attr('boolean', { defaultValue: true }),
2727
position : attr('number'),

app/templates/components/public/ticket-list.hbs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<td>
1717
<div class="ui small">
1818
{{ticket.name}}
19+
{{#if (eq ticket.type 'donation')}}
20+
{{ui-popup tagName="i" class="info icon" content=(concat "Donation value should be greater than " ticket.minPrice " " eventCurrency)}}
21+
{{/if}}
1922
</div>
2023
{{#if ticket.isDescriptionVisible}}
2124
<small class="ui gray-text tiny">{{ticket.description}}</small>
@@ -47,7 +50,13 @@
4750
</td>
4851
{{else}}
4952
<td id="{{ticket.id}}_price">
50-
{{currency-symbol eventCurrency}} {{format-number ticket.price}}
53+
{{#if (eq ticket.type 'donation') }}
54+
<div class="field">
55+
{{input type='number' name="price" placeholder=(t 'Enter Donation') min=ticket.minPrice max=ticket.maxPrice value=ticket.price}}<br>
56+
</div>
57+
{{else}}
58+
{{currency-symbol eventCurrency}} {{format-number ticket.price}}
59+
{{/if}}
5160
{{#if (and taxInfo (not-eq ticket.type 'free'))}}
5261
{{#if showTaxIncludedMessage}}
5362
<small class="ui gray-text small">
@@ -63,22 +72,6 @@
6372
</div>
6473
{{/if}}
6574
</td>
66-
{{#if (eq ticket.type 'donation') }}
67-
<div class="three wide column">
68-
<td id="{{ticket.id}}_price">{{input type='number' value=ticket.price}}</td>
69-
</div>
70-
{{else}}
71-
{{#if ticket.discount}}
72-
<td>
73-
<div id="{{ticket.id}}_price" class="strike text">
74-
{{currency-symbol eventCurrency}} {{format-number ticket.price}}
75-
</div>
76-
<div id="{{ticket.id}}_discount">
77-
{{currency-symbol eventCurrency}} {{format-number (sub ticket.price ticket.discount)}}
78-
</div>
79-
</td>
80-
{{/if}}
81-
{{/if}}
8275
{{/if}}
8376
<td>
8477
<div class="field">

app/templates/components/widgets/forms/ticket-input.hbs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
{{else if (eq ticket.type 'donation')}}
1313
<div class="two fields">
1414
<div class="field">
15-
{{input type='number' name='min_price' placeholder=(t 'Min') value=ticket.minOrder}}
15+
{{input type='number' name='min_price' placeholder=(t 'Min') value=ticket.minPrice min=1}}
1616
</div>
1717
<div class="field">
18-
{{input type='number' name='max_price' placeholder=(t 'Max') value=ticket.maxOrder}}
18+
{{input type='number' name='max_price' placeholder=(t 'Max') value=ticket.maxPrice min=1}}
1919
</div>
2020
</div>
2121
{{else if (eq ticket.type 'free')}}
@@ -26,19 +26,11 @@
2626
</div>
2727
{{/if}}
2828
</div>
29-
{{#if (eq ticket.type 'donation')}}
30-
<div class="four wide column">
31-
<span class="text muted ticket-input">
32-
{{t 'This is a Donation Ticket'}}
33-
</span>
34-
</div>
35-
{{else}}
36-
<div class="four wide column">
37-
<div class="field">
38-
{{input type='number' name='ticket_quantity' placeholder=(t 'Quantity') value=ticket.maxOrder min=1}}
39-
</div>
29+
<div class="four wide column">
30+
<div class="field">
31+
{{input type='number' name='ticket_quantity' placeholder=(t 'Quantity') value=ticket.quantity min=1}}
4032
</div>
41-
{{/if}}
33+
</div>
4234
<div class="column {{unless device.isLargeMonitor 'less right padding'}}">
4335
<div class="field">
4436
<div class="ui icon buttons">

0 commit comments

Comments
 (0)