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

Commit c92ced4

Browse files
author
Jenkins Continuous Integration Server
committed
Merge commit '84e89f88cc3b0599e4b2aa309bb1ec0468324b99' into HEAD
2 parents 35817ce + 84e89f8 commit c92ced4

File tree

13 files changed

+131
-27
lines changed

13 files changed

+131
-27
lines changed

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

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,25 @@
66
function tcFileInput() {
77
return {
88
restrict: 'E',
9-
require: '^form',
9+
require: ['^form', '^ngModel'],
1010
templateUrl: 'directives/tc-file-input/tc-file-input.html',
1111
scope: {
1212
labelText: '@',
1313
fieldId: '@',
1414
placeholder: '@',
1515
fileType: '@',
16+
showFileType: '=',
1617
mandatory: '=',
1718
buttonText: '@',
1819
setFileReference: '&',
19-
fileValue: '=ngModel'
20+
ngModel: '='
2021
},
21-
link: function(scope, element, attrs, formController) {
22+
link: function(scope, element, attrs, controllers) {
23+
var formController = controllers[0];
24+
var ngModel = controllers[1];
25+
2226
scope.selectFile = selectFile;
27+
var fileTypes = scope.fileType.split(',');
2328

2429
// fieldId is not set on element at this point, so grabbing with class .none
2530
// which exists on the element right away
@@ -29,12 +34,28 @@
2934
fileInput.bind('change', function() {
3035
var file = fileInput[0].files[0];
3136

32-
// Pass file object up through callback into controller
33-
scope.setFileReference({file: file, fieldId: scope.fieldId});
37+
var selectedFileType = file.type.slice(file.type.lastIndexOf('/') + 1);
38+
var isAllowedFileFormat = _.some(fileTypes, _.matches(selectedFileType));
39+
40+
scope.$apply(function(){
41+
if (!isAllowedFileFormat) {
42+
fileNameInput[0].value = file.name;
43+
44+
// Manually setting is required since Angular doesn't support file inputs
45+
formController[attrs.fieldId].$setTouched();
46+
formController[attrs.fieldId].$setValidity('required', false);
47+
48+
} else {
49+
// Pass file object up through callback into controller
50+
scope.setFileReference({file: file, fieldId: scope.fieldId});
51+
52+
// Set the file name as the value of the disabled input
53+
fileNameInput[0].value = file.name;
3454

35-
// Set the file name as the value of the disabled input
36-
fileNameInput[0].value = file.name;
37-
formController[attrs.fieldId].$setValidity('required', true);
55+
// Manually set validity of specific input field
56+
formController[attrs.fieldId].$setValidity('required', true);
57+
}
58+
});
3859
});
3960

4061
function selectFile() {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
.tc-file-field__label
22
label.tc-label {{labelText}}
3-
span.lowercase(ng-if="fileType") {{fileType | addBeginningSpace}}
3+
span.lowercase(ng-if="showFileType") {{ ' *(.' + fileType + ')'}}
44

55
span.tc-label__mandatory.lowercase(ng-if="mandatory") #[span *]mandatory
66

77
.tc-file-field__inputs
8-
input.tc-file-field__input(type="text", placeholder="{{placeholder}}")
8+
input.tc-file-field__input(type="text", placeholder="{{placeholder}}", disabled)
99

1010
button.tc-btn(ng-click="selectFile()") {{buttonText}}
1111

12-
input.none(name="{{fieldId}}", type="file", id="{{fieldId}}", required, ng-model="fileValue")
12+
input.none(name="{{fieldId}}", type="file", required, ng-model="ngModel")

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/submissions.routes.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,17 @@
4444
var phaseId;
4545

4646
var isPhaseSubmission = _.some(challenge.currentPhases, function(phase) {
47-
if (phase.phaseStatus === 'Open' && phase.phaseType === 'Submission') {
48-
phaseType = 'Submission';
49-
phaseId = phase.id;
50-
return true;
47+
if (phase.phaseStatus === 'Open') {
48+
if (phase.phaseType === 'Submission') {
49+
phaseType = 'SUBMISSION';
50+
phaseId = phase.id;
51+
return true;
52+
53+
} else if (phase.phaseType === 'Checkpoint Submission') {
54+
phaseType = 'CHECKPOINT_SUBMISSION';
55+
phaseId = phase.id;
56+
return true;
57+
}
5158
}
5259

5360
return false;

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;

app/submissions/submit-file/submit-file.jade

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
.mobile-redirect__body
55
p Our team is working hard on new features, and file upload currently only works on the web. Please open this page on your desktop if you want to create a submission.
66

7-
a Learn more about formatting your submission file
7+
a(ng-href="http://help.{{DOMAIN}}/design/submitting-to-a-design-challenge/formatting-your-submission-for-design-challenges/") Learn more about formatting your submission file
88

9-
a.tc-btn.tc-btn-s(ng-click="'TODO: go back to challenge details'") Back to Challenge Details
9+
a.tc-btn.tc-btn-s(ng-href="https://www.{{DOMAIN}}/challenge-details/{{submissions.challengeId}}/?type={{submissions.track}}") Back to Challenge Details
1010

1111
.panel-body
1212
form.form-blocks(name="submissionForm", role="form", ng-submit="submissionForm.$valid && vm.uploadSubmission()", novalidate)
@@ -29,35 +29,56 @@
2929
label-text="Submission",
3030
field-id="SUBMISSION_ZIP",
3131
button-text="Add File",
32-
file-type="(*.zip)",
32+
file-type="zip",
33+
show-file-type="true",
3334
placeholder="Attach all visible files as a single .zip file",
3435
mandatory="true",
3536
set-file-reference="vm.setFileReference(file, fieldId)",
36-
file-value="vm.submissionForm.submissionZip"
37+
ng-model="vm.submissionForm.submissionZip"
3738
)
3839

40+
.tc-error-messages(ng-show="submissionForm['SUBMISSION_ZIP'].$touched && submissionForm['SUBMISSION_ZIP'].$invalid")
41+
p(ng-show="submissionForm['SUBMISSION_ZIP'].$error.required") This is not the correct file format. Please select a .zip file.
42+
3943
tc-file-input.tc-file-field(
4044
label-text="Source",
4145
field-id="SOURCE_ZIP",
4246
button-text="Add File",
43-
file-type="(*.zip)",
47+
file-type="zip",
48+
show-file-type="true",
4449
placeholder="Attach all source files as a single .zip file",
4550
mandatory="true",
4651
set-file-reference="vm.setFileReference(file, fieldId)",
47-
file-value="vm.submissionForm.sourceZip"
52+
ng-model="vm.submissionForm.sourceZip"
4853
)
4954

55+
.tc-error-messages(ng-show="submissionForm['SOURCE_ZIP'].$touched && submissionForm['SOURCE_ZIP'].$invalid")
56+
p(ng-show="submissionForm['SOURCE_ZIP'].$error.required") This is not the correct file format. Please select a .zip file.
57+
5058
tc-file-input.tc-file-field(
5159
label-text="Preview Image",
5260
field-id="DESIGN_COVER",
5361
button-text="Add File",
62+
file-type="jpg,jpeg,png"
5463
placeholder="Image file as .jpg or .png",
5564
mandatory="true",
5665
set-file-reference="vm.setFileReference(file, fieldId)",
57-
file-value="vm.submissionForm.designCover"
66+
ng-model="vm.submissionForm.designCover"
67+
)
68+
69+
.tc-error-messages(ng-show="submissionForm['DESIGN_COVER'].$touched && submissionForm['DESIGN_COVER'].$invalid")
70+
p(ng-show="submissionForm['DESIGN_COVER'].$error.required") This is not the correct file format. Please select a .jpg or .png file.
71+
72+
tc-input.fieldset__input.submitterRank(
73+
label-text="Rank #",
74+
input-name="Submission_Rank",
75+
input-value="vm.submissionForm.submitterRank",
76+
input-pattern="vm.rankRegEx",
77+
update-value-on-blur="vm.setRankTo1(inputValue)"
5878
)
5979

60-
tc-input.fieldset__input.submitterRank(label-text="Rank #", input-value="vm.submissionForm.submitterRank")
80+
.tc-error-messages(ng-show="submissionForm.Submission_Rank.$dirty && submissionForm.Submission_Rank.$invalid")
81+
p(ng-show="submissionForm.Submission_Rank.$error.pattern") Please enter a positive integer.
6182

6283
.form-block.flex.wrap
6384
.form-block__instructions
@@ -91,6 +112,8 @@
91112
.form-block__fields
92113
.fieldsets
93114
ng-form.fieldset(name="font{{$index + 1}}", ng-repeat="font in vm.submissionForm.fonts track by font.id")
115+
label.tc-label Font Source
116+
94117
dropdown(
95118
name="'font-source{{$index + 1}}'",
96119
options="vm.fontList{{$index + 1}}",
@@ -104,13 +127,15 @@
104127
tc-input.fieldset__input(
105128
label-text="Font Name",
106129
placeholder="Select font source to edit field"
107-
input-value="font.name"
130+
input-value="font.name",
131+
input-name="fontName{{$index}}"
108132
)
109133

110134
tc-input.fieldset__input(
111135
label-text="Font URL",
112136
placeholder="Select font source to edit field",
113-
input-value="font.sourceUrl"
137+
input-value="font.sourceUrl",
138+
input-name="fontUrl{{$index}}"
114139
)
115140

116141
button.fieldset__button.tc-btn.tc-btn-s(type="button", ng-click="vm.createAnotherFontFieldset()") + Add Font

assets/css/submissions/submit-file.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,15 @@
3434
}
3535

3636
.submitterRank {
37+
width: 100px;
3738
margin-top: 10px;
3839
}
40+
41+
.Select {
42+
max-width: 300px;
43+
margin-bottom: 20px;
44+
}
45+
46+
.tc-error-messages {
47+
max-width: 500px;
48+
}

assets/images/skills/id-126.svg

100755100644
File mode changed.

assets/images/skills/id-149.svg

100755100644
File mode changed.

assets/images/skills/id-155.svg

100755100644
File mode changed.

assets/images/skills/id-237.svg

100755100644
File mode changed.

assets/images/skills/id-269.svg

100755100644
File mode changed.

assets/images/skills/id-323.svg

Lines changed: 15 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)