From bb039386f2b38348c15112c5c77f24955830a7e2 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 4 Apr 2019 11:53:13 +0200 Subject: [PATCH] fixed input focus #1302 --- front/core/components/input-number/index.js | 22 +++++++++++++++---- front/core/components/input-time/index.js | 2 +- modules/client/front/credit/create/index.html | 6 +++-- modules/client/front/credit/create/index.js | 1 - modules/client/front/greuge/create/index.html | 2 +- modules/route/front/basic-data/index.html | 8 +++---- 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/front/core/components/input-number/index.js b/front/core/components/input-number/index.js index 0d45082c5..bfd78453f 100644 --- a/front/core/components/input-number/index.js +++ b/front/core/components/input-number/index.js @@ -1,14 +1,27 @@ import ngModule from '../../module'; -import Textfield from '../textfield/textfield'; +import Input from '../../lib/input'; import './style.scss'; -export default class InputNumber extends Textfield { - constructor($element, $scope, $attrs, vnTemplate, $transclude) { - super($element, $scope, $attrs, vnTemplate, $transclude); +export default class InputNumber extends Input { + constructor($element, $scope, $attrs, vnTemplate) { + super($element, $scope); + vnTemplate.normalizeInputAttrs($attrs); this.displayControls = true; + this.hasFocus = false; + this.registerEvents(); + } + + /** + * Registers all event emitters + */ + registerEvents() { this.input.addEventListener('change', () => { this.validateValue(); }); + + this.input.addEventListener('focus', event => { + this.emit('focus', {event}); + }); } get value() { @@ -18,6 +31,7 @@ export default class InputNumber extends Textfield { set value(value) { this._value = value; this.hasValue = this._value !== null; + this.input.value = this._value; if (this.hasValue) this.element.classList.add('not-empty'); else this.element.classList.remove('not-empty'); diff --git a/front/core/components/input-time/index.js b/front/core/components/input-time/index.js index 97179ae38..535d6004f 100644 --- a/front/core/components/input-time/index.js +++ b/front/core/components/input-time/index.js @@ -15,8 +15,8 @@ export default class InputTime extends Input { newDate.setMilliseconds(0); this._value = newDate; - this.hasValue = this._value !== null; + this.input.value = this._value; if (this.hasValue) this.element.classList.add('not-empty'); diff --git a/modules/client/front/credit/create/index.html b/modules/client/front/credit/create/index.html index 2c59a5388..b16219005 100644 --- a/modules/client/front/credit/create/index.html +++ b/modules/client/front/credit/create/index.html @@ -8,10 +8,12 @@
- + field="$ctrl.client.credit" + vn-focus> diff --git a/modules/client/front/credit/create/index.js b/modules/client/front/credit/create/index.js index 75ec81838..0b67eb5d1 100644 --- a/modules/client/front/credit/create/index.js +++ b/modules/client/front/credit/create/index.js @@ -37,7 +37,6 @@ class Controller { } ); } - } Controller.$inject = ['$http', '$scope', '$state']; diff --git a/modules/client/front/greuge/create/index.html b/modules/client/front/greuge/create/index.html index f0f3d6718..3f903a67f 100644 --- a/modules/client/front/greuge/create/index.html +++ b/modules/client/front/greuge/create/index.html @@ -8,7 +8,7 @@ - diff --git a/modules/route/front/basic-data/index.html b/modules/route/front/basic-data/index.html index 10d8c0b62..fb14d4098 100644 --- a/modules/route/front/basic-data/index.html +++ b/modules/route/front/basic-data/index.html @@ -44,16 +44,16 @@ - - - + - +