fixed input focus #1302
gitea/salix/master This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-04-04 11:53:13 +02:00
parent eea4f53151
commit bb039386f2
6 changed files with 28 additions and 13 deletions

View File

@ -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');

View File

@ -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');

View File

@ -8,10 +8,12 @@
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
<vn-card pad-large>
<vn-horizontal>
<vn-input-number vn-one min="0" vn-focus
<vn-input-number
vn-one min="0"
display-controls="false"
label="Credit"
field="$ctrl.client.credit">
field="$ctrl.client.credit"
vn-focus>
</vn-input-number>
</vn-horizontal>
</vn-card>

View File

@ -37,7 +37,6 @@ class Controller {
}
);
}
}
Controller.$inject = ['$http', '$scope', '$state'];

View File

@ -8,7 +8,7 @@
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
<vn-card pad-large>
<vn-horizontal>
<vn-input-number vn-one vn-focus min="0"
<vn-input-number vn-one vn-focus
display-controls="false"
label="Amount"
field="$ctrl.greuge.amount">

View File

@ -44,16 +44,16 @@
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
<vn-input-number
vn-one
label="Km start"
field="$ctrl.route.kmStart">
</vn-textfield>
<vn-textfield
</vn-input-number>
<vn-input-number
vn-one
label="Km end"
model="$ctrl.route.kmEnd">
</vn-textfield>
</vn-input-number>
</vn-horizontal>
<vn-horizontal>
<vn-date-picker