337 lines
16 KiB
Vue
337 lines
16 KiB
Vue
<script setup lang="ts">
|
|
import { Form, Head, Link } from '@inertiajs/vue3';
|
|
import ProjectBoardController from '@/actions/App/Http/Controllers/ProjectBoardController';
|
|
import Heading from '@/components/Heading.vue';
|
|
import { Badge } from '@/components/ui/badge';
|
|
import { Button } from '@/components/ui/button';
|
|
import {
|
|
Card,
|
|
CardContent,
|
|
CardDescription,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from '@/components/ui/card';
|
|
import AppLayout from '@/layouts/AppLayout.vue';
|
|
import { index as backlogIndex } from '@/routes/projects/backlog';
|
|
import { index as projectIndex, show } from '@/routes/projects/index';
|
|
import { board as boardSettings } from '@/routes/projects/settings';
|
|
import { index as boardIndex } from '@/routes/projects/board';
|
|
import { create as createTicket, show as showTicket } from '@/routes/projects/tickets';
|
|
import type { BreadcrumbItem, ProjectBoardPageProps } from '@/types';
|
|
import type { TicketModel } from '@/types/models/ticket-model';
|
|
import type { TicketStatusModel } from '@/types/models/ticket-status-model';
|
|
|
|
const props = defineProps<ProjectBoardPageProps>();
|
|
|
|
const breadcrumbs: BreadcrumbItem[] = [
|
|
{
|
|
title: 'Projects',
|
|
href: projectIndex(),
|
|
},
|
|
{
|
|
title: props.project.name,
|
|
href: show(props.project.id),
|
|
},
|
|
{
|
|
title: 'Board',
|
|
href: boardIndex(props.project.id),
|
|
},
|
|
];
|
|
|
|
const ticketStatusLabel = (ticketStatus: TicketStatusModel | null): string => {
|
|
if (ticketStatus === null) {
|
|
return 'Unknown status';
|
|
}
|
|
|
|
if (
|
|
ticketStatus.board_column === null ||
|
|
ticketStatus.board_column === undefined
|
|
) {
|
|
return ticketStatus.name;
|
|
}
|
|
|
|
if (ticketStatus.board_column.name === ticketStatus.name) {
|
|
return ticketStatus.name;
|
|
}
|
|
|
|
return `${ticketStatus.board_column.name} / ${ticketStatus.name}`;
|
|
};
|
|
|
|
const allowedTargetStatuses = (ticket: TicketModel): TicketStatusModel[] => {
|
|
return (ticket.ticket_status?.allowed_target_statuses ?? []).filter(
|
|
(ticketStatus) => ticketStatus.id !== ticket.ticket_status_id,
|
|
);
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<AppLayout :breadcrumbs="breadcrumbs">
|
|
<Head :title="`${project.name} board`" />
|
|
|
|
<div class="flex flex-1 flex-col gap-6 p-4">
|
|
<div
|
|
class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"
|
|
>
|
|
<div class="space-y-3">
|
|
<Badge variant="outline" class="px-3 py-1">
|
|
{{ project.key }}
|
|
</Badge>
|
|
<Heading
|
|
:title="`${project.name} board`"
|
|
description="Tickets only appear here once they are assigned to one of the project's workflow columns."
|
|
/>
|
|
</div>
|
|
|
|
<div class="flex flex-wrap gap-3">
|
|
<Button v-if="canCreateTickets" as-child>
|
|
<Link
|
|
:href="
|
|
createTicket(
|
|
{ project: project.id },
|
|
{ query: { source: 'board' } },
|
|
)
|
|
"
|
|
>
|
|
Create ticket
|
|
</Link>
|
|
</Button>
|
|
|
|
<Button as-child variant="outline">
|
|
<Link :href="backlogIndex(project.id)"
|
|
>Open backlog</Link
|
|
>
|
|
</Button>
|
|
|
|
<Button as-child variant="outline">
|
|
<Link :href="show(project.id)">Back to project</Link>
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
|
|
<div
|
|
v-if="status"
|
|
class="rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-900 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-100"
|
|
>
|
|
{{ status }}
|
|
</div>
|
|
|
|
<Card v-if="boardColumns.length === 0">
|
|
<CardContent class="flex flex-col gap-4 p-6 text-sm">
|
|
<p class="text-muted-foreground">
|
|
The board has no workflow columns yet, so no tickets can
|
|
appear here.
|
|
</p>
|
|
<div v-if="canEditTickets">
|
|
<Button as-child variant="outline">
|
|
<Link :href="boardSettings(project.id)">
|
|
Open board settings
|
|
</Link>
|
|
</Button>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
|
|
<div v-else class="grid gap-4 xl:grid-cols-3">
|
|
<Card
|
|
v-for="boardColumn in boardColumns"
|
|
:key="boardColumn.id"
|
|
class="flex h-full flex-col gap-0 overflow-hidden"
|
|
>
|
|
<CardHeader class="bg-muted/20 border-b">
|
|
<div class="flex items-start justify-between gap-3">
|
|
<div>
|
|
<CardTitle>{{ boardColumn.name }}</CardTitle>
|
|
<CardDescription>
|
|
{{ boardColumn.tickets?.length ?? 0 }}
|
|
active ticket(s)
|
|
</CardDescription>
|
|
<div
|
|
v-if="
|
|
(boardColumn.ticket_statuses?.length ??
|
|
0) > 0
|
|
"
|
|
class="mt-3 flex flex-wrap gap-2"
|
|
>
|
|
<Badge
|
|
v-for="ticketStatus in boardColumn.ticket_statuses"
|
|
:key="ticketStatus.id"
|
|
variant="outline"
|
|
>
|
|
{{ ticketStatus.name }}
|
|
</Badge>
|
|
</div>
|
|
</div>
|
|
|
|
<Badge variant="secondary">
|
|
#{{ boardColumn.position }}
|
|
</Badge>
|
|
</div>
|
|
</CardHeader>
|
|
|
|
<CardContent class="flex flex-1 flex-col gap-4 p-4">
|
|
<div
|
|
v-if="(boardColumn.tickets?.length ?? 0) === 0"
|
|
class="border-border text-muted-foreground rounded-xl border border-dashed px-4 py-6 text-sm"
|
|
>
|
|
No tickets are currently in this column.
|
|
</div>
|
|
|
|
<div v-else class="flex flex-col gap-4">
|
|
<Card
|
|
v-for="ticket in boardColumn.tickets"
|
|
:key="ticket.id"
|
|
:class="[
|
|
'gap-0',
|
|
ticket.is_blocked
|
|
? 'border-amber-300 bg-amber-50/70 dark:border-amber-700/60 dark:bg-amber-950/30'
|
|
: '',
|
|
]"
|
|
>
|
|
<CardHeader class="pb-4">
|
|
<div class="flex flex-wrap gap-2">
|
|
<Badge variant="outline">
|
|
{{ ticket.ticket_key }}
|
|
</Badge>
|
|
<Badge
|
|
v-if="ticket.is_blocked"
|
|
variant="destructive"
|
|
>
|
|
Blocked
|
|
</Badge>
|
|
<Badge variant="secondary">
|
|
{{ ticket.ticket_type.name }}
|
|
</Badge>
|
|
<Badge variant="secondary">
|
|
{{ ticket.ticket_priority.name }}
|
|
</Badge>
|
|
<Badge variant="outline">
|
|
{{
|
|
ticketStatusLabel(
|
|
ticket.ticket_status,
|
|
)
|
|
}}
|
|
</Badge>
|
|
</div>
|
|
<CardTitle class="text-base">
|
|
<Link
|
|
:href="
|
|
showTicket({
|
|
project: project.id,
|
|
ticket: ticket.id,
|
|
})
|
|
"
|
|
class="hover:text-primary transition"
|
|
>
|
|
{{ ticket.title }}
|
|
</Link>
|
|
</CardTitle>
|
|
<CardDescription
|
|
v-if="ticket.description"
|
|
class="line-clamp-3"
|
|
>
|
|
{{ ticket.description }}
|
|
</CardDescription>
|
|
<CardDescription
|
|
v-if="
|
|
ticket.is_blocked &&
|
|
ticket.blocked_comment
|
|
"
|
|
class="mt-2 text-amber-900 dark:text-amber-200"
|
|
>
|
|
{{ ticket.blocked_comment }}
|
|
</CardDescription>
|
|
</CardHeader>
|
|
|
|
<CardContent v-if="canEditTickets" class="pt-0">
|
|
<Form
|
|
v-bind="
|
|
ProjectBoardController.move.form({
|
|
project: project.id,
|
|
ticket: ticket.id,
|
|
})
|
|
"
|
|
class="flex flex-col gap-2"
|
|
v-slot="{ processing }"
|
|
>
|
|
<input
|
|
type="hidden"
|
|
name="redirect_to"
|
|
value="board"
|
|
/>
|
|
<label
|
|
:for="`ticket-status-${ticket.id}`"
|
|
class="text-muted-foreground text-xs font-medium uppercase tracking-wide"
|
|
>
|
|
Move ticket
|
|
</label>
|
|
<div
|
|
class="flex flex-col gap-2 sm:flex-row"
|
|
>
|
|
<select
|
|
:id="`ticket-status-${ticket.id}`"
|
|
name="ticket_status_id"
|
|
:disabled="
|
|
allowedTargetStatuses(
|
|
ticket,
|
|
).length === 0 || processing
|
|
"
|
|
class="border-input bg-background shadow-xs focus-visible:border-ring focus-visible:ring-ring/50 min-w-44 rounded-md border px-3 py-2 text-sm outline-none transition-[color,box-shadow] focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-60"
|
|
>
|
|
<option
|
|
v-if="
|
|
allowedTargetStatuses(
|
|
ticket,
|
|
).length === 0
|
|
"
|
|
value=""
|
|
>
|
|
No allowed moves
|
|
</option>
|
|
<option
|
|
v-for="ticketStatus in allowedTargetStatuses(
|
|
ticket,
|
|
)"
|
|
:key="ticketStatus.id"
|
|
:value="ticketStatus.id"
|
|
>
|
|
{{
|
|
ticketStatusLabel(
|
|
ticketStatus,
|
|
)
|
|
}}
|
|
</option>
|
|
</select>
|
|
<Button
|
|
type="submit"
|
|
size="sm"
|
|
:disabled="
|
|
processing ||
|
|
allowedTargetStatuses(
|
|
ticket,
|
|
).length === 0
|
|
"
|
|
>
|
|
Update status
|
|
</Button>
|
|
</div>
|
|
<p
|
|
v-if="
|
|
allowedTargetStatuses(ticket)
|
|
.length === 0
|
|
"
|
|
class="text-muted-foreground text-xs"
|
|
>
|
|
This status does not allow moving
|
|
anywhere else.
|
|
</p>
|
|
</Form>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
</div>
|
|
</AppLayout>
|
|
</template>
|