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

Commit f5a1073

Browse files
author
vikasrohit
committed
#839, After uploading a file to Submission/Source/Preview Image boxes; info text must remove
-- Fixed #849, "Remove" button is hard to find when we upload a file with a long name -- Fixed
1 parent ca9e292 commit f5a1073

File tree

6 files changed

+62
-54
lines changed

6 files changed

+62
-54
lines changed

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

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,28 @@ import _ from 'lodash'
7272

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

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
@@ -17,9 +17,9 @@ import _ from 'lodash'
1717
vm.rankRegEx = new RegExp(/^[1-9]\d*$/)
1818
vm.comments = ''
1919
vm.uploadProgress = 0
20-
vm.uploading = false
2120
vm.preparing = false
2221
vm.finishing = false
22+
vm.finished = false
2323
vm.showProgress = false
2424
vm.errorInUpload = false
2525
vm.formFonts = {}
@@ -77,21 +77,25 @@ import _ from 'lodash'
7777
}
7878

7979
function setFileReference(file, fieldId) {
80-
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+
var fileObject = null
81+
if (file) {
82+
fileObject = {
83+
name: file.name,
84+
type: fieldId,
85+
status: 'STAGED',
86+
stagedFileContainer: file.container,
87+
stagedFilePath: file.path,
88+
size: file.size,
89+
mediaType: file.mimetype
90+
}
8891
}
8992

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

94-
if (file.type === fileObject.type) {
97+
if (file && file.type === fieldId) {
98+
// when file is removed, it would set correspding file as null
9599
filesArray[i] = fileObject
96100
return true
97101
}
@@ -100,7 +104,7 @@ import _ from 'lodash'
100104
}, false)
101105

102106
// Add new files to the list
103-
if (!isFound) {
107+
if (!isFound && fileObject) {
104108
vm.submissionsBody.data.files.push(fileObject)
105109
}
106110
}
@@ -111,8 +115,8 @@ import _ from 'lodash'
111115
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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 14 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 {
@@ -61,4 +68,11 @@ tc-fp-file-input {
6168
.tc-fp-file-drag-drop-image::after {
6269
content: 'Drag and Drop your PNG or JPG file here';
6370
}
71+
72+
&.file-uploaded {
73+
.tc-file-field__input::after,
74+
.tc-fp-file-drag-drop::after {
75+
content: '';
76+
}
77+
}
6478
}

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)