diff --git a/awx/ui/client/src/forms/Projects.js b/awx/ui/client/src/forms/Projects.js index 2185381e69..d5f165bce8 100644 --- a/awx/ui/client/src/forms/Projects.js +++ b/awx/ui/client/src/forms/Projects.js @@ -137,6 +137,7 @@ angular.module('ProjectFormDefinition', ['SchedulesListDefinition']) }, ngShow: "scm_type && scm_type.value !== 'manual'", sourceModel: 'credential', + awLookupType: 'scm_credential', sourceField: 'name', ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)', subForm: 'sourceSubForm' diff --git a/awx/ui/client/src/shared/directives.js b/awx/ui/client/src/shared/directives.js index 1dcfb7ac62..ee67afcc90 100644 --- a/awx/ui/client/src/shared/directives.js +++ b/awx/ui/client/src/shared/directives.js @@ -482,6 +482,7 @@ function(ConfigurationUtils, i18n, $rootScope) { autopopulateLookup, modelKey = attrs.ngModel, modelName = attrs.source, + lookupType = attrs.awlookuptype, watcher = attrs.awRequiredWhen || undefined, watchBasePath; @@ -516,10 +517,14 @@ function(ConfigurationUtils, i18n, $rootScope) { } else { basePath = GetBasePath(elm.attr('data-basePath')) || elm.attr('data-basePath'); - switch(modelName) { + let switchType = lookupType ? lookupType : modelName; + switch(switchType) { case 'credential': query = '?kind=ssh&role_level=use_role'; break; + case 'scm_credential': + query = '?kind=scm&role_level=use_role'; + break; case 'network_credential': query = '?kind=net&role_level=use_role'; break; @@ -596,12 +601,12 @@ function(ConfigurationUtils, i18n, $rootScope) { function applyValidationStrategy(viewValue, ctrl) { // use supplied data attributes to build an endpoint, query, resolve outstanding promise - function applyValidation(viewValue) { + function applyValidation(viewValue) {console.log(viewValue); basePath = GetBasePath(elm.attr('data-basePath')) || elm.attr('data-basePath'); query = elm.attr('data-query'); query = query.replace(/\:value/, encodeURIComponent(viewValue)); - let base = ctrl.$name.split('_name')[0]; + let base = lookupType ? lookupType : ctrl.$name.split('_name')[0]; if (attrs.watchbasepath !== undefined && scope[attrs.watchbasepath] !== undefined) { basePath = scope[attrs.watchbasepath]; query += '&role_level=use_role'; @@ -612,6 +617,9 @@ function(ConfigurationUtils, i18n, $rootScope) { case 'credential': query += '&kind=ssh&role_level=use_role'; break; + case 'scm_credential': + query += '&kind=scm&role_level=use_role'; + break; case 'network_credential': query += '&kind=net&role_level=use_role'; break; diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index 600675f341..a1a2a6761f 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -1384,6 +1384,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += `data-basePath="${field.basePath}"`; html += `data-source="${field.sourceModel}"`; html += `data-query="?${field.sourceField}__iexact=:value"`; + html += (field.awLookupType !== undefined) ? ` data-awLookupType=${field.awLookupType} ` : ""; html += (field.autopopulateLookup !== undefined) ? ` autopopulateLookup=${field.autopopulateLookup} ` : ""; html += (field.watchBasePath !== undefined) ? ` watchBasePath=${field.watchBasePath} ` : ""; html += `ng-model-options="{ updateOn: 'default blur', debounce: { 'default': 300, 'blur': 0 } }"`;