From e943ae59b7f6932bc38ade07709bd144f0d4ccf8 Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Mon, 1 Apr 2019 15:49:41 -0400 Subject: [PATCH 1/5] auto-focus first input in jt launch modal --- .../other-prompts/prompt-other-prompts.controller.js | 9 ++++++++- .../other-prompts/prompt-other-prompts.directive.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.controller.js b/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.controller.js index 32ab75c786..b4b4fa4337 100644 --- a/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.controller.js +++ b/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.controller.js @@ -12,7 +12,7 @@ export default let scope; - vm.init = (_scope_) => { + vm.init = (_scope_, controller, el) => { scope = _scope_; scope.parseType = 'yaml'; @@ -102,6 +102,13 @@ export default return ToJSON(scope.parseType, scope.extraVariables, true); } scope.validate = validate; + + angular.element(el).ready(() => { + const inputs = el.find('input, select'); + if (inputs.length) { + inputs.get(0).focus(); + } + }); }; diff --git a/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.directive.js b/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.directive.js index 361f60e145..38ac48ef6b 100644 --- a/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.directive.js +++ b/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.directive.js @@ -28,7 +28,7 @@ export default [ 'templateUrl', const launchController = controllers[0]; const promptOtherPromptsController = controllers[1]; - promptOtherPromptsController.init(scope, launchController); + promptOtherPromptsController.init(scope, launchController, el); } }; }]; From e5f48bfa62b6f21a86f2cec7ab97b8ca96cc1186 Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Tue, 2 Apr 2019 11:10:02 -0400 Subject: [PATCH 2/5] set focus on first input in modal when launching jt --- .../src/templates/prompt/prompt.controller.js | 1 + .../src/templates/prompt/prompt.partial.html | 6 +++--- .../prompt-other-prompts.controller.js | 18 ++++++++++++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/awx/ui/client/src/templates/prompt/prompt.controller.js b/awx/ui/client/src/templates/prompt/prompt.controller.js index fedbbd2045..9612828b6b 100644 --- a/awx/ui/client/src/templates/prompt/prompt.controller.js +++ b/awx/ui/client/src/templates/prompt/prompt.controller.js @@ -216,6 +216,7 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f } else if(vm.steps[step].tab.order === currentTab.order + 1) { vm.steps[step].tab._active = true; vm.steps[step].tab._disabled = false; + scope.$broadcast('promptTabChange', { step }); } } }); diff --git a/awx/ui/client/src/templates/prompt/prompt.partial.html b/awx/ui/client/src/templates/prompt/prompt.partial.html index dc3ad632c2..68b8ad7086 100644 --- a/awx/ui/client/src/templates/prompt/prompt.partial.html +++ b/awx/ui/client/src/templates/prompt/prompt.partial.html @@ -10,9 +10,9 @@
- + prompt-data="vm.promptDataClone" + read-only-prompts="vm.readOnlyPrompts"> +
{ - const inputs = el.find('input, select'); + function focusFirstInput () { + const inputs = el.find('input[type=text], select, textarea:visible, .CodeMirror textarea'); if (inputs.length) { inputs.get(0).focus(); } + } + + angular.element(el).ready(() => { + focusFirstInput(); + }); + + scope.$on('promptTabChange', (event, args) => { + if (args.step === 'other_prompts') { + angular.element(el).ready(() => { + focusFirstInput(); + }); + } }); }; - - vm.toggleDiff = () => { scope.promptData.prompts.diffMode.value = !scope.promptData.prompts.diffMode.value; }; From 5b2f00b9786c1efd43b30cae12d33c02b2fc20de Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Tue, 2 Apr 2019 13:26:31 -0400 Subject: [PATCH 3/5] make Enter key navigate to next tab in launch modal --- .../src/templates/prompt/prompt.controller.js | 14 +++++++++++++- .../src/templates/prompt/prompt.directive.js | 2 +- .../src/templates/prompt/prompt.partial.html | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/awx/ui/client/src/templates/prompt/prompt.controller.js b/awx/ui/client/src/templates/prompt/prompt.controller.js index 9612828b6b..3cb6af385c 100644 --- a/awx/ui/client/src/templates/prompt/prompt.controller.js +++ b/awx/ui/client/src/templates/prompt/prompt.controller.js @@ -7,8 +7,9 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f let scope; let modal; + let activeTab; - vm.init = (_scope_) => { + vm.init = (_scope_, el) => { scope = _scope_; ({ modal } = scope[scope.ns]); @@ -137,6 +138,7 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f _active: true, order: order }; + activeTab = activeTab || vm.steps.inventory.tab; order++; } if (vm.promptDataClone.launchConf.ask_credential_on_launch || @@ -152,6 +154,7 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f _disabled: (order === 1 || vm.readOnlyPrompts) ? false : true, order: order }; + activeTab = activeTab || vm.steps.credentials.tab; order++; } if(vm.promptDataClone.launchConf.ask_verbosity_on_launch || vm.promptDataClone.launchConf.ask_job_type_on_launch || vm.promptDataClone.launchConf.ask_limit_on_launch || vm.promptDataClone.launchConf.ask_tags_on_launch || vm.promptDataClone.launchConf.ask_skip_tags_on_launch || (vm.promptDataClone.launchConf.ask_variables_on_launch && !vm.promptDataClone.launchConf.ignore_ask_variables) || vm.promptDataClone.launchConf.ask_diff_mode_on_launch) { @@ -161,6 +164,7 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f _disabled: (order === 1 || vm.readOnlyPrompts) ? false : true, order: order }; + activeTab = activeTab || vm.steps.other_prompts.tab; order++; let codemirror = () => { @@ -177,6 +181,7 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f _disabled: (order === 1 || vm.readOnlyPrompts) ? false : true, order: order }; + activeTab = activeTab || vm.steps.survey.tab; order++; } vm.steps.preview.tab.order = order; @@ -214,6 +219,7 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f if(vm.steps[step].tab.order === currentTab.order) { vm.steps[step].tab._active = false; } else if(vm.steps[step].tab.order === currentTab.order + 1) { + activeTab = currentTab vm.steps[step].tab._active = true; vm.steps[step].tab._disabled = false; scope.$broadcast('promptTabChange', { step }); @@ -222,6 +228,12 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f }); }; + vm.keypress = (event) => { + if (event.key === 'Enter') { + vm.next(activeTab); + } + }; + vm.finish = () => { // Disable the action button to prevent double clicking vm.actionButtonClicked = true; diff --git a/awx/ui/client/src/templates/prompt/prompt.directive.js b/awx/ui/client/src/templates/prompt/prompt.directive.js index dcc25fb784..25b13bc3e6 100644 --- a/awx/ui/client/src/templates/prompt/prompt.directive.js +++ b/awx/ui/client/src/templates/prompt/prompt.directive.js @@ -20,7 +20,7 @@ export default [ 'templateUrl', scope.ns = 'launch'; scope[scope.ns] = { modal: {} }; - promptController.init(scope); + promptController.init(scope, el); } }; }]; diff --git a/awx/ui/client/src/templates/prompt/prompt.partial.html b/awx/ui/client/src/templates/prompt/prompt.partial.html index 68b8ad7086..1ebfcb9977 100644 --- a/awx/ui/client/src/templates/prompt/prompt.partial.html +++ b/awx/ui/client/src/templates/prompt/prompt.partial.html @@ -7,7 +7,7 @@ {{:: vm.strings.get('prompt.SURVEY') }} {{:: vm.strings.get('prompt.PREVIEW') }} -
+
Date: Tue, 2 Apr 2019 13:54:26 -0400 Subject: [PATCH 4/5] remove unused parameter --- awx/ui/client/src/templates/prompt/prompt.controller.js | 2 +- awx/ui/client/src/templates/prompt/prompt.directive.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/templates/prompt/prompt.controller.js b/awx/ui/client/src/templates/prompt/prompt.controller.js index 3cb6af385c..8f3f11be77 100644 --- a/awx/ui/client/src/templates/prompt/prompt.controller.js +++ b/awx/ui/client/src/templates/prompt/prompt.controller.js @@ -9,7 +9,7 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f let modal; let activeTab; - vm.init = (_scope_, el) => { + vm.init = (_scope_) => { scope = _scope_; ({ modal } = scope[scope.ns]); diff --git a/awx/ui/client/src/templates/prompt/prompt.directive.js b/awx/ui/client/src/templates/prompt/prompt.directive.js index 25b13bc3e6..dcc25fb784 100644 --- a/awx/ui/client/src/templates/prompt/prompt.directive.js +++ b/awx/ui/client/src/templates/prompt/prompt.directive.js @@ -20,7 +20,7 @@ export default [ 'templateUrl', scope.ns = 'launch'; scope[scope.ns] = { modal: {} }; - promptController.init(scope, el); + promptController.init(scope); } }; }]; From dbe4417ac323475ec90425a8021b041255f69e40 Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Wed, 3 Apr 2019 08:59:14 -0400 Subject: [PATCH 5/5] fix lint error --- awx/ui/client/src/templates/prompt/prompt.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/templates/prompt/prompt.controller.js b/awx/ui/client/src/templates/prompt/prompt.controller.js index 8f3f11be77..5bf6cee2df 100644 --- a/awx/ui/client/src/templates/prompt/prompt.controller.js +++ b/awx/ui/client/src/templates/prompt/prompt.controller.js @@ -219,7 +219,7 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f if(vm.steps[step].tab.order === currentTab.order) { vm.steps[step].tab._active = false; } else if(vm.steps[step].tab.order === currentTab.order + 1) { - activeTab = currentTab + activeTab = currentTab; vm.steps[step].tab._active = true; vm.steps[step].tab._disabled = false; scope.$broadcast('promptTabChange', { step });