Compare commits

..

No commits in common. "main" and "feature/requests" have entirely different histories.

13 changed files with 61 additions and 247 deletions

View File

@ -197,9 +197,9 @@ def get_events(
if not with_backup:
for event in events:
clear_backup(event)
# logger.debug(end)
# for event in events:
# logger.debug(f"{event.start} < {end} = {event.start < end}")
logger.debug(end)
for event in events:
logger.debug(f"{event.start} < {end} = {event.start < end}")
return count, events

View File

@ -1,6 +1,6 @@
[metadata]
license = MIT
version = 1.0.0
version = 0.0.1-dev.1
name = flaschengeist-events
description = Events plugin for Flaschengeist
url = https://flaschengeist.dev/Flaschengeist/flaschengeist-schedule
@ -24,10 +24,7 @@ python_requires = >=3.8
packages =
flaschengeist_events
install_requires =
flaschengeist >= 2.0.0
[options.package_data]
* = *.toml, script.py.mako, *.ini, migrations/*.py
flaschengeist == 2.0.*
[options.entry_points]
flaschengeist.plugins =

View File

@ -1,6 +1,6 @@
{
"license": "MIT",
"version": "1.1.0",
"version": "1.0.0-alpha.6",
"name": "@flaschengeist/schedule",
"author": "Ferdinand Thiessen <rpm@fthiessen.de>",
"homepage": "https://flaschengeist.dev/Flaschengeist",
@ -22,24 +22,24 @@
"@quasar/quasar-ui-qcalendar": "^4.0.0-beta.11"
},
"devDependencies": {
"@flaschengeist/api": "^1.0.0",
"@flaschengeist/types": "^1.0.0",
"@quasar/app-webpack": "^3.7.2",
"@typescript-eslint/eslint-plugin": "^5.8.0",
"@typescript-eslint/parser": "^5.8.0",
"@flaschengeist/api": "^1.0.0-alpha.7",
"@flaschengeist/types": "^1.0.0-alpha.10",
"@quasar/app": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^5.6.0",
"@typescript-eslint/parser": "^5.6.0",
"axios": "^0.24.0",
"eslint": "^8.5.0",
"eslint": "^8.4.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.2.0",
"pinia": "^2.0.8",
"pinia": "^2.0.6",
"prettier": "^2.5.1",
"quasar": "^2.11.10",
"typescript": "^4.5.4"
"quasar": "^2.3.4",
"typescript": "^4.5.2"
},
"peerDependencies": {
"@flaschengeist/api": "^1.0.0",
"@flaschengeist/users": "^1.0.0"
"@flaschengeist/api": "^1.0.0-alpha.7",
"@flaschengeist/users": "^1.0.0-alpha.3"
},
"prettier": {
"singleQuote": true,

View File

@ -52,7 +52,6 @@
class="col-xs-12 col-sm-6 q-pa-sm"
label="Veranstaltungsende"
:rules="[afterStart]"
:key="update_time"
/>
<q-input
v-model="event.description"
@ -62,7 +61,7 @@
filled
/>
</q-card-section>
<q-card-section v-if="modelValue === undefined">
<q-card-section v-if="event.is_template !== true && modelValue === undefined">
<q-btn-toggle
v-model="recurrent"
spread
@ -82,7 +81,8 @@
<q-btn color="primary" label="Schicht hinzufügen" @click="addJob()" />
</div>
</div>
<template v-for="(job, index) in event.jobs" :key="index + update_time">
<template v-for="(job, index) in event.jobs" :key="index">
<!--:ref="active === index ? 'activeJob' : undefined"-->
<edit-job-slot
ref="activeJob"
v-model="event.jobs[index]"
@ -138,7 +138,6 @@ export default defineComponent({
},
emits: {
done: (val: boolean) => typeof val === 'boolean',
'update:modelValue': (val?: FG.Event) => typeof val === 'object',
},
setup(props, { emit }) {
const store = useEventStore();
@ -183,7 +182,7 @@ export default defineComponent({
}
function fromTemplate(tpl: FG.Event) {
const today = props.modelValue?.start || new Date();
const today = new Date();
template.value = tpl;
event.value = Object.assign({}, tpl, { id: undefined });
@ -197,27 +196,16 @@ export default defineComponent({
const diff = event.value.start.getTime() - tpl.start.getTime();
// Adjust end of event and all jobs
if (event.value.end) event.value.end.setTime(event.value.end.getTime() + diff);
event.value.jobs = [];
tpl.jobs.forEach((job) => {
const copied_job: FG.Job = Object.assign({}, job, {
id: NaN,
start: new Date(),
end: undefined,
});
copied_job.start.setTime(job.start.getTime() + diff);
if (job.end) {
copied_job.end = new Date();
copied_job.end.setTime(job.end.getTime() + diff);
}
event.value.jobs.push(<Job>copied_job);
event.value.jobs.forEach((job) => {
job.start.setTime(job.start.getTime() + diff);
if (job.end) job.end.setTime(job.end.getTime() + diff);
});
}
async function save(is_template = false) {
event.value.is_template = is_template;
async function save(template = false) {
event.value.is_template = template;
try {
const _event = await store.addEvent(event.value);
emit('update:modelValue', _event);
await store.addEvent(event.value);
if (props.modelValue === undefined && recurrent.value && !event.value.is_template) {
let count = 0;
@ -279,55 +267,7 @@ export default defineComponent({
});
}
const computed_start = computed({
get: () => event.value?.start,
set: (value) => {
event.value.start = value;
},
});
const computed_end = computed({
get: () => event.value?.end,
set: (value) => {
event.value.end = value;
},
});
const update_time = ref(false);
watch(computed_start, (newValue, oldValue) => {
update_time.value = true;
const diff = newValue.getTime() - oldValue.getTime();
event.value?.jobs.forEach((job) => {
job.start.setTime(job.start.getTime() + diff);
job.end?.setTime(job.end.getTime() + diff);
});
computed_end.value?.setTime(computed_end.value?.getTime() + diff);
setTimeout(() => {
update_time.value = false;
}, 0);
});
watch(computed_end, (newValue, oldValue) => {
if (newValue && oldValue) {
update_time.value = true;
if (!newValue || !oldValue) return;
const diff = newValue.getTime() - oldValue.getTime();
event.value?.jobs.forEach((job) => {
if (job.end) job.end.setTime(job.end.getTime() + diff);
else job.end = new Date(newValue.getTime());
});
} else if (newValue && !oldValue) {
event.value?.jobs.forEach((job) => {
if (!job.end) job.end = new Date(newValue.getTime());
});
}
setTimeout(() => {
update_time.value = false;
}, 0);
});
return {
update_time,
activate,
active,
addJob,

View File

@ -40,12 +40,12 @@
:rules="[notEmpty]"
/>
<q-input
v-model.number="job.required_services"
v-model="job.required_services"
filled
class="col-xs-12 col-sm-6 q-pa-sm"
label="Dienstanzahl"
type="number"
:rules="[minOneService, notEmpty]"
:rules="[notEmpty]"
/>
<q-input
v-model="job.comment"
@ -134,10 +134,6 @@ export default defineComponent({
validate: () => form.value?.validate() || Promise.resolve(true),
});
function minOneService(val: number) {
return parseInt(val) > 0 || 'Mindestens ein Dienst nötig';
}
return {
form,
formatStartEnd,
@ -145,7 +141,6 @@ export default defineComponent({
job,
jobtypes,
notEmpty,
minOneService,
typeName,
};
},

View File

@ -30,17 +30,10 @@
<q-table :title="title" :rows="rows" row-key="id" :columns="columns">
<template #top-right>
<q-input
ref="input"
v-model="actualType.name"
:rules="rules"
dense
filled
placeholder="Neuer Typ"
>
<template #after
><q-btn color="primary" icon="mdi-plus" title="Hinzufügen" round @click="addType"
/></template>
<q-input ref="input" v-model="actualType.name" :rules="rules" dense placeholder="Neuer Typ">
<slot name="after"
><q-btn color="primary" icon="mdi-plus" title="Hinzufügen" @click="addType"
/></slot>
</q-input>
</template>
<template #body-cell-actions="props">

View File

@ -88,10 +88,9 @@
</template>
<script lang="ts">
import { ComponentPublicInstance, computed, defineComponent, onBeforeMount, ref, watch } from 'vue';
import { ComponentPublicInstance, computed, defineComponent, onBeforeMount, ref } from 'vue';
import { QCalendarAgenda } from '@quasar/quasar-ui-qcalendar';
import { date, QDate, QPopupProxy, useQuasar } from 'quasar';
import { useRoute, useRouter } from 'vue-router';
import { EditableEvent, emptyEvent } from '../../store/models';
import { startOfWeek } from '@flaschengeist/api';
import { useEventStore } from '../../store';
@ -106,8 +105,6 @@ export default defineComponent({
setup() {
const store = useEventStore();
const quasar = useQuasar();
const route = useRoute();
const router = useRouter();
const datepicker = ref<QDate>();
const proxy = ref<QPopupProxy>();
@ -144,19 +141,6 @@ export default defineComponent({
}
onBeforeMount(async () => {
await router.replace({ query: { ...route.query, q_tab: 'agendaView' } });
if (!Object.keys(route.query).includes('q_date')) {
const q_date = date.formatDate(selectedDate.value, 'YYYY-MM-DD');
await router.replace({ query: { ...route.query, q_date } });
} else {
selectedDate.value = date.extractDate(route.query.q_date as string, 'YYYY-MM-DD');
}
if (!Object.keys(route.query).includes('q_view')) {
const q_view = calendarView.value;
await router.replace({ query: { ...route.query, q_view } });
} else {
calendarView.value = route.query.q_view as string;
}
await loadAgendas();
});
@ -187,11 +171,7 @@ export default defineComponent({
}
}
const loading = ref(false);
async function loadAgendas() {
if (loading.value) return;
loading.value = true;
const from =
calendarView.value === 'day' ? selectedDate.value : startOfWeek(selectedDate.value);
const to = date.addToDate(from, { days: calendarView.value === 'day' ? 1 : 7 });
@ -204,11 +184,8 @@ export default defineComponent({
if (!events.value[day]) {
events.value[day] = [];
}
const idx = events.value[day].findIndex((e) => e.id === event.id);
if (idx === -1) events.value[day].push(event);
else events.value[day][idx] = event;
events.value[day].push(event);
});
loading.value = false;
}
function addDays(reverse: boolean) {
@ -235,24 +212,12 @@ export default defineComponent({
'November',
'Dezember',
'-',
][value?.getMonth() === 0 ? 0 : value?.getMonth() || 12];
][value?.getMonth() || 12];
}
function asYear(value?: Date) {
return value?.getFullYear() || '-';
}
watch(selectedDate, async (newValue) => {
const q_date = date.formatDate(newValue, 'YYYY-MM-DD');
await router.replace({ query: { ...route.query, q_date } });
await loadAgendas();
});
watch(calendarView, async (newValue) => {
const q_view = newValue;
await router.replace({ query: { ...route.query, q_view } });
await loadAgendas();
});
return {
asYear,
asMonth,

View File

@ -28,7 +28,7 @@
<q-separator />
<q-item-label header>{{ asDate(index) }}</q-item-label>
<q-item v-for="(event, idx) in events" :key="idx">
<event-slot v-model="events[idx]" @edit-event="edit" @remove-event="remove" />
<event-slot :model-value="event" />
</q-item>
</template>
</q-list>
@ -88,10 +88,6 @@ export default defineComponent({
function editDone(changed: boolean) {
//if (changed) void loadAgendas();
const idx = events.value.findIndex((event) => event.id === editor.value?.id);
if (idx >= 0) {
events.value[idx] = editor.value as FG.Event;
}
editor.value = undefined;
}
@ -99,12 +95,7 @@ export default defineComponent({
const start = new Date();
if (index < 0) {
const { result } = await store.getEvents({ to: start, limit: 5, descending: true });
//events.value.unshift(...result);
for (const event of result) {
const idx = events.value.findIndex((e) => e.id === event.id);
if (idx === -1) events.value.unshift(event);
else events.value[idx] = event;
}
events.value.unshift(...result);
if (done) done(false);
} else {
const len = events.value.length;
@ -113,12 +104,7 @@ export default defineComponent({
offset: (index - 1) * 10,
limit: 10,
});
for (const event of result) {
const idx = events.value.findIndex((e) => e.id === event.id);
if (idx === -1) events.value.unshift(event);
else events.value[idx] = event;
}
if (len == events.value.length) {
if (len == events.value.push(...result)) {
if (done) return done(true);
} else if (done) done(false);
}
@ -131,11 +117,17 @@ export default defineComponent({
async function remove(id: number) {
if (await store.removeEvent(id)) {
const idx = events.value.findIndex((event) => event.id === id);
if (idx !== -1) {
events.value.splice(idx, 1);
// Successfull removed
for (const idx in agendas.value) {
const i = agendas.value[idx].findIndex((event) => event.id === id);
if (i !== -1) {
agendas.value[idx].splice(i, 1);
break;
}
}
} else {
// Not found, this means our eventa are outdated
}
}
function asMonth(value: string) {

View File

@ -54,7 +54,7 @@
</q-select>
<div class="row col-12 justify-end">
<q-btn
v-if="!modelValue.locked && !isEnrolled && !isFull && canAssign"
v-if="!modelValue.locked && !isEnrolled && !isFull"
flat
color="primary"
label="Eintragen"
@ -101,7 +101,6 @@ import { PERMISSIONS } from '../../../permissions';
import TransferInviteDialog from './TransferInviteDialog.vue';
import ServiceUserChip from './ServiceUserChip.vue';
import { UserAvatar } from '@flaschengeist/api/components';
import { DisplayNameMode } from '@flaschengeist/users';
export default defineComponent({
name: 'JobSlot',
@ -124,34 +123,11 @@ export default defineComponent({
const quasar = useQuasar();
// Make sure users are loaded if we can assign them
onBeforeMount(() => {
void userStore.getUsers();
void userStore.getDisplayNameModeSetting(true);
});
onBeforeMount(() => void userStore.getUsers());
/* Stuff used for general display */
// Get displayname of user
function userDisplay(id: string) {
switch (userStore.userSettings.display_name) {
case DisplayNameMode.FIRSTNAME:
return userStore.findUser(id)?.firstname || id;
case DisplayNameMode.LASTNAME:
return userStore.findUser(id)?.lastname || id;
case DisplayNameMode.DISPLAYNAME:
return userStore.findUser(id)?.display_name || id;
case DisplayNameMode.FIRSTNAME_LASTNAME:
return (
`${<string>userStore.findUser(id)?.firstname} ${<string>(
userStore.findUser(id)?.lastname
)}` || id
);
case DisplayNameMode.LASTNAME_FIRSTNAME:
return (
`${<string>userStore.findUser(id)?.lastname}, ${<string>(
userStore.findUser(id)?.firstname
)}` || id
);
}
return userStore.findUser(id)?.display_name || id;
}
@ -229,8 +205,6 @@ export default defineComponent({
// Current user can assign other users
const canAssignOther = computed(() => hasPermission(PERMISSIONS.ASSIGN_OTHER));
const canAssign = computed(() => hasPermission(PERMISSIONS.ASSIGN));
// options shown in the select
const options = ref([] as FG.Service[]);
@ -283,7 +257,6 @@ export default defineComponent({
unassign: (s?: FG.Service) => assign(Object.assign({}, s || service.value, { value: -1 })),
backup: (is_backup: boolean) => assign(Object.assign({}, service.value, { is_backup })),
canAssignOther,
canAssign,
canInvite,
filterUsers,
isBackup,

View File

@ -44,8 +44,7 @@
</template>
<script lang="ts">
import { computed, defineComponent, ref, onBeforeMount, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { computed, defineComponent, ref } from 'vue';
import ManageTypes from '../components/management/ManageTypes.vue';
import EditEvent from '../components/management/EditEvent.vue';
import { hasPermission } from '@flaschengeist/api';
@ -71,21 +70,6 @@ export default defineComponent({
: []),
]);
const route = useRoute();
const router = useRouter();
onBeforeMount(async () => {
if (
(route.query.q_tab && route.query.q_tab === 'create') ||
route.query.q_tab === 'jobtypes' ||
route.query.q_tab === 'eventtypes'
) {
tab.value = route.query.q_tab;
} else {
await router.replace({ query: { q_tab: tab.value } });
}
});
const drawer = ref<boolean>(false);
const tab = ref<string>('create');
@ -98,10 +82,6 @@ export default defineComponent({
},
});
watch(tab, async (val) => {
await router.replace({ query: { q_tab: val } });
});
return {
showDrawer,
tab,

View File

@ -43,8 +43,7 @@
</template>
<script lang="ts">
import { computed, defineComponent, ref, onBeforeMount, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { computed, defineComponent, ref, onBeforeMount } from 'vue';
import { useQuasar } from 'quasar';
import AgendaView from '../components/overview/AgendaView.vue';
import ListView from '../components/overview/ListView.vue';
@ -56,19 +55,8 @@ export default defineComponent({
components: { AgendaView, ListView },
setup() {
const store = useEventStore();
const route = useRoute();
const router = useRouter();
const tab = ref<string>('agendaView');
onBeforeMount(async () => {
onBeforeMount(() => {
void store.getJobTypes();
if (
Object.keys(route.query).includes('q_tab') &&
(route.query.q_tab === 'listView' || route.query.q_tab === 'agendaView')
) {
tab.value = route.query.q_tab as string;
} else {
await router.replace({ query: { ...route.query, q_tab: tab.value } });
}
});
const quasar = useQuasar();
@ -86,10 +74,7 @@ export default defineComponent({
},
});
watch(tab, async (val) => {
console.log(val);
await router.replace({ query: { ...route.query, q_tab: val } });
});
const tab = ref<string>('agendaView');
return {
showDrawer,

View File

@ -56,7 +56,6 @@
<script lang="ts">
import { formatStartEnd, useMainStore, useUserStore } from '@flaschengeist/api';
import { computed, defineComponent, ref, onBeforeMount, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { QTableProps } from 'quasar';
import { Job } from '../store/models';
import { useEventStore } from '../store';
@ -68,8 +67,6 @@ export default defineComponent({
const store = useEventStore();
const userStore = useUserStore();
const mainStore = useMainStore();
const router = useRouter();
const route = useRoute();
interface RowData extends FG.Invitation {
inviter: FG.User;
@ -158,11 +155,7 @@ export default defineComponent({
.finally(() => (loading.value = false));
};
onBeforeMount(async () => {
if (route.query.sent === 'true') {
showSent.value = true;
}
onBeforeMount(() => {
void Promise.allSettled([
userStore.getUsers(),
store.getInvitations(),
@ -172,9 +165,8 @@ export default defineComponent({
);
});
watch(showSent, async () => {
watch(showSent, () => {
onRequest({ pagination: pagination.value, filter: () => [], getCellValue: () => [] });
await router.replace({ query: { sent: showSent.value ? 'true' : 'false' } });
});
function getType(row: RowData) {

View File

@ -150,13 +150,15 @@ export const useEventStore = defineStore({
if (event?.id === undefined) {
const { data } = await api.post<FG.Event>('/events', event);
if (data.is_template) this.templates.push(data);
fixEvent(data);
return data;
} else {
if (typeof event.type === 'object') event.type = event.type.id;
const { data } = await api.put<FG.Event>(`/events/${event.id}`, event);
const { data } = await api.put<FG.Event>(
`/events/${event.id}`,
// Object.assign(event, { jobs: undefined })
event
);
if (data.is_template) this.templates.push(data);
fixEvent(data);
return data;
}
},