mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 20:30:46 -03:30
revamp services for pulling in the search options
This commit is contained in:
parent
9705a90d43
commit
c67a9031ca
@ -176,7 +176,7 @@ TeamsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$r
|
||||
|
||||
export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, TeamForm, GenerateForm, Rest, Alert, ProcessErrors,
|
||||
LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt, GetBasePath, CheckAccess,
|
||||
OrganizationList, Wait, Stream, permissionsLabel) {
|
||||
OrganizationList, Wait, Stream, permissionsChoices, permissionsLabel, permissionsSearchSelect) {
|
||||
|
||||
ClearScope();
|
||||
|
||||
@ -188,12 +188,22 @@ export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
id = $routeParams.team_id,
|
||||
relatedSets = {};
|
||||
|
||||
$scope.permission_label = {};
|
||||
$scope.permission_label = {};
|
||||
$scope.permission_search_select = [];
|
||||
|
||||
permissionsLabel({
|
||||
// return a promise from the options request with the permission type choices (including adhoc) as a param
|
||||
var permissionsChoice = permissionsChoices({
|
||||
scope: $scope,
|
||||
url: 'api/v1/' + base + '/' + id + '/permissions/'
|
||||
}).then(function(choices) {
|
||||
});
|
||||
|
||||
// manipulate the choices from the options request to be set on
|
||||
// scope and be usable by the list form
|
||||
permissionsChoice.then(function (choices) {
|
||||
choices =
|
||||
permissionsLabel({
|
||||
choices: choices
|
||||
});
|
||||
_.map(choices, function(n, key) {
|
||||
$scope.permission_label[key] = n;
|
||||
});
|
||||
@ -201,8 +211,17 @@ export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
|
||||
$scope.team_id = id;
|
||||
|
||||
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
||||
generator.reset();
|
||||
// manipulate the choices from the options request to be usable
|
||||
// by the search option for permission_type, you can't inject the
|
||||
// list until this is done!
|
||||
permissionsChoice.then(function (choices) {
|
||||
form.related.permissions.fields.permission_type.searchOptions =
|
||||
permissionsSearchSelect({
|
||||
choices: choices
|
||||
});
|
||||
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
||||
generator.reset();
|
||||
});
|
||||
|
||||
$scope.PermissionAddAllowed = false;
|
||||
|
||||
@ -412,5 +431,5 @@ export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
|
||||
TeamsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'TeamForm',
|
||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit',
|
||||
'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt', 'GetBasePath', 'CheckAccess', 'OrganizationList', 'Wait', 'Stream', 'permissionsLabel'
|
||||
'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt', 'GetBasePath', 'CheckAccess', 'OrganizationList', 'Wait', 'Stream', 'permissionsChoices', 'permissionsLabel', 'permissionsSearchSelect'
|
||||
];
|
||||
|
||||
@ -208,7 +208,7 @@ UsersAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$r
|
||||
|
||||
export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm, GenerateForm, Rest, Alert,
|
||||
ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, GetBasePath,
|
||||
Prompt, CheckAccess, ResetForm, Wait, Stream, permissionsLabel) {
|
||||
Prompt, CheckAccess, ResetForm, Wait, Stream, permissionsChoices, permissionsLabel, permissionsSearchSelect) {
|
||||
|
||||
ClearScope();
|
||||
|
||||
@ -221,11 +221,21 @@ export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
relatedSets = {};
|
||||
|
||||
$scope.permission_label = {};
|
||||
$scope.permission_search_select = [];
|
||||
|
||||
permissionsLabel({
|
||||
// return a promise from the options request with the permission type choices (including adhoc) as a param
|
||||
var permissionsChoice = permissionsChoices({
|
||||
scope: $scope,
|
||||
url: 'api/v1/' + base + '/' + id + '/permissions/'
|
||||
}).then(function(choices) {
|
||||
});
|
||||
|
||||
// manipulate the choices from the options request to be set on
|
||||
// scope and be usable by the list form
|
||||
permissionsChoice.then(function (choices) {
|
||||
choices =
|
||||
permissionsLabel({
|
||||
choices: choices
|
||||
});
|
||||
_.map(choices, function(n, key) {
|
||||
$scope.permission_label[key] = n;
|
||||
});
|
||||
@ -235,9 +245,17 @@ export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
$scope.removeFormReady();
|
||||
}
|
||||
$scope.removeFormReady = $scope.$on('formReady', function () {
|
||||
|
||||
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
||||
generator.reset();
|
||||
// manipulate the choices from the options request to be usable
|
||||
// by the search option for permission_type, you can't inject the
|
||||
// list until this is done!
|
||||
permissionsChoice.then(function (choices) {
|
||||
form.related.permissions.fields.permission_type.searchOptions =
|
||||
permissionsSearchSelect({
|
||||
choices: choices
|
||||
});
|
||||
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
||||
generator.reset();
|
||||
});
|
||||
|
||||
if ($scope.removePostRefresh) {
|
||||
$scope.removePostRefresh();
|
||||
@ -501,5 +519,5 @@ export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
|
||||
UsersEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm', 'GenerateForm',
|
||||
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope',
|
||||
'GetBasePath', 'Prompt', 'CheckAccess', 'ResetForm', 'Wait', 'Stream', 'permissionsLabel'
|
||||
'GetBasePath', 'Prompt', 'CheckAccess', 'ResetForm', 'Wait', 'Stream', 'permissionsChoices', 'permissionsLabel', 'permissionsSearchSelect'
|
||||
];
|
||||
|
||||
@ -158,16 +158,7 @@ export default
|
||||
permission_type: {
|
||||
label: 'Permission',
|
||||
ngBind: 'getPermissionText()',
|
||||
searchType: 'select',
|
||||
searchOptions: [
|
||||
{ name: "Read Inventory", value: "read" },
|
||||
{ name: "Edit Inventory", value: "write" },
|
||||
{ name: "Administrate Inventory", value: "admin" },
|
||||
{ name: "Deploy to Inventory", value: "run" },
|
||||
{ name: "Deploy to Inventory (Dry Run)", value: "check" },
|
||||
{ name: "Scan an Inventory", value: "scan" },
|
||||
{ name: "Create a Job Template", value: "create" }
|
||||
]
|
||||
searchType: 'select'
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -213,16 +213,7 @@ export default
|
||||
permission_type: {
|
||||
label: 'Permission',
|
||||
ngBind: 'getPermissionText()',
|
||||
searchType: 'select',
|
||||
searchOptions: [
|
||||
{ name: "Read Inventory", value: "read" },
|
||||
{ name: "Edit Inventory", value: "write" },
|
||||
{ name: "Administrate Inventory", value: "admin" },
|
||||
{ name: "Deploy to Inventory", value: "run" },
|
||||
{ name: "Deploy to Inventory (Dry Run)", value: "check" },
|
||||
{ name: "Scan an Inventory", value: "scan" },
|
||||
{ name: "Create a Job Template", value: "create" }
|
||||
]
|
||||
searchType: 'select'
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -10,8 +10,8 @@
|
||||
* @description This controller for permissions add
|
||||
*/
|
||||
export default
|
||||
['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'permissionsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'permissionsCategoryChange', 'permissionsLabel',
|
||||
function($scope, $rootScope, $compile, $location, $log, $routeParams, permissionsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, permissionsCategoryChange, permissionsLabel) {
|
||||
['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'permissionsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'permissionsCategoryChange', 'permissionsChoices', 'permissionsLabel',
|
||||
function($scope, $rootScope, $compile, $location, $log, $routeParams, permissionsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, permissionsCategoryChange, permissionsChoices, permissionsLabel) {
|
||||
|
||||
ClearScope();
|
||||
|
||||
@ -22,10 +22,16 @@ export default
|
||||
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||
master = {};
|
||||
|
||||
permissionsLabel({
|
||||
var permissionsChoice = permissionsChoices({
|
||||
scope: $scope,
|
||||
url: 'api/v1/' + base + '/' + id + '/permissions/'
|
||||
}).then(function(choices) {
|
||||
});
|
||||
|
||||
permissionsChoice.then(function (choices) {
|
||||
return permissionsLabel({
|
||||
choices: choices
|
||||
});
|
||||
}).then(function (choices) {
|
||||
_.map(choices, function(n, key) {
|
||||
$scope.permission_label[key] = n;
|
||||
});
|
||||
|
||||
@ -10,8 +10,8 @@
|
||||
* @description This controller for permissions edit
|
||||
*/
|
||||
export default
|
||||
['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'permissionsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'Prompt', 'GetBasePath', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'permissionsCategoryChange', 'permissionsLabel',
|
||||
function($scope, $rootScope, $compile, $location, $log, $routeParams, permissionsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, Prompt, GetBasePath, InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, permissionsCategoryChange, permissionsLabel) {
|
||||
['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'permissionsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'Prompt', 'GetBasePath', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'permissionsCategoryChange', 'permissionsChoices', 'permissionsLabel',
|
||||
function($scope, $rootScope, $compile, $location, $log, $routeParams, permissionsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, Prompt, GetBasePath, InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, permissionsCategoryChange, permissionsChoices, permissionsLabel) {
|
||||
|
||||
ClearScope();
|
||||
|
||||
@ -25,10 +25,16 @@ export default
|
||||
|
||||
$scope.permission_label = {};
|
||||
|
||||
permissionsLabel({
|
||||
var permissionsChoice = permissionsChoices({
|
||||
scope: $scope,
|
||||
url: 'api/v1/' + base + '/' + base_id + '/permissions/'
|
||||
}).then(function(choices) {
|
||||
});
|
||||
|
||||
permissionsChoice.then(function (choices) {
|
||||
return permissionsLabel({
|
||||
choices: choices
|
||||
});
|
||||
}).then(function (choices) {
|
||||
_.map(choices, function(n, key) {
|
||||
$scope.permission_label[key] = n;
|
||||
});
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
|
||||
|
||||
export default
|
||||
['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'permissionsList', 'generateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors', 'GetBasePath', 'CheckAccess', 'Wait', 'permissionsLabel',
|
||||
function ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, permissionsList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, CheckAccess, Wait, permissionsLabel) {
|
||||
['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'permissionsList', 'generateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors', 'GetBasePath', 'CheckAccess', 'Wait', 'permissionsChoices', 'permissionsLabel', 'permissionsSearchSelect',
|
||||
function ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, permissionsList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, CheckAccess, Wait, permissionsChoices, permissionsLabel, permissionsSearchSelect) {
|
||||
|
||||
ClearScope();
|
||||
|
||||
@ -24,17 +24,37 @@ export default
|
||||
generator = GenerateList;
|
||||
|
||||
$scope.permission_label = {};
|
||||
$scope.permission_search_select = [];
|
||||
|
||||
permissionsLabel({
|
||||
// return a promise from the options request with the permission type choices (including adhoc) as a param
|
||||
var permissionsChoice = permissionsChoices({
|
||||
scope: $scope,
|
||||
url: 'api/v1/' + base + '/' + base_id + '/permissions/'
|
||||
}).then(function(choices) {
|
||||
});
|
||||
|
||||
// manipulate the choices from the options request to be set on
|
||||
// scope and be usable by the list form
|
||||
permissionsChoice.then(function (choices) {
|
||||
choices =
|
||||
permissionsLabel({
|
||||
choices: choices
|
||||
});
|
||||
_.map(choices, function(n, key) {
|
||||
$scope.permission_label[key] = n;
|
||||
});
|
||||
});
|
||||
|
||||
generator.inject(list, { mode: 'edit', scope: $scope, breadCrumbs: true });
|
||||
// manipulate the choices from the options request to be usable
|
||||
// by the search option for permission_type, you can't inject the
|
||||
// list until this is done!
|
||||
permissionsChoice.then(function (choices) {
|
||||
list.fields.permission_type.searchOptions =
|
||||
permissionsSearchSelect({
|
||||
choices: choices
|
||||
});
|
||||
generator.inject(list, { mode: 'edit', scope: $scope, breadCrumbs: true });
|
||||
});
|
||||
|
||||
defaultUrl += ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id;
|
||||
defaultUrl += '/permissions/';
|
||||
|
||||
|
||||
@ -17,14 +17,13 @@
|
||||
return function (params) {
|
||||
// convert the choices from the API from the format
|
||||
// [["read", "Read Inventory"], ...] to
|
||||
// {name: "read", value: "Read Inventory", ...}
|
||||
return params.choices.reduce(function(obj, kvp) {
|
||||
// for now, remove adhoc from those choices
|
||||
if (kvp[0] !== adhoc) {
|
||||
return {name: kvp[0], value: kvp[1]};
|
||||
} else {
|
||||
return null;
|
||||
// [{name: "read", value: "Read Inventory"}, ...]
|
||||
return params.choices.filter(function (kvp) {
|
||||
return (kvp[0] !== "adhoc");
|
||||
}).map(function (kvp) {
|
||||
if (kvp[0] !== "adhoc") {
|
||||
return {name: kvp[1], value: kvp[0]};
|
||||
}
|
||||
}, {});
|
||||
});
|
||||
};
|
||||
}];
|
||||
|
||||
@ -38,16 +38,7 @@
|
||||
permission_type: {
|
||||
label: 'Permission',
|
||||
ngBind: 'getPermissionText()',
|
||||
searchType: 'select',
|
||||
searchOptions: [
|
||||
{ name: "Read Inventory", value: "read" },
|
||||
{ name: "Edit Inventory", value: "write" },
|
||||
{ name: "Administrate Inventory", value: "admin" },
|
||||
{ name: "Deploy to Inventory", value: "run" },
|
||||
{ name: "Deploy to Inventory (Dry Run)", value: "check" },
|
||||
{ name: "Scan an Inventory", value: "scan" },
|
||||
{ name: "Create a Job Template", value: "create" }
|
||||
]
|
||||
searchType: 'select'
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user