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

Commit 93f81f2

Browse files
author
Nick Litwin
committed
Make font and stock art buttons diabled when everything isn't filled out
1 parent ddec3aa commit 93f81f2

File tree

6 files changed

+57
-2
lines changed

6 files changed

+57
-2
lines changed

app/directives/tc-form-fonts/tc-form-fonts.directive.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@
9292
delete $scope.formFonts[index];
9393
}
9494
}
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+
}
95105
}]
96106
}
97107
}

app/directives/tc-form-fonts/tc-form-fonts.jade

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
p(ng-message="required") This field is required.
3030

3131
tc-input.fieldset__input(
32+
ng-hide="formFonts[fontId].source === 'STUDIO_STANDARD_FONTS_LIST'",
3233
label-text="Font URL",
3334
placeholder="Select font source to edit field",
3435
input-value="font.sourceUrl",
@@ -45,4 +46,4 @@
4546
p(ng-message="pattern") Please enter a valid url.
4647
p(ng-message="required") This field is required.
4748

48-
button.fieldset__button.tc-btn.tc-btn-s(type="button", ng-click="createAdditionalFontFieldset()") + Add Font
49+
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+
});

app/directives/tc-form-stockart/tc-form-stockart.directive.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@
4444
delete $scope.formStockarts[index];
4545
}
4646
}
47+
48+
$scope.isButtonDisabled = function() {
49+
return _.some($scope.formStockarts, function(stockart) {
50+
return !stockart.description || !stockart.sourceUrl || !stockart.fileNumber;
51+
});
52+
}
4753
}]
4854
}
4955
}

app/directives/tc-form-stockart/tc-form-stockart.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
input-name="fileNumber{{stockartId}}"
2727
)
2828

29-
button.fieldset__button.tc-btn.tc-btn-s(type="button", ng-click="createAdditionalStockartFieldset()") + Add Stock Photo
29+
button.fieldset__button.tc-btn.tc-btn-s(type="button", ng-click="createAdditionalStockartFieldset()", ng-disabled="isButtonDisabled()") + Add Stock Photo
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 Stockart 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)