From b1ebcb76f09f0be1cd1c0a238def31ab7cd23fa1 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 9 Jun 2017 09:46:25 -0400 Subject: [PATCH] bulk move logins --- src/app/vault/vaultController.js | 21 ++++++++++++- src/app/vault/vaultMoveLoginsController.js | 28 ++++++++++++++++++ src/app/vault/views/vaultMoveLogins.html | 34 ++++++++++++++++++++++ src/index.html | 1 + 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 src/app/vault/vaultMoveLoginsController.js create mode 100644 src/app/vault/views/vaultMoveLogins.html diff --git a/src/app/vault/vaultController.js b/src/app/vault/vaultController.js index 6e479dd93c..7d29a28d45 100644 --- a/src/app/vault/vaultController.js +++ b/src/app/vault/vaultController.js @@ -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 () { diff --git a/src/app/vault/vaultMoveLoginsController.js b/src/app/vault/vaultMoveLoginsController.js new file mode 100644 index 0000000000..b5e5c8484c --- /dev/null +++ b/src/app/vault/vaultMoveLoginsController.js @@ -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'); + }; + }); diff --git a/src/app/vault/views/vaultMoveLogins.html b/src/app/vault/views/vaultMoveLogins.html new file mode 100644 index 0000000000..c6ae5cfab1 --- /dev/null +++ b/src/app/vault/views/vaultMoveLogins.html @@ -0,0 +1,34 @@ + +
+ + +
diff --git a/src/index.html b/src/index.html index 52085a2552..29f1e2be16 100644 --- a/src/index.html +++ b/src/index.html @@ -159,6 +159,7 @@ +