Files
mixtape/zero.Backoffice.UI/app/components/ui-calendar.vue
T

57 lines
914 B
Vue
Raw Normal View History

2020-06-15 10:41:27 +02:00
<template>
2021-12-10 14:23:14 +01:00
<div ref="calendar" class="ui-calendar"></div>
2020-06-15 10:41:27 +02:00
</template>
<script>
2020-06-15 13:38:32 +02:00
import flatpickr from 'flatpickr';
2021-12-10 14:23:14 +01:00
import { extendObject } from '../utils/objects';
2020-06-15 13:38:32 +02:00
2020-06-15 10:41:27 +02:00
export default {
2021-12-10 14:23:14 +01:00
name: 'uiCalendar',
2020-06-15 10:41:27 +02:00
props: {
2021-12-10 14:23:14 +01:00
today: String,
2020-06-15 13:38:32 +02:00
options: {
type: Object,
default: () => { }
}
2020-06-15 10:41:27 +02:00
},
data: () => ({
2020-06-15 13:38:32 +02:00
date: null,
initialized: false
2020-06-15 10:41:27 +02:00
}),
2020-06-15 13:38:32 +02:00
mounted()
2020-06-15 10:41:27 +02:00
{
2020-06-15 13:38:32 +02:00
let vm = this;
if (this.initialized)
{
return;
}
2021-12-10 14:23:14 +01:00
flatpickr(this.$refs.calendar, extendObject({
2020-06-15 13:38:32 +02:00
inline: true,
enableTime: true,
time_24hr: true,
2021-12-10 14:23:14 +01:00
defaultDate: this.today,
2020-06-15 13:38:32 +02:00
minuteIncrement: 1,
onChange(dates)
{
vm.$emit('change', dates[0]);
},
}, this.options));
this.initialized = true;
2020-06-15 10:41:27 +02:00
}
}
</script>
<style lang="scss">
2021-12-10 14:23:14 +01:00
.ui-calendar
2020-06-15 13:38:32 +02:00
{
}
2020-06-15 10:41:27 +02:00
</style>