Skip to content

Commit 0bbaa13

Browse files
authored
fix: minOrder-maxOrder & minPrice-maxPrice validation in basic-details-step (#3849)
1 parent 0c4fa2e commit 0bbaa13

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { inject as service } from '@ember/service';
1212
import EventWizardMixin from 'open-event-frontend/mixins/event-wizard';
1313
import { protocolLessValidUrlPattern } from 'open-event-frontend/utils/validators';
1414
import ENV from 'open-event-frontend/config/environment';
15+
import $ from 'jquery';
1516

1617
export default Component.extend(FormMixin, EventWizardMixin, {
1718

@@ -128,6 +129,12 @@ export default Component.extend(FormMixin, EventWizardMixin, {
128129

129130
// TODO: Removing the Event Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667
130131
getValidationRules() {
132+
$.fn.form.settings.rules.checkMaxMinPrice = () => {
133+
return $('.ui.form').form('get value', 'min_price') <= $('.ui.form').form('get value', 'max_price');
134+
};
135+
$.fn.form.settings.rules.checkMaxMinOrder = () => {
136+
return $('.ui.form').form('get value', 'ticket_min_order') <= $('.ui.form').form('get value', 'ticket_max_order');
137+
};
131138

132139
let validationRules = {
133140
inline : true,
@@ -257,6 +264,10 @@ export default Component.extend(FormMixin, EventWizardMixin, {
257264
{
258265
type : 'number',
259266
prompt : this.l10n.t('Invalid number')
267+
},
268+
{
269+
type : 'checkMaxMinOrder',
270+
prompt : this.l10n.t('Minimum order should not be greater than maximum')
260271
}
261272
]
262273
},
@@ -274,6 +285,10 @@ export default Component.extend(FormMixin, EventWizardMixin, {
274285
{
275286
type : 'integer[1..]',
276287
prompt : this.l10n.t('Maximum tickets per order should be greater than 0')
288+
},
289+
{
290+
type : 'checkMaxMinOrder',
291+
prompt : this.l10n.t('Maximum order should not be less than minimum')
277292
}
278293
]
279294
},
@@ -287,6 +302,10 @@ export default Component.extend(FormMixin, EventWizardMixin, {
287302
{
288303
type : 'integer[1..]',
289304
prompt : this.l10n.t('Minimum price needs to be greater than zero')
305+
},
306+
{
307+
type : 'checkMaxMinPrice',
308+
prompt : this.l10n.t('Minimum price should not be greater than maximum')
290309
}
291310
]
292311
},
@@ -300,6 +319,10 @@ export default Component.extend(FormMixin, EventWizardMixin, {
300319
{
301320
type : 'integer[1..]',
302321
prompt : this.l10n.t('Maximum price needs to be greater than zero')
322+
},
323+
{
324+
type : 'checkMaxMinPrice',
325+
prompt : this.l10n.t('Maximum price should not be less than minimum')
303326
}
304327
]
305328
},

0 commit comments

Comments
 (0)