1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

bulk move logins

This commit is contained in:
Kyle Spearrin 2017-06-09 09:46:25 -04:00
parent 488dbb6715
commit b1ebcb76f0
4 changed files with 83 additions and 1 deletions

View File

@ -338,7 +338,26 @@
return;
}
// TODO
var modal = $uibModal.open({
animation: true,
templateUrl: 'app/vault/views/vaultMoveLogins.html',
controller: 'vaultMoveLoginsController',
resolve: {
ids: function () { return ids; }
}
});
modal.result.then(function (folderId) {
for (var i = 0; i < ids.length; i++) {
var login = $filter('filter')($rootScope.vaultLogins, { id: ids[i] });
if (login.length) {
login[0].folderId = folderId;
}
}
clearLoginSelections();
sortScopedLoginData();
});
};
$scope.bulkDelete = function () {

View File

@ -0,0 +1,28 @@
angular
.module('bit.vault')
.controller('vaultMoveLoginsController', function ($scope, apiService, $uibModalInstance, ids, $analytics,
$rootScope) {
$analytics.eventTrack('vaultMoveLoginsController', { category: 'Modal' });
$scope.folders = $rootScope.vaultFolders;
$scope.count = ids.length;
$scope.save = function () {
$scope.savePromise = apiService.ciphers.moveMany({ ids: ids, folderId: $scope.folderId }, function () {
$analytics.eventTrack('Bulk Moved Logins');
$uibModalInstance.close($scope.folderId || null);
}).$promise;
};
$scope.folderSort = function (item) {
if (!item.id) {
return '!';
}
return item.name.toLowerCase();
};
$scope.close = function () {
$uibModalInstance.dismiss('cancel');
};
});

View File

@ -0,0 +1,34 @@
<div class="modal-header">
<button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">
<i class="fa fa-share"></i> Move Logins
</h4>
</div>
<form name="form" ng-submit="form.$valid && save()" api-form="savePromise">
<div class="modal-body">
<div class="callout callout-danger validation-errors" ng-show="form.$errors">
<h4>Errors have occurred</h4>
<ul>
<li ng-repeat="e in form.$errors">{{e}}</li>
</ul>
</div>
<p>
Select a folder that you would like to move the <b>{{count}}</b> selected
<span ng-pluralize count="count" when="{'1': 'login', 'other': 'logins'}"></span> to.
</p>
<div class="form-group" show-errors>
<label for="folder">Folder</label>
<select id="folder" name="FolderId" ng-model="folderId" class="form-control" api-field>
<option ng-repeat="folder in folders | orderBy: folderSort" value="{{folder.id}}">
{{folder.name}}
</option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="form.$loading">
<i class="fa fa-refresh fa-spin loading-icon" ng-show="form.$loading"></i>Save
</button>
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
</div>
</form>

View File

@ -159,6 +159,7 @@
<script src="app/vault/vaultShareLoginController.js"></script>
<script src="app/vault/vaultSharedController.js"></script>
<script src="app/vault/vaultLoginCollectionsController.js"></script>
<script src="app/vault/vaultMoveLoginsController.js"></script>
<script src="app/organization/organizationModule.js"></script>
<script src="app/organization/organizationDashboardController.js"></script>