418 lines
17 KiB
Vue
418 lines
17 KiB
Vue
<script setup lang="ts">
|
|
import { useForm } from '@inertiajs/vue3';
|
|
import ProjectTicketController from '@/actions/App/Http/Controllers/ProjectTicketController';
|
|
import InputError from '@/components/InputError.vue';
|
|
import TicketPriorityIcon from '@/components/TicketPriorityIcon.vue';
|
|
import TicketTypeIcon from '@/components/TicketTypeIcon.vue';
|
|
import { Button } from '@/components/ui/button';
|
|
import {
|
|
Card,
|
|
CardContent,
|
|
CardDescription,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from '@/components/ui/card';
|
|
import { Checkbox } from '@/components/ui/checkbox';
|
|
import { Input } from '@/components/ui/input';
|
|
import { Label } from '@/components/ui/label';
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from '@/components/ui/select';
|
|
import { Textarea } from '@/components/ui/textarea';
|
|
import {
|
|
fieldLabelClass,
|
|
frostedCardClass,
|
|
inputClass,
|
|
nativeSelectClass,
|
|
selectContentClass,
|
|
selectTriggerClass,
|
|
textareaClass,
|
|
} from '@/lib/ticket-styles';
|
|
import type { ProjectModel } from '@/types/models/project-model';
|
|
import type { TicketFieldDefinitionModel } from '@/types/models/ticket-field-definition-model';
|
|
import type { TicketModel } from '@/types/models/ticket-model';
|
|
import type { TicketPriorityModel } from '@/types/models/ticket-priority-model';
|
|
import type { TicketReferenceModel } from '@/types/models/ticket-reference-model';
|
|
import type { TicketTypeModel } from '@/types/models/ticket-type-model';
|
|
import type { UserModel } from '@/types/models/user-model';
|
|
|
|
const props = defineProps<{
|
|
canEditAuthor: boolean;
|
|
canEditTicket: boolean;
|
|
canViewAuthor: boolean;
|
|
parentTicketOptions: TicketReferenceModel[];
|
|
project: ProjectModel;
|
|
ticket: TicketModel;
|
|
ticketFieldDefinitions: TicketFieldDefinitionModel[];
|
|
ticketPriorities: TicketPriorityModel[];
|
|
ticketTypes: TicketTypeModel[];
|
|
users: UserModel[];
|
|
}>();
|
|
|
|
const form = useForm({
|
|
acceptance_criteria: props.ticket.acceptance_criteria ?? '',
|
|
assignee_user_id: props.ticket.assignee_user_id ?? '',
|
|
author_user_id: props.ticket.author_user_id ?? '',
|
|
blocked_comment: props.ticket.blocked_comment ?? '',
|
|
description: props.ticket.description ?? '',
|
|
field_values: props.ticketFieldDefinitions.map((ticketFieldDefinition) => {
|
|
const currentFieldValue = props.ticket.field_values?.find(
|
|
(fieldValue) =>
|
|
fieldValue.ticket_field_definition_id ===
|
|
ticketFieldDefinition.id,
|
|
);
|
|
|
|
return {
|
|
ticket_field_definition_id: ticketFieldDefinition.id,
|
|
value_number: currentFieldValue?.value_number ?? '',
|
|
value_user_id: currentFieldValue?.value_user_id ?? '',
|
|
};
|
|
}),
|
|
is_blocked: props.ticket.is_blocked,
|
|
parent_ticket_id: props.ticket.parent_ticket_id ?? '',
|
|
ticket_priority_id: String(props.ticket.ticket_priority_id),
|
|
ticket_type_id: String(props.ticket.ticket_type_id),
|
|
title: props.ticket.title,
|
|
story_points: props.ticket.story_points,
|
|
});
|
|
|
|
const submit = (): void => {
|
|
if (!props.canEditTicket) {
|
|
return;
|
|
}
|
|
|
|
form.submit(
|
|
ProjectTicketController.update({
|
|
project: props.project.id,
|
|
ticket: props.ticket.id,
|
|
}),
|
|
{
|
|
preserveScroll: true,
|
|
},
|
|
);
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<Card :class="frostedCardClass">
|
|
<CardHeader>
|
|
<CardTitle
|
|
class="font-display dark:text-foreground text-2xl text-[#2d3335]"
|
|
>
|
|
Ticket details
|
|
</CardTitle>
|
|
<CardDescription class="max-w-2xl leading-6">
|
|
{{
|
|
canEditTicket
|
|
? 'Tracked ticket changes create worklog entries automatically.'
|
|
: 'You can review the tracked fields, but editing requires project edit permission.'
|
|
}}
|
|
</CardDescription>
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
|
<form class="grid gap-6" @submit.prevent="submit">
|
|
<div class="grid gap-2">
|
|
<Label for="title" :class="fieldLabelClass">Title</Label>
|
|
<Input
|
|
id="title"
|
|
v-model="form.title"
|
|
:disabled="!canEditTicket || form.processing"
|
|
:class="inputClass"
|
|
/>
|
|
<InputError :message="form.errors.title" />
|
|
</div>
|
|
|
|
<div class="grid gap-2 md:grid-cols-2 md:gap-6">
|
|
<div class="grid gap-2">
|
|
<Label for="ticket_type_id" :class="fieldLabelClass">
|
|
Type
|
|
</Label>
|
|
<Select
|
|
v-model="form.ticket_type_id"
|
|
:disabled="!canEditTicket || form.processing"
|
|
>
|
|
<SelectTrigger
|
|
id="ticket_type_id"
|
|
:class="selectTriggerClass"
|
|
>
|
|
<SelectValue placeholder="Choose a type" />
|
|
</SelectTrigger>
|
|
<SelectContent :class="selectContentClass">
|
|
<SelectItem
|
|
v-for="ticketType in ticketTypes"
|
|
:key="ticketType.id"
|
|
:value="String(ticketType.id)"
|
|
>
|
|
<TicketTypeIcon class="size-5" />
|
|
<span>{{ ticketType.name }}</span>
|
|
</SelectItem>
|
|
</SelectContent>
|
|
</Select>
|
|
<InputError :message="form.errors.ticket_type_id" />
|
|
</div>
|
|
|
|
<div class="grid gap-2">
|
|
<Label
|
|
for="ticket_priority_id"
|
|
:class="fieldLabelClass"
|
|
>
|
|
Priority
|
|
</Label>
|
|
<Select
|
|
v-model="form.ticket_priority_id"
|
|
:disabled="!canEditTicket || form.processing"
|
|
>
|
|
<SelectTrigger
|
|
id="ticket_priority_id"
|
|
:class="selectTriggerClass"
|
|
>
|
|
<SelectValue placeholder="Choose a priority" />
|
|
</SelectTrigger>
|
|
<SelectContent :class="selectContentClass">
|
|
<SelectItem
|
|
v-for="ticketPriority in ticketPriorities"
|
|
:key="ticketPriority.id"
|
|
:value="String(ticketPriority.id)"
|
|
>
|
|
<TicketPriorityIcon class="size-5" />
|
|
<span>{{ ticketPriority.name }}</span>
|
|
</SelectItem>
|
|
</SelectContent>
|
|
</Select>
|
|
<InputError :message="form.errors.ticket_priority_id" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="grid gap-2 md:grid-cols-2 md:gap-6">
|
|
<div class="grid gap-2">
|
|
<Label for="assignee_user_id" :class="fieldLabelClass">
|
|
Assignee
|
|
</Label>
|
|
<select
|
|
id="assignee_user_id"
|
|
v-model="form.assignee_user_id"
|
|
:disabled="!canEditTicket || form.processing"
|
|
:class="nativeSelectClass"
|
|
>
|
|
<option value="">Unassigned</option>
|
|
<option
|
|
v-for="user in users"
|
|
:key="user.id"
|
|
:value="user.id"
|
|
>
|
|
{{ user.name }}
|
|
</option>
|
|
</select>
|
|
<InputError :message="form.errors.assignee_user_id" />
|
|
</div>
|
|
|
|
<div v-if="canViewAuthor" class="grid gap-2">
|
|
<Label for="author_user_id" :class="fieldLabelClass">
|
|
Author
|
|
</Label>
|
|
<select
|
|
id="author_user_id"
|
|
v-model="form.author_user_id"
|
|
:disabled="!canEditAuthor || form.processing"
|
|
:class="nativeSelectClass"
|
|
>
|
|
<option value="">No author</option>
|
|
<option
|
|
v-for="user in users"
|
|
:key="user.id"
|
|
:value="user.id"
|
|
>
|
|
{{ user.name }}
|
|
</option>
|
|
</select>
|
|
<InputError :message="form.errors.author_user_id" />
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="project.show_story_points" class="grid gap-2">
|
|
<Label for="story_points" :class="fieldLabelClass">
|
|
Estimated story points
|
|
</Label>
|
|
<Input
|
|
id="story_points"
|
|
name="story_points"
|
|
v-model="form.story_points"
|
|
type="number"
|
|
step="1"
|
|
:class="inputClass"
|
|
/>
|
|
<InputError :message="form.errors.story_points" />
|
|
</div>
|
|
|
|
<div class="grid gap-2">
|
|
<Label for="parent_ticket_id" :class="fieldLabelClass">
|
|
Parent ticket
|
|
</Label>
|
|
<select
|
|
id="parent_ticket_id"
|
|
v-model="form.parent_ticket_id"
|
|
:disabled="!canEditTicket || form.processing"
|
|
:class="nativeSelectClass"
|
|
>
|
|
<option value="">No parent ticket</option>
|
|
<option
|
|
v-for="parentTicketOption in parentTicketOptions"
|
|
:key="parentTicketOption.id"
|
|
:value="parentTicketOption.id"
|
|
>
|
|
{{
|
|
`${parentTicketOption.ticket_key} - ${parentTicketOption.title}`
|
|
}}
|
|
</option>
|
|
</select>
|
|
<InputError :message="form.errors.parent_ticket_id" />
|
|
</div>
|
|
|
|
<div class="grid gap-2">
|
|
<Label for="description" :class="fieldLabelClass">
|
|
Description
|
|
</Label>
|
|
<Textarea
|
|
id="description"
|
|
v-model="form.description"
|
|
:disabled="!canEditTicket || form.processing"
|
|
:class="textareaClass"
|
|
/>
|
|
<InputError :message="form.errors.description" />
|
|
</div>
|
|
|
|
<div class="grid gap-2">
|
|
<Label for="acceptance_criteria" :class="fieldLabelClass">
|
|
Acceptance criteria
|
|
</Label>
|
|
<Textarea
|
|
id="acceptance_criteria"
|
|
v-model="form.acceptance_criteria"
|
|
:disabled="!canEditTicket || form.processing"
|
|
:class="textareaClass"
|
|
/>
|
|
<InputError :message="form.errors.acceptance_criteria" />
|
|
</div>
|
|
|
|
<div
|
|
class="dark:bg-muted/25 grid gap-4 rounded-[1.5rem] border border-dashed border-[#adb3b5]/35 bg-[#f8f9fa]/80 p-5 dark:border-white/10"
|
|
>
|
|
<div class="flex items-center gap-3">
|
|
<Checkbox
|
|
id="is_blocked"
|
|
:checked="form.is_blocked"
|
|
:disabled="!canEditTicket || form.processing"
|
|
@update:checked="
|
|
(value: boolean | 'indeterminate') =>
|
|
(form.is_blocked = value === true)
|
|
"
|
|
/>
|
|
<Label for="is_blocked" :class="fieldLabelClass">
|
|
Mark ticket as blocked
|
|
</Label>
|
|
</div>
|
|
|
|
<div class="grid gap-2">
|
|
<Label for="blocked_comment" :class="fieldLabelClass">
|
|
Blocker comment
|
|
</Label>
|
|
<Textarea
|
|
id="blocked_comment"
|
|
v-model="form.blocked_comment"
|
|
:disabled="!canEditTicket || form.processing"
|
|
placeholder="Describe what currently blocks progress on this ticket."
|
|
:class="textareaClass"
|
|
/>
|
|
<InputError :message="form.errors.blocked_comment" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="grid gap-4">
|
|
<div class="space-y-1">
|
|
<h3 class="text-sm font-semibold">Custom fields</h3>
|
|
<p class="text-muted-foreground text-sm">
|
|
Project-configured fields can be tracked directly on
|
|
the ticket.
|
|
</p>
|
|
</div>
|
|
|
|
<div
|
|
v-if="ticketFieldDefinitions.length === 0"
|
|
class="border-border text-muted-foreground rounded-xl border border-dashed px-4 py-6 text-sm"
|
|
>
|
|
No custom fields are configured for this project yet.
|
|
</div>
|
|
|
|
<div v-else class="grid gap-4 md:grid-cols-2">
|
|
<div
|
|
v-for="(
|
|
ticketFieldDefinition, index
|
|
) in ticketFieldDefinitions"
|
|
:key="ticketFieldDefinition.id"
|
|
class="grid gap-2"
|
|
>
|
|
<Label
|
|
:for="`field-${ticketFieldDefinition.id}`"
|
|
:class="fieldLabelClass"
|
|
>
|
|
{{ ticketFieldDefinition.label }}
|
|
</Label>
|
|
|
|
<select
|
|
v-if="
|
|
ticketFieldDefinition.field_type === 'user'
|
|
"
|
|
:id="`field-${ticketFieldDefinition.id}`"
|
|
v-model="form.field_values[index].value_user_id"
|
|
:disabled="!canEditTicket || form.processing"
|
|
:class="nativeSelectClass"
|
|
>
|
|
<option value="">Unassigned</option>
|
|
<option
|
|
v-for="user in users"
|
|
:key="user.id"
|
|
:value="user.id"
|
|
>
|
|
{{ user.name }}
|
|
</option>
|
|
</select>
|
|
|
|
<Input
|
|
v-else
|
|
:id="`field-${ticketFieldDefinition.id}`"
|
|
v-model="form.field_values[index].value_number"
|
|
type="number"
|
|
step="0.1"
|
|
:disabled="!canEditTicket || form.processing"
|
|
:class="inputClass"
|
|
/>
|
|
|
|
<InputError
|
|
:message="
|
|
form.errors[
|
|
`field_values.${index}.value_user_id`
|
|
] ??
|
|
form.errors[
|
|
`field_values.${index}.value_number`
|
|
]
|
|
"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="canEditTicket" class="flex items-center gap-3">
|
|
<Button type="submit" :disabled="form.processing">
|
|
Save changes
|
|
</Button>
|
|
</div>
|
|
</form>
|
|
</CardContent>
|
|
</Card>
|
|
</template>
|