1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-22 14:11:39 +00:00

#208: rename files

This commit is contained in:
Benjamin Gamard
2018-03-23 12:52:42 +01:00
parent 37ca5ff84e
commit 55a4bb7621
13 changed files with 205 additions and 102 deletions

View File

@@ -103,7 +103,7 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $
var attachOrphanFiles = function(data) {
var promises = [];
_.each($scope.orphanFiles, function(fileId) {
promises.push(Restangular.one('file/' + fileId).post('', { id: data.id }));
promises.push(Restangular.one('file/' + fileId).post('attach', { id: data.id }));
});
$scope.orphanFiles = [];
return $q.all(promises);

View File

@@ -3,7 +3,7 @@
/**
* Document view content controller.
*/
angular.module('docs').controller('DocumentViewContent', function ($scope, $rootScope, $stateParams, Restangular, $dialog, $state, Upload, $translate) {
angular.module('docs').controller('DocumentViewContent', function ($scope, $rootScope, $stateParams, Restangular, $dialog, $state, Upload, $translate, $uibModal) {
/**
* Configuration for file sorting.
*/
@@ -131,4 +131,30 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root
}
});
};
/**
* Rename a file.
*/
$scope.renameFile = function (file) {
$uibModal.open({
templateUrl: 'partial/docs/file.rename.html',
controller: 'FileRename',
resolve: {
file: function () {
return angular.copy(file);
}
}
}).result.then(function (fileUpdated) {
if (fileUpdated === null) {
return;
}
// Rename the file
Restangular.one('file/' + file.id).post('', {
name: fileUpdated.name
}).then(function () {
file.name = fileUpdated.name;
})
});
};
});

View File

@@ -0,0 +1,11 @@
'use strict';
/**
* File rename controller.
*/
angular.module('docs').controller('FileRename', function ($scope, file, $uibModalInstance) {
$scope.file = file;
$scope.close = function(file) {
$uibModalInstance.close(file);
}
});

View File

@@ -69,6 +69,7 @@
<script src="app/docs/controller/document/DocumentModalAddTag.js" type="text/javascript"></script>
<script src="app/docs/controller/document/FileView.js" type="text/javascript"></script>
<script src="app/docs/controller/document/FileModalView.js" type="text/javascript"></script>
<script src="app/docs/controller/document/FileRename.js" type="text/javascript"></script>
<script src="app/docs/controller/tag/Tag.js" type="text/javascript"></script>
<script src="app/docs/controller/tag/TagEdit.js" type="text/javascript"></script>
<script src="app/docs/controller/settings/Settings.js" type="text/javascript"></script>

View File

@@ -194,6 +194,10 @@
"previous": "Previous",
"next": "Next",
"not_found": "File not found"
},
"edit": {
"title": "Edit file",
"name": "Filename"
}
},
"tag": {
@@ -531,6 +535,7 @@
"export": "Export",
"edit": "Edit",
"delete": "Delete",
"rename": "Rename",
"loading": "Loading...",
"send": "Send",
"enabled": "Enabled",

View File

@@ -13,7 +13,7 @@
<img ng-src="../api/file/{{ file.id }}/data?size=thumb" uib-tooltip="{{ file.mimetype }} | {{ file.size | filesize }}" tooltip-placement="top" />
</a>
<div class="file-info">
<div class="caption caption-hover-inverse file-name" ng-click="openFile(file)" ng-if="file.name">{{ file.name }}</div>
<div class="v-align caption caption-hover-inverse file-name" ng-click="openFile(file)" ng-if="file.name">{{ file.name }}</div>
<div class="caption caption-hover">
<button class="btn btn-danger" ng-click="deleteFile($event, file)"><span class="fas fa-trash"></span></button>
</div>

View File

@@ -55,7 +55,7 @@
</a>
<div class="file-info">
<div class="caption caption-hover-inverse file-name" ng-click="openFile(file)" ng-if="file.name">{{ file.name }}</div>
<div class="v-align caption caption-hover-inverse file-name" ng-click="openFile(file)" ng-if="file.name">{{ file.name }}</div>
<div class="caption caption-hover" ng-show="document.writable">
<div class="btn btn-default handle"><span class="fas fa-arrows-alt-h"></span></div>
</div>
@@ -67,9 +67,13 @@
</button>
<ul class="dropdown-menu" uib-dropdown-menu>
<li>
<a href ng-click="renameFile(file)">
<span class="fas fa-pencil-alt"></span>
{{ 'rename' | translate }}
</a>
<a href ng-click="deleteFile(file)">
<span class="fas fa-trash"></span>
Delete
{{ 'delete' | translate }}
</a>
</li>
</ul>

View File

@@ -0,0 +1,16 @@
<div class="modal-header">
<h3>{{ 'file.edit.title' | translate }}</h3>
</div>
<form name="fileForm" novalidate>
<div class="modal-body">
<input type="text" name="name" ng-attr-placeholder="{{ 'file.edit.name' | translate }}" class="form-control"
ng-maxlength="200" required ng-model="file.name">
<span class="text-danger" ng-show="fileForm.name.$error.maxlength && fileForm.$dirty">{{ 'validation.too_long' | translate }}</span>
</div>
<div class="modal-footer">
<button ng-click="close(file)" ng-disabled="!fileForm.$valid" class="btn btn-primary">
<span class="fas fa-pencil-alt"></span> {{ 'save' | translate }}
</button>
<button ng-click="close(null)" class="btn btn-default">{{ 'cancel' | translate }}</button>
</div>
</form>

View File

@@ -207,6 +207,8 @@ ul.tag-tree {
white-space: normal;
display: block;
text-overflow: ellipsis;
margin-right: auto !important;
margin-left: auto !important;
}
.file-info {