set focus on first input in modal when launching jt

This commit is contained in:
Keith Grant 2019-04-02 11:10:02 -04:00
parent e943ae59b7
commit e5f48bfa62
3 changed files with 18 additions and 7 deletions

View File

@ -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 });
}
}
});

View File

@ -10,9 +10,9 @@
<div class="Prompt-step">
<div ng-if="vm.steps.inventory.includeStep" ng-show="vm.steps.inventory.tab._active" id="prompt_inventory_step">
<prompt-inventory
prompt-data="vm.promptDataClone"
read-only-prompts="vm.readOnlyPrompts">
</prompt-inventory>
prompt-data="vm.promptDataClone"
read-only-prompts="vm.readOnlyPrompts">
</prompt-inventory>
</div>
<div ng-if="vm.steps.credential.includeStep" ng-show="vm.steps.credential.tab._active" id="prompt_credential_step">
<prompt-credential

View File

@ -103,16 +103,26 @@ export default
}
scope.validate = validate;
angular.element(el).ready(() => {
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;
};