1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-06 09:20:43 +01:00

Clear selected subvaults when changing orgs

This commit is contained in:
Kyle Spearrin 2017-04-21 16:02:46 -04:00
parent d61b6c2faa
commit cfdd6dc0d9
2 changed files with 18 additions and 3 deletions

View File

@ -9,6 +9,7 @@
$scope.subvaults = []; $scope.subvaults = [];
$scope.selectedSubvaults = {}; $scope.selectedSubvaults = {};
$scope.organizations = []; $scope.organizations = [];
var organizationSubvaultCounts = {};
$scope.loadingSubvaults = true; $scope.loadingSubvaults = true;
$scope.readOnly = false; $scope.readOnly = false;
@ -37,6 +38,8 @@
name: profile.organizations[i].name name: profile.organizations[i].name
}); });
organizationSubvaultCounts[profile.organizations[i].id] = 0;
if (!setFirstOrg) { if (!setFirstOrg) {
setFirstOrg = true; setFirstOrg = true;
$scope.model.organizationId = profile.organizations[i].id; $scope.model.organizationId = profile.organizations[i].id;
@ -52,6 +55,7 @@
var decSubvault = cipherService.decryptSubvault(response.Data[i]); var decSubvault = cipherService.decryptSubvault(response.Data[i]);
decSubvault.organizationId = response.Data[i].OrganizationId; decSubvault.organizationId = response.Data[i].OrganizationId;
subvaults.push(decSubvault); subvaults.push(decSubvault);
organizationSubvaultCounts[decSubvault.organizationId]++;
} }
$scope.subvaults = subvaults; $scope.subvaults = subvaults;
@ -64,7 +68,9 @@
var subvaults = {}; var subvaults = {};
if ($event.target.checked) { if ($event.target.checked) {
for (var i = 0; i < $scope.subvaults.length; i++) { 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 () { $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; $scope.submitPromise = null;

View File

@ -21,7 +21,8 @@
<div ng-show="organizations.length"> <div ng-show="organizations.length">
<div class="form-group"> <div class="form-group">
<label for="organization">Organization</label> <span>*</span> <label for="organization">Organization</label> <span>*</span>
<select id="organization" name="Organization" ng-model="model.organizationId" class="form-control"> <select id="organization" name="Organization" ng-model="model.organizationId" class="form-control"
ng-change="orgChanged()">
<option ng-repeat="org in organizations | orderBy: ['name']" value="{{org.id}}">{{org.name}}</option> <option ng-repeat="org in organizations | orderBy: ['name']" value="{{org.id}}">{{org.name}}</option>
</select> </select>
</div> </div>