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

Commit 107c8b2

Browse files
author
Nick Litwin
committed
Work on stock art form fields
1 parent 7ea5256 commit 107c8b2

File tree

3 files changed

+65
-18
lines changed

3 files changed

+65
-18
lines changed

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

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,29 @@
77

88
function SubmitFileController($stateParams, UserService, SubmissionsService) {
99
var vm = this;
10-
vm.hasAgreedToTerms = false;
10+
var files = {};
1111
vm.comments = '';
12+
vm.submissionForm = {
13+
files: [],
14+
15+
// Should the rank input field be set to 1 automatically?
16+
submitterRank: 1,
17+
submitterComments: '',
18+
fonts: [{
19+
id: 1,
20+
name: '',
21+
sourceUrl: '',
22+
source: ''
23+
}],
24+
stockArts: [{
25+
id: 1,
26+
description: '',
27+
sourceUrl: '',
28+
fileNumber: ''
29+
}],
30+
hasAgreedToTerms: false
31+
};
32+
1233
var userId = parseInt(UserService.getUserIdentity().userId);
1334

1435
vm.submissionsBody = {
@@ -37,13 +58,15 @@
3758

3859
vm.setFileReference = setFileReference;
3960
vm.uploadSubmission = uploadSubmission;
40-
61+
vm.createAnotherStockArtFieldset = createAnotherStockArtFieldset;
4162

4263
activate();
4364

4465
function activate() {}
4566

4667
function setFileReference(file, fieldId) {
68+
files[fieldId] = file;
69+
4770
var fileObject = {
4871
name: file.name,
4972
type: fieldId,
@@ -61,6 +84,8 @@
6184
fileObject.mediaType = file.type;
6285
}
6386

87+
88+
6489
// If user picks a new file, replace the that file's fileObject with a new one
6590
// Or add it the list if it's not there
6691
if (vm.submissionsBody.data.files.length) {
@@ -76,9 +101,25 @@
76101
}
77102
}
78103

104+
function createAnotherStockArtFieldset() {
105+
vm.submissionForm.stockArts.push({
106+
id: vm.submissionForm.stockArts.length + 1,
107+
description: '',
108+
sourceUrl: '',
109+
fileNumber: ''
110+
});
111+
}
112+
79113
function uploadSubmission() {
80114
vm.submissionsBody.data.submitterComments = vm.comments;
81-
SubmissionsService.getPresignedURL(vm.submissionsBody);
115+
vm.submissionsBody.data.submitterRank = vm.submissionForm.submitterRank;
116+
117+
var stockArts = angular.copy(vm.submissionForm.stockArts);
118+
vm.submissionsBody.data.stockArts = stockArts.forEach(function(stockArt) {
119+
delete stockArt.id;
120+
});
121+
122+
SubmissionsService.getPresignedURL(vm.submissionsBody, files);
82123
}
83124
}
84125
})();

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
a.tc-btn.tc-btn-s(ng-click="'TODO: go back to challenge details'") Back to Challenge Details
1010

1111
.panel-body
12-
form.form-blocks(name="vm.submissionForm", role="form", ng-submit="vm.submissionForm.$valid && vm.uploadSubmission()", novalidate)
12+
form.form-blocks(name="submissionForm", role="form", ng-submit="submissionForm.$valid && vm.uploadSubmission()", novalidate)
1313
.form-block.flex.wrap
1414
.form-block__instructions
1515
.form-block__title Files
@@ -25,7 +25,7 @@
2525

2626
.form-block__fields
2727
.fieldset
28-
tc-file-input(
28+
tc-file-input.tc-file-field(
2929
label-text="Submission",
3030
field-id="SUBMISSION_ZIP",
3131
button-text="Add File",
@@ -35,7 +35,7 @@
3535
set-file-reference="vm.setFileReference(file, fieldId)"
3636
)
3737

38-
tc-file-input(
38+
tc-file-input.tc-file-field(
3939
label-text="Source",
4040
field-id="SOURCE_ZIP",
4141
button-text="Add File",
@@ -45,7 +45,7 @@
4545
set-file-reference="vm.setFileReference(file, fieldId)"
4646
)
4747

48-
tc-file-input(
48+
tc-file-input.tc-file-field(
4949
label-text="Preview Image",
5050
field-id="DESIGN_COVER",
5151
button-text="Add File",
@@ -54,6 +54,8 @@
5454
set-file-reference="vm.setFileReference(file, fieldId)"
5555
)
5656

57+
tc-input.fieldset__input.submitterRank(label-text="Rank #", input-value="vm.submissionForm.submitterRank")
58+
5759
.form-block.flex.wrap
5860
.form-block__instructions
5961
.form-block__title Notes
@@ -101,21 +103,21 @@
101103

102104
.form-block__fields
103105
.fieldsets
104-
.fieldset
105-
tc-input.fieldset__input(label-text="Photo Description", placeholder="A picture of a girl")
106+
ng-form.fieldset(name="stockArt_{{$index}}", ng-repeat="stockArt in vm.submissionForm.stockArts track by stockArt.id")
107+
tc-input.fieldset__input(label-text="Photo Description", placeholder="A picture of a girl", input-value="stockArt.description")
106108

107-
tc-input.fieldset__input(label-text="Photo URL", placeholder="www.istockphoto.com")
109+
tc-input.fieldset__input(label-text="Photo URL", placeholder="www.istockphoto.com", input-value="stockArt.sourceUrl")
108110

109-
tc-input.fieldset__input(label-text="File Number", placeholder="u2434312")
111+
tc-input.fieldset__input(label-text="File Number", placeholder="u2434312", input-value="stockArt.fileNumber")
110112

111-
button.fieldset__button.tc-btn.tc-btn-s(ng-click="") + Add Stock Photo
113+
button.fieldset__button.tc-btn.tc-btn-s(ng-click="vm.createAnotherStockArtFieldset()") + Add Stock Photo
112114

113-
.panel-footer
114-
p Submitting your files means you hereby agree to the #[a(href="https://www.{{DOMAIN}}/community/how-it-works/terms/", target="_blank") Topcoder terms of use] and to the extent your uploaded file wins a Topcoder Competition, you hereby assign, grant, and transfer to Topcoder all rights in and title to the Winning Submission (as further described in the terms of use).
115+
.panel-footer
116+
p Submitting your files means you hereby agree to the #[a(href="https://www.{{DOMAIN}}/community/how-it-works/terms/", target="_blank") Topcoder terms of use] and to the extent your uploaded file wins a Topcoder Competition, you hereby assign, grant, and transfer to Topcoder all rights in and title to the Winning Submission (as further described in the terms of use).
115117

116-
.checkbox.flex.center
117-
input(type="checkbox", ng-model="vm.hasAgreedToTerms", id="agree-to-terms", required)
118+
.checkbox.flex.center
119+
input(type="checkbox", ng-model="vm.submissionForm.hasAgreedToTerms", id="agree-to-terms", required)
118120

119-
label(for="agree-to-terms") I understand and agree
121+
label(for="agree-to-terms") I understand and agree
120122

121-
button.tc-btn.tc-btn-secondary(type="submit", ng-disabled="vm.submissionForm.$invalid") Submit
123+
button.tc-btn.tc-btn-secondary(type="submit", ng-disabled="submissionForm.$invalid") Submit

assets/css/submissions/submit-file.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@
3232
margin-top: 30px;
3333
}
3434
}
35+
36+
.submitterRank {
37+
margin-top: 10px;
38+
}

0 commit comments

Comments
 (0)