From b904dd2ae5a630e157950adbd9724fd7bf5b22c3 Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Tue, 30 Jul 2013 02:09:21 -0400 Subject: [PATCH] AC-301,AC-316 Initialize scope keys in both list generator and form generator. --- awx/ui/static/js/controllers/Authentication.js | 2 +- awx/ui/static/lib/ansible/authenticate.js | 12 ++---------- awx/ui/static/lib/ansible/form-generator.js | 8 ++++++++ awx/ui/static/lib/ansible/list-generator.js | 4 ++++ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/awx/ui/static/js/controllers/Authentication.js b/awx/ui/static/js/controllers/Authentication.js index d3fd4eb7cc..1385ef69f2 100644 --- a/awx/ui/static/js/controllers/Authentication.js +++ b/awx/ui/static/js/controllers/Authentication.js @@ -30,7 +30,7 @@ function Authenticate($window, $scope, $rootScope, $location, Authorization, Tog $scope.sessionExpired = false; } - $rootScope.userLoggedIn = false; //hide the logout link. if you got here, your logged out. + $rootScope.userLoggedIn = false; //hide the logout link. if you got here, you're logged out. //gets set back to true by Authorization.setToken(). $('#login-password').bind('keypress', function(e) { diff --git a/awx/ui/static/lib/ansible/authenticate.js b/awx/ui/static/lib/ansible/authenticate.js index 6b900db3e5..697cfa5ac6 100644 --- a/awx/ui/static/lib/ansible/authenticate.js +++ b/awx/ui/static/lib/ansible/authenticate.js @@ -5,9 +5,8 @@ * */ -angular.module('AuthService', ['ngCookies', 'OrganizationFormDefinition']) - .factory('Authorization', ['$http', '$rootScope', '$location', '$cookieStore', 'OrganizationForm', - function($http, $rootScope, $location, $cookieStore, OrganizationForm) { +angular.module('AuthService', ['ngCookies']) + .factory('Authorization', ['$http', '$rootScope', '$location', '$cookieStore', function($http, $rootScope, $location, $cookieStore) { return { setToken: function(token) { // set the session cookie @@ -73,13 +72,6 @@ angular.module('AuthService', ['ngCookies', 'OrganizationFormDefinition']) scope.$destroy(); $rootScope.$destroy(); - // Reset the scope for organizations. No matter what we have tried, nothing seems - // to clear the scope fast enough to prevent prior user's content from displaying - $rootScope['organizations'] = null; - for (var set in OrganizationForm.related) { - $rootScope[set] = null; - } - $cookieStore.remove('accordions'); $cookieStore.remove('token'); $cookieStore.remove('token_expire'); diff --git a/awx/ui/static/lib/ansible/form-generator.js b/awx/ui/static/lib/ansible/form-generator.js index e427e353b1..0da879d8c3 100644 --- a/awx/ui/static/lib/ansible/form-generator.js +++ b/awx/ui/static/lib/ansible/form-generator.js @@ -52,6 +52,14 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies']) this.scope = element.scope(); // Set scope specific to the element we're compiling, avoids circular reference // From here use 'scope' to manipulate the form, as the form is not in '$scope' $compile(element)(this.scope); + + // Reset the scope to prevent displaying old data from our last visit to this form + for (var fld in form.fields) { + this.scope[fld] = null; + } + for (var set in form.related) { + this.scope[set] = null; + } if ( ((!options.modal) && options.related) || this.form.forceListeners ) { this.addListeners(); diff --git a/awx/ui/static/lib/ansible/list-generator.js b/awx/ui/static/lib/ansible/list-generator.js index 5be1ffe29d..464fdffd92 100644 --- a/awx/ui/static/lib/ansible/list-generator.js +++ b/awx/ui/static/lib/ansible/list-generator.js @@ -79,6 +79,10 @@ angular.module('ListGenerator', ['GeneratorHelpers']) // From here use 'scope' to manipulate the form, as the form is not in '$scope' $compile(element)(this.scope); + // Reset the scope to prevent displaying old data from our last visit to this list + this.scope[list.name] = null; + this.scope[list.iterator] = null; + if (options.mode == 'lookup') { // options should include {hdr: , action: } this.scope.lookupHeader = options.hdr;