feat(task-drawer): enhance task navigation and hierarchy display

- Added functionality to navigate back to parent tasks for sub-tasks in the task drawer.
- Introduced a breadcrumb component to visually represent the hierarchy of tasks, improving user navigation.
- Updated task drawer header to display the current task name with truncation and tooltip for better readability.
- Enhanced styling for task name display and breadcrumb for improved user experience.
This commit is contained in:
chamikaJ
2025-07-14 12:28:04 +05:30
parent 02d814b935
commit 1c981312d4
11 changed files with 605 additions and 231 deletions

View File

@@ -3,7 +3,7 @@ import Drawer from 'antd/es/drawer';
import { InputRef } from 'antd/es/input';
import { useTranslation } from 'react-i18next';
import { useEffect, useRef, useState } from 'react';
import { PlusOutlined } from '@ant-design/icons';
import { PlusOutlined, CloseOutlined, ArrowLeftOutlined } from '@ant-design/icons';
import { useAppSelector } from '@/hooks/useAppSelector';
import { useAppDispatch } from '@/hooks/useAppDispatch';
@@ -13,6 +13,7 @@ import {
setTaskFormViewModel,
setTaskSubscribers,
setTimeLogEditing,
fetchTask,
} from '@/features/task-drawer/task-drawer.slice';
import './task-drawer.css';
@@ -33,6 +34,7 @@ const TaskDrawer = () => {
const { showTaskDrawer, timeLogEditing } = useAppSelector(state => state.taskDrawerReducer);
const { taskFormViewModel, selectedTaskId } = useAppSelector(state => state.taskDrawerReducer);
const { projectId } = useAppSelector(state => state.projectReducer);
const taskNameInputRef = useRef<InputRef>(null);
const isClosingManually = useRef(false);
@@ -54,6 +56,17 @@ const TaskDrawer = () => {
dispatch(setTaskSubscribers([]));
};
const handleBackToParent = () => {
if (taskFormViewModel?.task?.parent_task_id && projectId) {
// Navigate to parent task
dispatch(setSelectedTaskId(taskFormViewModel.task.parent_task_id));
dispatch(fetchTask({
taskId: taskFormViewModel.task.parent_task_id,
projectId
}));
}
};
const handleOnClose = (
e?: React.MouseEvent<Element, MouseEvent> | React.KeyboardEvent<Element>
) => {
@@ -68,10 +81,8 @@ const TaskDrawer = () => {
if (isClickOutsideDrawer || !taskFormViewModel?.task?.is_sub_task) {
resetTaskState();
} else {
dispatch(setSelectedTaskId(null));
dispatch(setTaskFormViewModel({}));
dispatch(setTaskSubscribers([]));
dispatch(setSelectedTaskId(taskFormViewModel?.task?.parent_task_id || null));
// For sub-tasks, navigate to parent instead of closing
handleBackToParent();
}
// Reset the flag after a short delay
setTimeout(() => {
@@ -205,6 +216,17 @@ const TaskDrawer = () => {
};
};
// Check if current task is a sub-task
const isSubTask = taskFormViewModel?.task?.is_sub_task || !!taskFormViewModel?.task?.parent_task_id;
// Custom close icon based on whether it's a sub-task
const getCloseIcon = () => {
if (isSubTask) {
return <ArrowLeftOutlined />;
}
return <CloseOutlined />;
};
const drawerProps = {
open: showTaskDrawer,
onClose: handleOnClose,
@@ -215,6 +237,7 @@ const TaskDrawer = () => {
footer: renderFooter(),
bodyStyle: getBodyStyle(),
footerStyle: getFooterStyle(),
closeIcon: getCloseIcon(),
};
return (