mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 11:20:39 -03:30
adding options callback for project type labels
This commit is contained in:
parent
4ce69f2f9c
commit
a36ce01537
@ -123,6 +123,36 @@ export default ['addPermissionsTeamsList', 'addPermissionsUsersList', 'TemplateL
|
||||
_.forEach(scope[`${list.name}`], isSelected);
|
||||
});
|
||||
|
||||
scope.$on(`${list.iterator}_options`, function(event, data){
|
||||
scope.options = data.data.actions.GET;
|
||||
optionsRequestDataProcessing();
|
||||
});
|
||||
|
||||
// iterate over the list and add fields like type label, after the
|
||||
// OPTIONS request returns, or the list is sorted/paginated/searched
|
||||
function optionsRequestDataProcessing(){
|
||||
if(scope.list.name === 'projects'){
|
||||
if (scope[list.name] !== undefined) {
|
||||
scope[list.name].forEach(function(item, item_idx) {
|
||||
var itm = scope[list.name][item_idx];
|
||||
|
||||
// Set the item type label
|
||||
if (list.fields.scm_type && scope.options &&
|
||||
scope.options.hasOwnProperty('scm_type')) {
|
||||
scope.options.scm_type.choices.every(function(choice) {
|
||||
if (choice[0] === item.scm_type) {
|
||||
itm.type_label = choice[1];
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isSelected(item){
|
||||
if(_.find(scope.allSelected, {id: item.id, type: item.type})){
|
||||
item.isSelected = true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user