diff --git a/awx/ui/static/js/controllers/Credentials.js b/awx/ui/static/js/controllers/Credentials.js index e26e70c5e0..b4fbff2e8a 100644 --- a/awx/ui/static/js/controllers/Credentials.js +++ b/awx/ui/static/js/controllers/Credentials.js @@ -14,6 +14,7 @@ function CredentialsList ($scope, $rootScope, $location, $log, $routeParams, Res GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, SelectionInit, GetChoices, Wait, Stream) { + ClearScope('tree-form'); ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior //scope. var list = CredentialList; @@ -61,7 +62,7 @@ function CredentialsList ($scope, $rootScope, $location, $log, $routeParams, Res if (scope.removeChoicesReady) { scope.removeChoicesReady(); } - scope.removeChoicesReady = scope.$on('choicesReady', function() { + scope.removeChoicesReady = scope.$on('choicesReadyCredential', function() { SearchInit({ scope: scope, set: 'credentials', list: list, url: defaultUrl }); PaginateInit({ scope: scope, list: list, url: defaultUrl }); scope.search(list.iterator); @@ -73,7 +74,7 @@ function CredentialsList ($scope, $rootScope, $location, $log, $routeParams, Res url: defaultUrl, field: 'kind', variable: 'credential_kind_options', - callback: 'choicesReady' + callback: 'choicesReadyCredential' }); @@ -124,6 +125,7 @@ function CredentialsAdd ($scope, $rootScope, $compile, $location, $log, $routePa GenerateList, SearchInit, PaginateInit, LookUpInit, UserList, TeamList, GetBasePath, GetChoices, Empty, KindChange, OwnerChange, FormSave, DebugForm) { + ClearScope('tree-form'); ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior //scope. @@ -256,6 +258,7 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP KindChange, UserList, TeamList, LookUpInit, Empty, OwnerChange, FormSave, Stream ) { + ClearScope('tree-form'); ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior //scope. @@ -324,7 +327,7 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP if (scope.removeChoicesReady) { scope.removeChoicesReady(); } - scope.removeChoicesReady = scope.$on('choicesReady', function() { + scope.removeChoicesReady = scope.$on('choicesReadyCredential', function() { // Retrieve detail record and prepopulate the form Rest.setUrl(defaultUrl + ':id/'); Rest.get({ params: {id: id} }) @@ -392,7 +395,7 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP url: defaultUrl, field: 'kind', variable: 'credential_kind_options', - callback: 'choicesReady' + callback: 'choicesReadyCredential' }); scope.showActivity = function() { Stream(); } diff --git a/awx/ui/static/js/controllers/JobTemplates.js b/awx/ui/static/js/controllers/JobTemplates.js index 0df423fd4f..d7f8b522db 100644 --- a/awx/ui/static/js/controllers/JobTemplates.js +++ b/awx/ui/static/js/controllers/JobTemplates.js @@ -483,6 +483,10 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route { hdr: 'Error!', msg: 'Failed to related cloud credential. GET returned status: ' + status }); }); } + else { + // No existing cloud credential + scope.$emit('cloudCredentialReady', null); + } }); // Retrieve detail record and prepopulate the form diff --git a/awx/ui/static/js/controllers/Projects.js b/awx/ui/static/js/controllers/Projects.js index 1caa72261e..9f4dfc8a50 100644 --- a/awx/ui/static/js/controllers/Projects.js +++ b/awx/ui/static/js/controllers/Projects.js @@ -15,8 +15,8 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, ClearScope, ProcessErrors, GetBasePath, SelectionInit, ProjectUpdate, ProjectStatus, FormatDate, Refresh, Wait, Stream, GetChoices) { - ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior - //scope. + ClearScope('tree-form'); + ClearScope('htmlTemplate'); var list = ProjectList; var defaultUrl = GetBasePath('projects'); @@ -84,7 +84,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, if (scope.removeChoicesHere) { scope.removeChoicesHere(); } - scope.removeChoicesHere = scope.$on('choicesHere', function() { + scope.removeChoicesHere = scope.$on('choicesCompleteProject', function() { list.fields.scm_type.searchOptions = scope.project_scm_type_options; list.fields.status.searchOptions = scope.project_status_options; @@ -130,10 +130,10 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, if (scope.removeChoicesReady) { scope.removeChoicesReady(); } - scope.removeChoicesReady = scope.$on('choicesReady', function() { + scope.removeChoicesReady = scope.$on('choicesReadyProject', function() { choiceCount++; if (choiceCount == 2) { - scope.$emit('choicesHere'); + scope.$emit('choicesCompleteProject'); } }); @@ -143,7 +143,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, url: defaultUrl, field: 'status', variable: 'project_status_options', - callback: 'choicesReady' + callback: 'choicesReadyProject' }); // Load the list of options for Kind @@ -152,7 +152,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, url: defaultUrl, field: 'scm_type', variable: 'project_scm_type_options', - callback: 'choicesReady' + callback: 'choicesReadyProject' }); LoadBreadCrumbs(); @@ -329,8 +329,8 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam GetBasePath, ReturnToCaller, GetProjectPath, LookUpInit, OrganizationList, CredentialList, GetChoices, DebugForm, Wait) { - ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior - //scope. + ClearScope('tree-form'); + ClearScope('htmlTemplate'); // Inject dynamic view var form = ProjectsForm; @@ -466,8 +466,8 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara RelatedPaginateInit, Prompt, ClearScope, GetBasePath, ReturnToCaller, GetProjectPath, Authorization, CredentialList, LookUpInit, GetChoices, Empty, DebugForm, Wait, Stream) { - ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior - //scope. + ClearScope('tree-form'); + ClearScope('htmlTemplate'); // Inject dynamic view var form = ProjectsForm; diff --git a/awx/ui/static/js/forms/JobTemplates.js b/awx/ui/static/js/forms/JobTemplates.js index 8119bdc08f..38084aff0b 100644 --- a/awx/ui/static/js/forms/JobTemplates.js +++ b/awx/ui/static/js/forms/JobTemplates.js @@ -103,8 +103,8 @@ angular.module('JobTemplateFormDefinition', []) sourceModel: 'credential', sourceField: 'name', ngClick: 'lookUpCredential()', - addRequired: true, - editRequired: true, + addRequired: false, + editRequired: false, column: 1, awPopOver: "

Select the credential you want the job to use when accessing the remote hosts. Choose the credential containing " + " the username and SSH key or password that Ansbile will need to log into the remote hosts.

", diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js index 9053747401..29c313e0de 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -719,18 +719,18 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' LookUpInit, CredentialList, Empty, Wait, GetChoices) { return function(params) { + $('#tree-form').hide().empty(); + var group_id = params.group_id; var inventory_id = params.inventory_id; var generator = GenerateForm; var form = GroupForm; var defaultUrl = GetBasePath('groups') + group_id + '/'; - - $('#tree-form').hide().empty(); - var element = angular.element(document.getElementById('tree-form')); - var scope = element.scope(); + var scope = generator.inject(form, + { mode: 'edit', modal: false, related: false, id: 'tree-form', breadCrumbs: false }); + generator.reset(); - //var scope = generator.inject(form, { mode: 'edit', modal: false, related: false, id: 'tree-form', breadCrumbs: false }); var master = {}; var relatedSets = {}; @@ -892,12 +892,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' if (scope.removeChoicesComplete) { scope.removeChoicesComplete(); } - scope.removeChoicesComplete = scope.$on('choicesComplete', function() { - - generator.inject(form, { mode: 'edit', modal: false, related: false, id: 'tree-form', - breadCrumbs: false, scope: scope }); - generator.reset(); - + scope.removeChoicesComplete = scope.$on('choicesCompleteGroup', function() { // Retrieve detail record and prepopulate the form Rest.setUrl(defaultUrl); Rest.get() @@ -929,10 +924,10 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' if (scope.removeChoicesReady) { scope.removeChoicesReady(); } - scope.removeChoicesReady = scope.$on('choicesReady', function() { + scope.removeChoicesReady = scope.$on('choicesReadyGroup', function() { choicesReady++; if (choicesReady == 2) { - scope.$emit('choicesComplete'); + scope.$emit('choicesCompleteGroup'); } }); @@ -943,7 +938,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' field: 'source_regions', variable: 'rax_regions', choice_name: 'rax_region_choices', - callback: 'choicesReady' + callback: 'choicesReadyGroup' }); GetChoices({ @@ -952,7 +947,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' field: 'source_regions', variable: 'ec2_regions', choice_name: 'ec2_region_choices', - callback: 'choicesReady' + callback: 'choicesReadyGroup' }); if (!scope.$$phase) { diff --git a/awx/ui/static/lib/ansible/Utilities.js b/awx/ui/static/lib/ansible/Utilities.js index 51ddeb6f2a..a03ecfe797 100644 --- a/awx/ui/static/lib/ansible/Utilities.js +++ b/awx/ui/static/lib/ansible/Utilities.js @@ -9,9 +9,12 @@ angular.module('Utilities',['RestServices', 'Utilities']) .factory('ClearScope', [ function() { return function(id) { + var element = document.getElementById(id); - var scope = angular.element(element).scope(); - scope.$destroy(); + if (element) { + var scope = angular.element(element).scope(); + scope.$destroy(); + } $('.tooltip').each( function(index) { // Remove any lingering tooltip and popover
elements @@ -378,7 +381,7 @@ angular.module('Utilities',['RestServices', 'Utilities']) }).fadeIn(400); } else if (directive == 'stop' && $rootScope.waiting){ - $('.spinny, .overlay').fadeOut(800, function(){ $rootScope.waiting = false; }); + $('.spinny, .overlay').fadeOut(400, function(){ $rootScope.waiting = false; }); } } }]) diff --git a/awx/ui/static/lib/ansible/form-generator.js b/awx/ui/static/lib/ansible/form-generator.js index e10d3a4ed7..7e6bc12025 100644 --- a/awx/ui/static/lib/ansible/form-generator.js +++ b/awx/ui/static/lib/ansible/form-generator.js @@ -25,6 +25,8 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies', 'Utilities']) accordion_count: 0, + scope: null, + has: function(key) { return (this.form[key] && this.form[key] != null && this.form[key] != undefined) ? true : false; }, diff --git a/awx/ui/static/lib/ansible/generator-helpers.js b/awx/ui/static/lib/ansible/generator-helpers.js index b9bef2f41a..0f35ef77b7 100644 --- a/awx/ui/static/lib/ansible/generator-helpers.js +++ b/awx/ui/static/lib/ansible/generator-helpers.js @@ -498,7 +498,7 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers']) html += "
\n"; html += "