diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js index 96c04b7eac..e8e8e41f09 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js @@ -18,8 +18,9 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition', init(); function init() { + $scope.mode = 'add'; // apply form definition's default field values - GenerateForm.applyDefaults(form, $scope); + GenerateForm.applyDefaults(form, $scope, true); $scope.canAdd = inventorySourcesOptions.actions.POST; $scope.envParseType = 'yaml'; initSources(); @@ -118,7 +119,6 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition', }); }; - $scope.projectBasePath = GetBasePath('projects'); $scope.credentialBasePath = GetBasePath('credentials') + '?credential_type__kind__in=cloud,network'; $scope.sourceChange = function(source) { @@ -144,10 +144,11 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition', } if (source === 'scm') { - $scope.overwrite_vars = true; - $scope.inventory_source_form.inventory_file.$setPristine(); + $scope.projectBasePath = GetBasePath('projects'); + $scope.overwrite_vars = true; + $scope.inventory_source_form.inventory_file.$setPristine(); } else { - $scope.overwrite_vars = false; + $scope.overwrite_vars = false; } // reset fields diff --git a/awx/ui/client/src/shared/directives.js b/awx/ui/client/src/shared/directives.js index 4fff94bca1..2967ffaba5 100644 --- a/awx/ui/client/src/shared/directives.js +++ b/awx/ui/client/src/shared/directives.js @@ -564,10 +564,6 @@ function(ConfigurationUtils, i18n, $rootScope) { _doAutoPopulate(); } }); - - if (attrs.watchbasepath === 'projectBasePath') { - _doAutoPopulate(); - } } function _doAutoPopulate() { diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index ff3bcbf568..10923c5329 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -375,11 +375,13 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat return this.build(options); }, - applyDefaults: function (form, scope) { - // Note: This is a hack. Ideally, mode should be set in each -.controller.js - // The mode is needed by the awlookup directive to auto-populate form fields when there is a - // single related resource. - scope.mode = this.mode; + applyDefaults: function (form, scope, ignoreMode) { + if(!ignoreMode) { + // Note: This is a hack. Ideally, mode should be set in each -.controller.js + // The mode is needed by the awlookup directive to auto-populate form fields when there is a + // single related resource. + scope.mode = this.mode; + } for (var fld in form.fields) { if (form.fields[fld]['default'] || form.fields[fld]['default'] === 0) {