diff --git a/awx/ui/client/components/form/form.directive.js b/awx/ui/client/components/form/form.directive.js index 8814e6b742..5922a08b20 100644 --- a/awx/ui/client/components/form/form.directive.js +++ b/awx/ui/client/components/form/form.directive.js @@ -1,32 +1,42 @@ -function track (element) { +function use (componentScope, componentElement) { let vm = this; - let input = { - el: element, - tabindex: vm.form.inputs.length + 1, - autofocus: vm.form.inputs.length === 0 - }; + let input = vm.track(componentElement); - vm.form.inputs.push(input); + componentScope.meta = input; +} - return 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.form = { - inputs: [] - }; - + vm.inputs = []; + vm.use = use; vm.track = track; } -function atForm () { +function atForm (pathService) { return { restrict: 'E', transclude: true, - templateUrl: 'static/partials/components/form/form.partial.html', + templateUrl: pathService.getPartialPath('components/form/form'), controller, controllerAs: 'vm', scope: { @@ -35,4 +45,6 @@ function atForm () { }; } +atForm.$inject = ['PathService']; + export default atForm; diff --git a/awx/ui/client/components/index.js b/awx/ui/client/components/index.js index 48bdd08955..bdcccc1470 100644 --- a/awx/ui/client/components/index.js +++ b/awx/ui/client/components/index.js @@ -1,6 +1,5 @@ import badge from './badge/badge.directive'; import form from './form/form.directive'; -import inputDropdown from './input/dropdown.directive'; import inputSearch from './input/search.directive'; import inputSelect from './input/select.directive'; import inputText from './input/text.directive'; @@ -14,7 +13,6 @@ angular .module('at.components', []) .directive('atBadge', badge) .directive('atForm', form) - .directive('atInputDropdown', inputDropdown) .directive('atInputSearch', inputSearch) .directive('atInputSelect', inputSelect) .directive('atInputText', inputText) diff --git a/awx/ui/client/components/input/_index.less b/awx/ui/client/components/input/_index.less index 6c746fc2b6..79492ed1da 100644 --- a/awx/ui/client/components/input/_index.less +++ b/awx/ui/client/components/input/_index.less @@ -42,25 +42,25 @@ & > i { position: absolute; - z-index: 4; + z-index: 3; pointer-events: none; right: @at-padding-sm; top: @at-padding-sm; } } -.at-Dropdown { +.at-Select { height: @at-input-height-md; position: relative; } -.at-Dropdown-input { +.at-Select-input { position: relative; z-index: 2; pointer-events: none; } -.at-Dropdown-select { +.at-Select-select { position: absolute; z-index: 1; top: 0; diff --git a/awx/ui/client/components/input/dropdown.directive.js b/awx/ui/client/components/input/dropdown.directive.js deleted file mode 100644 index 3027fc1f11..0000000000 --- a/awx/ui/client/components/input/dropdown.directive.js +++ /dev/null @@ -1,41 +0,0 @@ -function link (scope, el, attrs, form) { - scope.form = form.track(el); - - scope.open = false; - - let input = el.find('input')[0]; - let select = el.find('select')[0]; - - input.addEventListener('focus', () => select.focus()); - select.addEventListener('focus', () => input.classList.add('at-Input--focus')); - - select.addEventListener('mousedown', () => { - scope.open = true; - }); - - select.addEventListener('blur', () => { - input.classList.remove('at-Input--focus'); - scope.open = false; - }); - - select.addEventListener('change', () => { - scope.open = false; - }); -} - -function atInputDropdown () { - return { - restrict: 'E', - transclude: true, - replace: true, - require: '^^at-form', - templateUrl: 'static/partials/components/input/dropdown.partial.html', - link, - scope: { - config: '=', - col: '@' - } - }; -} - -export default atInputDropdown; diff --git a/awx/ui/client/components/input/dropdown.partial.html b/awx/ui/client/components/input/dropdown.partial.html deleted file mode 100644 index cfa1291b6c..0000000000 --- a/awx/ui/client/components/input/dropdown.partial.html +++ /dev/null @@ -1,24 +0,0 @@ -