mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
Add comments and minor changes from PR feedback
This commit is contained in:
@@ -70,6 +70,11 @@ function EditCredentialsController (models, $state, $scope, strings) {
|
|||||||
_key: 'inputs'
|
_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 => {
|
vm.form.save = data => {
|
||||||
data.user = me.getSelf().id;
|
data.user = me.getSelf().id;
|
||||||
credential.unset('inputs');
|
credential.unset('inputs');
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ function AtInputLookupController (baseInputController, $q, $state, $stateParams)
|
|||||||
vm.search = () => {
|
vm.search = () => {
|
||||||
scope.state._touched = true;
|
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)
|
return model.search({ [search.key]: scope.state._displayValue }, search.config)
|
||||||
.then(found => {
|
.then(found => {
|
||||||
if (!found) {
|
if (!found) {
|
||||||
@@ -105,8 +109,6 @@ function AtInputLookupController (baseInputController, $q, $state, $stateParams)
|
|||||||
return vm.resetDebounce();
|
return vm.resetDebounce();
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.state._touched = true;
|
|
||||||
|
|
||||||
vm.searchAfterDebounce();
|
vm.searchAfterDebounce();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,19 @@ function request (method, resource) {
|
|||||||
return this.http[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) {
|
function search (params, config) {
|
||||||
let req = {
|
let req = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -19,19 +32,19 @@ function search (params, config) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return $http(req)
|
return $http(req)
|
||||||
.then(res => {
|
.then(({ data }) => {
|
||||||
if (!res.data.count) {
|
if (!data.count) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.unique) {
|
if (config.unique) {
|
||||||
if (res.data.count !== 1) {
|
if (data.count !== 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.model.GET = res.data.results[0];
|
this.model.GET = data.results[0];
|
||||||
} else {
|
} else {
|
||||||
this.model.GET = res.data;
|
this.model.GET = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user