Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit e0ea727

Browse files
committed
Merge pull request #639 from appirio-tech/SUP-2942-rank-validation
Add validations and error message for rank
2 parents 21a4b80 + bf0483a commit e0ea727

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

app/directives/tc-input/tc-input.directive.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,23 @@
1313
inputValue: '=',
1414
inputName: '@',
1515
inputType: '@',
16-
inputPattern: '='
16+
inputPattern: '=',
17+
updateValueOnBlur: '&?'
1718
},
1819
link: function(scope, element, attrs) {
20+
var input = $(element[0]).find('input');
21+
1922
if (!scope.inputType) {
2023
scope.inputType = 'text';
2124
}
25+
26+
if (scope.updateValueOnBlur) {
27+
input.bind('blur', function(event) {
28+
var newValue = scope.updateValueOnBlur({inputValue: scope.inputValue});
29+
scope.inputValue = newValue;
30+
scope.$apply();
31+
});
32+
}
2233
}
2334
}
2435
}

app/submissions/submit-file/submit-file.controller.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// Must provide React Select component a list with ID, since currently
1212
// the onChange callback does not indicate which dropdown called the callback.
13-
// There are pull requets pending for react-select which will clean this code up
13+
// There are pull requests pending for react-select which will clean this code up
1414
vm.fontList1 = [
1515
{ label: 'Studio Standard Fonts List', value: 'STUDIO_STANDARD_FONTS_LIST', id: 1 },
1616
{ label: 'Fonts.com', value: 'FONTS_DOT_COM', id: 1 },
@@ -24,9 +24,15 @@
2424

2525
var files = {};
2626
vm.urlRegEx = new RegExp(/^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,3})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/);
27+
vm.rankRegEx = new RegExp(/^[1-9]\d*$/);
2728
vm.comments = '';
2829
vm.submissionForm = {
2930
files: [],
31+
32+
submissionZip: null,
33+
sourceZip: null,
34+
designCover: null,
35+
3036
submitterRank: 1,
3137
submitterComments: '',
3238
fonts: [{
@@ -68,6 +74,7 @@
6874
}
6975
};
7076

77+
vm.setRankTo1 = setRankTo1;
7178
vm.setFileReference = setFileReference;
7279
vm.uploadSubmission = uploadSubmission;
7380
vm.selectFont = selectFont;
@@ -78,6 +85,14 @@
7885

7986
function activate() {}
8087

88+
function setRankTo1(inputValue) {
89+
// If a user leaves the rank input blank, set it to 1
90+
if (inputValue === '') {
91+
return 1;
92+
}
93+
return inputValue;
94+
}
95+
8196
function setFileReference(file, fieldId) {
8297
// Can clean up since fileValue on tcFileInput has file reference?
8398
files[fieldId] = file;

0 commit comments

Comments
 (0)