@@ -12,6 +12,7 @@ import { inject as service } from '@ember/service';
12
12
import EventWizardMixin from 'open-event-frontend/mixins/event-wizard' ;
13
13
import { protocolLessValidUrlPattern } from 'open-event-frontend/utils/validators' ;
14
14
import ENV from 'open-event-frontend/config/environment' ;
15
+ import $ from 'jquery' ;
15
16
16
17
export default Component . extend ( FormMixin , EventWizardMixin , {
17
18
@@ -128,6 +129,12 @@ export default Component.extend(FormMixin, EventWizardMixin, {
128
129
129
130
// 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
130
131
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
+ } ;
131
138
132
139
let validationRules = {
133
140
inline : true ,
@@ -257,6 +264,10 @@ export default Component.extend(FormMixin, EventWizardMixin, {
257
264
{
258
265
type : 'number' ,
259
266
prompt : this . l10n . t ( 'Invalid number' )
267
+ } ,
268
+ {
269
+ type : 'checkMaxMinOrder' ,
270
+ prompt : this . l10n . t ( 'Minimum order should not be greater than maximum' )
260
271
}
261
272
]
262
273
} ,
@@ -274,6 +285,10 @@ export default Component.extend(FormMixin, EventWizardMixin, {
274
285
{
275
286
type : 'integer[1..]' ,
276
287
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' )
277
292
}
278
293
]
279
294
} ,
@@ -287,6 +302,10 @@ export default Component.extend(FormMixin, EventWizardMixin, {
287
302
{
288
303
type : 'integer[1..]' ,
289
304
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' )
290
309
}
291
310
]
292
311
} ,
@@ -300,6 +319,10 @@ export default Component.extend(FormMixin, EventWizardMixin, {
300
319
{
301
320
type : 'integer[1..]' ,
302
321
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' )
303
326
}
304
327
]
305
328
} ,
0 commit comments