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

Commit ade537b

Browse files
author
Nick Litwin
committed
Add buttons when upload is complete and change routes to handle different tracks
1 parent 55499c1 commit ade537b

11 files changed

+99
-83
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ Spec files live alongside the code they are testing. For example, in peer-review
5858
## UI-Router and States
5959
See any *.routes.js file as an example.
6060

61+
**Important** Make sure the url in your routes files ends with a /
62+
6163
## Contributing
6264

6365
### Style Guide and Naming Conventions
@@ -78,9 +80,9 @@ Jade Files
7880
```
7981
.wrapper
8082
h1 Lorem ipsum
81-
83+
8284
p Sibling tag
83-
85+
8486
.wrapper2
8587
p Child
8688
```
@@ -99,7 +101,7 @@ SCSS Files
99101
height: 100px;
100102
width: 100px;
101103
}
102-
104+
103105
.inside-box {
104106
font-size: 14px;
105107
@media screen and (min-width: 768px) {

app/index.jade

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,7 @@ html
335335
script(src="submissions/submissions.module.js")
336336
script(src="submissions/submissions.controller.js")
337337
script(src="submissions/submissions.routes.js")
338-
script(src="submissions/submit-file/submit-file.controller.js")
339-
script(src="submissions/submit-file/submit-file-completed.controller.js")
338+
script(src="submissions/submit-design-files/submit-design-files.controller.js")
340339
script(src="topcoder.constants.js")
341340
script(src="topcoder.controller.js")
342341
script(src="topcoder.interceptors.js")

app/submissions/submissions.controller.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

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

6-
SubmissionsController.$inject = ['challengeToSubmitTo'];
6+
SubmissionsController.$inject = ['challengeToSubmitTo', '$state'];
7+
8+
function SubmissionsController(challengeToSubmitTo, $state) {
79

8-
function SubmissionsController(challengeToSubmitTo) {
910
var vm = this;
1011

1112
var challenge = challengeToSubmitTo.challenge;
@@ -15,6 +16,14 @@
1516

1617
activate();
1718

18-
function activate() {}
19+
function activate() {
20+
var track = challengeToSubmitTo.challenge.track;
21+
22+
if (track === 'DESIGN') {
23+
$state.go('submissions.file.design');
24+
} else if (track === 'DEVELOP') {
25+
$state.go('submissions.file.develop')
26+
}
27+
}
1928
}
2029
})();

app/submissions/submissions.routes.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
controllerAs: 'submissions',
1919
data: {
2020
authRequired: true,
21-
22-
// TODO: Get title from PMs
23-
title: 'Submit'
21+
title: 'Challenge Submission'
2422
},
2523
resolve: {
2624
challengeToSubmitTo: ['ChallengeService', '$stateParams', 'UserService', function(ChallengeService, $stateParams, UserService) {
@@ -36,10 +34,9 @@
3634
challenge = challenge[0];
3735

3836
if (!challenge) {
39-
// There should be a challenge, redirect?
37+
// TODO: There should be a challenge, redirect?
4038
alert('User is not associated with this challenge.');
4139
}
42-
4340
var phaseType;
4441
var phaseId;
4542

@@ -84,17 +81,22 @@
8481
}
8582
},
8683
'submissions.file': {
87-
url: '?method',
88-
templateUrl: 'submissions/submit-file/submit-file.html',
89-
controller: 'SubmitFileController',
84+
url:'file/',
85+
abstract: true,
86+
template: '<ui-view/>'
87+
},
88+
'submissions.file.design': {
89+
url:'',
90+
templateUrl: 'submissions/submit-design-files/submit-design-files.html',
91+
controller: 'SubmitDesignFilesController',
92+
controllerAs: 'vm',
93+
},
94+
'submissions.file.develop': {
95+
url:'',
96+
templateUrl: 'submissions/submit-develop-files/submit-develop-files.html',
97+
controller: 'SubmitDevelopFilesController',
9098
controllerAs: 'vm',
9199
},
92-
'submissions.completed': {
93-
url: 'completed',
94-
templateUrl: 'submissions/submit-file-completed/submit-file-completed.html',
95-
controller: 'SubmitFileCompletedController',
96-
controllerAs: 'vm'
97-
}
98100
};
99101

100102
for (var name in states) {

app/submissions/submit-file/submit-file.controller.js renamed to app/submissions/submit-design-files/submit-design-files.controller.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
(function () {
22
'use strict';
33

4-
angular.module('tc.submissions').controller('SubmitFileController', SubmitFileController);
4+
angular.module('tc.submissions').controller('SubmitDesignFilesController', SubmitDesignFilesController);
55

6-
SubmitFileController.$inject = ['$scope','$state', '$stateParams', '$log', 'UserService', 'SubmissionsService', 'challengeToSubmitTo'];
6+
SubmitDesignFilesController.$inject = ['$scope','$window', '$stateParams', '$log', 'UserService', 'SubmissionsService', 'challengeToSubmitTo'];
77

8-
function SubmitFileController($scope, $state, $stateParams, $log, UserService, SubmissionsService, challengeToSubmitTo) {
8+
function SubmitDesignFilesController($scope, $window, $stateParams, $log, UserService, SubmissionsService, challengeToSubmitTo) {
99
var vm = this;
10-
$log = $log.getInstance('SubmitFileController');
10+
$log = $log.getInstance('SubmitDesignFilesController');
1111
var files = {};
1212
var fileUploadProgress = {};
1313
vm.urlRegEx = new RegExp(/^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,3})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/);
@@ -39,18 +39,14 @@
3939

4040
vm.submissionsBody = {
4141
reference: {
42-
43-
// type dynamic or static?
4442
type: 'CHALLENGE',
4543
id: $stateParams.challengeId,
4644
phaseType: challengeToSubmitTo.phaseType,
4745
phaseId: challengeToSubmitTo.phaseId
4846
},
4947
userId: userId,
5048
data: {
51-
52-
// Dynamic or static?
53-
method: 'DESIGN_CHALLENGE_ZIP_FILE',
49+
method: challengeToSubmitTo.challenge.track.toUpperCase() + '_CHALLENGE_ZIP_FILE',
5450

5551
// Can delete below since they are processed and added later?
5652
files: [],
@@ -64,6 +60,7 @@
6460
vm.setRankTo1 = setRankTo1;
6561
vm.setFileReference = setFileReference;
6662
vm.uploadSubmission = uploadSubmission;
63+
vm.refreshPage = refreshPage;
6764
vm.cancelRetry = cancelRetry;
6865

6966
activate();
@@ -194,11 +191,13 @@
194191
count++;
195192
}
196193
vm.uploadProgress = total / count;
194+
197195
// initiate digest cycle because this event (xhr event) is caused outside angular
198196
$scope.$apply();
199197
} else { // typeof args === 'number', mainly used a s fallback to mark completion of the UPLOAD phase
200198
vm.uploadProgress = args;
201199
}
200+
202201
// start next phase when UPLOAD is done
203202
if (vm.uploadProgress == 100) {
204203
$log.debug('Uploaded files.');
@@ -209,20 +208,20 @@
209208
// we are concerned only for completion of the phase
210209
if (args === 100) {
211210
$log.debug('Finished upload.');
212-
vm.finishing = false;
213-
vm.showProgress = false;
214-
215-
$state.go('submissions.completed');
216211
}
217-
} else { // assume it to be error condition
212+
} else {
213+
// assume it to be error condition
218214
$log.debug("Error Condition: " + phase);
219215
vm.errorInUpload = true;
220216
}
221217
}
222218

219+
function refreshPage() {
220+
$window.location.reload(true);
221+
}
222+
223223
function cancelRetry() {
224224
vm.showProgress = false;
225-
// TODO redirect to submission listing / challenge details page
226225
}
227226
}
228227
})();

app/submissions/submit-file/submit-file.jade renamed to app/submissions/submit-design-files/submit-design-files.jade

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,25 +151,32 @@
151151

152152
button.tc-btn.tc-btn-secondary(type="submit", ng-disabled="submissionForm.$invalid") Submit
153153

154-
modal.transition(show="vm.showProgress", background-click-close="true", style="background-color:white;")
154+
modal.transition(show="vm.showProgress", background-click-close="false", style="background-color:white;")
155155
.upload-progress(ng-class="{'upload-progress--error': vm.errorInUpload}")
156156
.upload-progress__title
157157
p Uploading submission for
158158

159159
p.upload-progress-title__challenge-name [Challenge name]
160160

161161
img.upload-progress__image(src="/images/robot.svg", ng-hide="vm.errorInUpload")
162-
163162
img.upload-progress__image--error(src="/images/robot-embarresed.svg", ng-show="vm.errorInUpload")
164163

165-
p.upload-progress__message(ng-hide="vm.errorInUpload") Hey, your work is AWESOME! Please don’t close the window while I’m working, you’ll loose all files!
164+
p.upload-progress__message(ng-hide="vm.errorInUpload") Hey, your work is AWESOME! Please don’t close the window while I’m working or you’ll loose all files!
166165

167-
p.upload-progress__message--error(ng-show="vm.errorInUpload") Oh, that’s embarrassing! The file couldn’t be uploaded, I’m so sorry.
166+
p.upload-progress__message--error(ng-show="vm.errorInUpload") Oh, that’s embarrassing! One of the files couldn’t be uploaded, I’m so sorry.
168167

169168
progress-bar.upload-progress__progress-bar(completed="vm.uploadProgress", message="of 3 files uploaded")
170169

171170
.upload-progress__preparing(ng-show="vm.preparing && !vm.errorInUpload") #[span Preparing...]
172-
.upload-progress__finishing(ng-show="vm.finishing && !vm.errorInUpload") #[span Finishing...]
171+
.upload-progress__finishing(ng-show="vm.finishing && !vm.errorInUpload")
172+
p Finished!
173+
174+
.upload-progess__links
175+
a.tc-btn.tc-btn-s(ng-href="https://www.{{DOMAIN}}/challenge-details/{{submissions.challengeId}}/?type={{submissions.track}}") Back to the challenge
176+
177+
a.tc-btn.tc-btn-s.tc-btn-ghost(ng-click="vm.refreshPage()") Submit another
178+
179+
173180
.upload-progress__error(ng-show="vm.errorInUpload") #[span File upload failed]
174181

175182
.upload-progress__error-action(ng-show="vm.errorInUpload")

app/submissions/submit-file/submit-file.spec.js renamed to app/submissions/submit-design-files/submit-design-files.spec.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* jshint -W117, -W030 */
2-
describe('Submit File Controller', function() {
2+
describe('Submit Design Files Controller', function() {
33
var controller, vm, scope;
44

55
var mockChallenge = {
@@ -22,6 +22,12 @@ describe('Submit File Controller', function() {
2222
getPresignedURL: function() {}
2323
};
2424

25+
var mockWindow = {
26+
location: {
27+
reload: function(val) { return val; }
28+
}
29+
};
30+
2531
beforeEach(function() {
2632
bard.appModule('tc.submissions');
2733
bard.inject(this, '$controller', '$rootScope');
@@ -32,11 +38,12 @@ describe('Submit File Controller', function() {
3238
bard.verifyNoOutstandingHttpRequests();
3339

3440
beforeEach(function() {
35-
controller = $controller('SubmitFileController', {
41+
controller = $controller('SubmitDesignFilesController', {
3642
$scope: scope,
3743
UserService: userService,
3844
challengeToSubmitTo: mockChallenge,
39-
SubmissionsService: submissionsService
45+
SubmissionsService: submissionsService,
46+
$window: mockWindow
4047
});
4148
vm = controller;
4249
});
@@ -265,6 +272,18 @@ describe('Submit File Controller', function() {
265272
});
266273
});
267274

275+
describe('refreshPage', function() {
276+
it('reloads the page', function() {
277+
var mockRefresh = sinon.spy(mockWindow.location, 'reload');
278+
279+
vm.refreshPage();
280+
scope.$digest();
281+
282+
expect(mockRefresh).calledWith(true);
283+
expect(mockRefresh).calledOnce;
284+
});
285+
});
286+
268287
describe('cancelRetry', function() {
269288
it('sets showProgress to false', function() {
270289
vm.showProgress = true;

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

Lines changed: 0 additions & 19 deletions
This file was deleted.

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

Lines changed: 0 additions & 8 deletions
This file was deleted.

app/topcoder.routes.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@
4242
window.location.href = CONSTANTS.MAIN_URL + '/404/';
4343
}]
4444
},
45-
/**
46-
* Base state that all other routes should inherit from.
47-
* Child routes can override any of the specified regions
48-
*/
45+
// Base state that all other routes should inherit from.
46+
// Child routes can override any of the specified regions
4947
'root': {
5048
url: '',
5149
abstract: true,
@@ -70,10 +68,8 @@
7068
}
7169
},
7270
'home': {
73-
// TODO - set new home page
7471
parent: 'root',
7572
url: '/',
76-
// template: 'This is the home page',
7773
controller: ['$state', function($state) {
7874
$state.go('dashboard');
7975
}]

assets/css/submissions/submit-file.scss

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,8 @@ tc-form-fonts, tc-form-stockart {
112112
}
113113

114114
modal {
115-
.close {
116-
.icon.cross {
117-
background-image: url(/images/x-mark-gray.svg);
118-
background-size: 25px;
119-
}
115+
> button {
116+
display: none;
120117
}
121118
}
122119
.upload-progress {
@@ -162,6 +159,7 @@ modal {
162159
font-size: 12px;
163160
line-height: 14px;
164161
color: $accent-gray-dark;
162+
text-align: center;
165163
}
166164

167165
.upload-progress__error {
@@ -180,3 +178,15 @@ modal {
180178
}
181179
}
182180
}
181+
182+
.upload-progess__links {
183+
margin-top: 40px;
184+
185+
a {
186+
display: inline-block;
187+
188+
&:first-child {
189+
margin-right: 10px;
190+
}
191+
}
192+
}

0 commit comments

Comments
 (0)