mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 22:37:41 -02:30
Fixed permissions multi-select issues
This commit is contained in:
@@ -62,13 +62,13 @@ export default ['$rootScope', '$scope', 'GetBasePath', 'Rest', '$q', 'Wait', 'Pr
|
|||||||
user.username;
|
user.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.isSelected) {
|
if (value.isSelected) {
|
||||||
if (item.type === 'user') {
|
if (item.type === 'user') {
|
||||||
item.name = buildName(item);
|
item.name = buildName(item);
|
||||||
}
|
}
|
||||||
scope.allSelected.push(item);
|
scope.allSelected.push(item);
|
||||||
} else {
|
} else {
|
||||||
scope.allSelected = _.remove(scope.allSelected, { id: item.id });
|
_.remove(scope.allSelected, { id: item.id });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ function(rootScope, scope, $state, i18n, CreateSelect2, GetBasePath, Rest, $q, W
|
|||||||
let resourceType = scope.currentTab(),
|
let resourceType = scope.currentTab(),
|
||||||
item = value.value;
|
item = value.value;
|
||||||
|
|
||||||
if (item.isSelected) {
|
if (value.isSelected) {
|
||||||
scope.selected[resourceType][item.id] = item;
|
scope.selected[resourceType][item.id] = item;
|
||||||
scope.selected[resourceType][item.id].roles = [];
|
scope.selected[resourceType][item.id].roles = [];
|
||||||
aggregateKey(item, resourceType);
|
aggregateKey(item, resourceType);
|
||||||
|
|||||||
@@ -9,12 +9,6 @@
|
|||||||
return {
|
return {
|
||||||
name: 'users',
|
name: 'users',
|
||||||
iterator: 'user',
|
iterator: 'user',
|
||||||
defaultSearchParams: function(term){
|
|
||||||
return {or__username__icontains: term,
|
|
||||||
or__first_name__icontains: term,
|
|
||||||
or__last_name__icontains: term
|
|
||||||
};
|
|
||||||
},
|
|
||||||
title: false,
|
title: false,
|
||||||
listTitleBadge: false,
|
listTitleBadge: false,
|
||||||
multiSelect: true,
|
multiSelect: true,
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ export default
|
|||||||
search: {
|
search: {
|
||||||
order_by: 'username'
|
order_by: 'username'
|
||||||
},
|
},
|
||||||
defaultSearchParams: function(term){
|
|
||||||
return {or__username__icontains: term,
|
|
||||||
or__first_name__icontains: term,
|
|
||||||
or__last_name__icontains: term
|
|
||||||
};
|
|
||||||
},
|
|
||||||
iterator: 'user',
|
iterator: 'user',
|
||||||
selectTitle: i18n._('Add Users'),
|
selectTitle: i18n._('Add Users'),
|
||||||
editTitle: i18n._('Users'),
|
editTitle: i18n._('Users'),
|
||||||
|
|||||||
@@ -11,10 +11,10 @@
|
|||||||
* Controller for handling permissions adding
|
* Controller for handling permissions adding
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default ['$scope', '$rootScope', 'ProcessErrors', 'GetBasePath',
|
export default ['$scope', '$rootScope', 'ProcessErrors', 'GetBasePath', 'generateList',
|
||||||
'SelectionInit', 'templateUrl', '$state', 'Rest', '$q', 'Wait', '$window',
|
'SelectionInit', 'templateUrl', '$state', 'Rest', '$q', 'Wait', '$window', 'QuerySet', 'UserList',
|
||||||
function($scope, $rootScope, ProcessErrors, GetBasePath,
|
function($scope, $rootScope, ProcessErrors, GetBasePath, generateList,
|
||||||
SelectionInit, templateUrl, $state, Rest, $q, Wait, $window) {
|
SelectionInit, templateUrl, $state, Rest, $q, Wait, $window, qs, UserList) {
|
||||||
$scope.$on("linkLists", function() {
|
$scope.$on("linkLists", function() {
|
||||||
|
|
||||||
if ($state.current.name.split(".")[1] === "users") {
|
if ($state.current.name.split(".")[1] === "users") {
|
||||||
@@ -26,16 +26,59 @@ function($scope, $rootScope, ProcessErrors, GetBasePath,
|
|||||||
init();
|
init();
|
||||||
|
|
||||||
function init(){
|
function init(){
|
||||||
// search init
|
$scope.add_user_default_params = {
|
||||||
$scope.list = $scope.$parent.add_user_list;
|
order_by: 'username',
|
||||||
$scope.add_user_dataset = $scope.$parent.add_user_dataset;
|
page_size: 5
|
||||||
$scope.add_users = $scope.$parent.add_user_dataset.results;
|
};
|
||||||
|
|
||||||
|
$scope.add_user_queryset = {
|
||||||
|
order_by: 'username',
|
||||||
|
page_size: 5
|
||||||
|
};
|
||||||
|
|
||||||
|
let list = _.cloneDeep(UserList);
|
||||||
|
list.basePath = 'users';
|
||||||
|
list.iterator = 'add_user';
|
||||||
|
list.name = 'add_users';
|
||||||
|
list.multiSelect = true;
|
||||||
|
list.fields.username.ngClick = 'linkoutUser(add_user.id)';
|
||||||
|
delete list.actions;
|
||||||
|
delete list.fieldActions;
|
||||||
|
|
||||||
|
// Fire off the initial search
|
||||||
|
qs.search(GetBasePath('users'), $scope.add_user_default_params)
|
||||||
|
.then(function(res) {
|
||||||
|
$scope.add_user_dataset = res.data;
|
||||||
|
$scope.add_users = $scope.add_user_dataset.results;
|
||||||
|
|
||||||
|
let html = generateList.build({
|
||||||
|
list: list,
|
||||||
|
mode: 'edit',
|
||||||
|
title: false
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.list = list;
|
||||||
|
|
||||||
|
$scope.compileList(html);
|
||||||
|
|
||||||
|
$scope.$watchCollection('add_users', function () {
|
||||||
|
if($scope.selectedItems) {
|
||||||
|
// Loop across the users and see if any of them should be "checked"
|
||||||
|
$scope.add_users.forEach(function(row, i) {
|
||||||
|
if (_.includes($scope.selectedItems, row.id)) {
|
||||||
|
$scope.add_users[i].isSelected = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
$scope.selectedItems = [];
|
$scope.selectedItems = [];
|
||||||
$scope.$on('selectedOrDeselected', function(e, value) {
|
$scope.$on('selectedOrDeselected', function(e, value) {
|
||||||
let item = value.value;
|
let item = value.value;
|
||||||
|
|
||||||
if (item.isSelected) {
|
if (value.isSelected) {
|
||||||
$scope.selectedItems.push(item.id);
|
$scope.selectedItems.push(item.id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
/* jshint unused: vars */
|
/* jshint unused: vars */
|
||||||
import addUsers from './addUsers.controller';
|
import addUsers from './addUsers.controller';
|
||||||
export default
|
export default
|
||||||
['Wait', 'templateUrl', '$state', '$view', function(Wait, templateUrl, $state, $view) {
|
['Wait', 'templateUrl', '$state', '$view', '$compile', function(Wait, templateUrl, $state, $view, $compile) {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
scope: {
|
scope: {
|
||||||
@@ -48,6 +48,10 @@ export default
|
|||||||
scope.closeModal();
|
scope.closeModal();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
scope.compileList = function(html) {
|
||||||
|
$('#add-users-list').append($compile(html)(scope));
|
||||||
|
};
|
||||||
|
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
|
|
||||||
window.scrollTo(0,0);
|
window.scrollTo(0,0);
|
||||||
|
|||||||
@@ -15,8 +15,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ui-view="modalBody" class="AddUsers-body">
|
<div id="add-users-list" class="AddUsers-body"></div>
|
||||||
</div>
|
|
||||||
<div class="AddUsers-footer">
|
<div class="AddUsers-footer">
|
||||||
<div class="buttons Form-buttons AddUsers-buttons">
|
<div class="buttons Form-buttons AddUsers-buttons">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
export default ['$stateParams', '$scope', 'UserList', 'Rest', '$state',
|
export default ['$stateParams', '$scope', 'UserList', 'Rest', '$state',
|
||||||
'generateList', '$compile', 'Wait', 'OrgAdminList', 'AddAdminList',
|
'generateList', '$compile', 'Wait', 'OrgAdminList',
|
||||||
'OrgAdminsDataset', 'AddAdminsDataset',
|
'OrgAdminsDataset',
|
||||||
'Prompt', 'ProcessErrors', 'GetBasePath', '$filter',
|
'Prompt', 'ProcessErrors', 'GetBasePath', '$filter',
|
||||||
function($stateParams, $scope, UserList, Rest, $state, GenerateList,
|
function($stateParams, $scope, UserList, Rest, $state, GenerateList,
|
||||||
$compile, Wait, OrgAdminList, AddAdminList, OrgAdminsDataset, AddAdminsDataset, Prompt, ProcessErrors,
|
$compile, Wait, OrgAdminList, OrgAdminsDataset, Prompt, ProcessErrors,
|
||||||
GetBasePath, $filter) {
|
GetBasePath, $filter) {
|
||||||
|
|
||||||
var orgBase = GetBasePath('organizations');
|
var orgBase = GetBasePath('organizations');
|
||||||
@@ -19,11 +19,8 @@ export default ['$stateParams', '$scope', 'UserList', 'Rest', '$state',
|
|||||||
function init() {
|
function init() {
|
||||||
// search init
|
// search init
|
||||||
$scope.list = OrgAdminList;
|
$scope.list = OrgAdminList;
|
||||||
$scope.add_user_list = AddAdminList;
|
|
||||||
$scope.user_dataset = OrgAdminsDataset.data;
|
$scope.user_dataset = OrgAdminsDataset.data;
|
||||||
$scope.users = $scope.user_dataset.results;
|
$scope.users = $scope.user_dataset.results;
|
||||||
$scope.add_user_dataset = AddAdminsDataset.data;
|
|
||||||
$scope.add_users = $scope.add_user_dataset.results;
|
|
||||||
|
|
||||||
Rest.setUrl(orgBase + $stateParams.organization_id);
|
Rest.setUrl(orgBase + $stateParams.organization_id);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
export default ['$stateParams', '$scope', 'OrgUserList', 'AddUserList','Rest', '$state',
|
export default ['$stateParams', '$scope', 'OrgUserList','Rest', '$state',
|
||||||
'generateList', '$compile', 'Wait', 'OrgUsersDataset', 'AddUsersDataset',
|
'generateList', '$compile', 'Wait', 'OrgUsersDataset',
|
||||||
'Prompt', 'ProcessErrors', 'GetBasePath', '$filter',
|
'Prompt', 'ProcessErrors', 'GetBasePath', '$filter',
|
||||||
function($stateParams, $scope, OrgUserList, AddUserList, Rest, $state, GenerateList,
|
function($stateParams, $scope, OrgUserList, Rest, $state, GenerateList,
|
||||||
$compile, Wait, OrgUsersDataset, AddUsersDataset, Prompt, ProcessErrors,
|
$compile, Wait, OrgUsersDataset, Prompt, ProcessErrors,
|
||||||
GetBasePath, $filter) {
|
GetBasePath, $filter) {
|
||||||
|
|
||||||
var orgBase = GetBasePath('organizations');
|
var orgBase = GetBasePath('organizations');
|
||||||
@@ -18,12 +18,8 @@ export default ['$stateParams', '$scope', 'OrgUserList', 'AddUserList','Rest', '
|
|||||||
function init() {
|
function init() {
|
||||||
// search init
|
// search init
|
||||||
$scope.list = OrgUserList;
|
$scope.list = OrgUserList;
|
||||||
$scope.add_user_list = AddUserList;
|
|
||||||
$scope.user_dataset = OrgUsersDataset.data;
|
$scope.user_dataset = OrgUsersDataset.data;
|
||||||
$scope.users = $scope.user_dataset.results;
|
$scope.users = $scope.user_dataset.results;
|
||||||
$scope.add_user_dataset = AddUsersDataset.data;
|
|
||||||
$scope.add_users = $scope.add_user_dataset.results;
|
|
||||||
|
|
||||||
|
|
||||||
Rest.setUrl(orgBase + $stateParams.organization_id);
|
Rest.setUrl(orgBase + $stateParams.organization_id);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
|
|||||||
@@ -27,16 +27,6 @@ export default [{
|
|||||||
});
|
});
|
||||||
return generateList.wrapPanel(html);
|
return generateList.wrapPanel(html);
|
||||||
},
|
},
|
||||||
},
|
|
||||||
'modalBody@': {
|
|
||||||
templateProvider: function(AddUserList, generateList) {
|
|
||||||
let html = generateList.build({
|
|
||||||
list: AddUserList,
|
|
||||||
mode: 'edit',
|
|
||||||
listTitle: false
|
|
||||||
});
|
|
||||||
return html;
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
@@ -44,14 +34,6 @@ export default [{
|
|||||||
value: {
|
value: {
|
||||||
order_by: 'username'
|
order_by: 'username'
|
||||||
}
|
}
|
||||||
},
|
|
||||||
add_user_search: {
|
|
||||||
value: {
|
|
||||||
order_by: 'username',
|
|
||||||
page_size: '5',
|
|
||||||
},
|
|
||||||
dynamic: true,
|
|
||||||
squash: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ncyBreadcrumb: {
|
ncyBreadcrumb: {
|
||||||
@@ -73,12 +55,6 @@ export default [{
|
|||||||
return qs.search(path, $stateParams.user_search);
|
return qs.search(path, $stateParams.user_search);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
AddUsersDataset: ['AddUserList', 'QuerySet', '$stateParams', 'GetBasePath',
|
|
||||||
function(list, qs, $stateParams, GetBasePath) {
|
|
||||||
let path = GetBasePath(list.basePath) || list.basePath;
|
|
||||||
return qs.search(path, $stateParams.add_user_search);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
OrgUserList: ['UserList', 'GetBasePath', '$stateParams', function(UserList, GetBasePath, $stateParams) {
|
OrgUserList: ['UserList', 'GetBasePath', '$stateParams', function(UserList, GetBasePath, $stateParams) {
|
||||||
let list = _.cloneDeep(UserList);
|
let list = _.cloneDeep(UserList);
|
||||||
delete list.actions.add;
|
delete list.actions.add;
|
||||||
@@ -93,17 +69,6 @@ export default [{
|
|||||||
};
|
};
|
||||||
list.searchSize = "col-lg-12 col-md-12 col-sm-12 col-xs-12";
|
list.searchSize = "col-lg-12 col-md-12 col-sm-12 col-xs-12";
|
||||||
return list;
|
return list;
|
||||||
}],
|
|
||||||
AddUserList: ['UserList', function(UserList) {
|
|
||||||
let list = _.cloneDeep(UserList);
|
|
||||||
list.basePath = 'users';
|
|
||||||
list.iterator = 'add_user';
|
|
||||||
list.name = 'add_users';
|
|
||||||
list.multiSelect = true;
|
|
||||||
list.fields.username.ngClick = 'linkoutUser(add_user.id)';
|
|
||||||
delete list.actions;
|
|
||||||
delete list.fieldActions;
|
|
||||||
return list;
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
@@ -342,16 +307,6 @@ export default [{
|
|||||||
});
|
});
|
||||||
return generateList.wrapPanel(html);
|
return generateList.wrapPanel(html);
|
||||||
},
|
},
|
||||||
},
|
|
||||||
'modalBody@': {
|
|
||||||
templateProvider: function(AddAdminList, generateList) {
|
|
||||||
let html = generateList.build({
|
|
||||||
list: AddAdminList,
|
|
||||||
mode: 'edit',
|
|
||||||
listTitle: false
|
|
||||||
});
|
|
||||||
return html;
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
@@ -372,12 +327,6 @@ export default [{
|
|||||||
return qs.search(path, $stateParams[`user_search`]);
|
return qs.search(path, $stateParams[`user_search`]);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
AddAdminsDataset: ['AddAdminList', 'QuerySet', '$stateParams', 'GetBasePath',
|
|
||||||
function(list, qs, $stateParams, GetBasePath) {
|
|
||||||
let path = GetBasePath(list.basePath) || list.basePath;
|
|
||||||
return qs.search(path, $stateParams[`add_user_search`]);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
OrgAdminList: ['UserList', 'GetBasePath', '$stateParams', function(UserList, GetBasePath, $stateParams) {
|
OrgAdminList: ['UserList', 'GetBasePath', '$stateParams', function(UserList, GetBasePath, $stateParams) {
|
||||||
let list = _.cloneDeep(UserList);
|
let list = _.cloneDeep(UserList);
|
||||||
delete list.actions.add;
|
delete list.actions.add;
|
||||||
@@ -393,17 +342,6 @@ export default [{
|
|||||||
list.searchSize = "col-lg-12 col-md-12 col-sm-12 col-xs-12";
|
list.searchSize = "col-lg-12 col-md-12 col-sm-12 col-xs-12";
|
||||||
list.listTitle = 'Admins';
|
list.listTitle = 'Admins';
|
||||||
return list;
|
return list;
|
||||||
}],
|
|
||||||
AddAdminList: ['UserList', function(UserList) {
|
|
||||||
let list = _.cloneDeep(UserList);
|
|
||||||
list.basePath = 'users';
|
|
||||||
list.iterator = 'add_user';
|
|
||||||
list.name = 'add_users';
|
|
||||||
list.multiSelect = true;
|
|
||||||
list.fields.username.ngClick = 'linkoutUser(add_user.id)';
|
|
||||||
delete list.actions;
|
|
||||||
delete list.fieldActions;
|
|
||||||
return list;
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export default
|
|||||||
item: '=item'
|
item: '=item'
|
||||||
},
|
},
|
||||||
require: '^multiSelectList',
|
require: '^multiSelectList',
|
||||||
template: '<input type="checkbox" data-multi-select-list-item ng-model="item.isSelected" ng-change="userInteractionSelect()">',
|
template: '<input type="checkbox" data-multi-select-list-item ng-model="item.isSelected" ng-click="userInteractionSelect()">',
|
||||||
link: function(scope, element, attrs, multiSelectList) {
|
link: function(scope, element, attrs, multiSelectList) {
|
||||||
|
|
||||||
scope.decoratedItem = multiSelectList.registerItem(scope.item);
|
scope.decoratedItem = multiSelectList.registerItem(scope.item);
|
||||||
|
|||||||
Reference in New Issue
Block a user