Add new file creation action and collapse new and upload actions
This commit is contained in:
@@ -437,6 +437,40 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
}
|
||||
};
|
||||
|
||||
$scope.newFile = {
|
||||
busy: false,
|
||||
error: null,
|
||||
name: '',
|
||||
|
||||
show: function () {
|
||||
$scope.newFile.error = null;
|
||||
$scope.newFile.name = '';
|
||||
$scope.newFile.busy = false;
|
||||
|
||||
$scope.newFileForm.$setUntouched();
|
||||
$scope.newFileForm.$setPristine();
|
||||
|
||||
$('#newFileModal').modal('show');
|
||||
},
|
||||
|
||||
submit: function () {
|
||||
$scope.newFile.busy = true;
|
||||
$scope.newFile.error = null;
|
||||
|
||||
var filePath = sanitize($scope.cwd + '/' + $scope.newFile.name);
|
||||
|
||||
Client.filesUpload($scope.appId, filePath, new File([], $scope.newFile.name), function () {}, function (error) {
|
||||
$scope.newFile.busy = false;
|
||||
if (error && error.statusCode === 409) return $scope.newFile.error = 'Already exists';
|
||||
if (error) return Client.error(error);
|
||||
|
||||
$scope.refresh();
|
||||
|
||||
$('#newFileModal').modal('hide');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.renameEntry = {
|
||||
busy: false,
|
||||
error: null,
|
||||
@@ -681,7 +715,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
});
|
||||
|
||||
// setup all the dialog focus handling
|
||||
['newDirectoryModal', 'renameEntryModal'].forEach(function (id) {
|
||||
['newFileModal', 'newDirectoryModal', 'renameEntryModal'].forEach(function (id) {
|
||||
$('#' + id).on('shown.bs.modal', function () {
|
||||
$(this).find('[autofocus]:first').focus();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user