From 1ccddb228dd1e160155c7d8d59cfdb1dc8bc90d9 Mon Sep 17 00:00:00 2001 From: Dominik Date: Tue, 26 Jan 2021 20:38:46 +0100 Subject: [PATCH] Minor changes to createEvent --- .../components/management/CreateEvent.vue | 173 ++++++++++++++++-- .../components/management/JobTypes.vue | 1 - src/plugins/schedule/store/schedule.ts | 38 +++- 3 files changed, 194 insertions(+), 18 deletions(-) diff --git a/src/plugins/schedule/components/management/CreateEvent.vue b/src/plugins/schedule/components/management/CreateEvent.vue index 7be95b0..a1ad9b7 100644 --- a/src/plugins/schedule/components/management/CreateEvent.vue +++ b/src/plugins/schedule/components/management/CreateEvent.vue @@ -6,24 +6,88 @@ + + + + + + + + + + + + + + + + + + @@ -35,28 +99,107 @@ diff --git a/src/plugins/schedule/components/management/JobTypes.vue b/src/plugins/schedule/components/management/JobTypes.vue index 2362235..50eb558 100644 --- a/src/plugins/schedule/components/management/JobTypes.vue +++ b/src/plugins/schedule/components/management/JobTypes.vue @@ -63,7 +63,6 @@ export default defineComponent({ onBeforeMount(() => { void store.dispatch('schedule/getJobTypes'); - console.log(store); }); const rows = computed(() => state.jobTypes); diff --git a/src/plugins/schedule/store/schedule.ts b/src/plugins/schedule/store/schedule.ts index b0a1309..015545a 100644 --- a/src/plugins/schedule/store/schedule.ts +++ b/src/plugins/schedule/store/schedule.ts @@ -16,13 +16,33 @@ export interface EventType { export interface ScheduleInterface { jobTypes: JobType[]; eventTypes: EventType[]; + events: FG.Event[]; } const state: ScheduleInterface = { jobTypes: [], - eventTypes: [] + eventTypes: [], + events: [] }; +interface Event { + start: Date; + end?: Date; + description: string; + type: EventType; + jobs: Job[]; +} + +interface Job { + id: number; + start: Date | null; + end?: Date | null; + comment: string; + type: FG.JobType | null; + services: Array; + required_services: number; +} + const mutations: MutationTree = { setJobTypes(state, jobTypes: JobType[]) { state.jobTypes = jobTypes; @@ -55,6 +75,9 @@ const mutations: MutationTree = { if (_eventtype) { _eventtype.name = eventType.name; } + }, + addEvent(state, event: FG.Event) { + state.events.unshift(event); } }; @@ -146,9 +169,20 @@ const actions: ActionTree = { .catch(err => { console.warn(err); }); + }, + + addEvent({ commit }, event: Event) { + axios + .post('/schedule/events', event) + .then((response: AxiosResponse) => { + commit('addEvent', response.data); + }) + .catch(err => { + console.warn(err); + }); + console.log('Events: ', state.events); } }; - const getters: GetterTree = { jobTypes(state) { return state.jobTypes;