From cfdd6dc0d9e6a31d9e75dd06b0de1d2fb1130196 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 21 Apr 2017 16:02:46 -0400 Subject: [PATCH] Clear selected subvaults when changing orgs --- src/app/vault/vaultShareController.js | 18 ++++++++++++++++-- src/app/vault/views/vaultShare.html | 3 ++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/app/vault/vaultShareController.js b/src/app/vault/vaultShareController.js index 98c5498e39..3af82bf942 100644 --- a/src/app/vault/vaultShareController.js +++ b/src/app/vault/vaultShareController.js @@ -9,6 +9,7 @@ $scope.subvaults = []; $scope.selectedSubvaults = {}; $scope.organizations = []; + var organizationSubvaultCounts = {}; $scope.loadingSubvaults = true; $scope.readOnly = false; @@ -37,6 +38,8 @@ name: profile.organizations[i].name }); + organizationSubvaultCounts[profile.organizations[i].id] = 0; + if (!setFirstOrg) { setFirstOrg = true; $scope.model.organizationId = profile.organizations[i].id; @@ -52,6 +55,7 @@ var decSubvault = cipherService.decryptSubvault(response.Data[i]); decSubvault.organizationId = response.Data[i].OrganizationId; subvaults.push(decSubvault); + organizationSubvaultCounts[decSubvault.organizationId]++; } $scope.subvaults = subvaults; @@ -64,7 +68,9 @@ var subvaults = {}; if ($event.target.checked) { for (var i = 0; i < $scope.subvaults.length; i++) { - subvaults[$scope.subvaults[i].id] = true; + if ($scope.model.organizationId && $scope.subvaults[i].organizationId === $scope.model.organizationId) { + subvaults[$scope.subvaults[i].id] = true; + } } } @@ -85,7 +91,15 @@ }; $scope.allSelected = function () { - return Object.keys($scope.selectedSubvaults).length === $scope.subvaults.length; + if (!$scope.model.organizationId) { + return false; + } + + return Object.keys($scope.selectedSubvaults).length === organizationSubvaultCounts[$scope.model.organizationId]; + }; + + $scope.orgChanged = function () { + $scope.selectedSubvaults = {}; }; $scope.submitPromise = null; diff --git a/src/app/vault/views/vaultShare.html b/src/app/vault/views/vaultShare.html index 0a480f82fe..36c48c9ddc 100644 --- a/src/app/vault/views/vaultShare.html +++ b/src/app/vault/views/vaultShare.html @@ -21,7 +21,8 @@
* -