diff --git a/src/plugins/schedule/components/management/CreateEvent.vue b/src/plugins/schedule/components/management/CreateEvent.vue
index 56f74b6..a5bdd8e 100644
--- a/src/plugins/schedule/components/management/CreateEvent.vue
+++ b/src/plugins/schedule/components/management/CreateEvent.vue
@@ -3,29 +3,9 @@
-
-
-
-
-
-
+
+ Veranstaltung erstellen
+
+
+
+
+
@@ -52,21 +47,21 @@
class="col-xs-12 col-sm-6 q-pa-sm"
v-model="job.start"
label="Beginn"
- type="time"
+ type="datetime"
:rules="[noValidDate, notEmpty]"
/>
@@ -85,7 +80,12 @@
:rules="[notEmpty]"
/>
-
+
@@ -112,61 +112,43 @@ export default defineComponent({
setup(_, { root }) {
const store = >root.$store;
const state = store.state.schedule;
- const eventname = ref('');
- const eventdescription = ref('');
- const eventdate = ref();
- // const eventtype = ref('');
const eventtypes = computed(() => state.eventTypes);
const jobtypes = computed(() => state.jobTypes);
- let jobnum = 1;
- const newJob: FG.Job = {
- id: jobnum,
- start: new Date(),
- end: new Date(),
+ const jobDeleteDisabled = computed(() => event.value.jobs.length < 2);
+
+ const newJob = ref(({
+ id: NaN,
+ start: undefined,
+ end: undefined,
comment: '',
- type: { id: NaN, name: '' },
services: [],
required_services: 2
- };
- // interface EventTypeToPost {
- // name: string;
- // }
- // interface EventToPost {
- // id: number;
- // start: Date;
- // description?: string;
- // type: EventTypeToPost;
- // jobs: Array;
- // }
+ } as unknown) as FG.Job);
+
const event = ref({
id: NaN,
start: new Date(),
description: '',
- type: { id: NaN, name: '' },
- jobs: [newJob]
- });
-
- const jobs = ref([newJob]);
+ jobs: [Object.assign({}, newJob.value)]
+ } as FG.Event);
onBeforeMount(() => {
void store.dispatch('schedule/getEventTypes');
void store.dispatch('schedule/getJobTypes');
});
+
function addJob() {
- console.log('Jobs: ', jobs);
- event.value.jobs.unshift(newJob);
- jobnum++;
+ const addJob = Object.assign({}, newJob.value);
+ event.value.jobs.unshift(addJob);
}
function removeJob(id: number) {
let jobtoremove = event.value.jobs.findIndex(job => job.id == id);
if (jobtoremove != undefined) {
- jobs.value.splice(jobtoremove, 1);
event.value.jobs.splice(jobtoremove, 1);
}
}
function save() {
- // console.log('Eventtype:', eventtype);
console.log('Event:', event);
store.dispatch('schedule/addEvent', event.value).catch(error => {
console.warn(error);
@@ -174,9 +156,11 @@ export default defineComponent({
}
function reset() {
- let nothing = 2;
- nothing++;
- nothing = 3;
+ event.value.id = NaN;
+ event.value.start = new Date();
+ event.value.description = '';
+ delete event.value['type'];
+ event.value.jobs = [Object.assign({}, newJob.value)];
}
function notEmpty(val: string) {
return !!val || 'Feld darf nicht leer sein!';
@@ -184,11 +168,12 @@ export default defineComponent({
function noValidDate(val: string) {
return !!date.isValid(val) || 'Datum/Zeit muss gesetzt sein!';
}
+
+ function isAfterDate(val: Date) {
+ // return event.value.jobsstart.getTime() > val.getTime() || 'Ende muss hinter dem Start liegen';
+ }
return {
- eventname,
- eventdescription,
- eventdate,
- jobs,
+ jobDeleteDisabled,
addJob,
eventtypes,
removeJob,
@@ -197,7 +182,8 @@ export default defineComponent({
noValidDate,
save,
reset,
- event
+ event,
+ isAfterDate
};
}
});