Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/dev This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2019-04-02 11:10:16 +02:00
commit 23bb644812
2 changed files with 8 additions and 31 deletions

View File

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

View File

@ -3,36 +3,20 @@ import Input from '../../lib/input';
import './style.scss'; import './style.scss';
export default class InputTime extends Input { export default class InputTime extends Input {
set offsetedValue(value) {
if (!value) return;
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;
}
get value() { get value() {
return this._value; return this._value;
} }
set value(value) { set value(value) {
if (!value) return; 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'); if (this.hasValue) this.element.classList.add('not-empty');
@ -46,13 +30,6 @@ export default class InputTime extends Input {
set step(value) { set step(value) {
this.input.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']; InputTime.$inject = ['$element', '$scope', '$attrs', 'vnTemplate', '$transclude'];