diff --git a/css/style.scss b/css/style.scss index 4245715f7..673c4b45c 100644 --- a/css/style.scss +++ b/css/style.scss @@ -877,6 +877,9 @@ input.input-inline { button.icon-history { width: 44px; } + progress { + margin-top: 3px; + } } } diff --git a/js/controller/CardController.js b/js/controller/CardController.js index 29ce7e9fe..e7904054d 100644 --- a/js/controller/CardController.js +++ b/js/controller/CardController.js @@ -43,6 +43,7 @@ app.controller('CardController', function ($scope, $rootScope, $sce, $location, return $state.params; }, function (params) { $scope.params = params; + $scope.fileservice.reset(); }, true); $scope.params = $state.params; diff --git a/js/service/FileService.js b/js/service/FileService.js index 8248debd0..0d511c428 100644 --- a/js/service/FileService.js +++ b/js/service/FileService.js @@ -1,5 +1,5 @@ /* - * @copyright Copyright (c) 2018 Julius Härtl +* @copyright Copyright (c) 2018 Julius Härtl * * @author Julius Härtl * @@ -32,8 +32,14 @@ export default class FileService { this.uploader.onAfterAddingFile = this.onAfterAddingFile.bind(this); this.uploader.onSuccessItem = this.onSuccessItem.bind(this); this.uploader.onErrorItem = this.onErrorItem.bind(this); - + this.uploader.onCancelItem = this.onCancelItem.bind(this); + this.maxUploadSize = $rootScope.config.maxUploadSize; + this.progress = []; + this.status = null; + } + + reset () { this.status = null; } @@ -66,6 +72,7 @@ export default class FileService { // Fetch card details before trying to upload so we can detect filename collisions properly let self = this; + this.progress.push(fileItem); this.cardservice.fetchOne(fileItem.cardId).then(function (data) { let attachments = self.cardservice.get(fileItem.cardId).attachments; let existingFile = attachments.find((attachment) => { @@ -94,7 +101,7 @@ export default class FileService { self.runUpload(fileItem); } }, function (error) { - + this.progress = this.progress.filter((item) => (fileItem.file.name !== item.file.name)); }); } @@ -106,15 +113,25 @@ export default class FileService { attachments = attachments.splice(index, 1); } this.cardservice.get(item.cardId).attachments.push(response); + this.progress = this.progress.filter((fileItem) => (fileItem.file.name !== item.file.name)); } onErrorItem (item, response) { + this.progress = this.progress.filter((fileItem) => (fileItem.file.name !== item.file.name)); this.status = { error: t('deck', `Failed to upload:`) + ' ' + item.file.name, message: response.message }; } + onCancelItem (item) { + this.progress = this.progress.filter((fileItem) => (fileItem.file.name !== item.file.name)); + } + + getProgressItemsForCard (cardId) { + return this.progress.filter((fileItem) => (fileItem.cardId === cardId)); + } + } -app.service('FileService', FileService); \ No newline at end of file +app.service('FileService', FileService); diff --git a/templates/part.card.attachments.php b/templates/part.card.attachments.php index 421a1bb9a..6a07de3e8 100644 --- a/templates/part.card.attachments.php +++ b/templates/part.card.attachments.php @@ -2,6 +2,19 @@

t('Select an attachment')); ?>

    +
  • + +
    +
    + {{ attachment.file.name }} +
    + +
    + +