diff --git a/src/app/services/apiService.js b/src/app/services/apiService.js index 979bfe425a..77a27649b0 100644 --- a/src/app/services/apiService.js +++ b/src/app/services/apiService.js @@ -29,7 +29,8 @@ 'import': { url: _apiUri + '/ciphers/import', method: 'POST', params: {} }, favorite: { url: _apiUri + '/ciphers/:id/favorite', method: 'POST', params: { id: '@id' } }, putPartial: { url: _apiUri + '/ciphers/:id/partial', method: 'POST', params: { id: '@id' } }, - move: { url: _apiUri + '/ciphers/:id/move', method: 'POST', params: { id: '@id' } }, + putShare: { url: _apiUri + '/ciphers/:id/share', method: 'POST', params: { id: '@id' } }, + putSubvaults: { url: _apiUri + '/ciphers/:id/subvaults', method: 'POST', params: { id: '@id' } }, del: { url: _apiUri + '/ciphers/:id/delete', method: 'POST', params: { id: '@id' } } }); diff --git a/src/app/vault/vaultLoginSubvaultsController.js b/src/app/vault/vaultLoginSubvaultsController.js index bc5fca7c3e..e9ba59b3f8 100644 --- a/src/app/vault/vaultLoginSubvaultsController.js +++ b/src/app/vault/vaultLoginSubvaultsController.js @@ -84,17 +84,25 @@ return Object.keys($scope.selectedSubvaults).length === $scope.subvaults.length; }; - $scope.submit = function (model) { + $scope.submit = function () { var request = { - subvaultIds: model.subvaultIds + subvaultIds: [] }; - $scope.submitPromise = apiService.ciphers.putSubvaults({ id: loginId }, request, function (response) { - $analytics.eventTrack('Edited Login Subvaults'); - $uibModalInstance.close({ - action: 'subvaultsEdit' + for (var id in $scope.selectedSubvaults) { + if ($scope.selectedSubvaults.hasOwnProperty(id)) { + request.subvaultIds.push(id); + } + } + + $scope.submitPromise = apiService.ciphers.putSubvaults({ id: loginId }, request) + .$promise.then(function (response) { + $analytics.eventTrack('Edited Login Subvaults'); + $uibModalInstance.close({ + action: 'subvaultsEdit', + subvaultIds: request.subvaultIds + }); }); - }).$promise; }; $scope.close = function () { diff --git a/src/app/vault/vaultShareController.js b/src/app/vault/vaultShareController.js index 48f0d1c990..fd4d4540cd 100644 --- a/src/app/vault/vaultShareController.js +++ b/src/app/vault/vaultShareController.js @@ -103,7 +103,7 @@ } } - $scope.submitPromise = apiService.ciphers.move({ id: loginId }, request, function (response) { + $scope.submitPromise = apiService.ciphers.putShare({ id: loginId }, request, function (response) { $analytics.eventTrack('Shared Login'); $uibModalInstance.close(); }).$promise; diff --git a/src/app/vault/vaultSubvaultsController.js b/src/app/vault/vaultSubvaultsController.js index 12c7cec32c..5c653c78b3 100644 --- a/src/app/vault/vaultSubvaultsController.js +++ b/src/app/vault/vaultSubvaultsController.js @@ -100,6 +100,23 @@ }); }; + $scope.editSubvaults = function (login) { + var modal = $uibModal.open({ + animation: true, + templateUrl: 'app/vault/views/vaultLoginSubvaults.html', + controller: 'vaultLoginSubvaultsController', + resolve: { + loginId: function () { return login.id; } + } + }); + + modal.result.then(function (response) { + if (response.subvaultIds) { + login.subvaultIds = response.subvaultIds; + } + }); + }; + function getFoldersPromise() { var deferred = $q.defer(); diff --git a/src/app/vault/views/vaultLoginSubvaults.html b/src/app/vault/views/vaultLoginSubvaults.html index 6d8d1ac2fe..e216240863 100644 --- a/src/app/vault/views/vaultLoginSubvaults.html +++ b/src/app/vault/views/vaultLoginSubvaults.html @@ -2,7 +2,7 @@