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++) {
groupsArr.push({
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) {
return group.id in $scope.selectedGroups;
return group.id in $scope.selectedGroups || group.accessAll;
};
$scope.allSelected = function () {

View File

@ -45,7 +45,8 @@
for (var i = 0; i < groups.Data.length; i++) {
groupsArr.push({
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) {
return group.id in $scope.selectedGroups;
return group.id in $scope.selectedGroups || group.accessAll;
};
$scope.allSelected = function () {

View File

@ -46,12 +46,15 @@
$scope.submit = function (model) {
var group = {
name: model.name,
collectionIds: []
accessAll: !!model.accessAll
};
for (var id in $scope.selectedCollections) {
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

@ -13,7 +13,8 @@
}).then(function (group) {
$scope.group = {
id: id,
name: group.Name
name: group.Name,
accessAll: group.AccessAll
};
var collections = {};
@ -59,11 +60,17 @@
};
$scope.submit = function () {
var group = $scope.group;
group.collectionIds = [];
for (var id in $scope.selectedCollections) {
if ($scope.selectedCollections.hasOwnProperty(id)) {
group.collectionIds.push(id);
var group = {
name: $scope.group.name,
accessAll: !!$scope.group.accessAll
};
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[]"
value="{{group.id}}"
ng-checked="groupSelected(group)"
ng-click="toggleGroupSelection(group.id)">
ng-click="toggleGroupSelection(group.id)"
ng-disabled="group.accessAll">
</td>
<td valign="middle">
{{group.name}}
<i class="fa fa-unlock text-muted" ng-show="group.accessAll"
title="This group can access all items"></i>
</td>
</tr>
</tbody>

View File

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

View File

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

View File

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