Fixed bug where typing in scm credential when adding/editing project wouldn't work

This commit is contained in:
Michael Abashian 2017-03-01 14:12:03 -05:00
parent 87da7d6a93
commit 2610009b56
3 changed files with 13 additions and 3 deletions

View File

@ -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'

View File

@ -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;

View File

@ -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 } }"`;