Skip to content
This repository was archived by the owner on Jul 6, 2020. It is now read-only.

Commit 224c7e9

Browse files
authored
Merge branch 'master' into leaderboard_decimal_precision
2 parents 3e96ffd + ada5b64 commit 224c7e9

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
[name]="'max_submissions_per_day'" [isRequired]="true"
6060
[label]="'max_submissions_per_day'" [placeholder]="''"
6161
[type]="'number'" [value]="maxSubmissionsPerDay" #formmodal></app-input>
62+
<div class="editor-validation-message fs-12"
63+
*ngIf="isPerDaySubmissionFieldMessage">{{perDaySubmisionValidationMessage}}</div>
6264
</div>
6365
</div>
6466

@@ -70,6 +72,8 @@
7072
[name]="'max_submissions'" [isRequired]="true"
7173
[label]="'max_submissions_per_month'" [placeholder]="''"
7274
[type]="'number'" [value]="maxSubmissionsPerMonth" #formmodal></app-input>
75+
<div class="editor-validation-message fs-12"
76+
*ngIf="isPerMonthSubmissionFieldMessage">{{PerMonthSubmissionValidationMessage}}</div>
7377
</div>
7478
</div>
7579

src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,31 @@ export class EditphasemodalComponent implements OnInit {
6464
*/
6565
isEditorFieldMessage = false;
6666

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+
6777
/**
6878
* Editor validation message
6979
*/
7080
editorValidationMessage = '';
7181

82+
/**
83+
* per day submission validation message
84+
*/
85+
perDaySubmisionValidationMessage = '';
86+
87+
/**
88+
* Editor validation message
89+
*/
90+
PerMonthSubmissionValidationMessage = '';
91+
7292
/**
7393
* Modal accept button
7494
*/
@@ -165,6 +185,17 @@ export class EditphasemodalComponent implements OnInit {
165185
* Form Validate function.
166186
*/
167187
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+
});
168199
if (this.formComponents.length > 0) {
169200
this.globalService.formValidate(this.formComponents, this.confirmed, this);
170201
} else {
@@ -182,6 +213,18 @@ export class EditphasemodalComponent implements OnInit {
182213
self.editorValidationMessage = 'This field cannot be empty!';
183214
return;
184215
}
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+
}
185228
const PARAMS = self.globalService.formFields(self.formComponents);
186229
PARAMS[self.label] = self.description;
187230
self.globalService.hideEditPhaseModal();

0 commit comments

Comments
 (0)