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

Commit 3c07881

Browse files
author
Jenkins Continuous Integration Server
committed
Merge commit 'cecf5f6d99243f1c11f34cade1e5087ebcd530d9' into HEAD
2 parents c92ced4 + cecf5f6 commit 3c07881

File tree

8 files changed

+169
-86
lines changed

8 files changed

+169
-86
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
@@ -227,6 +227,7 @@ html
227227
script(src="directives/srm-tile/srm-tile.directive.js")
228228
script(src="directives/tc-endless-paginator/tc-endless-paginator.directive.js")
229229
script(src="directives/tc-file-input/tc-file-input.directive.js")
230+
script(src="directives/tc-form-fonts/tc-form-fonts.directive.js")
230231
script(src="directives/tc-input/tc-input.directive.js")
231232
script(src="directives/tc-paginator/tc-paginator.directive.js")
232233
script(src="directives/tc-section/tc-section.directive.js")

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

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

88
function SubmitFileController($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
vm.urlRegEx = new RegExp(/^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,3})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/);
2712
vm.rankRegEx = new RegExp(/^[1-9]\d*$/);
2813
vm.comments = '';
14+
vm.formFonts = [{
15+
id: 0,
16+
source: '',
17+
name: '',
18+
sourceUrl: '',
19+
isFontUrlRequired: false,
20+
isFontUrlDisabled: true,
21+
isFontNameRequired: false,
22+
isFontNameDisabled: true,
23+
isFontSourceRequired: false
24+
}];
2925
vm.submissionForm = {
3026
files: [],
3127

@@ -35,12 +31,7 @@
3531

3632
submitterRank: 1,
3733
submitterComments: '',
38-
fonts: [{
39-
id: 1,
40-
source: '',
41-
name: '',
42-
sourceUrl: ''
43-
}],
34+
fonts: [],
4435
stockArts: [{
4536
id: 1,
4637
description: '',
@@ -77,8 +68,6 @@
7768
vm.setRankTo1 = setRankTo1;
7869
vm.setFileReference = setFileReference;
7970
vm.uploadSubmission = uploadSubmission;
80-
vm.selectFont = selectFont;
81-
vm.createAnotherFontFieldset = createAnotherFontFieldset;
8271
vm.createAnotherStockArtFieldset = createAnotherStockArtFieldset;
8372

8473
activate();
@@ -114,8 +103,6 @@
114103
fileObject.mediaType = file.type;
115104
}
116105

117-
118-
119106
// If user picks a new file, replace the that file's fileObject with a new one
120107
// Or add it the list if it's not there
121108
if (vm.submissionsBody.data.files.length) {
@@ -131,31 +118,6 @@
131118
}
132119
}
133120

134-
function selectFont(newFont) {
135-
// See above for explanation
136-
var id = newFont.id - 1;
137-
vm.submissionForm.fonts[id].source = newFont.value;
138-
}
139-
140-
function createAnotherFontFieldset() {
141-
// See above for explanation on why this is done the way it is
142-
var id = vm.submissionForm.fonts.length;
143-
144-
// Create copy of list with new, incremented ID
145-
var newFontList = vm['fontList' + (id + 1)] = angular.copy(vm['fontList' + id]);
146-
147-
newFontList.forEach(function(font) {
148-
font.id++;
149-
});
150-
151-
vm.submissionForm.fonts.push({
152-
id: vm.submissionForm.fonts.length + 1,
153-
source: '',
154-
name: '',
155-
sourceUrl: ''
156-
});
157-
}
158-
159121
function createAnotherStockArtFieldset() {
160122
vm.submissionForm.stockArts.push({
161123
id: vm.submissionForm.stockArts.length + 1,
@@ -169,6 +131,7 @@
169131
vm.submissionsBody.data.submitterComments = vm.comments;
170132
vm.submissionsBody.data.submitterRank = vm.submissionForm.submitterRank;
171133

134+
// Process stock art
172135
if (vm.submissionForm.stockArts[0].description === '') {
173136
vm.submissionsBody.data.stockArts = [];
174137
} else {
@@ -179,18 +142,25 @@
179142
});
180143
}
181144

182-
if (vm.submissionForm.fonts[0].source === '') {
145+
// Process fonts
146+
if (vm.formFonts[0].source === '') {
183147
vm.submissionsBody.data.fonts = [];
184148
} else {
185-
var fonts = angular.copy(vm.submissionForm.fonts);
149+
var fonts = angular.copy(vm.formFonts);
186150
vm.submissionsBody.data.fonts = fonts.map(function(font) {
187151
if (font.source) {
188152
delete font.id;
153+
delete font.isFontUrlRequired;
154+
delete font.isFontUrlDisabled;
155+
delete font.isFontNameRequired;
156+
delete font.isFontNameDisabled;
157+
delete font.isFontSourceRequired;
189158
return font;
190159
}
191160
});
192161
}
193162

163+
console.log('ABOUT TO SEND: ', vm.submissionsBody);
194164
SubmissionsService.getPresignedURL(vm.submissionsBody, files);
195165
}
196166
}

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

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -98,51 +98,22 @@
9898

9999
.form-block.flex.wrap
100100
.form-block__instructions
101-
.form-block__title Fonts
101+
.form-block__title Did you use custom fonts?
102102

103103
.form-block__text
104104
p Check to see if your font is on the Studio Standard Fonts list. If it is, leave the URL field blank.
105105

106106
p Read the #[a(href="Need link") Studio Fonts Policy].
107107

108-
p If you only used fonts that came with the client files, choose "I did not introduce any new fonts" from the dropdown box.
109-
110108
p If your font is not on the list, you must provide the URL to the font page (not file) from one of the approved font websites in the dropdown box.
111109

112110
.form-block__fields
113111
.fieldsets
114-
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-
117-
dropdown(
118-
name="'font-source{{$index + 1}}'",
119-
options="vm.fontList{{$index + 1}}",
120-
placeholder="'Select from the list'",
121-
searchable="false",
122-
clearable="false",
123-
on-change="vm.selectFont",
124-
value="vm.submissionForm.fonts[{{$index}}].source"
125-
)
126-
127-
tc-input.fieldset__input(
128-
label-text="Font Name",
129-
placeholder="Select font source to edit field"
130-
input-value="font.name",
131-
input-name="fontName{{$index}}"
132-
)
133-
134-
tc-input.fieldset__input(
135-
label-text="Font URL",
136-
placeholder="Select font source to edit field",
137-
input-value="font.sourceUrl",
138-
input-name="fontUrl{{$index}}"
139-
)
140-
141-
button.fieldset__button.tc-btn.tc-btn-s(type="button", ng-click="vm.createAnotherFontFieldset()") + Add Font
112+
tc-form-fonts(form-fonts="vm.formFonts")
142113

143114
.form-block.flex.wrap
144115
.form-block__instructions
145-
.form-block__title Stock Art
116+
.form-block__title Did you use stock art?
146117

147118
.form-block__text
148119
p If you used any stock photos in your design mocks, please provide the location and details so that the client can obtain them. Follow the guidelines at our #[a(href="Need link") Studio Stock Art Policy].
@@ -166,7 +137,7 @@
166137
)
167138

168139
.tc-error-messages(ng-show="submissionForm['photoURL' + $index].$dirty && submissionForm['photoURL' + $index].$invalid")
169-
p(ng-show="submissionForm['photoURL' + $index].$error.pattern") Not a valid url.
140+
p(ng-show="submissionForm['photoURL' + $index].$error.pattern") Please enter a valid url.
170141

171142
tc-input.fieldset__input(
172143
label-text="File Number",

assets/css/submissions/submit-file.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
margin-top: 10px;
3939
}
4040

41+
tc-form-fonts {
42+
.fieldset {
43+
max-width: 500px;
44+
}
45+
}
46+
4147
.Select {
4248
max-width: 300px;
4349
margin-bottom: 20px;

0 commit comments

Comments
 (0)