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

Commit 6075bca

Browse files
committed
Merge pull request #634 from appirio-tech/SUP-2920-required-form-inputs
Require files to be set in order for form to be submitted
2 parents 1596851 + 50d4727 commit 6075bca

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
function tcFileInput() {
77
return {
88
restrict: 'E',
9+
require: '^form',
910
templateUrl: 'directives/tc-file-input/tc-file-input.html',
1011
scope: {
1112
labelText: '@',
@@ -14,9 +15,10 @@
1415
fileType: '@',
1516
mandatory: '=',
1617
buttonText: '@',
17-
setFileReference: '&'
18+
setFileReference: '&',
19+
fileValue: '=ngModel'
1820
},
19-
link: function(scope, element, attrs) {
21+
link: function(scope, element, attrs, formController) {
2022
scope.selectFile = selectFile;
2123

2224
// fieldId is not set on element at this point, so grabbing with class .none
@@ -32,6 +34,7 @@
3234

3335
// Set the file name as the value of the disabled input
3436
fileNameInput[0].value = file.name;
37+
formController[attrs.fieldId].$setValidity('required', true);
3538
});
3639

3740
function selectFile() {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
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}}", required)
8+
input.tc-file-field__input(type="text", placeholder="{{placeholder}}")
99

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

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

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
vm.comments = '';
2727
vm.submissionForm = {
2828
files: [],
29+
submissionZip: null,
30+
sourceZip: null,
31+
designCover: null,
32+
2933

3034
// Should the rank input field be set to 1 automatically?
3135
submitterRank: 1,
@@ -80,6 +84,7 @@
8084
function activate() {}
8185

8286
function setFileReference(file, fieldId) {
87+
// Can clean up since fileValue on tcFileInput has file reference?
8388
files[fieldId] = file;
8489

8590
var fileObject = {

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
file-type="(*.zip)",
3333
placeholder="Attach all visible files as a single .zip file",
3434
mandatory="true",
35-
set-file-reference="vm.setFileReference(file, fieldId)"
35+
set-file-reference="vm.setFileReference(file, fieldId)",
36+
file-value="vm.submissionForm.submissionZip"
3637
)
3738

3839
tc-file-input.tc-file-field(
@@ -42,7 +43,8 @@
4243
file-type="(*.zip)",
4344
placeholder="Attach all source files as a single .zip file",
4445
mandatory="true",
45-
set-file-reference="vm.setFileReference(file, fieldId)"
46+
set-file-reference="vm.setFileReference(file, fieldId)",
47+
file-value="vm.submissionForm.sourceZip"
4648
)
4749

4850
tc-file-input.tc-file-field(
@@ -51,7 +53,8 @@
5153
button-text="Add File",
5254
placeholder="Image file as .jpg or .png",
5355
mandatory="true",
54-
set-file-reference="vm.setFileReference(file, fieldId)"
56+
set-file-reference="vm.setFileReference(file, fieldId)",
57+
file-value="vm.submissionForm.designCover"
5558
)
5659

5760
tc-input.fieldset__input.submitterRank(label-text="Rank #", input-value="vm.submissionForm.submitterRank")

0 commit comments

Comments
 (0)