2018-09-19 13:05:07 +00:00
|
|
|
import ngModule from '../../module';
|
|
|
|
import Textfield from '../textfield/textfield';
|
|
|
|
import './style.scss';
|
|
|
|
|
|
|
|
export default class InputTime extends Textfield {
|
|
|
|
|
|
|
|
get value() {
|
|
|
|
return this._value;
|
|
|
|
}
|
|
|
|
|
|
|
|
set value(value) {
|
2018-09-24 08:43:54 +00:00
|
|
|
if (!value) return;
|
|
|
|
|
|
|
|
let newDate = new Date(value);
|
|
|
|
newDate.setSeconds(0);
|
|
|
|
newDate.setMilliseconds(0);
|
|
|
|
|
|
|
|
this._value = newDate;
|
|
|
|
|
2018-09-19 13:05:07 +00:00
|
|
|
this.hasValue = this._value !== null;
|
|
|
|
|
|
|
|
if (this.hasValue) this.element.classList.add('not-empty');
|
|
|
|
|
|
|
|
this.element.querySelector('.infix').classList.remove('invalid', 'validated');
|
|
|
|
}
|
|
|
|
|
|
|
|
get step() {
|
2018-09-24 08:43:54 +00:00
|
|
|
return parseInt(this.input.step);
|
2018-09-19 13:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set step(value) {
|
|
|
|
this.input.step = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-24 08:43:54 +00:00
|
|
|
InputTime.$inject = ['$element', '$scope', '$attrs', 'vnTemplate', '$transclude'];
|
2018-09-19 13:05:07 +00:00
|
|
|
|
|
|
|
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: '&'
|
|
|
|
}
|
|
|
|
});
|