2021-02-05 23:07:58 +00:00
|
|
|
<template>
|
|
|
|
<q-card
|
2021-02-07 19:16:21 +00:00
|
|
|
class="background: radial-gradient(circle, #35a2ff 0%, #014a88 100%) justify-start content-center items-center rounded-borders border-primary shadow-5 q-mb-xs"
|
2021-02-05 23:07:58 +00:00
|
|
|
bordered
|
|
|
|
>
|
2021-02-07 19:16:21 +00:00
|
|
|
<header class="text-primary q-px-xs">
|
|
|
|
<div class="col text-weight-bolder ellipsis">
|
|
|
|
{{ event.type.name }}
|
|
|
|
</div>
|
2021-02-05 23:07:58 +00:00
|
|
|
|
2021-02-07 19:16:21 +00:00
|
|
|
<div v-if="event.description" class=" col text-weight-medium " style="font-size: 10px">
|
|
|
|
Info
|
|
|
|
{{ event.description }}
|
|
|
|
</div>
|
|
|
|
</header>
|
2021-02-05 23:07:58 +00:00
|
|
|
|
|
|
|
<div v-for="(job, index) in event.jobs" v-bind:key="index">
|
|
|
|
<q-separator style="justify-start content-center" />
|
2021-02-07 19:16:21 +00:00
|
|
|
<div class="text-weight-medium q-px-xs">
|
|
|
|
{{ job.start | formatToHour }} - {{ job.end | formatToHour }}
|
|
|
|
</div>
|
|
|
|
<div class="q-px-xs">
|
2021-02-05 23:07:58 +00:00
|
|
|
{{ job.type.name }}
|
|
|
|
</div>
|
2021-02-07 19:16:21 +00:00
|
|
|
<div class="col-auto q-px-xs" style="font-size: 10px">
|
2021-02-05 23:07:58 +00:00
|
|
|
{{ job.comment }}
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<q-select
|
|
|
|
filled
|
2021-02-07 19:16:21 +00:00
|
|
|
v-model="job.services"
|
|
|
|
:option-label="opt => userDisplay(opt)"
|
2021-02-05 23:07:58 +00:00
|
|
|
multiple
|
2021-02-07 19:16:21 +00:00
|
|
|
disable
|
2021-02-05 23:07:58 +00:00
|
|
|
use-chips
|
|
|
|
stack-label
|
|
|
|
label="Dienste"
|
2021-02-07 19:16:21 +00:00
|
|
|
class="col-auto q-px-xs"
|
|
|
|
style="font-size: 6px "
|
2021-02-05 23:07:58 +00:00
|
|
|
counter
|
|
|
|
:max-values="job.required_services"
|
2021-02-07 19:16:21 +00:00
|
|
|
:key="refreshKey"
|
2021-02-05 23:07:58 +00:00
|
|
|
>
|
|
|
|
</q-select>
|
2021-02-07 19:16:21 +00:00
|
|
|
<div class="row col-12 justify-end">
|
|
|
|
<q-btn v-if="false" />
|
|
|
|
<q-btn
|
|
|
|
v-if="!isUserEnrolled(job) && !jobFull(job)"
|
|
|
|
flat
|
|
|
|
color="primary"
|
|
|
|
label="Eintragen"
|
|
|
|
@click="enrollForJob(job)"
|
|
|
|
:key="refreshKey"
|
|
|
|
/>
|
|
|
|
<q-btn
|
|
|
|
v-if="isUserEnrolled(job)"
|
|
|
|
flat
|
|
|
|
color="negative"
|
|
|
|
label="Austragen"
|
|
|
|
@click="signOutFromJob(job)"
|
|
|
|
:key="refreshKey"
|
|
|
|
/>
|
|
|
|
</div>
|
2021-02-05 23:07:58 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</q-card>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-02-07 19:16:21 +00:00
|
|
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
2021-02-07 19:35:08 +00:00
|
|
|
import { defineComponent, ref, onBeforeMount } from '@vue/composition-api';
|
2021-02-05 23:07:58 +00:00
|
|
|
import { Store } from 'vuex';
|
|
|
|
import { StateInterface } from 'src/store';
|
|
|
|
import { date } from 'quasar';
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
event: FG.Event;
|
|
|
|
}
|
|
|
|
export default defineComponent({
|
|
|
|
name: 'Eventslot',
|
|
|
|
components: {},
|
|
|
|
props: {
|
|
|
|
event: {
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
filters: {
|
|
|
|
formatToHour: function(value: Date) {
|
|
|
|
if (value) {
|
|
|
|
return date.formatDate(value, 'HH:mm');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-02-07 19:16:21 +00:00
|
|
|
setup(props: Props, { root, emit }) {
|
2021-02-05 23:07:58 +00:00
|
|
|
const store = <Store<StateInterface>>root.$store;
|
2021-02-07 19:16:21 +00:00
|
|
|
const state = store.state.user;
|
2021-02-05 23:07:58 +00:00
|
|
|
const availableUsers = null;
|
|
|
|
const refreshKey = ref(0);
|
|
|
|
|
2021-02-07 19:16:21 +00:00
|
|
|
const users = ref(state.users);
|
|
|
|
function refresh() {
|
2021-02-07 19:35:08 +00:00
|
|
|
root.$router.go(0);
|
2021-02-07 19:16:21 +00:00
|
|
|
refreshKey.value += 1;
|
|
|
|
}
|
2021-02-07 19:35:08 +00:00
|
|
|
onBeforeMount(() => {
|
|
|
|
store.dispatch('user/getUsers').catch(error => {
|
|
|
|
console.warn(error);
|
|
|
|
});
|
|
|
|
});
|
2021-02-07 19:16:21 +00:00
|
|
|
|
|
|
|
function isUserEnrolled(job: FG.Job) {
|
|
|
|
return (
|
|
|
|
job.services.filter(service => service.userid == state.currentUser?.userid).length >= 1
|
|
|
|
);
|
|
|
|
}
|
|
|
|
function jobFull(job: FG.Job) {
|
|
|
|
console.log('jobFull', job.services.length >= job.required_services);
|
|
|
|
return job.services.length >= job.required_services;
|
|
|
|
}
|
|
|
|
function userDisplay(userid: string) {
|
|
|
|
return state.users.find(user => (user.userid = userid))?.display_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
function enrollForJob(this: any, job: FG.Job) {
|
|
|
|
console.log(job.services);
|
|
|
|
if (state.currentUser) {
|
|
|
|
const newService: FG.Service = {
|
|
|
|
userid: state.currentUser?.userid,
|
|
|
|
value: 1
|
|
|
|
};
|
|
|
|
|
|
|
|
const newUserService = { user: newService };
|
|
|
|
const UpdateInformation = {
|
|
|
|
eventId: <number>this.event.id,
|
|
|
|
JobId: job.id,
|
|
|
|
service: newUserService
|
|
|
|
};
|
|
|
|
void store.dispatch('schedule/updateEvent', UpdateInformation).catch(error => {
|
|
|
|
console.warn(error);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
function signOutFromJob(this: any, job: FG.Job) {
|
|
|
|
console.log(job.services);
|
|
|
|
if (state.currentUser) {
|
|
|
|
const newService: FG.Service = {
|
|
|
|
userid: state.currentUser?.userid,
|
|
|
|
value: -1
|
|
|
|
};
|
|
|
|
|
|
|
|
const newUserService = { user: newService };
|
|
|
|
const UpdateInformation = {
|
|
|
|
eventId: <number>this.event.id,
|
|
|
|
JobId: job.id,
|
|
|
|
service: newUserService
|
|
|
|
};
|
|
|
|
void store.dispatch('schedule/updateEvent', UpdateInformation).catch(error => {
|
|
|
|
console.warn(error);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
|
2021-02-05 23:07:58 +00:00
|
|
|
return {
|
|
|
|
refreshKey,
|
2021-02-07 19:16:21 +00:00
|
|
|
availableUsers,
|
|
|
|
enrollForJob,
|
|
|
|
state,
|
|
|
|
users,
|
|
|
|
isUserEnrolled,
|
|
|
|
signOutFromJob,
|
|
|
|
jobFull,
|
|
|
|
userDisplay,
|
|
|
|
refresh
|
2021-02-05 23:07:58 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2021-02-07 19:16:21 +00:00
|
|
|
<style scoped></style>
|