awx/awx/ui/client/components/form/form.directive.js
2017-06-12 09:53:11 -04:00

51 lines
908 B
JavaScript

function use (componentScope, componentElement) {
let vm = this;
let input = vm.track(componentElement);
componentScope.meta = input;
}
function track (componentElement) {
let vm = this;
let input = {
el: componentElement,
tabindex: vm.inputs.length + 1
};
if (vm.inputs.length === 0) {
input.autofocus = true;
componentElement.find('input').focus();
}
vm.inputs.push(input);
return input;
}
function controller () {
let vm = this;
vm.inputs = [];
vm.use = use;
vm.track = track;
}
function atForm (pathService) {
return {
restrict: 'E',
transclude: true,
templateUrl: pathService.getPartialPath('components/form/form'),
controller,
controllerAs: 'vm',
scope: {
config: '='
}
};
}
atForm.$inject = ['PathService'];
export default atForm;