scinote-web/app/javascript/vue/shared/time_picker.vue
artoscinote 3df030b29e
Fix date/time filter loading and overwriting [SCI-6582] (#3898)
* Fix filter overwrite [SCI-6582]

* Fix date/time filter loading [SCI-6582]

* Fix time/time range filter loading [SCI-6582]

* Code style fixes [SCI-6582]
2022-02-25 15:27:31 +01:00

55 lines
1.3 KiB
Vue

<template>
<div class="sci-input-container time-container right-icon">
<input class="time-part sci-input-field"
@input="update"
:id="this.selectorId"
type="text"
data-mask-type="time"
v-model="value"
placeholder="HH:mm"/>
<i class="fas fa-clock"></i>
</div>
</template>
<script>
export default {
name: 'TimePicker',
props: {
selectorId: { type: String, required: true },
defaultValue: { type: String, required: false }
},
data() {
return {
value: ''
}
},
mounted() {
Inputmask('datetime', {
inputFormat: 'HH:MM',
placeholder: 'HH:mm',
clearIncomplete: true,
showMaskOnHover: true,
hourFormat: 24
}).mask($('#' + this.selectorId));
$('#' + this.selectorId).next().click(() => {
var inputField = $('#' + this.selectorId);
var d = new Date();
var h = ('0' + d.getHours()).slice(-2);
var m = ('0' + d.getMinutes()).slice(-2);
var value= h + ':' + m
inputField.val(value);
this.value = value;
this.update();
});
this.value = this.defaultValue;
this.update();
},
methods: {
update() {
this.$emit('change', this.value);
}
}
}
</script>