update listing when cipher is edited

This commit is contained in:
Kyle Spearrin 2017-10-12 15:48:30 -04:00
parent 001a116c8b
commit 598c7ea068
5 changed files with 23 additions and 16 deletions

View File

@ -88,8 +88,11 @@
editModel.result.then(function (returnVal) { editModel.result.then(function (returnVal) {
if (returnVal.action === 'edit') { if (returnVal.action === 'edit') {
cipher.name = returnVal.data.name; var index = $scope.ciphers.indexOf(cipher);
cipher.subTitle = returnVal.data.login.username; if (index > -1) {
returnVal.data.collectionIds = $scope.ciphers[index].collectionIds;
$scope.ciphers[index] = returnVal.data;
}
} }
else if (returnVal.action === 'delete') { else if (returnVal.action === 'delete') {
var index = $scope.ciphers.indexOf(cipher); var index = $scope.ciphers.indexOf(cipher);

View File

@ -17,7 +17,7 @@
var cipher = cipherService.encryptCipher(model, $scope.cipher.type); var cipher = cipherService.encryptCipher(model, $scope.cipher.type);
$scope.savePromise = apiService.ciphers.putAdmin({ id: cipherId }, cipher, function (cipherResponse) { $scope.savePromise = apiService.ciphers.putAdmin({ id: cipherId }, cipher, function (cipherResponse) {
$analytics.eventTrack('Edited Organization Cipher'); $analytics.eventTrack('Edited Organization Cipher');
var decCipher = cipherService.decryptCipher(cipherResponse); var decCipher = cipherService.decryptCipherPreview(cipherResponse);
$uibModalInstance.close({ $uibModalInstance.close({
action: 'edit', action: 'edit',
data: decCipher data: decCipher

View File

@ -149,13 +149,10 @@
editModel.result.then(function (returnVal) { editModel.result.then(function (returnVal) {
if (returnVal.action === 'edit') { if (returnVal.action === 'edit') {
cipher.folderId = returnVal.data.folderId; var index = $scope.ciphers.indexOf(cipher);
cipher.name = returnVal.data.name; if (index > -1) {
cipher.favorite = returnVal.data.favorite; $rootScope.vaultCiphers[index] = returnVal.data;
}
cipher.subTitle = returnVal.data.login.username;
cipher.meta.password = returnVal.data.login.password;
sortScopedCipherData(); sortScopedCipherData();
} }
else if (returnVal.action === 'partialEdit') { else if (returnVal.action === 'partialEdit') {

View File

@ -39,7 +39,7 @@
var cipher = cipherService.encryptCipher(model, $scope.cipher.type); var cipher = cipherService.encryptCipher(model, $scope.cipher.type);
$scope.savePromise = apiService.ciphers.put({ id: cipherId }, cipher, function (cipherResponse) { $scope.savePromise = apiService.ciphers.put({ id: cipherId }, cipher, function (cipherResponse) {
$analytics.eventTrack('Edited Cipher'); $analytics.eventTrack('Edited Cipher');
var decCipher = cipherService.decryptCipher(cipherResponse); var decCipher = cipherService.decryptCipherPreview(cipherResponse);
$uibModalInstance.close({ $uibModalInstance.close({
action: 'edit', action: 'edit',
data: decCipher data: decCipher

View File

@ -145,11 +145,18 @@
var rootCipher = findRootCipher(cipher) || { meta: {} }; var rootCipher = findRootCipher(cipher) || { meta: {} };
if (returnVal.action === 'edit') { if (returnVal.action === 'edit') {
cipher.folderId = rootCipher.folderId = returnVal.data.folderId; var index = $scope.ciphers.indexOf(cipher);
cipher.name = rootCipher.name = returnVal.data.name; if (index > -1) {
cipher.subTitle = rootCipher.subTitle = returnVal.data.login.username; returnVal.data.collectionIds = $scope.ciphers[index].collectionIds;
cipher.meta.password = rootCipher.meta.password = returnVal.data.login.password; $scope.ciphers[index] = returnVal.data;
cipher.favorite = rootCipher.favorite = returnVal.data.favorite;
if ($rootScope.vaultCiphers) {
index = $rootScope.vaultCiphers.indexOf(rootCipher);
if (index > -1) {
$rootScope.vaultCiphers[index] = returnVal.data;
}
}
}
} }
else if (returnVal.action === 'partialEdit') { else if (returnVal.action === 'partialEdit') {
cipher.folderId = rootCipher.folderId = returnVal.data.folderId; cipher.folderId = rootCipher.folderId = returnVal.data.folderId;