1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

access all subvaults option for org users

This commit is contained in:
Kyle Spearrin 2017-04-20 22:19:18 -04:00
parent f92c5a214f
commit 4ba21638b1
4 changed files with 128 additions and 88 deletions

View File

@ -24,6 +24,7 @@
} }
$scope.email = user.Email; $scope.email = user.Email;
$scope.type = user.Type; $scope.type = user.Type;
$scope.accessAllSubvaults = user.AccessAllSubvaults;
$scope.selectedSubvaults = subvaults; $scope.selectedSubvaults = subvaults;
}); });
}); });
@ -72,15 +73,18 @@
$scope.submitPromise = null; $scope.submitPromise = null;
$scope.submit = function (model) { $scope.submit = function (model) {
var subvaults = []; var subvaults = [];
for (var subvaultId in $scope.selectedSubvaults) { if (!$scope.accessAllSubvaults) {
if ($scope.selectedSubvaults.hasOwnProperty(subvaultId)) { for (var subvaultId in $scope.selectedSubvaults) {
subvaults.push($scope.selectedSubvaults[subvaultId]); if ($scope.selectedSubvaults.hasOwnProperty(subvaultId)) {
subvaults.push($scope.selectedSubvaults[subvaultId]);
}
} }
} }
$scope.submitPromise = apiService.organizationUsers.put({ orgId: $state.params.orgId, id: id }, { $scope.submitPromise = apiService.organizationUsers.put({ orgId: $state.params.orgId, id: id }, {
type: $scope.type, type: $scope.type,
subvaults: subvaults subvaults: subvaults,
accessAllSubvaults: $scope.accessAllSubvaults
}, function () { }, function () {
$uibModalInstance.close(); $uibModalInstance.close();
}).$promise; }).$promise;

View File

@ -60,16 +60,20 @@
$scope.submitPromise = null; $scope.submitPromise = null;
$scope.submit = function (model) { $scope.submit = function (model) {
var subvaults = []; var subvaults = [];
for (var subvaultId in $scope.selectedSubvaults) {
if ($scope.selectedSubvaults.hasOwnProperty(subvaultId)) { if (!model.accessAllSubvaults) {
subvaults.push($scope.selectedSubvaults[subvaultId]); for (var subvaultId in $scope.selectedSubvaults) {
if ($scope.selectedSubvaults.hasOwnProperty(subvaultId)) {
subvaults.push($scope.selectedSubvaults[subvaultId]);
}
} }
} }
$scope.submitPromise = apiService.organizationUsers.invite({ orgId: $state.params.orgId }, { $scope.submitPromise = apiService.organizationUsers.invite({ orgId: $state.params.orgId }, {
email: model.email, email: model.email,
type: model.type, type: model.type,
subvaults: subvaults subvaults: subvaults,
accessAllSubvaults: model.accessAllSubvaults
}, function () { }, function () {
$uibModalInstance.close(); $uibModalInstance.close();
}).$promise; }).$promise;

View File

@ -32,48 +32,64 @@
</div> </div>
</div> </div>
<h4>Subvault Access</h4> <h4>Subvault Access</h4>
<div ng-show="loading && !subvaults.length"> <div class="radio">
Loading... <label>
<input type="radio" ng-model="accessAllSubvaults" name="AccessAllSubvaults"
ng-value="true" ng-checked="accessAllSubvaults">
This user can access and modify items in <u>all</u> current and future subvaults.
</label>
</div> </div>
<div ng-show="!loading && !subvaults.length"> <div class="radio">
<p>No subvaults for your organization.</p> <label>
<input type="radio" ng-model="accessAllSubvaults" name="AccessAllSubvaults"
ng-value="false" ng-checked="!accessAllSubvaults">
This user can access only the selected subvaults.
</label>
</div> </div>
<div class="table-responsive" ng-show="subvaults.length" style="margin: 0;"> <div ng-show="!accessAllSubvaults">
<table class="table table-striped table-hover" style="margin: 0;"> <div ng-show="loading && !subvaults.length">
<thead> Loading subvaults...
<tr> </div>
<th style="width: 40px;"> <div ng-show="!loading && !subvaults.length">
<input type="checkbox" <p>No subvaults for your organization.</p>
ng-checked="allSelected()" </div>
ng-click="toggleSubvaultSelectionAll($event)"> <div class="table-responsive" ng-show="subvaults.length" style="margin: 0;">
</th> <table class="table table-striped table-hover" style="margin: 0;">
<th>Name</th> <thead>
<th style="width: 100px; text-align: center;">Read Only</th> <tr>
</tr> <th style="width: 40px;">
</thead> <input type="checkbox"
<tbody> ng-checked="allSelected()"
<tr ng-repeat="subvault in subvaults | orderBy: ['name']"> ng-click="toggleSubvaultSelectionAll($event)">
<td valign="middle"> </th>
<input type="checkbox" <th>Name</th>
name="selectedSubvaults[]" <th style="width: 100px; text-align: center;">Read Only</th>
value="{{subvault.id}}" </tr>
ng-checked="subvaultSelected(subvault)" </thead>
ng-click="toggleSubvaultSelection(subvault.id)"> <tbody>
</td> <tr ng-repeat="subvault in subvaults | orderBy: ['name']">
<td valign="middle"> <td valign="middle">
{{subvault.name}} <input type="checkbox"
</td> name="selectedSubvaults[]"
<td style="text-align: center;" valign="middle"> value="{{subvault.id}}"
<input type="checkbox" ng-checked="subvaultSelected(subvault)"
name="selectedSubvaultsReadonly[]" ng-click="toggleSubvaultSelection(subvault.id)">
value="{{subvault.id}}" </td>
ng-disabled="!subvaultSelected(subvault)" <td valign="middle">
ng-checked="subvaultSelected(subvault) && selectedSubvaults[subvault.id].readOnly" {{subvault.name}}
ng-click="toggleSubvaultReadOnlySelection(subvault.id)"> </td>
</td> <td style="text-align: center;" valign="middle">
</tr> <input type="checkbox"
</tbody> name="selectedSubvaultsReadonly[]"
</table> value="{{subvault.id}}"
ng-disabled="!subvaultSelected(subvault)"
ng-checked="subvaultSelected(subvault) && selectedSubvaults[subvault.id].readOnly"
ng-click="toggleSubvaultReadOnlySelection(subvault.id)">
</td>
</tr>
</tbody>
</table>
</div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -40,48 +40,64 @@
</div> </div>
</div> </div>
<h4>Subvault Access</h4> <h4>Subvault Access</h4>
<div ng-show="loading && !subvaults.length"> <div class="radio">
Loading... <label>
<input type="radio" ng-model="model.accessAllSubvaults" name="AccessAllSubvaults"
ng-value="true" ng-checked="model.accessAllSubvaults">
This user can access and modify items in <u>all</u> current and future subvaults.
</label>
</div> </div>
<div ng-show="!loading && !subvaults.length"> <div class="radio">
<p>No subvaults for your organization.</p> <label>
<input type="radio" ng-model="model.accessAllSubvaults" name="AccessAllSubvaults"
ng-value="false" ng-checked="!model.accessAllSubvaults">
This user can access only the selected subvaults.
</label>
</div> </div>
<div class="table-responsive" ng-show="subvaults.length" style="margin: 0;"> <div ng-show="!model.accessAllSubvaults">
<table class="table table-striped table-hover" style="margin: 0;"> <div ng-show="loading && !subvaults.length">
<thead> Loading subvaults...
<tr> </div>
<th style="width: 40px;"> <div ng-show="!loading && !subvaults.length">
<input type="checkbox" <p>No subvaults for your organization.</p>
ng-checked="allSelected()" </div>
ng-click="toggleSubvaultSelectionAll($event)"> <div class="table-responsive" ng-show="subvaults.length" style="margin: 0;">
</th> <table class="table table-striped table-hover" style="margin: 0;">
<th>Name</th> <thead>
<th style="width: 100px; text-align: center;">Read Only</th> <tr>
</tr> <th style="width: 40px;">
</thead> <input type="checkbox"
<tbody> ng-checked="allSelected()"
<tr ng-repeat="subvault in subvaults | orderBy: ['name'] track by subvault.id"> ng-click="toggleSubvaultSelectionAll($event)">
<td style="width: 40px;" valign="middle"> </th>
<input type="checkbox" <th>Name</th>
name="selectedSubvaults[]" <th style="width: 100px; text-align: center;">Read Only</th>
value="{{subvault.id}}" </tr>
ng-checked="subvaultSelected(subvault)" </thead>
ng-click="toggleSubvaultSelection(subvault.id)"> <tbody>
</td> <tr ng-repeat="subvault in subvaults | orderBy: ['name'] track by subvault.id">
<td valign="middle"> <td style="width: 40px;" valign="middle">
{{subvault.name}} <input type="checkbox"
</td> name="selectedSubvaults[]"
<td style="width: 100px; text-align: center;" valign="middle"> value="{{subvault.id}}"
<input type="checkbox" ng-checked="subvaultSelected(subvault)"
name="selectedSubvaultsReadonly[]" ng-click="toggleSubvaultSelection(subvault.id)">
value="{{subvault.id}}" </td>
ng-disabled="!subvaultSelected(subvault)" <td valign="middle">
ng-checked="subvaultSelected(subvault) && selectedSubvaults[subvault.id].readOnly" {{subvault.name}}
ng-click="toggleSubvaultReadOnlySelection(subvault.id)"> </td>
</td> <td style="width: 100px; text-align: center;" valign="middle">
</tr> <input type="checkbox"
</tbody> name="selectedSubvaultsReadonly[]"
</table> value="{{subvault.id}}"
ng-disabled="!subvaultSelected(subvault)"
ng-checked="subvaultSelected(subvault) && selectedSubvaults[subvault.id].readOnly"
ng-click="toggleSubvaultReadOnlySelection(subvault.id)">
</td>
</tr>
</tbody>
</table>
</div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">