salix/front/core/components/input-time/index.js

56 lines
1.2 KiB
JavaScript

import ngModule from '../../module';
import Input from '../../lib/input';
import './style.scss';
export default class InputTime extends Input {
get value() {
return this._value;
}
set value(value) {
if (!value) return;
let newDate = new Date(value);
newDate.setSeconds(0);
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');
this.element.querySelector('.infix').classList.remove('invalid', 'validated');
}
get step() {
return parseInt(this.input.step);
}
set step(value) {
this.input.step = value;
}
}
InputTime.$inject = ['$element', '$scope', '$attrs', 'vnTemplate', '$transclude'];
ngModule.component('vnInputTime', {
template: require('./index.html'),
controller: InputTime,
transclude: {
leftIcons: '?tLeftIcons',
rightIcons: '?tRightIcons'
},
bindings: {
label: '@?',
disabled: '<?',
readonly: '<?',
step: '<?',
rule: '@?',
value: '=model',
vnTabIndex: '@?',
onChange: '&',
onClear: '&'
}
});