group accessall and readonly

This commit is contained in:
Kyle Spearrin 2017-05-10 12:17:26 -04:00
parent a4473ad739
commit ea24d72f01
8 changed files with 130 additions and 80 deletions

View File

@ -32,7 +32,8 @@
for (var i = 0; i < groups.Data.length; i++) { for (var i = 0; i < groups.Data.length; i++) {
groupsArr.push({ groupsArr.push({
id: groups.Data[i].Id, id: groups.Data[i].Id,
name: groups.Data[i].Name name: groups.Data[i].Name,
accessAll: groups.Data[i].AccessAll
}); });
} }
@ -61,7 +62,7 @@
}; };
$scope.groupSelected = function (group) { $scope.groupSelected = function (group) {
return group.id in $scope.selectedGroups; return group.id in $scope.selectedGroups || group.accessAll;
}; };
$scope.allSelected = function () { $scope.allSelected = function () {

View File

@ -45,7 +45,8 @@
for (var i = 0; i < groups.Data.length; i++) { for (var i = 0; i < groups.Data.length; i++) {
groupsArr.push({ groupsArr.push({
id: groups.Data[i].Id, id: groups.Data[i].Id,
name: groups.Data[i].Name name: groups.Data[i].Name,
accessAll: groups.Data[i].AccessAll
}); });
} }
@ -74,7 +75,7 @@
}; };
$scope.groupSelected = function (group) { $scope.groupSelected = function (group) {
return group.id in $scope.selectedGroups; return group.id in $scope.selectedGroups || group.accessAll;
}; };
$scope.allSelected = function () { $scope.allSelected = function () {

View File

@ -46,12 +46,15 @@
$scope.submit = function (model) { $scope.submit = function (model) {
var group = { var group = {
name: model.name, name: model.name,
collectionIds: [] accessAll: !!model.accessAll
}; };
for (var id in $scope.selectedCollections) { if (!group.accessAll) {
if ($scope.selectedCollections.hasOwnProperty(id)) { group.collectionIds = [];
group.collectionIds.push(id); for (var id in $scope.selectedCollections) {
if ($scope.selectedCollections.hasOwnProperty(id)) {
group.collectionIds.push(id);
}
} }
} }

View File

@ -13,7 +13,8 @@
}).then(function (group) { }).then(function (group) {
$scope.group = { $scope.group = {
id: id, id: id,
name: group.Name name: group.Name,
accessAll: group.AccessAll
}; };
var collections = {}; var collections = {};
@ -59,11 +60,17 @@
}; };
$scope.submit = function () { $scope.submit = function () {
var group = $scope.group; var group = {
group.collectionIds = []; name: $scope.group.name,
for (var id in $scope.selectedCollections) { accessAll: !!$scope.group.accessAll
if ($scope.selectedCollections.hasOwnProperty(id)) { };
group.collectionIds.push(id);
if (!group.accessAll) {
group.collectionIds = [];
for (var id in $scope.selectedCollections) {
if ($scope.selectedCollections.hasOwnProperty(id)) {
group.collectionIds.push(id);
}
} }
} }

View File

@ -51,10 +51,13 @@
name="selectedGroups[]" name="selectedGroups[]"
value="{{group.id}}" value="{{group.id}}"
ng-checked="groupSelected(group)" ng-checked="groupSelected(group)"
ng-click="toggleGroupSelection(group.id)"> ng-click="toggleGroupSelection(group.id)"
ng-disabled="group.accessAll">
</td> </td>
<td valign="middle"> <td valign="middle">
{{group.name}} {{group.name}}
<i class="fa fa-unlock text-muted" ng-show="group.accessAll"
title="This group can access all items"></i>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@ -52,10 +52,13 @@
name="selectedGroups[]" name="selectedGroups[]"
value="{{group.id}}" value="{{group.id}}"
ng-checked="groupSelected(group)" ng-checked="groupSelected(group)"
ng-click="toggleGroupSelection(group.id)"> ng-click="toggleGroupSelection(group.id)"
ng-disabled="group.accessAll">
</td> </td>
<td valign="middle"> <td valign="middle">
{{group.name}} {{group.name}}
<i class="fa fa-unlock text-muted" ng-show="group.accessAll"
title="This group can access all items"></i>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@ -21,40 +21,56 @@
<label for="email">Name</label> <label for="email">Name</label>
<input type="text" id="name" name="Name" ng-model="model.name" class="form-control" required api-field /> <input type="text" id="name" name="Name" ng-model="model.name" class="form-control" required api-field />
</div> </div>
<h4>Collections</h4> <h4>Access</h4>
<div ng-show="loading && !collections.length"> <div class="radio">
Loading collections... <label>
<input type="radio" ng-model="model.accessAll" name="AccessAll"
ng-value="true" ng-checked="model.accessAll">
This group can access and modify <u>all items</u>.
</label>
</div> </div>
<div ng-show="!loading && !collections.length"> <div class="radio">
<p>No collections for your organization.</p> <label>
<input type="radio" ng-model="model.accessAll" name="AccessAll"
ng-value="false" ng-checked="!model.accessAll">
This group can access only the selected collections.
</label>
</div> </div>
<div class="table-responsive" ng-show="collections.length" style="margin: 0;"> <div ng-show="!model.accessAll">
<table class="table table-striped table-hover" style="margin: 0;"> <div ng-show="loading && !collections.length">
<thead> Loading collections...
<tr> </div>
<th style="width: 40px;"> <div ng-show="!loading && !collections.length">
<input type="checkbox" <p>No collections for your organization.</p>
ng-checked="allSelected()" </div>
ng-click="toggleCollectionSelectionAll($event)"> <div class="table-responsive" ng-show="collections.length" style="margin: 0;">
</th> <table class="table table-striped table-hover" style="margin: 0;">
<th>Name</th> <thead>
</tr> <tr>
</thead> <th style="width: 40px;">
<tbody> <input type="checkbox"
<tr ng-repeat="collection in collections | orderBy: ['name']"> ng-checked="allSelected()"
<td valign="middle"> ng-click="toggleCollectionSelectionAll($event)">
<input type="checkbox" </th>
name="selectedCollections[]" <th>Name</th>
value="{{collection.id}}" </tr>
ng-checked="collectionSelected(collection)" </thead>
ng-click="toggleCollectionSelection(collection.id)"> <tbody>
</td> <tr ng-repeat="collection in collections | orderBy: ['name']">
<td valign="middle"> <td valign="middle">
{{collection.name}} <input type="checkbox"
</td> name="selectedCollections[]"
</tr> value="{{collection.id}}"
</tbody> ng-checked="collectionSelected(collection)"
</table> ng-click="toggleCollectionSelection(collection.id)">
</td>
<td valign="middle">
{{collection.name}}
</td>
</tr>
</tbody>
</table>
</div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -21,40 +21,56 @@
<label for="email">Name</label> <label for="email">Name</label>
<input type="text" id="name" name="Name" ng-model="group.name" class="form-control" required api-field /> <input type="text" id="name" name="Name" ng-model="group.name" class="form-control" required api-field />
</div> </div>
<h4>Collections</h4> <h4>Access</h4>
<div ng-show="loading && !collections.length"> <div class="radio">
Loading collections... <label>
<input type="radio" ng-model="group.accessAll" name="AccessAll"
ng-value="true" ng-checked="group.accessAll">
This group can access and modify <u>all items</u>.
</label>
</div> </div>
<div ng-show="!loading && !collections.length"> <div class="radio">
<p>No collections for your organization.</p> <label>
<input type="radio" ng-model="group.accessAll" name="AccessAll"
ng-value="false" ng-checked="!group.accessAll">
This group can access only the selected collections.
</label>
</div> </div>
<div class="table-responsive" ng-show="collections.length" style="margin: 0;"> <div ng-show="!group.accessAll">
<table class="table table-striped table-hover" style="margin: 0;"> <div ng-show="loading && !collections.length">
<thead> Loading collections...
<tr> </div>
<th style="width: 40px;"> <div ng-show="!loading && !collections.length">
<input type="checkbox" <p>No collections for your organization.</p>
ng-checked="allSelected()" </div>
ng-click="toggleCollectionSelectionAll($event)"> <div class="table-responsive" ng-show="collections.length" style="margin: 0;">
</th> <table class="table table-striped table-hover" style="margin: 0;">
<th>Name</th> <thead>
</tr> <tr>
</thead> <th style="width: 40px;">
<tbody> <input type="checkbox"
<tr ng-repeat="collection in collections | orderBy: ['name']"> ng-checked="allSelected()"
<td valign="middle"> ng-click="toggleCollectionSelectionAll($event)">
<input type="checkbox" </th>
name="selectedCollections[]" <th>Name</th>
value="{{collection.id}}" </tr>
ng-checked="collectionSelected(collection)" </thead>
ng-click="toggleCollectionSelection(collection.id)"> <tbody>
</td> <tr ng-repeat="collection in collections | orderBy: ['name']">
<td valign="middle"> <td valign="middle">
{{collection.name}} <input type="checkbox"
</td> name="selectedCollections[]"
</tr> value="{{collection.id}}"
</tbody> ng-checked="collectionSelected(collection)"
</table> ng-click="toggleCollectionSelection(collection.id)">
</td>
<td valign="middle">
{{collection.name}}
</td>
</tr>
</tbody>
</table>
</div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">