mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
Only assign name property if response has value
This commit is contained in:
parent
ac232fcff0
commit
a171bd7cee
@ -413,7 +413,22 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
||||
var results = data.data.results;
|
||||
if (results.length > 0) {
|
||||
scope[elm.attr('data-source')] = results[0].id;
|
||||
scope[elm.attr('name')] = results[0].name;
|
||||
|
||||
// For user lookups the API endpoint doesn't
|
||||
// have a `name` property, so this is `undefined`
|
||||
// which causes the input to clear after typing
|
||||
// a valid value O_o
|
||||
//
|
||||
// Only assign if there is a value, so that we avoid
|
||||
// this situation.
|
||||
//
|
||||
// TODO: Evaluate if assigning name on the scope is
|
||||
// even necessary at all.
|
||||
//
|
||||
if (!_.isEmpty(results[0].name)) {
|
||||
scope[elm.attr('name')] = results[0].name;
|
||||
}
|
||||
|
||||
ctrl.$setValidity('required', true);
|
||||
ctrl.$setValidity('awlookup', true);
|
||||
return viewValue;
|
||||
|
Loading…
Reference in New Issue
Block a user