From a845904bd78b329d49ca2b6bc6747d60408d8445 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Fri, 15 Jul 2016 12:00:26 -0400 Subject: [PATCH] Rolled back the onExit solution previously implemented to handle the backspace navigation on the job launch modal. New solution listens for state changes within the directive and cleans itself up. --- awx/ui/client/src/app.js | 20 ------------------- .../host-summary/host-summary.route.js | 10 ---------- .../client/src/job-detail/job-detail.route.js | 12 +---------- .../job-submission.directive.js | 6 ++++++ .../add/job-templates-add.route.js | 8 +------- .../edit/job-templates-edit.route.js | 8 +------- .../list/job-templates-list.route.js | 10 ---------- .../linkout/organizations-linkout.route.js | 10 ---------- .../src/portal-mode/portal-mode.route.js | 10 ---------- 9 files changed, 9 insertions(+), 85 deletions(-) diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index 0698a2fdbb..e25d53ac51 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -255,16 +255,6 @@ var tower = angular.module('Tower', [ }); }); }] - }, - onExit: function(){ - // close the job launch modal - // using an onExit event to handle cases where the user navs away using the url bar / back and not modal "X" - // Destroy the dialog - if($("#job-launch-modal").hasClass('ui-dialog-content')) { - $('#job-launch-modal').dialog('destroy'); - } - // Remove the directive from the page (if it's there) - $('#content-container').find('submit-job').remove(); } }). @@ -274,16 +264,6 @@ var tower = angular.module('Tower', [ controller: JobsListController, ncyBreadcrumb: { label: "JOBS" - }, - onExit: function(){ - // close the job launch modal - // using an onExit event to handle cases where the user navs away using the url bar / back and not modal "X" - // Destroy the dialog - if($("#job-launch-modal").hasClass('ui-dialog-content')) { - $('#job-launch-modal').dialog('destroy'); - } - // Remove the directive from the page (if it's there) - $('#content-container').find('submit-job').remove(); } }). diff --git a/awx/ui/client/src/job-detail/host-summary/host-summary.route.js b/awx/ui/client/src/job-detail/host-summary/host-summary.route.js index f7722462a0..a2de70e5d4 100644 --- a/awx/ui/client/src/job-detail/host-summary/host-summary.route.js +++ b/awx/ui/client/src/job-detail/host-summary/host-summary.route.js @@ -17,15 +17,5 @@ export default { }, ncyBreadcrumb: { skip: true // Never display this state in breadcrumb. - }, - onExit: function(){ - // close the job launch modal - // using an onExit event to handle cases where the user navs away using the url bar / back and not modal "X" - // Destroy the dialog - if($("#job-launch-modal").hasClass('ui-dialog-content')) { - $('#job-launch-modal').dialog('destroy'); - } - // Remove the directive from the page (if it's there) - $('#content-container').find('submit-job').remove(); } }; diff --git a/awx/ui/client/src/job-detail/job-detail.route.js b/awx/ui/client/src/job-detail/job-detail.route.js index bf21fb8e5a..dda2722511 100644 --- a/awx/ui/client/src/job-detail/job-detail.route.js +++ b/awx/ui/client/src/job-detail/job-detail.route.js @@ -30,15 +30,5 @@ export default { }] }, templateUrl: templateUrl('job-detail/job-detail'), - controller: 'JobDetailController', - onExit: function(){ - // close the job launch modal - // using an onExit event to handle cases where the user navs away using the url bar / back and not modal "X" - // Destroy the dialog - if($("#job-launch-modal").hasClass('ui-dialog-content')) { - $('#job-launch-modal').dialog('destroy'); - } - // Remove the directive from the page (if it's there) - $('#content-container').find('submit-job').remove(); - } + controller: 'JobDetailController' }; diff --git a/awx/ui/client/src/job-submission/job-submission.directive.js b/awx/ui/client/src/job-submission/job-submission.directive.js index bd1c90ff92..26a3d9c826 100644 --- a/awx/ui/client/src/job-submission/job-submission.directive.js +++ b/awx/ui/client/src/job-submission/job-submission.directive.js @@ -89,6 +89,12 @@ export default [ 'templateUrl', 'CreateDialog', 'Wait', 'CreateSelect2', 'ParseT } }; + scope.$on("$stateChangeStart", function() { + scope.$evalAsync(function( scope ) { + scope.clearDialog(); + }); + }); + scope.init(); } diff --git a/awx/ui/client/src/job-templates/add/job-templates-add.route.js b/awx/ui/client/src/job-templates/add/job-templates-add.route.js index 8218cabc32..68275c0f22 100644 --- a/awx/ui/client/src/job-templates/add/job-templates-add.route.js +++ b/awx/ui/client/src/job-templates/add/job-templates-add.route.js @@ -16,14 +16,8 @@ export default { label: "CREATE JOB TEMPLATE" }, onExit: function(){ - // close the job launch modal + // close the survey maker modal // using an onExit event to handle cases where the user navs away using the url bar / back and not modal "X" - // Destroy the dialog - if($("#job-launch-modal").hasClass('ui-dialog-content')) { - $('#job-launch-modal').dialog('destroy'); - } - // Remove the directive from the page (if it's there) - $('#content-container').find('submit-job').remove(); if($("#survey-modal-dialog").hasClass('ui-dialog-content')) { $('#survey-modal-dialog').dialog('destroy'); diff --git a/awx/ui/client/src/job-templates/edit/job-templates-edit.route.js b/awx/ui/client/src/job-templates/edit/job-templates-edit.route.js index 78d383fa42..b2dffa229b 100644 --- a/awx/ui/client/src/job-templates/edit/job-templates-edit.route.js +++ b/awx/ui/client/src/job-templates/edit/job-templates-edit.route.js @@ -19,14 +19,8 @@ export default { label: "{{name}}" }, onExit: function(){ - // close the job launch modal + // close the survey maker modal // using an onExit event to handle cases where the user navs away using the url bar / back and not modal "X" - // Destroy the dialog - if($("#job-launch-modal").hasClass('ui-dialog-content')) { - $('#job-launch-modal').dialog('destroy'); - } - // Remove the directive from the page (if it's there) - $('#content-container').find('submit-job').remove(); if($("#survey-modal-dialog").hasClass('ui-dialog-content')) { $('#survey-modal-dialog').dialog('destroy'); diff --git a/awx/ui/client/src/job-templates/list/job-templates-list.route.js b/awx/ui/client/src/job-templates/list/job-templates-list.route.js index 6c646af729..deeb1982bd 100644 --- a/awx/ui/client/src/job-templates/list/job-templates-list.route.js +++ b/awx/ui/client/src/job-templates/list/job-templates-list.route.js @@ -17,15 +17,5 @@ export default { }, ncyBreadcrumb: { label: "JOB TEMPLATES" - }, - onExit: function(){ - // close the job launch modal - // using an onExit event to handle cases where the user navs away using the url bar / back and not modal "X" - // Destroy the dialog - if($("#job-launch-modal").hasClass('ui-dialog-content')) { - $('#job-launch-modal').dialog('destroy'); - } - // Remove the directive from the page (if it's there) - $('#content-container').find('submit-job').remove(); } }; diff --git a/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js b/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js index caa8d7692f..13d51cc68f 100644 --- a/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js +++ b/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js @@ -121,16 +121,6 @@ export default [ features: ['FeaturesService', function(FeaturesService) { return FeaturesService.get(); }] - }, - onExit: function(){ - // close the job launch modal - // using an onExit event to handle cases where the user navs away using the url bar / back and not modal "X" - // Destroy the dialog - if($("#job-launch-modal").hasClass('ui-dialog-content')) { - $('#job-launch-modal').dialog('destroy'); - } - // Remove the directive from the page (if it's there) - $('#content-container').find('submit-job').remove(); } }, { diff --git a/awx/ui/client/src/portal-mode/portal-mode.route.js b/awx/ui/client/src/portal-mode/portal-mode.route.js index 6982f10620..c0f7e5f3fb 100644 --- a/awx/ui/client/src/portal-mode/portal-mode.route.js +++ b/awx/ui/client/src/portal-mode/portal-mode.route.js @@ -24,15 +24,5 @@ export default { templateUrl: templateUrl('portal-mode/portal-mode-jobs'), controller: PortalModeJobsController } - }, - onExit: function(){ - // close the job launch modal - // using an onExit event to handle cases where the user navs away using the url bar / back and not modal "X" - // Destroy the dialog - if($("#job-launch-modal").hasClass('ui-dialog-content')) { - $('#job-launch-modal').dialog('destroy'); - } - // Remove the directive from the page (if it's there) - $('#content-container').find('submit-job').remove(); } };