feat: enhance task filtering in EditCheckboxModal
- Updated `filteredTasks` logic to exclude tasks marked as "objectif principal" (isPinned = true) for better task management. - Added `tagDetails` property to `Task` interface to store detailed tag information, improving task data structure. - Adjusted `TasksService` to extract and include tag details when retrieving tasks from the database.
This commit is contained in:
@@ -58,11 +58,17 @@ export function EditCheckboxModal({
|
|||||||
}
|
}
|
||||||
}, [taskId, allTasks]);
|
}, [taskId, allTasks]);
|
||||||
|
|
||||||
// Filtrer les tâches selon la recherche
|
// Filtrer les tâches selon la recherche et exclure les tâches avec des tags "objectif principal"
|
||||||
const filteredTasks = allTasks.filter(task =>
|
const filteredTasks = allTasks.filter(task => {
|
||||||
task.title.toLowerCase().includes(taskSearch.toLowerCase()) ||
|
// Exclure les tâches avec des tags marqués comme "objectif principal" (isPinned = true)
|
||||||
(task.description && task.description.toLowerCase().includes(taskSearch.toLowerCase()))
|
if (task.tagDetails && task.tagDetails.some(tag => tag.isPinned)) {
|
||||||
);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filtrer selon la recherche
|
||||||
|
return task.title.toLowerCase().includes(taskSearch.toLowerCase()) ||
|
||||||
|
(task.description && task.description.toLowerCase().includes(taskSearch.toLowerCase()));
|
||||||
|
});
|
||||||
|
|
||||||
const handleTaskSelect = (task: Task) => {
|
const handleTaskSelect = (task: Task) => {
|
||||||
setTaskId(task.id);
|
setTaskId(task.id);
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export interface Task {
|
|||||||
source: TaskSource;
|
source: TaskSource;
|
||||||
sourceId?: string;
|
sourceId?: string;
|
||||||
tags: string[];
|
tags: string[];
|
||||||
|
tagDetails?: Tag[]; // Tags avec informations complètes (isPinned, etc.)
|
||||||
dueDate?: Date;
|
dueDate?: Date;
|
||||||
completedAt?: Date;
|
completedAt?: Date;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { prisma } from '@/services/core/database';
|
import { prisma } from '@/services/core/database';
|
||||||
import { Task, TaskStatus, TaskPriority, TaskSource, BusinessError, DailyCheckbox, DailyCheckboxType } from '@/lib/types';
|
import { Task, TaskStatus, TaskPriority, TaskSource, BusinessError, DailyCheckbox, DailyCheckboxType, Tag } from '@/lib/types';
|
||||||
import { Prisma } from '@prisma/client';
|
import { Prisma } from '@prisma/client';
|
||||||
import { getToday } from '@/lib/date-utils';
|
import { getToday } from '@/lib/date-utils';
|
||||||
|
|
||||||
@@ -358,12 +358,19 @@ export class TasksService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}> | Prisma.TaskGetPayload<object>): Task {
|
}> | Prisma.TaskGetPayload<object>): Task {
|
||||||
// Extraire les tags depuis les relations TaskTag ou fallback sur tagsJson
|
// Extraire les tags depuis les relations TaskTag
|
||||||
let tags: string[] = [];
|
let tags: string[] = [];
|
||||||
|
let tagDetails: Tag[] = [];
|
||||||
|
|
||||||
if ('taskTags' in prismaTask && prismaTask.taskTags && Array.isArray(prismaTask.taskTags)) {
|
if ('taskTags' in prismaTask && prismaTask.taskTags && Array.isArray(prismaTask.taskTags)) {
|
||||||
// Utiliser les relations Prisma
|
// Utiliser les relations Prisma pour récupérer les noms et détails des tags
|
||||||
tags = prismaTask.taskTags.map((tt) => tt.tag.name);
|
tags = prismaTask.taskTags.map((tt) => tt.tag.name);
|
||||||
|
tagDetails = prismaTask.taskTags.map((tt) => ({
|
||||||
|
id: tt.tag.id,
|
||||||
|
name: tt.tag.name,
|
||||||
|
color: tt.tag.color,
|
||||||
|
isPinned: tt.tag.isPinned
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extraire le count des todos
|
// Extraire le count des todos
|
||||||
@@ -381,6 +388,7 @@ export class TasksService {
|
|||||||
source: prismaTask.source as TaskSource,
|
source: prismaTask.source as TaskSource,
|
||||||
sourceId: prismaTask.sourceId ?? undefined,
|
sourceId: prismaTask.sourceId ?? undefined,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
|
tagDetails: tagDetails,
|
||||||
dueDate: prismaTask.dueDate ?? undefined,
|
dueDate: prismaTask.dueDate ?? undefined,
|
||||||
completedAt: prismaTask.completedAt ?? undefined,
|
completedAt: prismaTask.completedAt ?? undefined,
|
||||||
createdAt: prismaTask.createdAt,
|
createdAt: prismaTask.createdAt,
|
||||||
|
|||||||
Reference in New Issue
Block a user