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

Commit 78b31cc

Browse files
author
Nick Litwin
committed
Pass phasetype and id down to controller
1 parent d38911e commit 78b31cc

File tree

4 files changed

+40
-18
lines changed

4 files changed

+40
-18
lines changed

app/services/submissions.service.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
return service;
1919

2020
function getPresignedURL(body, files) {
21-
console.log('body to get presigned url: ', body)
21+
console.log('Body of request for presigned url: ', body);
2222

2323
return api.all('submissions').customPOST(JSON.stringify({param: body}))
2424
.then(function(response) {
25-
console.log('POST Response: ', response.plain());
25+
console.log('POST/Presigned URL Response: ', response.plain());
2626

27-
uploadSubmissionFileToS3(response.data.files, files);
27+
uploadSubmissionFileToS3(response, response.data.files, files);
2828
})
2929
.catch(function(err) {
3030
console.log(err);
@@ -33,7 +33,8 @@
3333
});
3434
}
3535

36-
function uploadSubmissionFileToS3(filesWithPresignedURL, files) {
36+
function uploadSubmissionFileToS3(presignedURLResponse, files) {
37+
var filesWithPresignedURL = presignedURLResponse.data.files;
3738

3839
var promises = filesWithPresignedURL.map(function(fileWithPresignedURL) {
3940
var deferred = $q.defer();
@@ -73,6 +74,9 @@
7374
return $q.all(promises)
7475
.then(function(response) {
7576
console.log('response from S3: ', response);
77+
console.log('response to use .save restnagular with: ', presignedURLResponse);
78+
79+
// Update and start processing
7680

7781
})
7882
.catch(function(err) {

app/submissions/submissions.controller.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
function SubmissionsController(challengeToSubmitTo) {
99
var vm = this;
10-
vm.challengeTitle = challengeToSubmitTo.name;
11-
vm.challengeId = challengeToSubmitTo.id;
12-
vm.track = challengeToSubmitTo.track.toLowerCase();
10+
11+
var challenge = challengeToSubmitTo.challenge;
12+
vm.challengeTitle = challenge.name;
13+
vm.challengeId = challenge.id;
14+
vm.track = challenge.track.toLowerCase();
1315

1416
activate();
1517

app/submissions/submissions.routes.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,17 @@
4040
alert('User is not associated with this challenge.');
4141
}
4242

43-
var isPhaseSubmission = _.some(challenge.currentPhases, {
44-
phaseStatus: 'Open',
45-
phaseType: 'Submission'
43+
var phaseType;
44+
var phaseId;
45+
46+
var isPhaseSubmission = _.some(challenge.currentPhases, function(phase) {
47+
if (phase.phaseStatus === 'Open' && phase.phaseType === 'Submission') {
48+
phaseType = 'Submission';
49+
phaseId = phase.id;
50+
return true;
51+
}
52+
53+
return false;
4654
});
4755

4856
var isSubmitter = _.some(challenge.userDetails.roles, function(role) {
@@ -54,7 +62,11 @@
5462
alert('You should not have access to this page');
5563
}
5664

57-
return challenge;
65+
return {
66+
challenge: challenge,
67+
phaseType: phaseType,
68+
phaseId: phaseId
69+
};
5870
})
5971
.catch(function(err) {
6072
console.log('ERROR GETTING CHALLENGE: ', err);

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33

44
angular.module('tc.submissions').controller('SubmitFileController', SubmitFileController);
55

6-
SubmitFileController.$inject = ['$stateParams', 'UserService', 'SubmissionsService'];
6+
SubmitFileController.$inject = ['$stateParams', 'UserService', 'SubmissionsService', 'challengeToSubmitTo'];
77

8-
function SubmitFileController($stateParams, UserService, SubmissionsService) {
8+
function SubmitFileController($stateParams, UserService, SubmissionsService, challengeToSubmitTo) {
99
var vm = this;
1010

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 requets pending for react-select which will clean this code up
1114
vm.fontList1 = [
1215
{ label: 'Studio Standard Fonts List', value: 'STUDIO_STANDARDS_FONTS_LIST', id: 1 },
1316
{ label: 'Fonts.com', value: 'FONTS_DOT_COM', id: 1 },
@@ -50,10 +53,8 @@
5053
// type dynamic or static?
5154
type: 'CHALLENGE',
5255
id: $stateParams.challengeId,
53-
54-
// Current phase check should come from challenge API?
55-
phase: 'SUBMISSION'
56-
56+
phaseType: challengeToSubmitTo.phaseType,
57+
phaseId: challengeToSubmitTo.phaseId
5758
},
5859
userId: userId,
5960
data: {
@@ -116,13 +117,16 @@
116117
}
117118

118119
function selectFont(newFont) {
119-
console.log('new value: ', newFont);
120+
// See above for explanation
120121
var id = newFont.id - 1;
121122
vm.submissionForm.fonts[id].source = newFont.value;
122123
}
123124

124125
function createAnotherFontFieldset() {
126+
// See above for explanation on why this is done the way it is
125127
var id = vm.submissionForm.fonts.length;
128+
129+
// Create copy of list with new, incremented ID
126130
var newFontList = vm['fontList' + (id + 1)] = angular.copy(vm['fontList' + id]);
127131

128132
newFontList.forEach(function(font) {

0 commit comments

Comments
 (0)