From 598c7ea06825fe16eeb53639bfd1f0012ec7e110 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 12 Oct 2017 15:48:30 -0400 Subject: [PATCH] update listing when cipher is edited --- .../organization/organizationVaultController.js | 7 +++++-- .../organizationVaultEditCipherController.js | 2 +- src/app/vault/vaultController.js | 11 ++++------- src/app/vault/vaultEditCipherController.js | 2 +- src/app/vault/vaultSharedController.js | 17 ++++++++++++----- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/app/organization/organizationVaultController.js b/src/app/organization/organizationVaultController.js index 8ec87af97a..d518c7c82c 100644 --- a/src/app/organization/organizationVaultController.js +++ b/src/app/organization/organizationVaultController.js @@ -88,8 +88,11 @@ editModel.result.then(function (returnVal) { if (returnVal.action === 'edit') { - cipher.name = returnVal.data.name; - cipher.subTitle = returnVal.data.login.username; + var index = $scope.ciphers.indexOf(cipher); + if (index > -1) { + returnVal.data.collectionIds = $scope.ciphers[index].collectionIds; + $scope.ciphers[index] = returnVal.data; + } } else if (returnVal.action === 'delete') { var index = $scope.ciphers.indexOf(cipher); diff --git a/src/app/organization/organizationVaultEditCipherController.js b/src/app/organization/organizationVaultEditCipherController.js index da6c694c19..3a1e1c9c2d 100644 --- a/src/app/organization/organizationVaultEditCipherController.js +++ b/src/app/organization/organizationVaultEditCipherController.js @@ -17,7 +17,7 @@ var cipher = cipherService.encryptCipher(model, $scope.cipher.type); $scope.savePromise = apiService.ciphers.putAdmin({ id: cipherId }, cipher, function (cipherResponse) { $analytics.eventTrack('Edited Organization Cipher'); - var decCipher = cipherService.decryptCipher(cipherResponse); + var decCipher = cipherService.decryptCipherPreview(cipherResponse); $uibModalInstance.close({ action: 'edit', data: decCipher diff --git a/src/app/vault/vaultController.js b/src/app/vault/vaultController.js index 33ce7b8457..4646680709 100644 --- a/src/app/vault/vaultController.js +++ b/src/app/vault/vaultController.js @@ -149,13 +149,10 @@ editModel.result.then(function (returnVal) { if (returnVal.action === 'edit') { - cipher.folderId = returnVal.data.folderId; - cipher.name = returnVal.data.name; - cipher.favorite = returnVal.data.favorite; - - cipher.subTitle = returnVal.data.login.username; - cipher.meta.password = returnVal.data.login.password; - + var index = $scope.ciphers.indexOf(cipher); + if (index > -1) { + $rootScope.vaultCiphers[index] = returnVal.data; + } sortScopedCipherData(); } else if (returnVal.action === 'partialEdit') { diff --git a/src/app/vault/vaultEditCipherController.js b/src/app/vault/vaultEditCipherController.js index 0814603913..09430b052d 100644 --- a/src/app/vault/vaultEditCipherController.js +++ b/src/app/vault/vaultEditCipherController.js @@ -39,7 +39,7 @@ var cipher = cipherService.encryptCipher(model, $scope.cipher.type); $scope.savePromise = apiService.ciphers.put({ id: cipherId }, cipher, function (cipherResponse) { $analytics.eventTrack('Edited Cipher'); - var decCipher = cipherService.decryptCipher(cipherResponse); + var decCipher = cipherService.decryptCipherPreview(cipherResponse); $uibModalInstance.close({ action: 'edit', data: decCipher diff --git a/src/app/vault/vaultSharedController.js b/src/app/vault/vaultSharedController.js index b6257c711c..a61da83db6 100644 --- a/src/app/vault/vaultSharedController.js +++ b/src/app/vault/vaultSharedController.js @@ -145,11 +145,18 @@ var rootCipher = findRootCipher(cipher) || { meta: {} }; if (returnVal.action === 'edit') { - cipher.folderId = rootCipher.folderId = returnVal.data.folderId; - cipher.name = rootCipher.name = returnVal.data.name; - cipher.subTitle = rootCipher.subTitle = returnVal.data.login.username; - cipher.meta.password = rootCipher.meta.password = returnVal.data.login.password; - cipher.favorite = rootCipher.favorite = returnVal.data.favorite; + var index = $scope.ciphers.indexOf(cipher); + if (index > -1) { + returnVal.data.collectionIds = $scope.ciphers[index].collectionIds; + $scope.ciphers[index] = returnVal.data; + + if ($rootScope.vaultCiphers) { + index = $rootScope.vaultCiphers.indexOf(rootCipher); + if (index > -1) { + $rootScope.vaultCiphers[index] = returnVal.data; + } + } + } } else if (returnVal.action === 'partialEdit') { cipher.folderId = rootCipher.folderId = returnVal.data.folderId;