#256: upload a new version UI

This commit is contained in:
Benjamin Gamard 2019-01-30 18:15:00 +01:00
parent b2dc460b4b
commit 4469bb7bee
3 changed files with 30 additions and 6 deletions

View File

@ -64,6 +64,22 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root
}); });
}; };
$scope.uploadNewVersion = function (files, file) {
if (!$scope.document.writable || !files || files.length === 0) {
return;
}
var uploadedfile = files[0];
var previousFileId = file.id;
file.id = undefined;
file.progress = 0;
file.name = uploadedfile.name;
file.create_date = new Date().getTime();
file.mimetype = uploadedfile.type;
file.version++;
$scope.uploadFile(uploadedfile, file, previousFileId);
};
/** /**
* File has been drag & dropped. * File has been drag & dropped.
*/ */
@ -101,7 +117,7 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root
/** /**
* Upload a file. * Upload a file.
*/ */
$scope.uploadFile = function(file, newfile) { $scope.uploadFile = function(file, newfile, previousFileId) {
// Upload the file // Upload the file
newfile.status = $translate.instant('document.view.content.upload_progress'); newfile.status = $translate.instant('document.view.content.upload_progress');
return Upload.upload({ return Upload.upload({
@ -109,7 +125,8 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root
url: '../api/file', url: '../api/file',
file: file, file: file,
fields: { fields: {
id: $stateParams.id id: $stateParams.id,
previousFileId: previousFileId
} }
}) })
.progress(function(e) { .progress(function(e) {

View File

@ -118,7 +118,8 @@
"drop_zone": "Drag & drop files here to upload", "drop_zone": "Drag & drop files here to upload",
"add_files": "Add files", "add_files": "Add files",
"file_processing_indicator": "This file is being processed. Searching will not be available before it is complete.", "file_processing_indicator": "This file is being processed. Searching will not be available before it is complete.",
"reprocess_file": "Reprocess this file" "reprocess_file": "Reprocess this file",
"upload_new_version": "Upload a new version"
}, },
"workflow": { "workflow": {
"workflow": "Workflow", "workflow": "Workflow",

View File

@ -56,7 +56,7 @@
<div class="file-info"> <div class="file-info">
<div></div><!-- Actually useful --> <div></div><!-- Actually useful -->
<div class="v-align file-name" ng-if="file.name">{{ file.name }}</div> <div class="v-align file-name" ng-if="file.name" title="{{ file.name }} (v{{ file.version + 1 }}.0)">{{ file.name }}</div>
<div class="v-align" ng-show="document.writable"> <div class="v-align" ng-show="document.writable">
<div uib-dropdown> <div uib-dropdown>
<button class="btn btn-default" uib-dropdown-toggle> <button class="btn btn-default" uib-dropdown-toggle>
@ -72,6 +72,12 @@
<span class="fas fa-eye"></span> <span class="fas fa-eye"></span>
{{ 'document.view.content.reprocess_file' | translate }} {{ 'document.view.content.reprocess_file' | translate }}
</a> </a>
<a href ngf-select
ngf-change="uploadNewVersion($files, file)"
ngf-multiple="false">
<span class="fas fa-plus"></span>
{{ 'document.view.content.upload_new_version' | translate }}
</a>
<a href ng-click="deleteFile(file)"> <a href ng-click="deleteFile(file)">
<span class="fas fa-trash"></span> <span class="fas fa-trash"></span>
{{ 'delete' | translate }} {{ 'delete' | translate }}