make Enter key navigate to next tab in launch modal

This commit is contained in:
Keith Grant
2019-04-02 13:26:31 -04:00
parent e5f48bfa62
commit 5b2f00b978
3 changed files with 15 additions and 3 deletions

View File

@@ -7,8 +7,9 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f
let scope; let scope;
let modal; let modal;
let activeTab;
vm.init = (_scope_) => { vm.init = (_scope_, el) => {
scope = _scope_; scope = _scope_;
({ modal } = scope[scope.ns]); ({ modal } = scope[scope.ns]);
@@ -137,6 +138,7 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f
_active: true, _active: true,
order: order order: order
}; };
activeTab = activeTab || vm.steps.inventory.tab;
order++; order++;
} }
if (vm.promptDataClone.launchConf.ask_credential_on_launch || 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, _disabled: (order === 1 || vm.readOnlyPrompts) ? false : true,
order: order order: order
}; };
activeTab = activeTab || vm.steps.credentials.tab;
order++; 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) { 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, _disabled: (order === 1 || vm.readOnlyPrompts) ? false : true,
order: order order: order
}; };
activeTab = activeTab || vm.steps.other_prompts.tab;
order++; order++;
let codemirror = () => { let codemirror = () => {
@@ -177,6 +181,7 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f
_disabled: (order === 1 || vm.readOnlyPrompts) ? false : true, _disabled: (order === 1 || vm.readOnlyPrompts) ? false : true,
order: order order: order
}; };
activeTab = activeTab || vm.steps.survey.tab;
order++; order++;
} }
vm.steps.preview.tab.order = 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) { if(vm.steps[step].tab.order === currentTab.order) {
vm.steps[step].tab._active = false; vm.steps[step].tab._active = false;
} else if(vm.steps[step].tab.order === currentTab.order + 1) { } else if(vm.steps[step].tab.order === currentTab.order + 1) {
activeTab = currentTab
vm.steps[step].tab._active = true; vm.steps[step].tab._active = true;
vm.steps[step].tab._disabled = false; vm.steps[step].tab._disabled = false;
scope.$broadcast('promptTabChange', { step }); 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 = () => { vm.finish = () => {
// Disable the action button to prevent double clicking // Disable the action button to prevent double clicking
vm.actionButtonClicked = true; vm.actionButtonClicked = true;

View File

@@ -20,7 +20,7 @@ export default [ 'templateUrl',
scope.ns = 'launch'; scope.ns = 'launch';
scope[scope.ns] = { modal: {} }; scope[scope.ns] = { modal: {} };
promptController.init(scope); promptController.init(scope, el);
} }
}; };
}]; }];

View File

@@ -7,7 +7,7 @@
<at-tab id="prompt_survey_tab" ng-if="vm.steps.survey.tab" state="vm.steps.survey.tab">{{:: vm.strings.get('prompt.SURVEY') }}</at-tab> <at-tab id="prompt_survey_tab" ng-if="vm.steps.survey.tab" state="vm.steps.survey.tab">{{:: vm.strings.get('prompt.SURVEY') }}</at-tab>
<at-tab id="prompt_preview_tab" state="vm.steps.preview.tab">{{:: vm.strings.get('prompt.PREVIEW') }}</at-tab> <at-tab id="prompt_preview_tab" state="vm.steps.preview.tab">{{:: vm.strings.get('prompt.PREVIEW') }}</at-tab>
</at-tab-group> </at-tab-group>
<div class="Prompt-step"> <div class="Prompt-step" ng-keypress="vm.keypress($event)">
<div ng-if="vm.steps.inventory.includeStep" ng-show="vm.steps.inventory.tab._active" id="prompt_inventory_step"> <div ng-if="vm.steps.inventory.includeStep" ng-show="vm.steps.inventory.tab._active" id="prompt_inventory_step">
<prompt-inventory <prompt-inventory
prompt-data="vm.promptDataClone" prompt-data="vm.promptDataClone"