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.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,9 +68,11 @@
var subvaults = {};
if ($event.target.checked) {
for (var i = 0; i < $scope.subvaults.length; i++) {
if ($scope.model.organizationId && $scope.subvaults[i].organizationId === $scope.model.organizationId) {
subvaults[$scope.subvaults[i].id] = true;
}
}
}
$scope.selectedSubvaults = subvaults;
};
@ -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;

View File

@ -21,7 +21,8 @@
<div ng-show="organizations.length">
<div class="form-group">
<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>
</select>
</div>