This commit is contained in:
parent
eea4f53151
commit
bb039386f2
|
@ -1,14 +1,27 @@
|
||||||
import ngModule from '../../module';
|
import ngModule from '../../module';
|
||||||
import Textfield from '../textfield/textfield';
|
import Input from '../../lib/input';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
export default class InputNumber extends Textfield {
|
export default class InputNumber extends Input {
|
||||||
constructor($element, $scope, $attrs, vnTemplate, $transclude) {
|
constructor($element, $scope, $attrs, vnTemplate) {
|
||||||
super($element, $scope, $attrs, vnTemplate, $transclude);
|
super($element, $scope);
|
||||||
|
vnTemplate.normalizeInputAttrs($attrs);
|
||||||
this.displayControls = true;
|
this.displayControls = true;
|
||||||
|
this.hasFocus = false;
|
||||||
|
this.registerEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers all event emitters
|
||||||
|
*/
|
||||||
|
registerEvents() {
|
||||||
this.input.addEventListener('change', () => {
|
this.input.addEventListener('change', () => {
|
||||||
this.validateValue();
|
this.validateValue();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.input.addEventListener('focus', event => {
|
||||||
|
this.emit('focus', {event});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get value() {
|
get value() {
|
||||||
|
@ -18,6 +31,7 @@ export default class InputNumber extends Textfield {
|
||||||
set value(value) {
|
set value(value) {
|
||||||
this._value = value;
|
this._value = value;
|
||||||
this.hasValue = this._value !== null;
|
this.hasValue = this._value !== null;
|
||||||
|
this.input.value = this._value;
|
||||||
|
|
||||||
if (this.hasValue) this.element.classList.add('not-empty');
|
if (this.hasValue) this.element.classList.add('not-empty');
|
||||||
else this.element.classList.remove('not-empty');
|
else this.element.classList.remove('not-empty');
|
||||||
|
|
|
@ -15,8 +15,8 @@ export default class InputTime extends Input {
|
||||||
newDate.setMilliseconds(0);
|
newDate.setMilliseconds(0);
|
||||||
|
|
||||||
this._value = newDate;
|
this._value = newDate;
|
||||||
|
|
||||||
this.hasValue = this._value !== null;
|
this.hasValue = this._value !== null;
|
||||||
|
this.input.value = this._value;
|
||||||
|
|
||||||
if (this.hasValue) this.element.classList.add('not-empty');
|
if (this.hasValue) this.element.classList.add('not-empty');
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,12 @@
|
||||||
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
|
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
|
||||||
<vn-card pad-large>
|
<vn-card pad-large>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-input-number vn-one min="0" vn-focus
|
<vn-input-number
|
||||||
|
vn-one min="0"
|
||||||
display-controls="false"
|
display-controls="false"
|
||||||
label="Credit"
|
label="Credit"
|
||||||
field="$ctrl.client.credit">
|
field="$ctrl.client.credit"
|
||||||
|
vn-focus>
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
|
|
|
@ -37,7 +37,6 @@ class Controller {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$http', '$scope', '$state'];
|
Controller.$inject = ['$http', '$scope', '$state'];
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
|
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
|
||||||
<vn-card pad-large>
|
<vn-card pad-large>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-input-number vn-one vn-focus min="0"
|
<vn-input-number vn-one vn-focus
|
||||||
display-controls="false"
|
display-controls="false"
|
||||||
label="Amount"
|
label="Amount"
|
||||||
field="$ctrl.greuge.amount">
|
field="$ctrl.greuge.amount">
|
||||||
|
|
|
@ -44,16 +44,16 @@
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textfield
|
<vn-input-number
|
||||||
vn-one
|
vn-one
|
||||||
label="Km start"
|
label="Km start"
|
||||||
field="$ctrl.route.kmStart">
|
field="$ctrl.route.kmStart">
|
||||||
</vn-textfield>
|
</vn-input-number>
|
||||||
<vn-textfield
|
<vn-input-number
|
||||||
vn-one
|
vn-one
|
||||||
label="Km end"
|
label="Km end"
|
||||||
model="$ctrl.route.kmEnd">
|
model="$ctrl.route.kmEnd">
|
||||||
</vn-textfield>
|
</vn-input-number>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-date-picker
|
<vn-date-picker
|
||||||
|
|
Loading…
Reference in New Issue