2021-02-05 23:07:58 +00:00
|
|
|
<template>
|
|
|
|
<q-page padding>
|
|
|
|
<q-card>
|
2021-02-04 23:07:51 +00:00
|
|
|
<div style="max-width: 1800px; width: 100%">
|
|
|
|
<q-toolbar class="bg-primary text-white q-my-md shadow-2 items-center row justify-center">
|
|
|
|
<div class="row justify-center items-center">
|
|
|
|
<q-btn flat dense label="Prev" @click="calendarPrev" />
|
|
|
|
<q-separator vertical />
|
|
|
|
<q-btn flat dense
|
|
|
|
>{{ asMonth(selectedDate) }} {{ asYear(selectedDate) }}
|
|
|
|
<q-popup-proxy
|
|
|
|
transition-show="scale"
|
|
|
|
transition-hide="scale"
|
|
|
|
@before-show="updateProxy"
|
|
|
|
>
|
|
|
|
<q-date v-model="proxyDate">
|
|
|
|
<div class="row items-center justify-end q-gutter-sm">
|
|
|
|
<q-btn v-close-popup label="Cancel" color="primary" flat />
|
|
|
|
<q-btn
|
|
|
|
v-close-popup
|
|
|
|
label="OK"
|
|
|
|
color="primary"
|
|
|
|
flat
|
|
|
|
@click="saveNewSelectedDate(proxyDate)"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</q-date>
|
|
|
|
</q-popup-proxy>
|
|
|
|
</q-btn>
|
|
|
|
<q-separator vertical />
|
|
|
|
<q-btn flat dense label="Next" @click="calendarNext" />
|
|
|
|
</div>
|
|
|
|
<!-- <q-space /> -->
|
2021-02-07 19:16:21 +00:00
|
|
|
|
2021-02-04 23:07:51 +00:00
|
|
|
<q-btn-toggle
|
|
|
|
v-model="calendarView"
|
|
|
|
class="row absolute-right"
|
|
|
|
flat
|
|
|
|
stretch
|
|
|
|
toggle-color=""
|
|
|
|
:options="[
|
2021-03-19 13:35:34 +00:00
|
|
|
{ label: 'Tag', value: 'day' },
|
|
|
|
{ label: 'Woche', value: 'week' },
|
2021-02-04 23:07:51 +00:00
|
|
|
]"
|
|
|
|
/>
|
|
|
|
</q-toolbar>
|
2021-03-19 01:36:31 +00:00
|
|
|
<q-calendar-agenda
|
2021-02-04 23:07:51 +00:00
|
|
|
ref="calendar"
|
|
|
|
v-model="selectedDate"
|
2021-03-19 20:01:50 +00:00
|
|
|
:view="calendarRealView"
|
|
|
|
:max-days="calendarDays"
|
2021-02-04 23:07:51 +00:00
|
|
|
:weekdays="[1, 2, 3, 4, 5, 6, 0]"
|
|
|
|
locale="de-de"
|
|
|
|
style="height: 100%; min-height: 400px"
|
|
|
|
>
|
2021-03-19 13:35:34 +00:00
|
|
|
<template #day="{ scope: { timestamp } }" style="min-height: 200px">
|
2021-03-19 20:01:50 +00:00
|
|
|
<template v-if="!events[timestamp.weekday]" style="min-height: 200px"> </template>
|
|
|
|
<template v-for="agenda in events[timestamp.weekday]" :key="agenda.id">
|
2021-02-04 23:07:51 +00:00
|
|
|
<eventslot :event="agenda" />
|
2021-02-05 23:07:58 +00:00
|
|
|
</template>
|
2021-02-04 23:07:51 +00:00
|
|
|
</template>
|
2021-03-19 01:36:31 +00:00
|
|
|
</q-calendar-agenda>
|
2021-02-04 23:07:51 +00:00
|
|
|
</div>
|
2021-02-05 23:07:58 +00:00
|
|
|
</q-card>
|
|
|
|
</q-page>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-03-19 20:01:50 +00:00
|
|
|
import { computed, defineComponent, onBeforeMount, ref } from 'vue';
|
2021-02-10 16:37:43 +00:00
|
|
|
import { useScheduleStore } from '../../store';
|
2021-02-05 23:07:58 +00:00
|
|
|
import Eventslot from './slots/EventSlot.vue';
|
|
|
|
import { date } from 'quasar';
|
2021-03-19 20:01:50 +00:00
|
|
|
import { startOfWeek } from 'src/utils/datetime';
|
2021-02-04 23:07:51 +00:00
|
|
|
|
2021-02-05 23:07:58 +00:00
|
|
|
export default defineComponent({
|
|
|
|
name: 'AgendaView',
|
|
|
|
components: { Eventslot },
|
2021-02-07 19:16:21 +00:00
|
|
|
|
2021-02-04 23:07:51 +00:00
|
|
|
setup() {
|
2021-02-10 16:37:43 +00:00
|
|
|
const store = useScheduleStore();
|
2021-03-19 20:01:50 +00:00
|
|
|
const windowWidth = ref(window.innerWidth);
|
2021-02-05 23:07:58 +00:00
|
|
|
const selectedDate = ref(date.formatDate(new Date(), 'YYYY-MM-DD'));
|
|
|
|
const proxyDate = ref('');
|
2021-03-19 01:36:31 +00:00
|
|
|
const calendar = ref<QCalendar.QCalendar>();
|
2021-03-19 20:01:50 +00:00
|
|
|
const calendarView = ref('week');
|
|
|
|
|
|
|
|
const calendarRealView = computed(() => (calendarDays.value != 7 ? 'day' : 'week'));
|
|
|
|
const calendarDays = computed(() =>
|
|
|
|
calendarView.value == 'day' ? 1 : windowWidth.value < 1000 ? 3 : 7
|
|
|
|
);
|
2021-02-10 16:37:43 +00:00
|
|
|
const events = ref<Agendas>({});
|
|
|
|
|
|
|
|
interface Agendas {
|
|
|
|
[index: number]: FG.Event[];
|
|
|
|
}
|
|
|
|
|
|
|
|
onBeforeMount(async () => {
|
2021-03-19 20:01:50 +00:00
|
|
|
window.addEventListener('resize', () => {
|
|
|
|
windowWidth.value = window.innerWidth;
|
|
|
|
});
|
|
|
|
|
|
|
|
await loadAgendas();
|
2021-02-05 23:07:58 +00:00
|
|
|
});
|
|
|
|
|
2021-03-19 20:01:50 +00:00
|
|
|
async function loadAgendas() {
|
|
|
|
const selected = new Date(selectedDate.value);
|
|
|
|
const start = calendarRealView.value === 'day' ? selected : startOfWeek(selected);
|
|
|
|
const end = date.addToDate(start, { days: calendarDays.value });
|
|
|
|
|
|
|
|
events.value = {};
|
|
|
|
const list = await store.getEvents({ from: start, to: end });
|
|
|
|
list.forEach((event) => {
|
|
|
|
const day = event.start.getDay();
|
|
|
|
|
|
|
|
if (!events.value[day]) {
|
|
|
|
events.value[day] = [];
|
|
|
|
}
|
|
|
|
events.value[day].push(event);
|
|
|
|
});
|
2021-02-05 23:07:58 +00:00
|
|
|
}
|
|
|
|
|
2021-02-04 23:07:51 +00:00
|
|
|
function calendarNext() {
|
2021-03-19 20:01:50 +00:00
|
|
|
calendar.value?.next();
|
|
|
|
void loadAgendas();
|
2021-02-05 23:07:58 +00:00
|
|
|
}
|
|
|
|
|
2021-02-04 23:07:51 +00:00
|
|
|
function calendarPrev() {
|
2021-03-19 20:01:50 +00:00
|
|
|
calendar.value?.prev();
|
|
|
|
void loadAgendas();
|
2021-02-05 23:07:58 +00:00
|
|
|
}
|
2021-03-19 20:01:50 +00:00
|
|
|
|
2021-02-04 23:07:51 +00:00
|
|
|
function updateProxy() {
|
2021-02-05 23:07:58 +00:00
|
|
|
proxyDate.value = selectedDate.value;
|
|
|
|
}
|
2021-02-04 23:07:51 +00:00
|
|
|
function saveNewSelectedDate() {
|
2021-02-05 23:07:58 +00:00
|
|
|
proxyDate.value = date.formatDate(proxyDate.value, 'YYYY-MM-DD');
|
|
|
|
selectedDate.value = proxyDate.value;
|
|
|
|
}
|
2021-02-04 23:07:51 +00:00
|
|
|
function asMonth(value: string) {
|
|
|
|
if (value) {
|
|
|
|
return date.formatDate(new Date(value), 'MMMM', {
|
|
|
|
months: [
|
|
|
|
'Januar',
|
|
|
|
'Februar',
|
|
|
|
'März',
|
|
|
|
'April',
|
|
|
|
'Mai',
|
|
|
|
'Juni',
|
|
|
|
'Juli',
|
|
|
|
'August',
|
|
|
|
'September',
|
|
|
|
'Oktober',
|
|
|
|
'November',
|
2021-02-10 16:37:43 +00:00
|
|
|
'Dezember',
|
|
|
|
],
|
2021-02-04 23:07:51 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function asYear(value: string) {
|
|
|
|
if (value) {
|
|
|
|
return date.formatDate(new Date(value), 'YYYY');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-05 23:07:58 +00:00
|
|
|
return {
|
2021-02-04 23:07:51 +00:00
|
|
|
asYear,
|
|
|
|
asMonth,
|
|
|
|
calendar,
|
2021-02-05 23:07:58 +00:00
|
|
|
selectedDate,
|
2021-02-10 16:37:43 +00:00
|
|
|
events,
|
2021-02-05 23:07:58 +00:00
|
|
|
calendarNext,
|
|
|
|
calendarPrev,
|
|
|
|
updateProxy,
|
|
|
|
saveNewSelectedDate,
|
2021-02-07 19:16:21 +00:00
|
|
|
proxyDate,
|
2021-03-19 20:01:50 +00:00
|
|
|
calendarDays,
|
2021-02-10 16:37:43 +00:00
|
|
|
calendarView,
|
2021-03-19 20:01:50 +00:00
|
|
|
calendarRealView,
|
2021-02-05 23:07:58 +00:00
|
|
|
};
|
2021-02-10 16:37:43 +00:00
|
|
|
},
|
2021-02-05 23:07:58 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style></style>
|