@@ -64,11 +64,31 @@ export class EditphasemodalComponent implements OnInit {
64
64
*/
65
65
isEditorFieldMessage = false ;
66
66
67
+ /**
68
+ * If per day maximum submission error message
69
+ */
70
+ isPerDaySubmissionFieldMessage = false ;
71
+
72
+ /**
73
+ * If per month maximum submission error message
74
+ */
75
+ isPerMonthSubmissionFieldMessage = false ;
76
+
67
77
/**
68
78
* Editor validation message
69
79
*/
70
80
editorValidationMessage = '' ;
71
81
82
+ /**
83
+ * per day submission validation message
84
+ */
85
+ perDaySubmisionValidationMessage = '' ;
86
+
87
+ /**
88
+ * Editor validation message
89
+ */
90
+ PerMonthSubmissionValidationMessage = '' ;
91
+
72
92
/**
73
93
* Modal accept button
74
94
*/
@@ -165,6 +185,17 @@ export class EditphasemodalComponent implements OnInit {
165
185
* Form Validate function.
166
186
*/
167
187
formValidate ( ) {
188
+ this . formComponents . map ( val => {
189
+ if ( val . label === 'max_submissions_per_day' ) {
190
+ this . maxSubmissionsPerDay = parseInt ( val . value , 10 ) ;
191
+ }
192
+ if ( val . label === 'max_submissions_per_month' ) {
193
+ this . maxSubmissionsPerMonth = parseInt ( val . value , 10 ) ;
194
+ }
195
+ if ( val . label === 'max_submissions' ) {
196
+ this . maxSubmissions = parseInt ( val . value , 10 ) ;
197
+ }
198
+ } ) ;
168
199
if ( this . formComponents . length > 0 ) {
169
200
this . globalService . formValidate ( this . formComponents , this . confirmed , this ) ;
170
201
} else {
@@ -182,6 +213,18 @@ export class EditphasemodalComponent implements OnInit {
182
213
self . editorValidationMessage = 'This field cannot be empty!' ;
183
214
return ;
184
215
}
216
+ if ( self . maxSubmissionsPerDay > self . maxSubmissionsPerMonth ) {
217
+ self . denyCallback ( ) ;
218
+ self . isPerDaySubmissionFieldMessage = true ;
219
+ self . perDaySubmisionValidationMessage = 'Max number of per day submission cannot be greater than max number of per month submissions' ;
220
+ return ;
221
+ }
222
+ if ( self . maxSubmissionsPerMonth > self . maxSubmissions ) {
223
+ self . denyCallback ( ) ;
224
+ self . isPerMonthSubmissionFieldMessage = true ;
225
+ self . PerMonthSubmissionValidationMessage = 'Max number of per month submissions cannot be greater than max total submissions' ;
226
+ return ;
227
+ }
185
228
const PARAMS = self . globalService . formFields ( self . formComponents ) ;
186
229
PARAMS [ self . label ] = self . description ;
187
230
self . globalService . hideEditPhaseModal ( ) ;
0 commit comments