diff --git a/awx/ui/client/components/form/form.directive.js b/awx/ui/client/components/form/form.directive.js new file mode 100644 index 0000000000..8814e6b742 --- /dev/null +++ b/awx/ui/client/components/form/form.directive.js @@ -0,0 +1,38 @@ +function track (element) { + let vm = this; + + let input = { + el: element, + tabindex: vm.form.inputs.length + 1, + autofocus: vm.form.inputs.length === 0 + }; + + vm.form.inputs.push(input); + + return input; +} + +function controller () { + let vm = this; + + vm.form = { + inputs: [] + }; + + vm.track = track; +} + +function atForm () { + return { + restrict: 'E', + transclude: true, + templateUrl: 'static/partials/components/form/form.partial.html', + controller, + controllerAs: 'vm', + scope: { + config: '=' + } + }; +} + +export default atForm; diff --git a/awx/ui/client/components/form/form.partial.html b/awx/ui/client/components/form/form.partial.html new file mode 100644 index 0000000000..95ccc844b1 --- /dev/null +++ b/awx/ui/client/components/form/form.partial.html @@ -0,0 +1,5 @@ +
diff --git a/awx/ui/client/components/index.js b/awx/ui/client/components/index.js index 3841db9070..48bdd08955 100644 --- a/awx/ui/client/components/index.js +++ b/awx/ui/client/components/index.js @@ -1,4 +1,6 @@ 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'; @@ -11,6 +13,8 @@ import toggleContent from './toggle/content.directive'; 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 4652ef3083..6c746fc2b6 100644 --- a/awx/ui/client/components/input/_index.less +++ b/awx/ui/client/components/input/_index.less @@ -5,9 +5,13 @@ border-radius: @at-border-radius-md; color: @at-gray-darkest; - &, &:focus, &:active { + &, &:active { border-color: @at-gray-light; } + + &:focus { + border-color: @at-link; + } } .at-Input-label { @@ -28,8 +32,36 @@ color: @at-gray; } -.at-Dropdown-option--placeholder { - &[value=""] { - display: none; +.at-Input--focus { + border-color: @at-link; +} + +.at-InputGroup { + position: relative; + width: 100%; + + & > i { + position: absolute; + z-index: 4; + pointer-events: none; + right: @at-padding-sm; + top: @at-padding-sm; } } + +.at-Dropdown { + height: @at-input-height-md; + position: relative; +} + +.at-Dropdown-input { + position: relative; + z-index: 2; + pointer-events: none; +} + +.at-Dropdown-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 new file mode 100644 index 0000000000..3027fc1f11 --- /dev/null +++ b/awx/ui/client/components/input/dropdown.directive.js @@ -0,0 +1,41 @@ +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 new file mode 100644 index 0000000000..cfa1291b6c --- /dev/null +++ b/awx/ui/client/components/input/dropdown.partial.html @@ -0,0 +1,24 @@ +