Skip to content

Commit

Permalink
#257 Fix the dropzone component to allow only one file in task log cr…
Browse files Browse the repository at this point in the history
…eation form
  • Loading branch information
nadouani committed Jul 26, 2017
1 parent 47d440d commit 296b090
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion ui/app/scripts/controllers/case/CaseTasksCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
// open task tab with its details
$scope.startTask = function(task) {
if (task.status === 'Waiting') {
$scope.updateTaskStatus(task.id, 'InProgress');
$scope.updateTaskStatus(task.id, 'InProgress')
.then($scope.showTask);
} else {
$scope.showTask(task);
}
Expand Down
17 changes: 11 additions & 6 deletions ui/app/scripts/directives/fileChooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
$(element[0].children[0]).remove();
// create a Dropzone for the element with the given options
dropzone = new Dropzone(element[0], {
// 'clickable' : '.dz-clickable',
'url': 'dummy',
'autoProcessQueue': false,
'maxFiles': 1,
// 'addRemoveLinks' : true,
'createImageThumbnails': (angular.isString(scope.preview)) ? (scope.preview === 'true') : true,
'acceptedFiles': (angular.isString(scope.accept)) ? scope.accept : undefined,
'previewTemplate': template
Expand All @@ -26,12 +24,19 @@
});
});
dropzone.on('removedfile', function() {
setTimeout(function() {
var files = this.files;

if(files && files.length !== 1) {
setTimeout(function() {
scope.$apply(function() {
delete scope.filemodel;
});
}, 0);
} else {
scope.$apply(function() {
delete scope.filemodel;
// scope.filemodel = undefined;
scope.filemodel = files[0];
});
}, 0);
}
});
dropzone.on('maxfilesexceeded', function(file) {
this.removeFile(file);
Expand Down
4 changes: 2 additions & 2 deletions ui/app/views/directives/dropzone.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div>
<span data-dz-name></span>
<span data-dz-size></span>
<button data-dz-remove class="btn btn-xs btn-danger delete">
<button data-dz-remove class="btn btn-xs btn-danger delete">
<i class="glyphicon glyphicon-remove-circle"></i>
<span>Remove</span>
</button>
</div>
<div ng-hide="filemodel != undefined" class="dz-clickable dz-message" style="border: 1px dashed red; height: 4em;">
<span style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center;">Drop file or click</span>
</div>
</div>
2 changes: 1 addition & 1 deletion ui/app/views/partials/case/case.tasks.item.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ <h4 class="mb-xs text-primary">Task logs</h4>
</div>
</div>
<div class="row" ng-show="adding">
<div class="col-md-12">
<div class="col-md-12">
<div class="clearfix">
<a class="pull-right" href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank"><i class="fa fa-question-circle"></i> Markdown Reference</a>
</div>
Expand Down

0 comments on commit 296b090

Please sign in to comment.