feat: add todosCount to RecentTasks and TaskCard components
- Included `todosCount` prop in `RecentTasks` and `TaskCard` for better task management visibility. - Updated `TaskCard` UI to display the number of related todos, enhancing user interaction. - Modified `Task` interface and `TasksService` to support todos count retrieval from the database. - Added sample `todosCount` values in `UIShowcaseClient` for demonstration purposes.
This commit is contained in:
@@ -58,6 +58,7 @@ export function RecentTasks({ tasks }: RecentTasksProps) {
|
||||
tfsPullRequestId={task.tfsPullRequestId}
|
||||
tfsProject={task.tfsProject}
|
||||
tfsRepository={task.tfsRepository}
|
||||
todosCount={task.todosCount}
|
||||
availableTags={availableTags}
|
||||
fontSize="small"
|
||||
onTitleClick={() => {
|
||||
|
||||
@@ -79,6 +79,7 @@ export function TaskCard({ task, onEdit, compactView = false }: TaskCardProps) {
|
||||
tfsPullRequestId={task.tfsPullRequestId}
|
||||
tfsProject={task.tfsProject}
|
||||
tfsRepository={task.tfsRepository}
|
||||
todosCount={task.todosCount}
|
||||
isDragging={isDragging}
|
||||
isPending={isPending}
|
||||
onEdit={handleEdit}
|
||||
|
||||
@@ -621,6 +621,7 @@ export function UIShowcaseClient() {
|
||||
priority="high"
|
||||
tags={["Frontend", "UI"]}
|
||||
source="manual"
|
||||
todosCount={3}
|
||||
fontSize="medium"
|
||||
availableTags={[
|
||||
{ id: "1", name: "Frontend", color: "#3b82f6" },
|
||||
@@ -643,6 +644,7 @@ export function UIShowcaseClient() {
|
||||
tags={["Design", "Components"]}
|
||||
source="manual"
|
||||
dueDate={new Date(Date.now() + 7 * 24 * 60 * 60 * 1000)}
|
||||
todosCount={5}
|
||||
fontSize="medium"
|
||||
availableTags={[
|
||||
{ id: "1", name: "Design", color: "#f59e0b" },
|
||||
@@ -668,6 +670,7 @@ export function UIShowcaseClient() {
|
||||
jiraProject="PROJ"
|
||||
jiraType="Bug"
|
||||
dueDate={new Date(Date.now() + 3 * 24 * 60 * 60 * 1000)}
|
||||
todosCount={2}
|
||||
fontSize="medium"
|
||||
availableTags={[
|
||||
{ id: "1", name: "Bug", color: "#ef4444" },
|
||||
@@ -693,6 +696,7 @@ export function UIShowcaseClient() {
|
||||
tfsPullRequestId={456}
|
||||
tfsProject="MyProject"
|
||||
tfsRepository="backend-api"
|
||||
todosCount={1}
|
||||
fontSize="medium"
|
||||
availableTags={[
|
||||
{ id: "1", name: "API", color: "#06b6d4" },
|
||||
@@ -727,6 +731,7 @@ export function UIShowcaseClient() {
|
||||
priority="medium"
|
||||
tags={["Archive"]}
|
||||
source="manual"
|
||||
todosCount={4}
|
||||
fontSize="small"
|
||||
availableTags={[
|
||||
{ id: "1", name: "Archive", color: "#6b7280" }
|
||||
@@ -739,6 +744,7 @@ export function UIShowcaseClient() {
|
||||
priority="high"
|
||||
tags={["Cancelled"]}
|
||||
source="manual"
|
||||
todosCount={1}
|
||||
fontSize="small"
|
||||
availableTags={[
|
||||
{ id: "1", name: "Cancelled", color: "#ef4444" }
|
||||
|
||||
@@ -28,6 +28,9 @@ interface TaskCardProps extends HTMLAttributes<HTMLDivElement> {
|
||||
tfsProject?: string;
|
||||
tfsRepository?: string;
|
||||
|
||||
// Task ID for todos count
|
||||
todosCount?: number;
|
||||
|
||||
// Interactive
|
||||
isDragging?: boolean;
|
||||
isPending?: boolean;
|
||||
@@ -62,6 +65,7 @@ const TaskCard = forwardRef<HTMLDivElement, TaskCardProps>(
|
||||
tfsPullRequestId,
|
||||
tfsProject,
|
||||
tfsRepository,
|
||||
todosCount,
|
||||
isDragging = false,
|
||||
isPending = false,
|
||||
onEdit,
|
||||
@@ -519,6 +523,13 @@ const TaskCard = forwardRef<HTMLDivElement, TaskCardProps>(
|
||||
✓ DONE
|
||||
</span>
|
||||
)}
|
||||
|
||||
{/* Nombre de todos reliés */}
|
||||
{todosCount !== undefined && todosCount > 0 && (
|
||||
<Badge variant="outline" size="sm" className="text-cyan-400 border-cyan-400/30">
|
||||
📝 {todosCount}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -60,6 +60,7 @@ export interface Task {
|
||||
tfsTargetBranch?: string;
|
||||
|
||||
assignee?: string;
|
||||
todosCount?: number; // Nombre de todos reliés à cette tâche
|
||||
}
|
||||
|
||||
// Interface pour les tags
|
||||
|
||||
@@ -37,6 +37,11 @@ export class TasksService {
|
||||
include: {
|
||||
tag: true
|
||||
}
|
||||
},
|
||||
_count: {
|
||||
select: {
|
||||
dailyCheckboxes: true
|
||||
}
|
||||
}
|
||||
},
|
||||
take: filters?.limit, // Pas de limite par défaut - récupère toutes les tâches
|
||||
@@ -338,6 +343,11 @@ export class TasksService {
|
||||
include: {
|
||||
tag: true
|
||||
}
|
||||
},
|
||||
_count: {
|
||||
select: {
|
||||
dailyCheckboxes: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}> | Prisma.TaskGetPayload<object>): Task {
|
||||
@@ -349,6 +359,12 @@ export class TasksService {
|
||||
tags = prismaTask.taskTags.map((tt) => tt.tag.name);
|
||||
}
|
||||
|
||||
// Extraire le count des todos
|
||||
let todosCount = 0;
|
||||
if ('_count' in prismaTask && prismaTask._count) {
|
||||
todosCount = prismaTask._count.dailyCheckboxes || 0;
|
||||
}
|
||||
|
||||
return {
|
||||
id: prismaTask.id,
|
||||
title: prismaTask.title,
|
||||
@@ -371,7 +387,8 @@ export class TasksService {
|
||||
tfsRepository: prismaTask.tfsRepository ?? undefined,
|
||||
tfsSourceBranch: prismaTask.tfsSourceBranch ?? undefined,
|
||||
tfsTargetBranch: prismaTask.tfsTargetBranch ?? undefined,
|
||||
assignee: prismaTask.assignee ?? undefined
|
||||
assignee: prismaTask.assignee ?? undefined,
|
||||
todosCount: todosCount
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user