2021-05-25 15:11:44 +00:00
|
|
|
<template>
|
2021-11-23 16:32:48 +00:00
|
|
|
<q-card class="fit">
|
|
|
|
<q-card-section
|
|
|
|
v-if="!active"
|
|
|
|
class="fit row justify-start content-center items-center text-center"
|
|
|
|
@click="$emit('activate')"
|
|
|
|
>
|
|
|
|
<div class="text-h6 col-12">{{ formatStartEnd(modelValue.start, modelValue.end) }}</div>
|
|
|
|
<div class="text-subtitle1 col-12">{{ typeName }} ({{ modelValue.required_services }})</div>
|
|
|
|
<div class="text-body2 text-italic text-left col-12">{{ modelValue.comment }}</div>
|
|
|
|
</q-card-section>
|
|
|
|
<q-card-section v-else>
|
|
|
|
<q-form ref="form" class="fit row justify-start content-center items-center">
|
|
|
|
<IsoDateInput
|
|
|
|
v-model="job.start"
|
|
|
|
class="col-xs-12 col-sm-6 q-pa-sm"
|
|
|
|
label="Beginn"
|
|
|
|
type="datetime"
|
|
|
|
:rules="[notEmpty]"
|
|
|
|
/>
|
|
|
|
<IsoDateInput
|
|
|
|
v-model="job.end"
|
|
|
|
class="col-xs-12 col-sm-6 q-pa-sm"
|
|
|
|
label="Ende"
|
|
|
|
type="datetime"
|
|
|
|
:rules="[notEmpty, isAfterDate]"
|
|
|
|
/>
|
|
|
|
<q-select
|
|
|
|
v-model="job.type"
|
|
|
|
filled
|
|
|
|
use-input
|
|
|
|
label="Dienstart"
|
|
|
|
input-debounce="0"
|
|
|
|
class="col-xs-12 col-sm-6 q-pa-sm"
|
|
|
|
:options="jobtypes"
|
|
|
|
option-label="name"
|
|
|
|
option-value="id"
|
|
|
|
map-options
|
|
|
|
clearable
|
|
|
|
:rules="[notEmpty]"
|
|
|
|
/>
|
|
|
|
<q-input
|
|
|
|
v-model="job.required_services"
|
|
|
|
filled
|
|
|
|
class="col-xs-12 col-sm-6 q-pa-sm"
|
|
|
|
label="Dienstanzahl"
|
|
|
|
type="number"
|
|
|
|
:rules="[notEmpty]"
|
|
|
|
/>
|
|
|
|
<q-input
|
|
|
|
v-model="job.comment"
|
|
|
|
class="col-12 q-pa-sm"
|
|
|
|
label="Kommentar"
|
|
|
|
type="textarea"
|
|
|
|
filled
|
|
|
|
/>
|
|
|
|
</q-form>
|
2021-05-25 15:11:44 +00:00
|
|
|
</q-card-section>
|
2021-11-22 11:00:59 +00:00
|
|
|
<q-card-actions>
|
2021-11-23 16:32:48 +00:00
|
|
|
<q-btn label="Schicht löschen" color="negative" :disabled="canDelete" @click="$emit('remove-job')" />
|
2021-11-22 11:00:59 +00:00
|
|
|
</q-card-actions>
|
|
|
|
</q-card>
|
2021-05-25 15:11:44 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-11-23 16:32:48 +00:00
|
|
|
import { defineComponent, computed, onBeforeMount, ref, PropType } from 'vue';
|
2021-05-25 15:11:44 +00:00
|
|
|
import { IsoDateInput } from '@flaschengeist/api/components';
|
2021-11-23 16:32:48 +00:00
|
|
|
import { formatStartEnd, notEmpty } from '@flaschengeist/api';
|
2021-11-21 11:39:02 +00:00
|
|
|
import { useEventStore } from '../../store';
|
2021-11-23 16:32:48 +00:00
|
|
|
import { QForm } from 'quasar';
|
2021-05-25 15:11:44 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
2021-11-16 22:27:20 +00:00
|
|
|
name: 'JobSlot',
|
2021-05-25 15:11:44 +00:00
|
|
|
components: { IsoDateInput },
|
|
|
|
props: {
|
2021-11-23 16:32:48 +00:00
|
|
|
active: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
2021-05-25 15:11:44 +00:00
|
|
|
modelValue: {
|
|
|
|
required: true,
|
|
|
|
type: Object as PropType<FG.Job>,
|
|
|
|
},
|
2021-11-22 11:00:59 +00:00
|
|
|
canDelete: {
|
2021-11-17 00:55:55 +00:00
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
2021-11-22 11:00:59 +00:00
|
|
|
},
|
2021-05-25 15:11:44 +00:00
|
|
|
},
|
|
|
|
emits: {
|
2021-11-23 16:32:48 +00:00
|
|
|
activate: () => true,
|
2021-05-25 15:11:44 +00:00
|
|
|
'remove-job': () => true,
|
|
|
|
'update:modelValue': (job: FG.Job) => !!job,
|
|
|
|
},
|
2021-11-23 16:32:48 +00:00
|
|
|
setup(props, { emit, expose }) {
|
2021-11-21 11:39:02 +00:00
|
|
|
const store = useEventStore();
|
2021-05-25 15:11:44 +00:00
|
|
|
|
|
|
|
onBeforeMount(() => store.getJobTypes());
|
|
|
|
|
2021-11-23 16:32:48 +00:00
|
|
|
const form = ref<QForm>();
|
|
|
|
|
2021-05-25 15:11:44 +00:00
|
|
|
const jobtypes = computed(() => store.jobTypes);
|
|
|
|
|
2021-11-23 16:32:48 +00:00
|
|
|
const typeName = computed(() =>
|
|
|
|
typeof props.modelValue.type === 'object'
|
|
|
|
? props.modelValue.type.name
|
|
|
|
: jobtypes.value.find((j) => j.id === props.modelValue.type)?.name || 'Kein Typ gesetzt!'
|
|
|
|
);
|
|
|
|
|
2021-05-25 15:11:44 +00:00
|
|
|
const job = new Proxy(props.modelValue, {
|
|
|
|
get(target, prop) {
|
|
|
|
if (typeof prop === 'string') {
|
2021-11-22 11:00:59 +00:00
|
|
|
return (props.modelValue as unknown as Record<string, unknown>)[prop];
|
2021-05-25 15:11:44 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
set(obj, prop, value) {
|
|
|
|
if (typeof prop === 'string') {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
|
|
emit('update:modelValue', Object.assign({}, props.modelValue, { [prop]: value }));
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-11-16 22:27:20 +00:00
|
|
|
function isAfterDate(val: Date) {
|
|
|
|
return props.modelValue.start < val || 'Ende muss hinter dem Start liegen';
|
2021-05-25 15:11:44 +00:00
|
|
|
}
|
|
|
|
|
2021-11-23 16:32:48 +00:00
|
|
|
expose({
|
|
|
|
validate: () => form.value?.validate() || Promise.resolve(true)
|
|
|
|
});
|
|
|
|
|
2021-05-25 15:11:44 +00:00
|
|
|
return {
|
2021-11-23 16:32:48 +00:00
|
|
|
form,
|
|
|
|
formatStartEnd,
|
|
|
|
isAfterDate,
|
2021-05-25 15:11:44 +00:00
|
|
|
job,
|
|
|
|
jobtypes,
|
|
|
|
notEmpty,
|
2021-11-23 16:32:48 +00:00
|
|
|
typeName,
|
2021-05-25 15:11:44 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
2021-11-23 16:32:48 +00:00
|
|
|
|
2021-05-25 15:11:44 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style></style>
|