collection add/edit groups
This commit is contained in:
parent
96a91b97e9
commit
bfae8e7def
|
@ -4,6 +4,7 @@
|
||||||
.controller('organizationCollectionsAddController', function ($scope, $state, $uibModalInstance, apiService, cipherService,
|
.controller('organizationCollectionsAddController', function ($scope, $state, $uibModalInstance, apiService, cipherService,
|
||||||
$analytics, authService) {
|
$analytics, authService) {
|
||||||
$analytics.eventTrack('organizationCollectionsAddController', { category: 'Modal' });
|
$analytics.eventTrack('organizationCollectionsAddController', { category: 'Modal' });
|
||||||
|
var groupsLength = 0;
|
||||||
$scope.groups = [];
|
$scope.groups = [];
|
||||||
$scope.selectedGroups = {};
|
$scope.selectedGroups = {};
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
|
@ -35,6 +36,10 @@
|
||||||
name: groups.Data[i].Name,
|
name: groups.Data[i].Name,
|
||||||
accessAll: groups.Data[i].AccessAll
|
accessAll: groups.Data[i].AccessAll
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!groups.Data[i].AccessAll) {
|
||||||
|
groupsLength++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.groups = groupsArr;
|
$scope.groups = groupsArr;
|
||||||
|
@ -45,7 +50,11 @@
|
||||||
var groups = {};
|
var groups = {};
|
||||||
if ($event.target.checked) {
|
if ($event.target.checked) {
|
||||||
for (var i = 0; i < $scope.groups.length; i++) {
|
for (var i = 0; i < $scope.groups.length; i++) {
|
||||||
groups[$scope.groups[i].id] = true;
|
groups[$scope.groups[i].id] = {
|
||||||
|
id: $scope.groups[i].id,
|
||||||
|
readOnly: ($scope.groups[i].id in $scope.selectedGroups) ?
|
||||||
|
$scope.selectedGroups[$scope.groups[i].id].readOnly : false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +66,16 @@
|
||||||
delete $scope.selectedGroups[id];
|
delete $scope.selectedGroups[id];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$scope.selectedGroups[id] = true;
|
$scope.selectedGroups[id] = {
|
||||||
|
id: id,
|
||||||
|
readOnly: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.toggleGroupReadOnlySelection = function (group) {
|
||||||
|
if (group.id in $scope.selectedGroups) {
|
||||||
|
$scope.selectedGroups[group.id].readOnly = !group.accessAll && !!!$scope.selectedGroups[group.id].readOnly;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,18 +84,25 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.allSelected = function () {
|
$scope.allSelected = function () {
|
||||||
return Object.keys($scope.selectedGroups).length === $scope.groups.length;
|
return Object.keys($scope.selectedGroups).length >= groupsLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.submit = function (model) {
|
$scope.submit = function (model) {
|
||||||
var collection = cipherService.encryptCollection(model, $state.params.orgId);
|
var collection = cipherService.encryptCollection(model, $state.params.orgId);
|
||||||
|
|
||||||
if ($scope.useGroups) {
|
if ($scope.useGroups) {
|
||||||
collection.groupIds = [];
|
collection.groups = [];
|
||||||
|
|
||||||
for (var groupId in $scope.selectedGroups) {
|
for (var groupId in $scope.selectedGroups) {
|
||||||
if ($scope.selectedGroups.hasOwnProperty(groupId)) {
|
if ($scope.selectedGroups.hasOwnProperty(groupId)) {
|
||||||
collection.groupIds.push(groupId);
|
for (var i = 0; i < $scope.groups.length; i++) {
|
||||||
|
if ($scope.groups[i].id === $scope.selectedGroups[groupId].id) {
|
||||||
|
if (!$scope.groups[i].accessAll) {
|
||||||
|
collection.groups.push($scope.selectedGroups[groupId]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
.controller('organizationCollectionsEditController', function ($scope, $state, $uibModalInstance, apiService, cipherService,
|
.controller('organizationCollectionsEditController', function ($scope, $state, $uibModalInstance, apiService, cipherService,
|
||||||
$analytics, id, authService) {
|
$analytics, id, authService) {
|
||||||
$analytics.eventTrack('organizationCollectionsEditController', { category: 'Modal' });
|
$analytics.eventTrack('organizationCollectionsEditController', { category: 'Modal' });
|
||||||
|
var groupsLength = 0;
|
||||||
$scope.collection = {};
|
$scope.collection = {};
|
||||||
$scope.groups = [];
|
$scope.groups = [];
|
||||||
$scope.selectedGroups = {};
|
$scope.selectedGroups = {};
|
||||||
|
@ -16,9 +17,12 @@
|
||||||
$scope.collection = cipherService.decryptCollection(collection);
|
$scope.collection = cipherService.decryptCollection(collection);
|
||||||
|
|
||||||
var groups = {};
|
var groups = {};
|
||||||
if (collection.GroupIds) {
|
if (collection.Groups) {
|
||||||
for (var i = 0; i < collection.GroupIds.length; i++) {
|
for (var i = 0; i < collection.Groups.length; i++) {
|
||||||
groups[collection.GroupIds[i]] = true;
|
groups[collection.Groups[i].Id] = {
|
||||||
|
id: collection.Groups[i].Id,
|
||||||
|
readOnly: collection.Groups[i].ReadOnly
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$scope.selectedGroups = groups;
|
$scope.selectedGroups = groups;
|
||||||
|
@ -48,6 +52,10 @@
|
||||||
name: groups.Data[i].Name,
|
name: groups.Data[i].Name,
|
||||||
accessAll: groups.Data[i].AccessAll
|
accessAll: groups.Data[i].AccessAll
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!groups.Data[i].AccessAll) {
|
||||||
|
groupsLength++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.groups = groupsArr;
|
$scope.groups = groupsArr;
|
||||||
|
@ -58,7 +66,11 @@
|
||||||
var groups = {};
|
var groups = {};
|
||||||
if ($event.target.checked) {
|
if ($event.target.checked) {
|
||||||
for (var i = 0; i < $scope.groups.length; i++) {
|
for (var i = 0; i < $scope.groups.length; i++) {
|
||||||
groups[$scope.groups[i].id] = true;
|
groups[$scope.groups[i].id] = {
|
||||||
|
id: $scope.groups[i].id,
|
||||||
|
readOnly: ($scope.groups[i].id in $scope.selectedGroups) ?
|
||||||
|
$scope.selectedGroups[$scope.groups[i].id].readOnly : false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +82,16 @@
|
||||||
delete $scope.selectedGroups[id];
|
delete $scope.selectedGroups[id];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$scope.selectedGroups[id] = true;
|
$scope.selectedGroups[id] = {
|
||||||
|
id: id,
|
||||||
|
readOnly: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.toggleGroupReadOnlySelection = function (group) {
|
||||||
|
if (group.id in $scope.selectedGroups) {
|
||||||
|
$scope.selectedGroups[group.id].readOnly = !group.accessAll && !!!$scope.selectedGroups[group.id].readOnly;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,18 +100,25 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.allSelected = function () {
|
$scope.allSelected = function () {
|
||||||
return Object.keys($scope.selectedGroups).length === $scope.groups.length;
|
return Object.keys($scope.selectedGroups).length >= groupsLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.submit = function (model) {
|
$scope.submit = function (model) {
|
||||||
var collection = cipherService.encryptCollection(model, $state.params.orgId);
|
var collection = cipherService.encryptCollection(model, $state.params.orgId);
|
||||||
|
|
||||||
if ($scope.useGroups) {
|
if ($scope.useGroups) {
|
||||||
collection.groupIds = [];
|
collection.groups = [];
|
||||||
|
|
||||||
for (var groupId in $scope.selectedGroups) {
|
for (var groupId in $scope.selectedGroups) {
|
||||||
if ($scope.selectedGroups.hasOwnProperty(groupId)) {
|
if ($scope.selectedGroups.hasOwnProperty(groupId)) {
|
||||||
collection.groupIds.push(groupId);
|
for (var i = 0; i < $scope.groups.length; i++) {
|
||||||
|
if ($scope.groups[i].id === $scope.selectedGroups[groupId].id) {
|
||||||
|
if (!$scope.groups[i].accessAll) {
|
||||||
|
collection.groups.push($scope.selectedGroups[groupId]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,11 @@
|
||||||
var collections = {};
|
var collections = {};
|
||||||
if ($event.target.checked) {
|
if ($event.target.checked) {
|
||||||
for (var i = 0; i < $scope.collections.length; i++) {
|
for (var i = 0; i < $scope.collections.length; i++) {
|
||||||
collections[$scope.collections[i].id] = true;
|
collections[$scope.collections[i].id] = {
|
||||||
|
id: $scope.collections[i].id,
|
||||||
|
readOnly: ($scope.collections[i].id in $scope.selectedCollections) ?
|
||||||
|
$scope.selectedCollections[$scope.collections[i].id].readOnly : false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +35,16 @@
|
||||||
delete $scope.selectedCollections[id];
|
delete $scope.selectedCollections[id];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$scope.selectedCollections[id] = true;
|
$scope.selectedCollections[id] = {
|
||||||
|
id: id,
|
||||||
|
readOnly: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.toggleCollectionReadOnlySelection = function (id) {
|
||||||
|
if (id in $scope.selectedCollections) {
|
||||||
|
$scope.selectedCollections[id].readOnly = !!!$scope.selectedCollections[id].readOnly;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,10 +63,10 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!group.accessAll) {
|
if (!group.accessAll) {
|
||||||
group.collectionIds = [];
|
group.collections = [];
|
||||||
for (var id in $scope.selectedCollections) {
|
for (var collectionId in $scope.selectedCollections) {
|
||||||
if ($scope.selectedCollections.hasOwnProperty(id)) {
|
if ($scope.selectedCollections.hasOwnProperty(collectionId)) {
|
||||||
group.collectionIds.push(id);
|
group.collections.push($scope.selectedCollections[collectionId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,12 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
var collections = {};
|
var collections = {};
|
||||||
if (group.CollectionIds) {
|
if (group.Collections) {
|
||||||
for (var i = 0; i < group.CollectionIds.length; i++) {
|
for (var i = 0; i < group.Collections.length; i++) {
|
||||||
collections[group.CollectionIds[i]] = true;
|
collections[group.Collections[i].Id] = {
|
||||||
|
id: group.Collections[i].Id,
|
||||||
|
readOnly: group.Collections[i].ReadOnly
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$scope.selectedCollections = collections;
|
$scope.selectedCollections = collections;
|
||||||
|
@ -35,7 +38,11 @@
|
||||||
var collections = {};
|
var collections = {};
|
||||||
if ($event.target.checked) {
|
if ($event.target.checked) {
|
||||||
for (var i = 0; i < $scope.collections.length; i++) {
|
for (var i = 0; i < $scope.collections.length; i++) {
|
||||||
collections[$scope.collections[i].id] = true;
|
collections[$scope.collections[i].id] = {
|
||||||
|
id: $scope.collections[i].id,
|
||||||
|
readOnly: ($scope.collections[i].id in $scope.selectedCollections) ?
|
||||||
|
$scope.selectedCollections[$scope.collections[i].id].readOnly : false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +54,16 @@
|
||||||
delete $scope.selectedCollections[id];
|
delete $scope.selectedCollections[id];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$scope.selectedCollections[id] = true;
|
$scope.selectedCollections[id] = {
|
||||||
|
id: id,
|
||||||
|
readOnly: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.toggleCollectionReadOnlySelection = function (id) {
|
||||||
|
if (id in $scope.selectedCollections) {
|
||||||
|
$scope.selectedCollections[id].readOnly = !!!$scope.selectedCollections[id].readOnly;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,10 +82,10 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!group.accessAll) {
|
if (!group.accessAll) {
|
||||||
group.collectionIds = [];
|
group.collections = [];
|
||||||
for (var collId in $scope.selectedCollections) {
|
for (var collectionId in $scope.selectedCollections) {
|
||||||
if ($scope.selectedCollections.hasOwnProperty(collId)) {
|
if ($scope.selectedCollections.hasOwnProperty(collectionId)) {
|
||||||
group.collectionIds.push(collId);
|
group.collections.push($scope.selectedCollections[collectionId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
if (user && user.Collections) {
|
if (user && user.Collections) {
|
||||||
for (var i = 0; i < user.Collections.length; i++) {
|
for (var i = 0; i < user.Collections.length; i++) {
|
||||||
collections[user.Collections[i].Id] = {
|
collections[user.Collections[i].Id] = {
|
||||||
collectionId: user.Collections[i].Id,
|
id: user.Collections[i].Id,
|
||||||
readOnly: user.Collections[i].ReadOnly
|
readOnly: user.Collections[i].ReadOnly
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
if ($event.target.checked) {
|
if ($event.target.checked) {
|
||||||
for (var i = 0; i < $scope.collections.length; i++) {
|
for (var i = 0; i < $scope.collections.length; i++) {
|
||||||
collections[$scope.collections[i].id] = {
|
collections[$scope.collections[i].id] = {
|
||||||
collectionId: $scope.collections[i].id,
|
id: $scope.collections[i].id,
|
||||||
readOnly: ($scope.collections[i].id in $scope.selectedCollections) ?
|
readOnly: ($scope.collections[i].id in $scope.selectedCollections) ?
|
||||||
$scope.selectedCollections[$scope.collections[i].id].readOnly : false
|
$scope.selectedCollections[$scope.collections[i].id].readOnly : false
|
||||||
};
|
};
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$scope.selectedCollections[id] = {
|
$scope.selectedCollections[id] = {
|
||||||
collectionId: id,
|
id: id,
|
||||||
readOnly: false
|
readOnly: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
if ($event.target.checked) {
|
if ($event.target.checked) {
|
||||||
for (var i = 0; i < $scope.collections.length; i++) {
|
for (var i = 0; i < $scope.collections.length; i++) {
|
||||||
collections[$scope.collections[i].id] = {
|
collections[$scope.collections[i].id] = {
|
||||||
collectionId: $scope.collections[i].id,
|
id: $scope.collections[i].id,
|
||||||
readOnly: ($scope.collections[i].id in $scope.selectedCollections) ?
|
readOnly: ($scope.collections[i].id in $scope.selectedCollections) ?
|
||||||
$scope.selectedCollections[$scope.collections[i].id].readOnly : false
|
$scope.selectedCollections[$scope.collections[i].id].readOnly : false
|
||||||
};
|
};
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$scope.selectedCollections[id] = {
|
$scope.selectedCollections[id] = {
|
||||||
collectionId: id,
|
id: id,
|
||||||
readOnly: false
|
readOnly: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
ng-click="toggleGroupSelectionAll($event)">
|
ng-click="toggleGroupSelectionAll($event)">
|
||||||
</th>
|
</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
<th style="width: 100px; text-align: center;">Read Only</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -59,6 +60,14 @@
|
||||||
<i class="fa fa-unlock text-muted fa-fw" ng-show="group.accessAll"
|
<i class="fa fa-unlock text-muted fa-fw" ng-show="group.accessAll"
|
||||||
title="This group can access all items"></i>
|
title="This group can access all items"></i>
|
||||||
</td>
|
</td>
|
||||||
|
<td style="width: 100px; text-align: center;" valign="middle">
|
||||||
|
<input type="checkbox"
|
||||||
|
name="selectedGroupsReadonly[]"
|
||||||
|
value="{{group.id}}"
|
||||||
|
ng-disabled="!groupSelected(group) || group.accessAll"
|
||||||
|
ng-checked="groupSelected(group) && selectedGroups[group.id].readOnly"
|
||||||
|
ng-click="toggleGroupReadOnlySelection(group)">
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
ng-click="toggleGroupSelectionAll($event)">
|
ng-click="toggleGroupSelectionAll($event)">
|
||||||
</th>
|
</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
<th style="width: 100px; text-align: center;">Read Only</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -60,6 +61,14 @@
|
||||||
<i class="fa fa-unlock text-muted fa-fw" ng-show="group.accessAll"
|
<i class="fa fa-unlock text-muted fa-fw" ng-show="group.accessAll"
|
||||||
title="This group can access all items"></i>
|
title="This group can access all items"></i>
|
||||||
</td>
|
</td>
|
||||||
|
<td style="width: 100px; text-align: center;" valign="middle">
|
||||||
|
<input type="checkbox"
|
||||||
|
name="selectedGroupsReadonly[]"
|
||||||
|
value="{{group.id}}"
|
||||||
|
ng-disabled="!groupSelected(group) || group.accessAll"
|
||||||
|
ng-checked="groupSelected(group) && selectedGroups[group.id].readOnly"
|
||||||
|
ng-click="toggleGroupReadOnlySelection(group)">
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
ng-click="toggleCollectionSelectionAll($event)">
|
ng-click="toggleCollectionSelectionAll($event)">
|
||||||
</th>
|
</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
<th style="width: 100px; text-align: center;">Read Only</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -67,6 +68,14 @@
|
||||||
<td valign="middle">
|
<td valign="middle">
|
||||||
{{collection.name}}
|
{{collection.name}}
|
||||||
</td>
|
</td>
|
||||||
|
<td style="width: 100px; text-align: center;" valign="middle">
|
||||||
|
<input type="checkbox"
|
||||||
|
name="selectedCollectionsReadonly[]"
|
||||||
|
value="{{collection.id}}"
|
||||||
|
ng-disabled="!collectionSelected(collection)"
|
||||||
|
ng-checked="collectionSelected(collection) && selectedCollections[collection.id].readOnly"
|
||||||
|
ng-click="toggleCollectionReadOnlySelection(collection.id)">
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
ng-click="toggleCollectionSelectionAll($event)">
|
ng-click="toggleCollectionSelectionAll($event)">
|
||||||
</th>
|
</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
<th style="width: 100px; text-align: center;">Read Only</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -67,6 +68,14 @@
|
||||||
<td valign="middle">
|
<td valign="middle">
|
||||||
{{collection.name}}
|
{{collection.name}}
|
||||||
</td>
|
</td>
|
||||||
|
<td style="width: 100px; text-align: center;" valign="middle">
|
||||||
|
<input type="checkbox"
|
||||||
|
name="selectedCollectionsReadonly[]"
|
||||||
|
value="{{collection.id}}"
|
||||||
|
ng-disabled="!collectionSelected(collection)"
|
||||||
|
ng-checked="collectionSelected(collection) && selectedCollections[collection.id].readOnly"
|
||||||
|
ng-click="toggleCollectionReadOnlySelection(collection.id)">
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in New Issue