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"
|
|
|
|
:view="calendarView"
|
|
|
|
: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-02-04 23:07:51 +00:00
|
|
|
<template v-if="!getAgenda(timestamp)" style="min-height: 200px"> </template>
|
|
|
|
<template v-for="agenda in getAgenda(timestamp)" :key="agenda.id">
|
|
|
|
<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-02-10 16:37:43 +00:00
|
|
|
import { defineComponent, onBeforeMount, ref } from 'vue';
|
|
|
|
import { useScheduleStore } from '../../store';
|
2021-02-05 23:07:58 +00:00
|
|
|
import Eventslot from './slots/EventSlot.vue';
|
|
|
|
import { date } from 'quasar';
|
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-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>();
|
|
|
|
const calendarView = 'week';
|
2021-02-10 16:37:43 +00:00
|
|
|
const events = ref<Agendas>({});
|
|
|
|
|
|
|
|
interface Agendas {
|
|
|
|
[index: number]: FG.Event[];
|
|
|
|
}
|
|
|
|
|
|
|
|
onBeforeMount(async () => {
|
2021-02-05 23:07:58 +00:00
|
|
|
let agenda: Agendas = {};
|
2021-02-07 19:16:21 +00:00
|
|
|
console.log('Hier Passiert was');
|
2021-02-10 16:37:43 +00:00
|
|
|
const list = await store.getEvents({ from: new Date(selectedDate.value) });
|
|
|
|
if (list)
|
|
|
|
list.forEach((event) => {
|
2021-02-05 23:07:58 +00:00
|
|
|
let day = event.start.getDay();
|
2021-03-19 17:33:57 +00:00
|
|
|
|
2021-02-05 23:07:58 +00:00
|
|
|
if (!agenda[day]) {
|
|
|
|
agenda[day] = [];
|
|
|
|
}
|
|
|
|
agenda[day].push(event);
|
|
|
|
});
|
|
|
|
console.log('finish agenda:', agenda);
|
2021-02-10 16:37:43 +00:00
|
|
|
events.value = agenda;
|
2021-02-05 23:07:58 +00:00
|
|
|
});
|
|
|
|
|
2021-02-04 23:07:51 +00:00
|
|
|
function getAgenda(day: { weekday: string }) {
|
2021-02-10 16:37:43 +00:00
|
|
|
return events.value[parseInt(day.weekday, 10)];
|
2021-02-05 23:07:58 +00:00
|
|
|
}
|
|
|
|
|
2021-02-04 23:07:51 +00:00
|
|
|
function calendarNext() {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call
|
2021-03-19 01:36:31 +00:00
|
|
|
return calendar.value?.next();
|
2021-02-05 23:07:58 +00:00
|
|
|
}
|
|
|
|
|
2021-02-04 23:07:51 +00:00
|
|
|
function calendarPrev() {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call
|
2021-03-19 01:36:31 +00:00
|
|
|
return calendar.value?.prev();
|
2021-02-05 23:07:58 +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
|
|
|
getAgenda,
|
|
|
|
calendarNext,
|
|
|
|
calendarPrev,
|
|
|
|
updateProxy,
|
|
|
|
saveNewSelectedDate,
|
2021-02-07 19:16:21 +00:00
|
|
|
proxyDate,
|
2021-02-10 16:37:43 +00:00
|
|
|
calendarView,
|
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>
|