This commit is contained in:
parent
eea4f53151
commit
bb039386f2
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -37,7 +37,6 @@ class Controller {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Controller.$inject = ['$http', '$scope', '$state'];
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue