From 575090552fcda8046346d627e271fa0f3113d64a Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 19 Mar 2021 21:01:50 +0100 Subject: [PATCH 1/3] [schedule] Improved calendar view * Load events on next and prev * Resize if display is not wide enough * Fixed permissions --- .../components/overview/AgendaView.vue | 64 +++++++++++-------- src/plugins/schedule/pages/Management.vue | 6 +- src/plugins/schedule/pages/Overview.vue | 19 ++---- src/plugins/schedule/permissions.ts | 24 ++++--- src/plugins/schedule/routes/index.ts | 4 +- src/utils/datetime.ts | 8 +++ 6 files changed, 71 insertions(+), 54 deletions(-) diff --git a/src/plugins/schedule/components/overview/AgendaView.vue b/src/plugins/schedule/components/overview/AgendaView.vue index 022ab2e..4a229e2 100644 --- a/src/plugins/schedule/components/overview/AgendaView.vue +++ b/src/plugins/schedule/components/overview/AgendaView.vue @@ -47,14 +47,15 @@ diff --git a/src/plugins/schedule/permissions.ts b/src/plugins/schedule/permissions.ts index 2ba1b10..40a5b92 100644 --- a/src/plugins/schedule/permissions.ts +++ b/src/plugins/schedule/permissions.ts @@ -1,12 +1,16 @@ export const PERMISSIONS = { - // Kann andere Nutzer bearbeiten - EDIT_OTHER: 'users_edit_other', - // Kann Rollen von Nutzern setzen - SET_ROLES: 'users_set_roles', - // Kann Nutzer löschen - DELETE: 'users_delete_other', - // Kann neue Nutzer hinzufügen - REGISTER: 'users_register', - // Kann Rollen löschen oder bearbeiten, z.b. Rechte hinzufügen etc - ROLES_EDIT: 'roles_edit', + // Can create events + CREATE: 'schedule_create', + // Can edit events + EDIT: 'schedule_edit', + // Can delete events + DELETE: 'schedule_delete', + // Can create and edit EventTypes + EVENT_TYPE: 'schedule_event_type', + // Can create and edit JobTypes + JOB_TYPE: 'schedule_job_type', + // Can self assign to jobs + ASSIGN: 'schedule_assign', + // Can assign other users to jobs + ASSIGN_OTHER: 'schedule_assign_other', }; diff --git a/src/plugins/schedule/routes/index.ts b/src/plugins/schedule/routes/index.ts index b7cc912..7c816a6 100644 --- a/src/plugins/schedule/routes/index.ts +++ b/src/plugins/schedule/routes/index.ts @@ -1,4 +1,5 @@ import { FG_Plugin } from 'src/plugins'; +import { PERMISSIONS } from '../permissions'; const mainRoutes: FG_Plugin.PluginRouteConfig[] = [ { @@ -14,9 +15,7 @@ const mainRoutes: FG_Plugin.PluginRouteConfig[] = [ { title: 'Dienstübersicht', icon: 'mdi-account-group', - shortcut: true, - permissions: [], route: { path: 'schedule-overview', name: 'schedule-overview', @@ -27,6 +26,7 @@ const mainRoutes: FG_Plugin.PluginRouteConfig[] = [ title: 'Dienstverwaltung', icon: 'mdi-account-details', shortcut: false, + permissions: [PERMISSIONS.CREATE], route: { path: 'schedule-management', name: 'schedule-management', diff --git a/src/utils/datetime.ts b/src/utils/datetime.ts index 48e2599..3fc0139 100644 --- a/src/utils/datetime.ts +++ b/src/utils/datetime.ts @@ -20,3 +20,11 @@ export function formatDateTime( export function asHour(date?: Date) { if (date) return formatDateTime(date, false, true); } + +export function startOfWeek(date: Date, startMonday = true) { + const start = new Date(date); + const day = date.getDay() || 7; + if (startMonday && day !== 1) start.setHours(-24 * (day - 1)); + else if (!startMonday && day !== 7) start.setHours(-24 * day); + return start; +} From a4ce273bb1002cfe5064ac036aa77fcaaa67def3 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 19 Mar 2021 21:34:49 +0100 Subject: [PATCH 2/3] [plugin] Fixed setting permission if non are set --- src/boot/plugins.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/boot/plugins.ts b/src/boot/plugins.ts index 21edae8..a049a17 100644 --- a/src/boot/plugins.ts +++ b/src/boot/plugins.ts @@ -33,8 +33,10 @@ interface Backend { export { Backend }; function setPermissions(object: FG_Plugin.PluginRouteConfig) { - if (object.route.meta === undefined) object.route.meta = {}; - object.route.meta['permissions'] = object.permissions; + if (object.permissions !== undefined) { + if (object.route.meta === undefined) object.route.meta = {}; + object.route.meta['permissions'] = object.permissions; + } } function convertRoutes(parent: RouteRecordRaw, children?: FG_Plugin.PluginRouteConfig[]) { From 7e7f9c943d10385bedd087a0412d62b309f8a501 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sat, 20 Mar 2021 00:59:44 +0100 Subject: [PATCH 3/3] [schedule] Improved creating new events --- src/flaschengeist.d.ts | 12 +-- .../components/management/CreateEvent.vue | 56 ++---------- .../schedule/components/management/Job.vue | 85 +++++++------------ src/plugins/schedule/store.ts | 17 ++-- 4 files changed, 53 insertions(+), 117 deletions(-) diff --git a/src/flaschengeist.d.ts b/src/flaschengeist.d.ts index afd25e1..28f38ba 100644 --- a/src/flaschengeist.d.ts +++ b/src/flaschengeist.d.ts @@ -28,11 +28,11 @@ declare namespace FG { id: number; time: Date; amount: number; - reversal_id: number; - sender_id?: string; - receiver_id?: string; + reversal_id?: number; author_id?: string; + sender_id?: string; original_id?: number; + receiver_id?: string; } interface Drink { id: number; @@ -91,7 +91,7 @@ declare namespace FG { start: Date; end?: Date; description?: string; - type: EventType; + type: EventType | number; jobs: Array; } interface EventType { @@ -102,8 +102,8 @@ declare namespace FG { id: number; start: Date; end?: Date; - comment: string; - type: JobType; + type: JobType | number; + comment?: string; services: Array; required_services: number; } diff --git a/src/plugins/schedule/components/management/CreateEvent.vue b/src/plugins/schedule/components/management/CreateEvent.vue index 99ac748..7c5aca2 100644 --- a/src/plugins/schedule/components/management/CreateEvent.vue +++ b/src/plugins/schedule/components/management/CreateEvent.vue @@ -43,13 +43,8 @@ @@ -78,59 +73,31 @@ export default defineComponent({ const eventtypes = computed(() => store.eventTypes); const jobDeleteDisabled = computed(() => event.value.jobs.length < 2); - const newJob = ref(({ + const newJob = ref({ id: NaN, - start: undefined, - end: undefined, - comment: '', + start: new Date(), + end: date.addToDate(new Date(), { hours: 1 }), services: [], required_services: 2, - } as unknown) as FG.Job); + type: store.jobTypes[0], + }); const event = ref({ id: NaN, start: new Date(), - description: '', jobs: [Object.assign({}, newJob.value)], - } as FG.Event); + type: store.eventTypes[0], + }); onBeforeMount(() => { void store.getEventTypes(); void store.getJobTypes(); }); - function setStart(data: { job: FG.Job; value: Date }) { - data.job.start = data.value; - } - - function setEnd(data: { job: FG.Job; value: Date }) { - data.job.end = data.value; - } - - function setComment(data: { job: FG.Job; value: string }) { - data.job.comment = data.value; - } - - function setJobType(job: FG.Job, value: FG.JobType) { - job.type = value; - } - - function setRequired(data: { job: FG.Job; value: number }) { - data.job.required_services = data.value; - } - function addJob() { - const addJob = Object.assign({}, newJob.value); - event.value.jobs.unshift(addJob); + event.value.jobs.push(Object.assign({}, newJob.value)); } - //function removeJob(id: number) { - // let jobtoremove = event.value.jobs.findIndex(job => job.id == id); - // if (jobtoremove != undefined) { - // event.value.jobs.splice(jobtoremove, 1); - // } - //} - function removeJob(index: number) { event.value.jobs.splice(index, 1); } @@ -174,11 +141,6 @@ export default defineComponent({ reset, event, isAfterDate, - setStart, - setEnd, - setComment, - setJobType, - setRequired, }; }, }); diff --git a/src/plugins/schedule/components/management/Job.vue b/src/plugins/schedule/components/management/Job.vue index 462d5d0..89a1a10 100644 --- a/src/plugins/schedule/components/management/Job.vue +++ b/src/plugins/schedule/components/management/Job.vue @@ -2,59 +2,52 @@ @@ -63,7 +56,7 @@