Change for Agrar
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 32s
Build and Push Docker Images / build-frontend (push) Successful in 1m10s

This commit is contained in:
2026-01-26 22:04:27 +01:00
parent c56fcfbd14
commit 2aed851224
3 changed files with 72 additions and 124 deletions

View File

@@ -1,6 +1,4 @@
<script setup>
import dayjs from 'dayjs'
const props = defineProps({
context: { type: Object, required: true },
token: { type: String, required: true },
@@ -8,23 +6,18 @@ const props = defineProps({
})
const runtimeConfig = useRuntimeConfig()
const emit = defineEmits(['success'])
const { $api } = useNuxtApp()
const toast = useToast()
const config = computed(() => props.context.config)
const data = computed(() => props.context.data)
// Initiale Werte setzen
// Initiale Werte setzen (Quantity statt Start/EndDate)
const form = ref({
profile: props.context.meta?.defaultProfileId || null,
project: null,
service: config.value?.defaults?.serviceId || null,
// Wenn manualTime erlaubt, setze Startzeit auf jetzt, sonst null (wird im Backend gesetzt)
startDate: config.value?.features?.timeTracking?.allowManualTime ? new Date() : null,
endDate: config.value?.features?.timeTracking?.allowManualTime ? dayjs().add(1, 'hour').toDate() : null,
quantity: config.value?.features?.timeTracking?.defaultDurationHours || 1,
dieselUsage: 0,
description: ''
})
@@ -32,13 +25,11 @@ const form = ref({
const isSubmitting = ref(false)
const errors = ref({})
// Validierung basierend auf JSON Config
const validate = () => {
errors.value = {}
let isValid = true
const validationRules = config.value.validation || {}
// Standard-Validierung
if (!form.value.project && data.value.projects?.length > 0) {
errors.value.project = 'Pflichtfeld'
isValid = false
@@ -49,13 +40,11 @@ const validate = () => {
isValid = false
}
// Profil nur validieren, wenn Auswahl möglich ist
if (!form.value.profile && data.value.profiles?.length > 0 && !props.context.meta.defaultProfileId) {
errors.value.profile = 'Bitte Mitarbeiter wählen'
if (!form.value.quantity || form.value.quantity <= 0) {
errors.value.quantity = 'Menge erforderlich'
isValid = false
}
// Feature: Agriculture
if (config.value.features?.agriculture?.showDieselUsage && validationRules.requireDiesel) {
if (!form.value.dieselUsage || form.value.dieselUsage <= 0) {
errors.value.diesel = 'Dieselverbrauch erforderlich'
@@ -72,12 +61,9 @@ const submit = async () => {
isSubmitting.value = true
try {
const payload = { ...form.value }
// Headers vorbereiten (PIN mitsenden!)
const headers = {}
if (props.pin) headers['x-public-pin'] = props.pin
// An den Submit-Endpunkt senden (den müssen wir im Backend noch bauen!)
await $fetch(`${runtimeConfig.public.apiBase}/workflows/submit/${props.token}`, {
method: 'POST',
body: payload,
@@ -104,7 +90,6 @@ const submit = async () => {
</template>
<div class="space-y-5">
<UFormGroup
v-if="!context?.meta?.defaultProfileId && data?.profiles?.length > 0"
label="Mitarbeiter"
@@ -118,7 +103,6 @@ const submit = async () => {
value-attribute="id"
placeholder="Name auswählen..."
searchable
searchable-placeholder="Suchen..."
/>
</UFormGroup>
@@ -135,7 +119,6 @@ const submit = async () => {
value-attribute="id"
placeholder="Wählen..."
searchable
searchable-placeholder="Suchen..."
/>
</UFormGroup>
@@ -152,37 +135,29 @@ const submit = async () => {
value-attribute="id"
placeholder="Wählen..."
searchable
searchable-placeholder="Suchen..."
/>
</UFormGroup>
<div v-if="config?.features?.timeTracking?.allowManualTime" class="grid grid-cols-2 gap-3">
<UFormGroup label="Start">
<input
type="datetime-local"
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-primary-600 sm:text-sm sm:leading-6 px-2"
:value="dayjs(form.startDate).format('YYYY-MM-DDTHH:mm')"
@input="e => form.startDate = new Date(e.target.value)"
/>
</UFormGroup>
<UFormGroup label="Dauer (Stunden)">
<input
type="number"
step="0.25"
placeholder="z.B. 1.5"
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-primary-600 sm:text-sm sm:leading-6 px-2"
@input="e => form.endDate = dayjs(form.startDate).add(parseFloat(e.target.value), 'hour').toDate()"
/>
</UFormGroup>
<UFormGroup label="Ende" class="col-span-2">
<input
type="datetime-local"
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-primary-600 sm:text-sm sm:leading-6 px-2"
:value="dayjs(form.endDate).format('YYYY-MM-DDTHH:mm')"
@input="e => form.endDate = new Date(e.target.value)"
/>
</UFormGroup>
</div>
<UFormGroup
v-if="config?.features?.timeTracking?.allowManualTime"
label="Menge / Dauer"
:error="errors.quantity"
required
>
<UInput
v-model="form.quantity"
type="number"
step="0.25"
size="lg"
placeholder="0.00"
>
<template #trailing>
<span class="text-gray-500 text-sm pr-2">
{{ data?.units?.[0]?.symbol || 'h' }}
</span>
</template>
</UInput>
</UFormGroup>
<UFormGroup
v-if="config?.features?.agriculture?.showDieselUsage"
@@ -200,7 +175,6 @@ const submit = async () => {
<UFormGroup :label="config?.ui?.labels?.description || 'Notiz'">
<UTextarea v-model="form.description" :rows="3" />
</UFormGroup>
</div>
<template #footer>