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

Commit df2b45f

Browse files
author
Jenkins Continuous Integration Server
committed
Merge commit 'd0cc9349ec9a6558e632db3500e963418a26f406' into HEAD
2 parents 0b6fef9 + d0cc934 commit df2b45f

File tree

7 files changed

+75
-57
lines changed

7 files changed

+75
-57
lines changed

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

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ import _ from 'lodash'
3131
if (scope.fieldId.indexOf('ZIP') > -1) {
3232
scope.filePath += _.join([userId, scope.fieldId, (new Date()).valueOf()], '-') + '.zip'
3333
}
34+
var dragAreaClasses = 'tc-fp-file-drag-drop'
3435
// set extensions
3536
if (scope.fieldId.indexOf('ZIP') > -1) {
3637
scope.extensions = '.zip'
3738
} else if (scope.fieldId.indexOf('DESIGN_COVER') > -1) {
3839
scope.extensions = '.png,.jpeg,.jpg,.bmp'
40+
dragAreaClasses += ' tc-fp-file-drag-drop-image'
3941
}
4042

4143
// set default services
@@ -49,6 +51,7 @@ import _ from 'lodash'
4951
*pass original event
5052
*/
5153
element.bind('change', function(event) {
54+
scope.$parent.submissionForm[scope.fieldId].$setTouched()
5255
event.preventDefault()
5356
scope.onSuccess(event.originalEvent || event)
5457
$rootScope.$apply()
@@ -59,7 +62,7 @@ import _ from 'lodash'
5962
input.setAttribute('data-fp-maxSize', scope.maxSize)
6063
input.setAttribute('data-fp-services', scope.fpServices)
6164
input.setAttribute('data-fp-button-class', 'tc-btn')
62-
input.setAttribute('data-fp-drag-class', 'tc-fp-file-drag-drop')
65+
input.setAttribute('data-fp-drag-class', dragAreaClasses)
6366
input.setAttribute('data-fp-multiple', false)
6467
input.setAttribute('data-fp-extensions', scope.extensions)
6568
input.setAttribute('data-fp-store-location', 's3')
@@ -70,18 +73,28 @@ import _ from 'lodash'
7073

7174
scope.onSuccess = function(event) {
7275
var fpFile = event.fpfile
73-
var _file = {
74-
name: scope.filename || fpFile.filename,
75-
container: fpFile.container || scope.fpContainer,
76-
path: fpFile.key,
77-
size: fpFile.size,
78-
mimetype: fpFile.mimetype
76+
if (fpFile) {
77+
element.addClass('file-uploaded')
78+
var _file = {
79+
name: scope.filename || fpFile.filename,
80+
container: fpFile.container || scope.fpContainer,
81+
path: fpFile.key,
82+
size: fpFile.size,
83+
mimetype: fpFile.mimetype
84+
}
85+
scope.ngModel = _file
86+
scope.setFileReference({
87+
file: _file,
88+
fieldId: scope.fieldId
89+
})
90+
} else {
91+
element.removeClass('file-uploaded')
92+
scope.ngModel = null
93+
scope.setFileReference({
94+
file: null,
95+
fieldId: scope.fieldId
96+
})
7997
}
80-
scope.ngModel = _file
81-
scope.setFileReference({
82-
file: _file,
83-
fieldId: scope.fieldId
84-
})
8598
}
8699
}
87100
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
.tc-label__wrapper
77
span.tc-label__asterisk.lowercase(ng-if="mandatory") #[span *]mandatory
88
input.tc-file-field__input(
9+
data-name="{{fieldId}}",
910
type="filepicker-dragdrop",
11+
ng-model="ngModel",
12+
ng-required="mandatory",
1013
data-fp-button-text="Pick A File",
1114
data-fp-drag-text=" ",
1215
on-success="onFileSeleted(event.fpfile)"

app/services/submissions.service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import angular from 'angular'
2323
function startSubmission(body, progressCallback) {
2424
return api.all('submissions').customPOST(body)
2525
.then(function(response) {
26-
//progressCallback.call(progressCallback, 'PREPARE', 100)
26+
progressCallback.call(progressCallback, 'PREPARE', 100)
2727
// uploadSubmissionFileToS3(response, response.data.files, files, progressCallback)
2828
processSubmission(response, progressCallback)
2929
})

app/submissions/submit-design-files/submit-design-files.controller.js

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ import _ from 'lodash'
1212
if (!challengeToSubmitTo.challenge) { return }
1313

1414
var vm = this
15-
var fileUploadProgress = {}
1615
vm.urlRegEx = new RegExp(/^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,3})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/)
1716
vm.rankRegEx = new RegExp(/^[1-9]\d*$/)
1817
vm.comments = ''
1918
vm.uploadProgress = 0
20-
vm.uploading = false
2119
vm.preparing = false
2220
vm.finishing = false
21+
vm.finished = false
2322
vm.showProgress = false
2423
vm.errorInUpload = false
2524
vm.formFonts = {}
@@ -78,20 +77,26 @@ import _ from 'lodash'
7877

7978
function setFileReference(file, fieldId) {
8079
var fileObject = {
81-
name: file.name,
82-
type: fieldId,
83-
status: 'STAGED',
84-
stagedFileContainer: file.container,
85-
stagedFilePath: file.path,
86-
size: file.size,
87-
mediaType: file.mimetype
80+
type: fieldId
81+
}
82+
if (file) {
83+
fileObject = {
84+
name: file.name,
85+
type: fieldId,
86+
status: 'STAGED',
87+
stagedFileContainer: file.container,
88+
stagedFilePath: file.path,
89+
size: file.size,
90+
mediaType: file.mimetype
91+
}
8892
}
8993

9094
// If user changes a file input's file, update the file details
9195
var isFound = vm.submissionsBody.data.files.reduce(function(isFound, file, i, filesArray) {
9296
if (isFound) { return true }
9397

94-
if (file.type === fileObject.type) {
98+
// when file is removed, fileObject would have only type field
99+
if (file.type === fieldId) {
95100
filesArray[i] = fileObject
96101
return true
97102
}
@@ -108,11 +113,10 @@ import _ from 'lodash'
108113
function uploadSubmission() {
109114
vm.errorInUpload = false
110115
vm.uploadProgress = 0
111-
vm.fileUploadProgress = {}
112116
vm.showProgress = true
113117
vm.preparing = true
114-
vm.uploading = false
115118
vm.finishing = false
119+
vm.finished = false
116120
vm.submissionsBody.data.submitterComments = vm.comments
117121
vm.submissionsBody.data.submitterRank = vm.submissionForm.submitterRank
118122

@@ -164,41 +168,16 @@ import _ from 'lodash'
164168
// we are concerned only for completion of the phase
165169
if (args === 100) {
166170
vm.preparing = false
167-
vm.uploading = true
168-
logger.debug('Prepared for upload.')
169-
}
170-
} else if (phase === 'UPLOAD') {
171-
// if args is object, this update is about XHRRequest's upload progress
172-
if (typeof args === 'object') {
173-
var requestId = args.file
174-
var progress = args.progress
175-
if (!fileUploadProgress[requestId] || fileUploadProgress[requestId] < progress) {
176-
fileUploadProgress[requestId] = progress
177-
}
178-
var total = 0, count = 0
179-
for(var requestIdKey in fileUploadProgress) {
180-
var prog = fileUploadProgress[requestIdKey]
181-
total += prog
182-
count++
183-
}
184-
vm.uploadProgress = total / count
185-
186-
// initiate digest cycle because this event (xhr event) is caused outside angular
187-
$scope.$apply()
188-
} else { // typeof args === 'number', mainly used a s fallback to mark completion of the UPLOAD phase
189-
vm.uploadProgress = args
190-
}
191-
192-
// start next phase when UPLOAD is done
193-
if (vm.uploadProgress == 100) {
194-
logger.debug('Uploaded files.')
195-
vm.uploading = false
196171
vm.finishing = true
172+
logger.debug('Prepared for upload.')
197173
}
198174
} else if (phase === 'FINISH') {
199175
// we are concerned only for completion of the phase
200176
if (args === 100) {
201177
logger.debug('Finished upload.')
178+
vm.preparing = false
179+
vm.finishing = false
180+
vm.finished = true
202181
}
203182
} else {
204183
// assume it to be error condition

app/submissions/submit-design-files/submit-design-files.jade

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
.panel-body
1212
p.tc-error-messages.submissions-access-error(ng-if="submissions.error", ng-bind="submissions.errorMessage")
13-
//- <pre>{{vm.submissionForm}}</pre>
13+
1414
form.form-blocks(ng-if="!submissions.error", name="submissionForm", role="form", ng-submit="submissionForm.$valid && vm.uploadSubmission()", novalidate)
1515
.form-block.flex
1616
.form-block__instructions
@@ -155,7 +155,7 @@
155155
input(type="checkbox", ng-model="vm.submissionForm.hasAgreedToTerms", id="agree-to-terms", required)
156156

157157
label(for="agree-to-terms") I understand and agree
158-
158+
159159
button.tc-btn.tc-btn-secondary(type="submit", ng-disabled="submissionForm.$invalid") Submit
160160

161161
modal.transition(show="vm.showProgress", background-click-close="false", style="background-color:white;")
@@ -170,10 +170,13 @@ modal.transition(show="vm.showProgress", background-click-close="false", style="
170170

171171
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.
172172

173-
progress-bar.upload-progress__progress-bar(completed="vm.uploadProgress", message="of 3 files uploaded")
173+
//- progress-bar.upload-progress__progress-bar(completed="vm.uploadProgress", message="of 3 files uploaded")
174174
175175
.upload-progress__preparing(ng-show="vm.preparing && !vm.errorInUpload") #[span Preparing...]
176176
.upload-progress__finishing(ng-show="vm.finishing && !vm.errorInUpload")
177+
p Finishing...
178+
179+
.upload-progress__finished(ng-show="vm.finished && !vm.errorInUpload")
177180
p Finished!
178181

179182
.upload-progess__links

assets/css/directives/tc-fp-file-input.directive.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ tc-fp-file-input {
4545
top: 0;
4646
height: 190px;
4747
width: 240px;
48+
position: relative;
49+
50+
> span {
51+
position: absolute;
52+
top: 0px;
53+
right: 0px;
54+
}
4855
}
4956

5057
.tc-fp-file-drag-drop::after {
@@ -57,4 +64,15 @@ tc-fp-file-input {
5764
left: 50%;
5865
transform: translateX(-50%)
5966
}
67+
68+
.tc-fp-file-drag-drop-image::after {
69+
content: 'Drag and Drop your PNG or JPG file here';
70+
}
71+
72+
&.file-uploaded {
73+
.tc-file-field__input::after,
74+
.tc-fp-file-drag-drop::after {
75+
content: '';
76+
}
77+
}
6078
}

assets/css/submissions/submit-file.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,14 @@ modal {
168168

169169
.upload-progress__preparing,
170170
.upload-progress__finishing,
171+
.upload-progress__finished,
171172
.upload-progress__error {
172173
@include font-with-weight('Sofia Pro', 500);
173174
font-size: 12px;
174175
line-height: 14px;
175176
color: $accent-gray-dark;
176177
text-align: center;
178+
margin-top: 40px;
177179
}
178180

179181
.upload-progress__error {

0 commit comments

Comments
 (0)