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:
parent
d61b6c2faa
commit
cfdd6dc0d9
@ -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;
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user