mirror of
https://github.com/ansible/awx.git
synced 2026-03-04 18:21:03 -03:30
Fixed several bugs with adding permissions where checkboxes weren't checked properly or were disappearing when paging was involved.
This commit is contained in:
@@ -41,11 +41,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="AddPermissions-list" ng-show="usersSelected">
|
<div class="AddPermissions-list" ng-show="usersSelected">
|
||||||
<add-permissions-list type="users">
|
<add-permissions-list all-selected="allSelected" type="users">
|
||||||
</add-permissions-list>
|
</add-permissions-list>
|
||||||
</div>
|
</div>
|
||||||
<div class="AddPermissions-list" ng-show="teamsSelected">
|
<div class="AddPermissions-list" ng-show="teamsSelected">
|
||||||
<add-permissions-list type="teams">
|
<add-permissions-list all-selected="allSelected" type="teams">
|
||||||
</add-permissions-list>
|
</add-permissions-list>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export default
|
|||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
scope: {
|
scope: {
|
||||||
|
allSelected: '='
|
||||||
},
|
},
|
||||||
template: "<div class='addPermissionsList-inner'></div>",
|
template: "<div class='addPermissionsList-inner'></div>",
|
||||||
link: function(scope, element, attrs, ctrl) {
|
link: function(scope, element, attrs, ctrl) {
|
||||||
@@ -50,6 +51,23 @@ export default
|
|||||||
PaginateInit({ scope: scope,
|
PaginateInit({ scope: scope,
|
||||||
list: list, url: url, pageSize: 5 });
|
list: list, url: url, pageSize: 5 });
|
||||||
|
|
||||||
|
if (scope.removePostRefresh) {
|
||||||
|
scope.removePostRefresh();
|
||||||
|
}
|
||||||
|
scope.removePostRefresh = scope.$on('PostRefresh', function () {
|
||||||
|
if(scope.allSelected && scope.allSelected.length > 0) {
|
||||||
|
// We need to check to see if any of the selected items are now in our list!
|
||||||
|
for(var i=0; i<scope.allSelected.length; i++) {
|
||||||
|
for(var j=0; j<scope[set].length; j++) {
|
||||||
|
if(scope.allSelected[i].id === scope[set][j].id && scope.allSelected[i].type === scope[set][j].type) {
|
||||||
|
// If so, let's go ahead and mark it as selected so that select-list-item knows to check the box
|
||||||
|
scope[set][j].isSelected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,11 @@ export default
|
|||||||
template: '<input type="checkbox" data-multi-select-list-item ng-model="isSelected" ng-change="userInteractionSelect()">',
|
template: '<input type="checkbox" data-multi-select-list-item ng-model="isSelected" ng-change="userInteractionSelect()">',
|
||||||
link: function(scope, element, attrs, multiSelectList) {
|
link: function(scope, element, attrs, multiSelectList) {
|
||||||
|
|
||||||
scope.isSelected = false;
|
var initializeItem = function() {
|
||||||
scope.decoratedItem = multiSelectList.registerItem(scope.item);
|
scope.decoratedItem = multiSelectList.registerItem(scope.item);
|
||||||
|
scope.isSelected = scope.item.isSelected ? true : false;
|
||||||
|
scope.decoratedItem.isSelected = scope.item.isSelected ? true : false;
|
||||||
|
};
|
||||||
|
|
||||||
scope.$watch('isSelected', function(value) {
|
scope.$watch('isSelected', function(value) {
|
||||||
if (value === true) {
|
if (value === true) {
|
||||||
@@ -44,8 +47,11 @@ export default
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.$watch('decoratedItem.isSelected', function(value) {
|
scope.$watch('item', function() {
|
||||||
scope.isSelected = value;
|
// This is necessary for page changes where $scope.item gets updated via ng-repeat
|
||||||
|
// but this link function never gets triggered (and scope.decoratedItem) never
|
||||||
|
// gets updated.
|
||||||
|
initializeItem();
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.$on('$destroy', function() {
|
scope.$on('$destroy', function() {
|
||||||
@@ -56,6 +62,8 @@ export default
|
|||||||
scope.$emit("selectedOrDeselected", scope.decoratedItem);
|
scope.$emit("selectedOrDeselected", scope.decoratedItem);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
initializeItem();
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}];
|
}];
|
||||||
|
|||||||
Reference in New Issue
Block a user