diff --git a/awx/ui/client/features/credentials/add-credentials.controller.js b/awx/ui/client/features/credentials/add-credentials.controller.js
index c28ca76e56..65c2c9db00 100644
--- a/awx/ui/client/features/credentials/add-credentials.controller.js
+++ b/awx/ui/client/features/credentials/add-credentials.controller.js
@@ -1,12 +1,11 @@
const DEFAULT_ORGANIZATION_PLACEHOLDER = 'SELECT AN ORGANIZATION';
-function AddCredentialsController (models, organizationList, $state) {
+function AddCredentialsController (models, $state) {
let vm = this || {};
let me = models.me;
let credential = models.credential;
let credentialType = models.credentialType;
- let organization = models.organization;
vm.panelTitle = 'NEW CREDENTIAL';
@@ -23,8 +22,8 @@ function AddCredentialsController (models, organizationList, $state) {
omit: ['user', 'team', 'inputs']
});
- vm.form.organization._model = organization;
- vm.form.organization._placeholder = DEFAULT_ORGANIZATION_PLACEHOLDER;
+ vm.form.organization._resource = 'organization';
+ vm.form.organization._route = 'credentials.add.organization';
vm.form.credential_type._data = credentialType.get('results');
vm.form.credential_type._placeholder = 'SELECT A TYPE';
@@ -53,7 +52,6 @@ function AddCredentialsController (models, organizationList, $state) {
AddCredentialsController.$inject = [
'resolvedModels',
- 'OrganizationList',
'$state'
];
diff --git a/awx/ui/client/features/credentials/index.js b/awx/ui/client/features/credentials/index.js
index 7a74b39657..8c4be51780 100644
--- a/awx/ui/client/features/credentials/index.js
+++ b/awx/ui/client/features/credentials/index.js
@@ -3,13 +3,12 @@ import AddController from './add-credentials.controller.js';
import EditController from './edit-credentials.controller.js';
import { N_ } from '../../src/i18n';
-function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType, Organization) {
+function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType) {
let id = $stateParams.credential_id;
let promises = {
me: new Me('get'),
- credentialType: new CredentialType('get'),
- organization: new Organization('get')
+ credentialType: new CredentialType('get')
};
if (id) {
@@ -26,8 +25,7 @@ CredentialsResolve.$inject = [
'$stateParams',
'MeModel',
'CredentialModel',
- 'CredentialTypeModel',
- 'OrganizationModel'
+ 'CredentialTypeModel'
];
function CredentialsConfig ($stateExtenderProvider, legacyProvider, pathProvider) {
diff --git a/awx/ui/client/lib/components/input/lookup.directive.js b/awx/ui/client/lib/components/input/lookup.directive.js
index 0b520136c7..2069789b82 100644
--- a/awx/ui/client/lib/components/input/lookup.directive.js
+++ b/awx/ui/client/lib/components/input/lookup.directive.js
@@ -2,9 +2,6 @@ function atInputLookupLink (scope, element, attrs, controllers) {
let formController = controllers[0];
let inputController = controllers[1];
- scope.ns = 'lookup';
- scope[scope.ns] = { modal: {} };
-
if (scope.tab === '1') {
element.find('input')[0].focus();
}
@@ -16,27 +13,30 @@ function AtInputLookupController (baseInputController, $state) {
let vm = this || {};
let scope;
- let modal;
vm.init = (_scope_, element, form) => {
baseInputController.call(vm, 'input', _scope_, element, form);
scope = _scope_;
- scope.$watch('organization', () => {
- if (scope.organization) {
- scope.state._value = scope.organization;
- scope.state._displayValue = scope.organization_name;
+ scope.$watch(scope.state._resource, () => {
+ if (scope[scope.state._resource]) {
+ scope.state._value = scope[scope.state._resource];
+ scope.state._displayValue = scope[`${scope.state._resource}_name`];
}
});
- modal = scope.lookup.modal;
-
vm.check();
};
vm.search = () => {
- $state.go('credentials.add.organization');
+ let params = {};
+
+ if (scope.state._value) {
+ params.selected = scope.state._value;
+ }
+
+ $state.go(scope.state._route, params);
};
}
diff --git a/awx/ui/client/lib/components/input/lookup.partial.html b/awx/ui/client/lib/components/input/lookup.partial.html
index 6f5797486b..6f4d7a0a68 100644
--- a/awx/ui/client/lib/components/input/lookup.partial.html
+++ b/awx/ui/client/lib/components/input/lookup.partial.html
@@ -23,5 +23,5 @@