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

Commit 75ba53b

Browse files
author
vikasrohit
committed
Merge branch 'dev' into feature/sup-1159-upload-progress-bar
* dev: Add outstanding error and css updates Add disabled ability to tc-input Copy update Add validation and error messages for fonts section Refactor fonts section to have its own directive and controller Add container directive for fonts Add url for help link on mobile Make error messages correct width updated some icons Add proper phaseTypes Add back link for devices page Add label and width to font dropdown and width to rank input Conflicts: app/submissions/submit-file/submit-file.controller.js assets/css/submissions/submit-file.scss
2 parents 66312c0 + 83a3daa commit 75ba53b

15 files changed

+212
-94
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
(function() {
2+
'use strict';
3+
4+
angular.module('tcUIComponents').directive('tcFormFonts', tcFormFonts);
5+
6+
function tcFormFonts() {
7+
return {
8+
restrict: 'E',
9+
require: '^form',
10+
templateUrl: 'directives/tc-form-fonts/tc-form-fonts.html',
11+
scope: {
12+
formFonts: '='
13+
},
14+
link: function(scope, element, attrs, formController) {
15+
scope.submissionForm = formController;
16+
},
17+
controller: ['$scope', function($scope) {
18+
// Must provide React Select component a list with ID, since currently
19+
// the onChange callback does not indicate which dropdown called the callback.
20+
// There are pull requests pending for react-select which will clean this code up
21+
$scope.fontList0 = [
22+
{ label: 'Studio Standard Fonts List', value: 'STUDIO_STANDARD_FONTS_LIST', id: 0 },
23+
{ label: 'Fonts.com', value: 'FONTS_DOT_COM', id: 0 },
24+
{ label: 'MyFonts', value: 'MYFONTS', id: 0 },
25+
{ label: 'Adobe Fonts', value: 'ADOBE_FONTS', id: 0 },
26+
{ label: 'Font Shop', value: 'FONT_SHOP', id: 0 },
27+
{ label: 'T.26 Digital Type Foundry', value: 'T26_DIGITAL_TYPE_FOUNDRY', id: 0 },
28+
{ label: 'Font Squirrel', value: 'FONT_SQUIRREL', id: 0 },
29+
{ label: 'Typography.com', value: 'TYPOGRAPHY_DOT_COM', id: 0 }
30+
];
31+
32+
$scope.urlRegEx = new RegExp(/^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,3})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/);
33+
34+
$scope.selectFont = function(newFont) {
35+
// Find the right font section and change that source value to the value that the user selected
36+
var id = newFont.id;
37+
$scope.formFonts[id].source = newFont.value;
38+
39+
if (newFont.value === 'STUDIO_STANDARD_FONTS_LIST') {
40+
$scope.formFonts[id].isFontNameRequired = true;
41+
$scope.formFonts[id].isFontNameDisabled = false;
42+
$scope.formFonts[id].isFontUrlRequired = false;
43+
$scope.formFonts[id].isFontUrlDisabled = false;
44+
45+
} else if (newFont.value) {
46+
$scope.formFonts[id].isFontNameRequired = true;
47+
$scope.formFonts[id].isFontNameDisabled = false;
48+
$scope.formFonts[id].isFontUrlRequired = true;
49+
$scope.formFonts[id].isFontUrlDisabled = false;
50+
51+
}
52+
};
53+
54+
$scope.createAdditionalFontFieldset = function() {
55+
var newId = $scope.formFonts.length;
56+
57+
// Create copy of list with new, incremented ID
58+
var newFontList = $scope['fontList' + newId] = angular.copy($scope['fontList' + (newId - 1)]);
59+
60+
newFontList.forEach(function(font) {
61+
font.id++;
62+
});
63+
64+
$scope.formFonts.push({
65+
id: newId,
66+
source: '',
67+
name: '',
68+
sourceUrl: '',
69+
isFontUrlRequired: false,
70+
isFontUrlDisabled: true,
71+
isFontNameRequired: false,
72+
isFontNameDisabled: true,
73+
isFontSourceRequired: false
74+
});
75+
}
76+
}]
77+
}
78+
}
79+
})();
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.fieldset(ng-repeat="font in formFonts track by font.id")
2+
label.tc-label Font Source
3+
4+
dropdown(
5+
name="'font-source{{$index}}'",
6+
options="fontList{{$index}}",
7+
placeholder="'Select a provider from the list'",
8+
searchable="false",
9+
clearable="false",
10+
on-change="selectFont",
11+
value="formFonts[{{$index}}].source"
12+
)
13+
14+
tc-input.fieldset__input(
15+
label-text="Font Name",
16+
placeholder="Select font source to edit field"
17+
input-value="font.name",
18+
input-name="fontName{{$index}}",
19+
input-required="formFonts[$index].isFontNameRequired",
20+
input-disabled="formFonts[$index].isFontNameDisabled"
21+
)
22+
23+
.tc-error-messages(
24+
ng-show="submissionForm['fontName' + $index].$dirty && submissionForm['fontName' + $index].$invalid"
25+
ng-messages="submissionForm['fontName' + $index].$error"
26+
)
27+
p(ng-message="required") This field is required.
28+
29+
tc-input.fieldset__input(
30+
label-text="Font URL",
31+
placeholder="Select font source to edit field",
32+
input-value="font.sourceUrl",
33+
input-name="fontUrl{{$index}}",
34+
input-required="formFonts[$index].isFontUrlRequired",
35+
input-disabled="formFonts[$index].isFontUrlDisabled",
36+
input-pattern="urlRegEx"
37+
)
38+
39+
.tc-error-messages(
40+
ng-show="submissionForm['fontUrl' + $index].$dirty && submissionForm['fontUrl' + $index].$invalid"
41+
ng-messages="submissionForm['fontUrl' + $index].$error"
42+
)
43+
p(ng-message="pattern") Please enter a valid url.
44+
p(ng-message="required") This field is required.
45+
46+
button.fieldset__button.tc-btn.tc-btn-s(type="button", ng-click="createAdditionalFontFieldset()") + Add Font

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
inputName: '@',
1515
inputType: '@',
1616
inputPattern: '=',
17+
inputRequired: '=',
18+
inputDisabled: '=',
1719
updateValueOnBlur: '&?'
1820
},
1921
link: function(scope, element, attrs) {

app/directives/tc-input/tc-input.jade

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
label.tc-label {{labelText}}
22

3-
input(name="{{inputName}}", type="{{inputType}}", placeholder="{{placeholder}}", ng-model="inputValue", ng-pattern="inputPattern")
3+
input(
4+
name="{{inputName}}",
5+
type="{{inputType}}",
6+
placeholder="{{placeholder}}",
7+
ng-model="inputValue",
8+
ng-pattern="inputPattern",
9+
ng-required="inputRequired",
10+
ng-disabled="inputDisabled"
11+
)

app/index.jade

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ html
230230
script(src="directives/srm-tile/srm-tile.directive.js")
231231
script(src="directives/tc-endless-paginator/tc-endless-paginator.directive.js")
232232
script(src="directives/tc-file-input/tc-file-input.directive.js")
233+
script(src="directives/tc-form-fonts/tc-form-fonts.directive.js")
233234
script(src="directives/tc-input/tc-input.directive.js")
234235
script(src="directives/tc-paginator/tc-paginator.directive.js")
235236
script(src="directives/tc-section/tc-section.directive.js")

app/submissions/submissions.routes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@
4646
var isPhaseSubmission = _.some(challenge.currentPhases, function(phase) {
4747
if (phase.phaseStatus === 'Open') {
4848
if (phase.phaseType === 'Submission') {
49-
phaseType = 'Submission';
49+
phaseType = 'SUBMISSION';
5050
phaseId = phase.id;
5151
return true;
5252

5353
} else if (phase.phaseType === 'Checkpoint Submission') {
54-
phaseType = 'Checkpoint_Submission';
54+
phaseType = 'CHECKPOINT_SUBMISSION';
5555
phaseId = phase.id;
5656
return true;
5757
}

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

Lines changed: 22 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,6 @@
77

88
function SubmitFileController($scope, $stateParams, UserService, SubmissionsService, challengeToSubmitTo) {
99
var vm = this;
10-
11-
// Must provide React Select component a list with ID, since currently
12-
// the onChange callback does not indicate which dropdown called the callback.
13-
// There are pull requests pending for react-select which will clean this code up
14-
vm.fontList1 = [
15-
{ label: 'Studio Standard Fonts List', value: 'STUDIO_STANDARD_FONTS_LIST', id: 1 },
16-
{ label: 'Fonts.com', value: 'FONTS_DOT_COM', id: 1 },
17-
{ label: 'MyFonts', value: 'MYFONTS', id: 1 },
18-
{ label: 'Adobe Fonts', value: 'ADOBE_FONTS', id: 1 },
19-
{ label: 'Font Shop', value: 'FONT_SHOP', id: 1 },
20-
{ label: 'T.26 Digital Type Foundry', value: 'T26_DIGITAL_TYPE_FOUNDRY', id: 1 },
21-
{ label: 'Font Squirrel', value: 'FONT_SQUIRREL', id: 1 },
22-
{ label: 'Typography.com', value: 'TYPOGRAPHY_DOT_COM', id: 1 }
23-
];
24-
2510
var files = {};
2611
var fileUploadProgress = {};
2712
vm.urlRegEx = new RegExp(/^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,3})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/);
@@ -33,6 +18,17 @@
3318
vm.finishing = false;
3419
vm.showProgress = false;
3520
vm.errorInUpload = false;
21+
vm.formFonts = [{
22+
id: 0,
23+
source: '',
24+
name: '',
25+
sourceUrl: '',
26+
isFontUrlRequired: false,
27+
isFontUrlDisabled: true,
28+
isFontNameRequired: false,
29+
isFontNameDisabled: true,
30+
isFontSourceRequired: false
31+
}];
3632
vm.submissionForm = {
3733
files: [],
3834

@@ -42,12 +38,7 @@
4238

4339
submitterRank: 1,
4440
submitterComments: '',
45-
fonts: [{
46-
id: 1,
47-
source: '',
48-
name: '',
49-
sourceUrl: ''
50-
}],
41+
fonts: [],
5142
stockArts: [{
5243
id: 1,
5344
description: '',
@@ -84,8 +75,6 @@
8475
vm.setRankTo1 = setRankTo1;
8576
vm.setFileReference = setFileReference;
8677
vm.uploadSubmission = uploadSubmission;
87-
vm.selectFont = selectFont;
88-
vm.createAnotherFontFieldset = createAnotherFontFieldset;
8978
vm.createAnotherStockArtFieldset = createAnotherStockArtFieldset;
9079
vm.cancelRetry = cancelRetry;
9180

@@ -122,8 +111,6 @@
122111
fileObject.mediaType = file.type;
123112
}
124113

125-
126-
127114
// If user picks a new file, replace the that file's fileObject with a new one
128115
// Or add it the list if it's not there
129116
if (vm.submissionsBody.data.files.length) {
@@ -139,31 +126,6 @@
139126
}
140127
}
141128

142-
function selectFont(newFont) {
143-
// See above for explanation
144-
var id = newFont.id - 1;
145-
vm.submissionForm.fonts[id].source = newFont.value;
146-
}
147-
148-
function createAnotherFontFieldset() {
149-
// See above for explanation on why this is done the way it is
150-
var id = vm.submissionForm.fonts.length;
151-
152-
// Create copy of list with new, incremented ID
153-
var newFontList = vm['fontList' + (id + 1)] = angular.copy(vm['fontList' + id]);
154-
155-
newFontList.forEach(function(font) {
156-
font.id++;
157-
});
158-
159-
vm.submissionForm.fonts.push({
160-
id: vm.submissionForm.fonts.length + 1,
161-
source: '',
162-
name: '',
163-
sourceUrl: ''
164-
});
165-
}
166-
167129
function createAnotherStockArtFieldset() {
168130
vm.submissionForm.stockArts.push({
169131
id: vm.submissionForm.stockArts.length + 1,
@@ -182,6 +144,7 @@
182144
vm.submissionsBody.data.submitterComments = vm.comments;
183145
vm.submissionsBody.data.submitterRank = vm.submissionForm.submitterRank;
184146

147+
// Process stock art
185148
if (vm.submissionForm.stockArts[0].description === '') {
186149
vm.submissionsBody.data.stockArts = [];
187150
} else {
@@ -192,18 +155,25 @@
192155
});
193156
}
194157

195-
if (vm.submissionForm.fonts[0].source === '') {
158+
// Process fonts
159+
if (vm.formFonts[0].source === '') {
196160
vm.submissionsBody.data.fonts = [];
197161
} else {
198-
var fonts = angular.copy(vm.submissionForm.fonts);
162+
var fonts = angular.copy(vm.formFonts);
199163
vm.submissionsBody.data.fonts = fonts.map(function(font) {
200164
if (font.source) {
201165
delete font.id;
166+
delete font.isFontUrlRequired;
167+
delete font.isFontUrlDisabled;
168+
delete font.isFontNameRequired;
169+
delete font.isFontNameDisabled;
170+
delete font.isFontSourceRequired;
202171
return font;
203172
}
204173
});
205174
}
206175

176+
console.log('Body for request: ', vm.submissionsBody);
207177
SubmissionsService.getPresignedURL(vm.submissionsBody, files, updateProgress);
208178
}
209179

0 commit comments

Comments
 (0)