mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 04:10:44 -03:30
Add comments and minor changes from PR feedback
This commit is contained in:
parent
6239df6778
commit
6a7e018100
@ -70,6 +70,11 @@ function EditCredentialsController (models, $state, $scope, strings) {
|
||||
_key: 'inputs'
|
||||
};
|
||||
|
||||
/**
|
||||
* If a credential's `credential_type` is changed while editing, the inputs associated with
|
||||
* the old type need to be cleared before saving the inputs associated with the new type.
|
||||
* Otherwise inputs are merged together making the request invalid.
|
||||
*/
|
||||
vm.form.save = data => {
|
||||
data.user = me.getSelf().id;
|
||||
credential.unset('inputs');
|
||||
|
||||
@ -81,6 +81,10 @@ function AtInputLookupController (baseInputController, $q, $state, $stateParams)
|
||||
vm.search = () => {
|
||||
scope.state._touched = true;
|
||||
|
||||
if (scope.state._displayValue === '' && !scope.state._required) {
|
||||
return vm.check({ isValid: true });
|
||||
}
|
||||
|
||||
return model.search({ [search.key]: scope.state._displayValue }, search.config)
|
||||
.then(found => {
|
||||
if (!found) {
|
||||
@ -105,8 +109,6 @@ function AtInputLookupController (baseInputController, $q, $state, $stateParams)
|
||||
return vm.resetDebounce();
|
||||
}
|
||||
|
||||
scope.state._touched = true;
|
||||
|
||||
vm.searchAfterDebounce();
|
||||
};
|
||||
}
|
||||
|
||||
@ -11,6 +11,19 @@ function request (method, resource) {
|
||||
return this.http[method](resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Intended to be useful in searching and filtering results using params
|
||||
* supported by the API.
|
||||
*
|
||||
* @param {object} params - An object of keys and values to to format and
|
||||
* to the URL as a query string. Refer to the API documentation for the
|
||||
* resource in use for specifics.
|
||||
* @param {object} config - Configuration specific to the UI to accommodate
|
||||
* common use cases.
|
||||
*
|
||||
* @returns {Promise} - $http
|
||||
* @yields {(Boolean|object)}
|
||||
*/
|
||||
function search (params, config) {
|
||||
let req = {
|
||||
method: 'GET',
|
||||
@ -19,19 +32,19 @@ function search (params, config) {
|
||||
};
|
||||
|
||||
return $http(req)
|
||||
.then(res => {
|
||||
if (!res.data.count) {
|
||||
.then(({ data }) => {
|
||||
if (!data.count) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (config.unique) {
|
||||
if (res.data.count !== 1) {
|
||||
if (data.count !== 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.model.GET = res.data.results[0];
|
||||
this.model.GET = data.results[0];
|
||||
} else {
|
||||
this.model.GET = res.data;
|
||||
this.model.GET = data;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user