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

Commit 3411389

Browse files
author
vikasrohit
committed
Merge branch 'dev' into feature/sup-2901-skill-field-width-for-less-skills
* dev: (101 commits) Add char limits to font and stockart inputs Show error for file size SUP-2899, Reliability detail link from Profiles is wrong. SUP-2899, Reliability detail link from Profiles is wrong. SUP-2975,Edit Profile || Placeholder for new password field is missing SUP-2970, Password input field - show password checkbox broken on Edit Profile SUP-2943, Add volatility to top-line SRM stats on Profile Make font and stock art buttons diabled when everything isn't filled out Add delete capability to stockart section Format fonts to send as body SUP-2930, Register--> 'Create Password' text fileld showing one line at beginning. SUP-1159, Progress bar to show %complete on upload Add todo for formatting fonts for body Add logic to delete any font fieldset Format form fonts into object instead of array Add CSS for font fieldset X's SUP-1159, Progress bar to show %complete on upload SUP-1159, Progress bar to show %complete on upload SUP-1159, Progress bar to show %complete on upload Add outstanding error and css updates ...
2 parents 747a13d + 42f1e79 commit 3411389

File tree

182 files changed

+4378
-2295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+4378
-2295
lines changed

app/directives/account/toggle-password-with-tips/toggle-password-with-tips.directive.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
link: function(scope, element, attrs, formController) {
1212
var vm = scope.vm;
1313
vm.passwordField = formController.password;
14+
vm.defaultPlaceholder = attrs.placeholder || 'Pick a new password';
1415
vm.placeholder = vm.defaultPlaceholder;
1516
vm.password = '';
1617

app/directives/on-file-change.directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
return {
1212
restrict: 'A',
1313
link: function(scope, element, attr, ctrl) {
14-
element.bind("change", function() {
14+
element.bind('change', function() {
1515
scope.vm.onFileChange(element[0].files[0]);
1616
this.value = '';
1717
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.progress-bar
2+
.progress-bar__bar
3+
.progress-bar__bar--completed
4+
.progress-bar__summary
5+
span(ng-bind="completed")
6+
span % {{message}}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
(function() {
2+
'use strict';
3+
4+
angular.module('tcUIComponents').directive('progressBar', progressBar);
5+
6+
progressBar.$inject = ['$timeout', '$parse'];
7+
8+
function progressBar($timeout, $parse) {
9+
return {
10+
restrict: 'E',
11+
templateUrl: 'directives/progress-bar/progress-bar.directive.html',
12+
link: function(scope, element, attr) {
13+
var model = $parse(attr.completed);
14+
var msg = attr.message;
15+
var progress = angular.element(element[0].querySelector('.progress-bar__bar--completed'));
16+
17+
scope.$watch(model, function(newValue, oldValue) {
18+
scope.completed = Math.round(newValue);
19+
// console.log("Updating progress bar with " + scope.completed);
20+
scope.message = msg;
21+
progress.css('width', scope.completed + '%')
22+
});
23+
},
24+
controller: ['$scope', function($scope) {
25+
26+
}]
27+
};
28+
}
29+
})();
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
(function() {
2+
'use strict';
3+
4+
angular.module('tcUIComponents').directive('tcFileInput', tcFileInput);
5+
6+
function tcFileInput() {
7+
return {
8+
restrict: 'E',
9+
require: '^form',
10+
templateUrl: 'directives/tc-file-input/tc-file-input.html',
11+
scope: {
12+
labelText: '@',
13+
fieldId: '@',
14+
placeholder: '@',
15+
fileType: '@',
16+
showFileType: '=',
17+
mandatory: '=',
18+
buttonText: '@',
19+
setFileReference: '&',
20+
ngModel: '='
21+
},
22+
link: function(scope, element, attrs, formController) {
23+
scope.selectFile = selectFile;
24+
var fileTypes = scope.fileType.split(',');
25+
26+
// fieldId is not set on element at this point, so grabbing with class .none
27+
// which exists on the element right away
28+
var fileInput = $(element[0]).find('.none');
29+
var fileNameInput = $(element[0]).find('input[type=text]');
30+
31+
fileInput.bind('change', function() {
32+
var file = fileInput[0].files[0];
33+
34+
// About 1 in 20 times, the file is undefined (must be race condition)
35+
// Return early in this case so no errors are thrown
36+
if (!file) {
37+
return;
38+
}
39+
40+
var fileSize = file.size;
41+
var isAllowedFileSize = fileSize < '500000000';
42+
43+
var selectedFileType = file.type.slice(file.type.lastIndexOf('/') + 1);
44+
var isAllowedFileFormat = _.some(fileTypes, _.matches(selectedFileType));
45+
46+
scope.$apply(function(){
47+
// Set the file name as the value of the disabled input
48+
fileNameInput[0].value = file.name;
49+
var clickedFileInput = formController[attrs.fieldId];
50+
51+
if (!isAllowedFileFormat) {
52+
// Manually setting is required since Angular doesn't support file inputs
53+
clickedFileInput.$setTouched();
54+
clickedFileInput.$setValidity('required', false);
55+
56+
} else {
57+
clickedFileInput.$setValidity('required', true);
58+
}
59+
60+
if (!isAllowedFileSize) {
61+
// Manually setting is required since Angular doesn't support file inputs
62+
clickedFileInput.$setTouched();
63+
clickedFileInput.$setValidity('filesize', false);
64+
65+
} else {
66+
clickedFileInput.$setValidity('filesize', true);
67+
}
68+
69+
if (isAllowedFileFormat && isAllowedFileSize) {
70+
// Pass file object up through callback into controller
71+
scope.setFileReference({file: file, fieldId: scope.fieldId});
72+
}
73+
});
74+
});
75+
76+
function selectFile() {
77+
fileInput.click();
78+
}
79+
}
80+
}
81+
}
82+
})();
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.tc-file-field__label
2+
label.tc-label {{labelText}}
3+
span.lowercase(ng-if="showFileType") {{ ' *(.' + fileType + ')'}}
4+
5+
span.tc-label__mandatory.lowercase(ng-if="mandatory") #[span *]mandatory
6+
7+
.tc-file-field__inputs
8+
input.tc-file-field__input(type="text", placeholder="{{placeholder}}", disabled)
9+
10+
button.tc-btn(ng-click="selectFile()") {{buttonText}}
11+
12+
input.none(name="{{fieldId}}", type="file", required, ng-model="ngModel")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* jshint -W117, -W030 */
2+
describe('Topcoder File Input Directive', function() {
3+
var scope;
4+
5+
// USE AS TEMPLATE FOR DIRECTIVES
6+
7+
beforeEach(function() {
8+
bard.appModule('tcUIComponents');
9+
bard.inject(this, '$compile', '$rootScope');
10+
});
11+
12+
bard.verifyNoOutstandingHttpRequests();
13+
14+
xdescribe('', function() {
15+
beforeEach(function() {});
16+
17+
it('', function() {});
18+
});
19+
});
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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+
var fontsId = 0;
19+
20+
// Must provide React Select component a list with ID, since currently
21+
// the onChange callback does not indicate which dropdown called the callback.
22+
// There are pull requests pending for react-select which will clean this code up
23+
$scope.fontList0 = [
24+
{ label: 'Studio Standard Fonts List', value: 'STUDIO_STANDARD_FONTS_LIST', id: 0 },
25+
{ label: 'Fonts.com', value: 'FONTS_DOT_COM', id: 0 },
26+
{ label: 'MyFonts', value: 'MYFONTS', id: 0 },
27+
{ label: 'Adobe Fonts', value: 'ADOBE_FONTS', id: 0 },
28+
{ label: 'Font Shop', value: 'FONT_SHOP', id: 0 },
29+
{ label: 'T.26 Digital Type Foundry', value: 'T26_DIGITAL_TYPE_FOUNDRY', id: 0 },
30+
{ label: 'Font Squirrel', value: 'FONT_SQUIRREL', id: 0 },
31+
{ label: 'Typography.com', value: 'TYPOGRAPHY_DOT_COM', id: 0 }
32+
];
33+
34+
var emptyFont = {
35+
source: '',
36+
name: '',
37+
sourceUrl: '',
38+
isFontUrlRequired: false,
39+
isFontUrlDisabled: true,
40+
isFontNameRequired: false,
41+
isFontNameDisabled: true,
42+
isFontSourceRequired: false
43+
};
44+
45+
$scope.urlRegEx = new RegExp(/^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,3})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/);
46+
47+
$scope.selectFont = function(newFont) {
48+
49+
// Find the right font section,
50+
// and change that source value to the value that the user selected
51+
var targetedFont = $scope.formFonts[newFont.id];
52+
53+
targetedFont.source = newFont.value;
54+
55+
if (newFont.value === 'STUDIO_STANDARD_FONTS_LIST') {
56+
targetedFont.isFontNameRequired = true;
57+
targetedFont.isFontNameDisabled = false;
58+
targetedFont.isFontUrlRequired = false;
59+
targetedFont.isFontUrlDisabled = false;
60+
61+
} else if (newFont.value) {
62+
targetedFont.isFontNameRequired = true;
63+
targetedFont.isFontNameDisabled = false;
64+
targetedFont.isFontUrlRequired = true;
65+
targetedFont.isFontUrlDisabled = false;
66+
}
67+
};
68+
69+
$scope.createAdditionalFontFieldset = function() {
70+
var newId = ++fontsId;
71+
72+
// Create copy of list with new, incremented ID
73+
var newFontList = $scope['fontList' + newId] = angular.copy($scope['fontList' + (newId - 1)]);
74+
newFontList.forEach(function(font) {
75+
font.id++;
76+
});
77+
78+
// Add empty font with new ID to scope
79+
$scope.formFonts[newId] = _.assign({ id: newId }, angular.copy(emptyFont));
80+
}
81+
82+
$scope.deleteFontFieldset = function(index) {
83+
84+
// If only one font fieldset is there, just reset the values
85+
// so that ng-repeat doesn't refresh and there is no UI flickering
86+
if (Object.keys($scope.formFonts).length === 1) {
87+
$scope.submissionForm['fontName' + index].$setPristine();
88+
$scope.submissionForm['fontUrl' + index].$setPristine();
89+
$scope.formFonts[index] = angular.copy(emptyFont);
90+
91+
} else {
92+
delete $scope.formFonts[index];
93+
}
94+
}
95+
96+
$scope.isButtonDisabled = function() {
97+
return _.some($scope.formFonts, function(font) {
98+
if (font.source === 'STUDIO_STANDARD_FONTS_LIST') {
99+
return !font.source || !font.name;
100+
} else {
101+
return !font.source || !font.name || !font.sourceUrl;
102+
}
103+
});
104+
}
105+
}]
106+
}
107+
}
108+
})();
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.fieldset(ng-repeat="(fontId, font) in formFonts")
2+
button.clean.remove-section(type="button", ng-click="deleteFontFieldset(fontId)")
3+
4+
label.tc-label Font Source
5+
6+
dropdown(
7+
name="'font-source{{fontId}}'",
8+
options="fontList{{fontId}}",
9+
placeholder="'Select a provider from the list'",
10+
searchable="false",
11+
clearable="false",
12+
on-change="selectFont",
13+
value="formFonts[{{fontId}}].source"
14+
)
15+
16+
tc-input.fieldset__input(
17+
label-text="Font Name",
18+
placeholder="Select font source to edit field"
19+
input-value="font.name",
20+
input-name="fontName{{fontId}}",
21+
input-required="formFonts[fontId].isFontNameRequired",
22+
input-disabled="formFonts[fontId].isFontNameDisabled",
23+
maxlength="50"
24+
)
25+
26+
.tc-error-messages(
27+
ng-show="submissionForm['fontName' + fontId].$dirty && submissionForm['fontName' + fontId].$invalid"
28+
ng-messages="submissionForm['fontName' + fontId].$error"
29+
)
30+
p(ng-message="required") This field is required.
31+
32+
tc-input.fieldset__input(
33+
ng-hide="formFonts[fontId].source === 'STUDIO_STANDARD_FONTS_LIST'",
34+
label-text="Font URL",
35+
placeholder="Select font source to edit field",
36+
input-value="font.sourceUrl",
37+
input-name="fontUrl{{fontId}}",
38+
input-required="formFonts[fontId].isFontUrlRequired",
39+
input-disabled="formFonts[fontId].isFontUrlDisabled",
40+
input-pattern="urlRegEx",
41+
maxlength="100"
42+
)
43+
44+
.tc-error-messages(
45+
ng-show="submissionForm['fontUrl' + fontId].$dirty && submissionForm['fontUrl' + fontId].$invalid"
46+
ng-messages="submissionForm['fontUrl' + fontId].$error"
47+
)
48+
p(ng-message="pattern") Please enter a valid url.
49+
p(ng-message="required") This field is required.
50+
51+
button.fieldset__button.tc-btn.tc-btn-s(type="button", ng-click="createAdditionalFontFieldset()", ng-disabled="isButtonDisabled()") + Add Font
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* jshint -W117, -W030 */
2+
describe('Topcoder Form Fonts Directive', function() {
3+
var scope;
4+
5+
// USE AS TEMPLATE FOR DIRECTIVES
6+
7+
beforeEach(function() {
8+
bard.appModule('tcUIComponents');
9+
bard.inject(this, '$compile', '$rootScope');
10+
});
11+
12+
bard.verifyNoOutstandingHttpRequests();
13+
14+
xdescribe('', function() {
15+
beforeEach(function() {});
16+
17+
it('', function() {});
18+
});
19+
});

0 commit comments

Comments
 (0)