mirror of
https://github.com/sismics/docs.git
synced 2024-11-25 23:27:57 +01:00
#256: upload a new version UI
This commit is contained in:
parent
b2dc460b4b
commit
4469bb7bee
@ -64,10 +64,26 @@ 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.
|
||||||
*/
|
*/
|
||||||
$scope.fileDropped = function(files) {
|
$scope.fileDropped = function (files) {
|
||||||
if (!$scope.document.writable) {
|
if (!$scope.document.writable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,7 +91,7 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root
|
|||||||
if (files && files.length) {
|
if (files && files.length) {
|
||||||
// Adding files to the UI
|
// Adding files to the UI
|
||||||
var newfiles = [];
|
var newfiles = [];
|
||||||
_.each(files, function(file) {
|
_.each(files, function (file) {
|
||||||
var newfile = {
|
var newfile = {
|
||||||
progress: 0,
|
progress: 0,
|
||||||
name: file.name,
|
name: file.name,
|
||||||
@ -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) {
|
||||||
|
@ -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",
|
||||||
|
@ -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 }}
|
||||||
|
Loading…
Reference in New Issue
Block a user