From 952958a83c5b8364859a46b2c38f717d5f9e5c13 Mon Sep 17 00:00:00 2001 From: gconsidine Date: Thu, 1 Jun 2017 16:57:16 -0400 Subject: [PATCH] Add partial implementation of drag and drop ssh key support --- .../lib/components/form/form.directive.js | 44 ++++++----- .../client/lib/components/input/_index.less | 41 +++++++++- .../lib/components/input/group.directive.js | 4 +- .../lib/components/input/label.partial.html | 9 ++- .../input/textarea-secret.directive.js | 74 +++++++++++++++++-- .../input/textarea-secret.partial.html | 31 ++++++-- .../components/input/textarea.partial.html | 2 +- .../lib/components/modal/modal.directive.js | 0 .../lib/components/modal/modal.partial.html | 0 .../client/lib/components/popover/_index.less | 7 +- .../components/popover/popover.directive.js | 5 +- .../components/popover/popover.partial.html | 4 +- awx/ui/client/lib/services/event.service.js | 12 ++- awx/ui/client/lib/theme/_mixins.less | 4 + awx/ui/client/lib/theme/_variables.less | 8 +- 15 files changed, 196 insertions(+), 49 deletions(-) create mode 100644 awx/ui/client/lib/components/modal/modal.directive.js create mode 100644 awx/ui/client/lib/components/modal/modal.partial.html diff --git a/awx/ui/client/lib/components/form/form.directive.js b/awx/ui/client/lib/components/form/form.directive.js index c827294dd9..f3d9b85ca0 100644 --- a/awx/ui/client/lib/components/form/form.directive.js +++ b/awx/ui/client/lib/components/form/form.directive.js @@ -85,7 +85,7 @@ function AtFormController (eventService) { let handled; if (err.status === 400) { - handled = vm.setValidationErrors(err.data); + handled = vm.handleValidationErrors(err.data); } if (!handled) { @@ -93,22 +93,8 @@ function AtFormController (eventService) { } }; - vm.setValidationErrors = errors => { - let errorMessageSet = false; - - for (let id in errors) { - vm.components - .filter(component => component.category === 'input') - .forEach(component => { - if (component.state._id === id) { - errorMessageSet = true; - - component.state._rejected = true; - component.state._isValid = false; - component.state._message = errors[id].join(' '); - } - }); - } + vm.handleValidationErrors = errors => { + let errorMessageSet = vm.setValidationMessages(errors); if (errorMessageSet) { vm.check(); @@ -117,6 +103,30 @@ function AtFormController (eventService) { return errorMessageSet; }; + vm.setValidationMessages = (errors, errorSet) => { + let errorMessageSet = errorSet || false; + + for (let id in errors) { + if (!Array.isArray(errors[id]) && typeof errors[id] === 'object') { + errorMessageSet = vm.setValidationMessages(errors[id], errorMessageSet); + continue; + } + + vm.components + .filter(component => component.category === 'input') + .filter(component => errors[component.state.id]) + .forEach(component => { + errorMessageSet = true; + + component.state._rejected = true; + component.state._isValid = false; + component.state._message = errors[component.state.id].join(' '); + }); + } + + return errorMessageSet; + }; + vm.validate = () => { let isValid = true; diff --git a/awx/ui/client/lib/components/input/_index.less b/awx/ui/client/lib/components/input/_index.less index 3be3213b18..1384a39b24 100644 --- a/awx/ui/client/lib/components/input/_index.less +++ b/awx/ui/client/lib/components/input/_index.less @@ -15,8 +15,14 @@ } } +.at-InputGroup-button { + height: 100%; +} + .at-Input-button { - width: 72px; + width: @at-input-button-width; + display: block; + height: 100%; &, &:active, &:hover, &:focus { color: @at-gray-dark-3x; @@ -36,6 +42,21 @@ } } +.at-InputFile--hidden { + position: absolute; + height: 100%; + width: 100%; + left: 0; + right: @at-input-button-width; + z-index: -2; + opacity: 0; +} + +.at-InputFile--drag { + z-index: 3; +} + + .at-InputGroup { padding: 0; margin: 0; @@ -64,6 +85,10 @@ height: @at-space-6x; } +.at-InputLabel { + display: inline-block; +} + .at-InputLabel-name { color: @at-gray-dark-4x; font-size: @at-font-size-2x; @@ -71,6 +96,14 @@ text-transform: uppercase; } +.at-InputLabel-hint { + margin-left: @at-space-4x; + color: @at-gray-dark-3x; + font-size: @at-font-size; + font-weight: @at-font-weight; + line-height: @at-line-height-short; +} + .at-InputMessage--rejected { font-size: @at-font-size; color: @at-red; @@ -82,8 +115,7 @@ color: @at-red; font-weight: @at-font-weight-2x; font-size: @at-font-size-2x; - line-height: @at-line-height-short; - margin: @at-space-3x @at-space 0 0; + margin: 0; } .at-InputSelect { @@ -123,3 +155,6 @@ } } +.at-Textarea { + .at-mixin-FontFixedWidth(); +} diff --git a/awx/ui/client/lib/components/input/group.directive.js b/awx/ui/client/lib/components/input/group.directive.js index 28c155dac3..882bc8aa7b 100644 --- a/awx/ui/client/lib/components/input/group.directive.js +++ b/awx/ui/client/lib/components/input/group.directive.js @@ -75,9 +75,9 @@ function AtInputGroupController ($scope, $compile) { if (input.type === 'string') { if (!input.multiline) { if (input.secret) { - config._component = 'at-input-text'; - } else { config._component = 'at-input-secret'; + } else { + config._component = 'at-input-text'; } } else { config._expand = true; diff --git a/awx/ui/client/lib/components/input/label.partial.html b/awx/ui/client/lib/components/input/label.partial.html index 124ae8a67f..d90495df74 100644 --- a/awx/ui/client/lib/components/input/label.partial.html +++ b/awx/ui/client/lib/components/input/label.partial.html @@ -1,5 +1,6 @@ -