input time last changes rollback

This commit is contained in:
Gerard 2019-04-02 11:02:59 +02:00
parent a44bb2a13c
commit fcde321edf
2 changed files with 10 additions and 32 deletions

View File

@ -6,7 +6,7 @@
<input
class="mdl-textfield__input"
type="time"
ng-model="$ctrl.offsetedValue"
ng-model="$ctrl.value"
vn-validation="{{$ctrl.rule}}"
ng-disabled="$ctrl.disabled"
ng-readonly="$ctrl.readonly"

View File

@ -1,37 +1,22 @@
import ngModule from '../../module';
import Textfield from '../textfield/textfield';
import Input from '../../lib/input';
import './style.scss';
export default class InputTime extends Textfield {
set offsetedValue(value) {
this._offsetedValue = value;
let date = new Date(value);
let offset = date.getTimezoneOffset() * 60000;
date.setTime(date.getTime() - offset);
this._value = date;
}
get offsetedValue() {
return this._offsetedValue;
}
export default class InputTime extends Input {
get value() {
return this._value;
}
set value(value) {
if (!value) return;
if (!this._offsetedValue) {
let date = new Date(value);
date.setSeconds(0);
date.setMilliseconds(0);
let offset = date.getTimezoneOffset() * 60000;
date.setTime(date.getTime() + offset);
this.offsetedValue = date;
}
this.hasValue = this._offsetedValue !== null;
let newDate = new Date(value);
newDate.setSeconds(0);
newDate.setMilliseconds(0);
this._value = newDate;
this.hasValue = this._value !== null;
if (this.hasValue) this.element.classList.add('not-empty');
@ -45,13 +30,6 @@ export default class InputTime extends Textfield {
set step(value) {
this.input.step = value;
}
clear() {
this.saveOldValue();
this.offsetedValue = null;
if (this.onClear) this.onClear();
this.input.focus();
}
}
InputTime.$inject = ['$element', '$scope', '$attrs', 'vnTemplate', '$transclude'];