2021-02-05 23:07:58 +00:00
|
|
|
<template>
|
|
|
|
<q-page padding>
|
|
|
|
<q-card>
|
|
|
|
<template>
|
2021-03-18 16:23:57 +00:00
|
|
|
<div style="max-width: 1800px; width: 100%">
|
2021-02-05 23:07:58 +00:00
|
|
|
<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
|
|
|
|
>{{ selectedDate | toMonth }} {{ selectedDate | toYear }}
|
|
|
|
<q-popup-proxy
|
|
|
|
@before-show="updateProxy"
|
|
|
|
transition-show="scale"
|
|
|
|
transition-hide="scale"
|
|
|
|
>
|
|
|
|
<q-date v-model="proxyDate">
|
|
|
|
<div class="row items-center justify-end q-gutter-sm">
|
|
|
|
<q-btn label="Cancel" color="primary" flat v-close-popup />
|
|
|
|
<q-btn
|
|
|
|
label="OK"
|
|
|
|
color="primary"
|
|
|
|
flat
|
|
|
|
@click="saveNewSelectedDate(proxyDate)"
|
|
|
|
v-close-popup
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</q-date>
|
|
|
|
</q-popup-proxy>
|
|
|
|
</q-btn>
|
|
|
|
<q-separator vertical />
|
|
|
|
<q-btn flat dense label="Next" @click="calendarNext" />
|
|
|
|
</div>
|
2021-02-07 19:16:21 +00:00
|
|
|
<!-- <q-space /> -->
|
|
|
|
|
|
|
|
<q-btn-toggle
|
|
|
|
class="row absolute-right"
|
|
|
|
v-model="calendarView"
|
|
|
|
flat
|
|
|
|
stretch
|
|
|
|
toggle-color=""
|
|
|
|
:options="[
|
|
|
|
{ label: 'Tag', value: 'day-agenda' },
|
2021-03-18 16:23:57 +00:00
|
|
|
{ label: 'Woche', value: 'week-agenda' },
|
2021-02-07 19:16:21 +00:00
|
|
|
]"
|
|
|
|
/>
|
2021-02-05 23:07:58 +00:00
|
|
|
</q-toolbar>
|
|
|
|
<q-calendar
|
|
|
|
v-model="selectedDate"
|
2021-02-07 19:16:21 +00:00
|
|
|
:view="calendarView"
|
2021-02-05 23:07:58 +00:00
|
|
|
:weekdays="[1, 2, 3, 4, 5, 6, 0]"
|
|
|
|
locale="de-de"
|
2021-03-18 16:23:57 +00:00
|
|
|
style="height: 100%; min-height: 400px"
|
2021-02-05 23:07:58 +00:00
|
|
|
ref="calendar"
|
|
|
|
>
|
2021-03-18 16:23:57 +00:00
|
|
|
<template #day-body="{ timestamp }" style="min-height: 200px">
|
|
|
|
<template !v-if="getAgenda(timestamp)" style="min-height: 200px"> </template>
|
2021-02-05 23:07:58 +00:00
|
|
|
<template v-for="agenda in getAgenda(timestamp)">
|
|
|
|
<eventslot :event="agenda" :key="agenda.id" />
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</q-calendar>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</q-card>
|
|
|
|
</q-page>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
|
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
|
|
import { computed, defineComponent, onBeforeMount, ref } from '@vue/composition-api';
|
|
|
|
import { Store } from 'vuex';
|
|
|
|
import { StateInterface } from 'src/store';
|
|
|
|
import { ScheduleInterface } from '../../store/schedule';
|
|
|
|
import Eventslot from './slots/EventSlot.vue';
|
|
|
|
import { date } from 'quasar';
|
|
|
|
export default defineComponent({
|
|
|
|
name: 'AgendaView',
|
|
|
|
components: { Eventslot },
|
|
|
|
filters: {
|
2021-03-18 16:23:57 +00:00
|
|
|
toMonth: function (value: string) {
|
2021-02-05 23:07:58 +00:00
|
|
|
if (value) {
|
|
|
|
return date.formatDate(new Date(value), 'MMMM', {
|
|
|
|
months: [
|
|
|
|
'Januar',
|
|
|
|
'Februar',
|
|
|
|
'März',
|
|
|
|
'April',
|
|
|
|
'Mai',
|
|
|
|
'Juni',
|
|
|
|
'Juli',
|
|
|
|
'August',
|
|
|
|
'September',
|
|
|
|
'Oktober',
|
|
|
|
'November',
|
2021-03-18 16:23:57 +00:00
|
|
|
'Dezember',
|
|
|
|
],
|
2021-02-05 23:07:58 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2021-03-18 16:23:57 +00:00
|
|
|
toYear: function (value: string) {
|
2021-02-05 23:07:58 +00:00
|
|
|
if (value) {
|
|
|
|
return date.formatDate(new Date(value), 'YYYY');
|
|
|
|
}
|
2021-03-18 16:23:57 +00:00
|
|
|
},
|
2021-02-05 23:07:58 +00:00
|
|
|
},
|
2021-02-07 19:16:21 +00:00
|
|
|
|
2021-02-05 23:07:58 +00:00
|
|
|
setup(_, { root }) {
|
|
|
|
const store = <Store<StateInterface>>root.$store;
|
2021-02-07 19:16:21 +00:00
|
|
|
const state = computed(() => <ScheduleInterface>store.state.schedule);
|
2021-02-05 23:07:58 +00:00
|
|
|
const selectedDate = ref(date.formatDate(new Date(), 'YYYY-MM-DD'));
|
|
|
|
const proxyDate = ref('');
|
2021-02-07 19:16:21 +00:00
|
|
|
const calendarView = 'week-agenda';
|
2021-02-05 23:07:58 +00:00
|
|
|
const events2 = computed(() => {
|
|
|
|
let agenda: Agendas = {};
|
2021-02-07 19:16:21 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
|
|
console.log('Hier Passiert was');
|
|
|
|
state.value.events
|
2021-03-18 16:23:57 +00:00
|
|
|
.filter((event) => {
|
2021-02-05 23:07:58 +00:00
|
|
|
const thisWeek = date.formatDate(new Date(selectedDate.value), 'w');
|
|
|
|
console.log(thisWeek, date.formatDate(event.start, 'w'));
|
|
|
|
return date.formatDate(event.start, 'w') == thisWeek;
|
|
|
|
})
|
2021-03-18 16:23:57 +00:00
|
|
|
.forEach((event) => {
|
2021-02-05 23:07:58 +00:00
|
|
|
let day = event.start.getDay();
|
|
|
|
console.log('event', event, day, !agenda[day]);
|
|
|
|
if (!agenda[day]) {
|
|
|
|
agenda[day] = [];
|
|
|
|
}
|
|
|
|
agenda[day].push(event);
|
|
|
|
});
|
|
|
|
console.log('finish agenda:', agenda);
|
|
|
|
return agenda;
|
|
|
|
});
|
|
|
|
|
|
|
|
interface Agendas {
|
|
|
|
[index: number]: FG.Event[];
|
|
|
|
}
|
|
|
|
|
|
|
|
onBeforeMount(() => {
|
|
|
|
void store.dispatch('schedule/getEvents');
|
|
|
|
});
|
|
|
|
function getAgenda(this: any, day: { weekday: string }) {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
|
|
return this.events2[parseInt(day.weekday, 10)];
|
|
|
|
}
|
|
|
|
|
|
|
|
function calendarNext(this: any) {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
|
|
return this.$refs.calendar.next();
|
|
|
|
}
|
|
|
|
|
|
|
|
function calendarPrev(this: any) {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
|
|
return this.$refs.calendar.prev();
|
|
|
|
}
|
|
|
|
function updateProxy(this: any) {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
|
|
proxyDate.value = selectedDate.value;
|
|
|
|
}
|
|
|
|
function saveNewSelectedDate(this: any) {
|
|
|
|
proxyDate.value = date.formatDate(proxyDate.value, 'YYYY-MM-DD');
|
|
|
|
selectedDate.value = proxyDate.value;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
selectedDate,
|
|
|
|
events2,
|
|
|
|
getAgenda,
|
|
|
|
calendarNext,
|
|
|
|
calendarPrev,
|
|
|
|
updateProxy,
|
|
|
|
saveNewSelectedDate,
|
2021-02-07 19:16:21 +00:00
|
|
|
proxyDate,
|
2021-03-18 16:23:57 +00:00
|
|
|
calendarView,
|
2021-02-05 23:07:58 +00:00
|
|
|
};
|
2021-03-18 16:23:57 +00:00
|
|
|
},
|
2021-02-05 23:07:58 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style></style>
|