# @acorex/modules/task-management

Secondary entry point of `@acorex/modules`. It can be used by importing from `@acorex/modules/task-management`.

# @acorex/modules/task-management

Secondary entry point of `@acorex/modules`. It can be used by importing from `@acorex/modules/task-management`.
This module defines the universal Task Engine used across the ACoreX Platform — powering everything from personal to-do lists to complex project workflows.

# ✅ ACoreX Task Management Module

## 📌 What is Task Management?

The **Task Management Module** is a core, standalone service in the ACoreX Platform responsible for creating, assigning, tracking, and managing **tasks** across the system. It is designed to be **reusable and integratable** into any other module (e.g., Project Management, Workflow, Meeting, Help Desk).

It supports:

- Generic and contextual tasks
- Full lifecycle and status management per task type
- Task type-based behavior, fields, and flows
- Comments, attachments, time tracking
- Visual boards (Kanban, Table, Scheduler)
- Notification, calendar, and chat integration

---

## 🧠 TaskType-Centric Architecture

Each task is linked to a **`TaskType`**, which defines:

- Allowed statuses and their transitions
- Supported features (e.g., checklists, time tracking)
- Form layout and validation (via `form-template-management`)
- Default permissions and assignment rules
- Allowed context types (e.g., `project`, `meeting`, or `null` for personal to-do)

This allows the module to support both **simple personal tasks** and **enterprise-grade tasks**.

---

## 🧱 Core Entities

| Entity                | Description                                                                                         |
| --------------------- | --------------------------------------------------------------------------------------------------- |
| **Task**              | The main work unit. Can be linked to one or more contexts (project, meeting, etc.) via TaskContext. |
| **TaskType**          | Defines allowed statuses, structure, form template, context scopes, etc.                            |
| **TaskStatus**        | Status configuration per TaskType (with allowed transitions)                                        |
| **TaskChecklistItem** | Optional checklist items inside tasks                                                               |
| **TaskAssignment**    | Maps users to tasks with optional roles                                                             |
| **TimeLog**           | Logs time spent by users per task                                                                   |
| **TaskTemplate**      | Reusable structure for task generation (optional)                                                   |
| **TaskDependency**    | Define dependencies between tasks (used in projects or workflows)                                   |

---

## ⚙️ Required Commands

| Command                            | Purpose                                    |
| ---------------------------------- | ------------------------------------------ |
| `AXPCreateTaskCommand`             | Create a new task                          |
| `AXPUpdateTaskCommand`             | Update task metadata                       |
| `AXPDeleteTaskCommand`             | Soft-delete a task                         |
| `AXPAssignTaskCommand`             | Assign task to user(s)                     |
| `AXPAddTimeLogCommand`             | Log time on a task                         |
| `AXPCompleteChecklistItemCommand`  | Mark checklist item as done                |
| `AXPSetTaskStatusCommand`          | Change task status                         |
| `AXPCreateTaskFromTemplateCommand` | Spawn task from a predefined template      |
| `AXPReorderTaskCommand`            | Change task position/order in a board view |
| `AXPSetTaskDependenciesCommand`    | Define task prerequisites                  |

---

## 🔍 Queries

| Query                           | Purpose                                        |
| ------------------------------- | ---------------------------------------------- |
| `AXPGetTaskDetailQuery`         | Fetch full task data with comments, logs, etc. |
| `AXPGetTaskBoardQuery`          | Paginated/filterable task board                |
| `AXPGetTaskBoardQuery`          | Fetch board data (Kanban, Table, Scheduler)    |
| `AXPGetMyTasksQuery`            | Tasks assigned to current user                 |
| `AXPGetTaskTemplatesQuery`      | Retrieve reusable templates                    |
| `AXPGetTaskCalendarEventsQuery` | Used for calendar views                        |
| `AXPGetTaskSuggestionsQuery`    | Used by AI assistant or filters                |
| `AXPGetTaskTypesQuery`          | Fetch metadata about all available task types  |

---

## 🧩 Integration with Other Modules

| Module                   | Integration Type                                         |
| ------------------------ | -------------------------------------------------------- |
| **Project Management**   | `taskType = 'project-task'`, `contextType = 'project'`   |
| **Meeting Management**   | `taskType = 'meeting-action'`, `contextType = 'meeting'` |
| **Workflow Management**  | `taskType = 'approval-step'`, flow hooks                 |
| **Help Desk**            | Internal tasks for resolution                            |
| **Learning Management**  | Course-based tasks                                       |
| **Calendar Management**  | Task due dates → calendar events                         |
| **Conversation Module**  | Comments, mentions, chat                                 |
| **Notification Module**  | Reminders, assignments, status changes                   |
| **EDMS**                 | File attachments                                         |
| **Form Template Engine** | Dynamic task forms per type                              |
| **Extra Fields Engine**  | Dynamic fields per task type/context                     |
| **Report Builder**       | KPI dashboards, task reports                             |
| **RBAC & Org Module**    | Role-based visibility and assignment                     |

---

## 🖼️ UI Features and Views

### ✅ Generic Task Board Page

A reusable component to visualize tasks in various modes:

| View Type          | Features                                                |
| ------------------ | ------------------------------------------------------- |
| **Scheduler View** | Monthly, weekly, daily calendar-style task board        |
| **Table View**     | Sortable and filterable data table with task columns    |
| **Kanban View**    | Drag-and-drop column-based layout by status or assignee |

All views support:

- Context and task-type filters
- My tasks toggle
- Saved view configurations

---

## 📋 UI Forms

| Form                  | Description                                                         |
| --------------------- | ------------------------------------------------------------------- |
| **Task Form**         | Dynamic form loaded via form-template per `taskType`                |
| **Checklist Editor**  | Add/edit checklist items                                            |
| **Assignment Form**   | Select assignees with roles or teams                                |
| **Time Log Form**     | Add/edit time logs                                                  |
| **Task Type Manager** | Admin UI to define task types, statuses, transitions, form mappings |

---

## 📊 Reports & Dashboards

| Report / Widget               | Description                          |
| ----------------------------- | ------------------------------------ |
| **Task Summary Report**       | By status, due date, project/type    |
| **Time Spent per Task/User**  | Aggregated time logs                 |
| **My Tasks Report**           | Assigned to user, filterable         |
| **Overdue Tasks Report**      | Tasks past due                       |
| **Task Completion Trend**     | Weekly/daily progress visualizations |
| **Checklist Completion Rate** | % done per task/project              |

---

## 🔐 Permissions (RBAC)

| Action              | Permission Key       |
| ------------------- | -------------------- |
| Create Task         | `task.create`        |
| Edit Task           | `task.edit`          |
| Delete Task         | `task.delete`        |
| View All Tasks      | `task.view.all`      |
| View Assigned Tasks | `task.view.assigned` |
| Assign Task         | `task.assign`        |
| Log Time            | `task.timelog.add`   |
| Comment on Task     | `task.comment`       |

---

## 🌐 Routing & Page Guidelines

- `/tasks` → All tasks (with filters/views)
- `/tasks/:id` → Task detail view
- `/projects/:id/tasks` → Project-specific view
- `/meetings/:id/tasks` → Post-meeting action view

---

## 🧠 Future Enhancements

- AI-generated task suggestions
- Task recurrence & SLA
- Workflow-triggered tasks
- Cross-module assignment rules
- Delegation and escalation logic

---

## ✅ Summary

The `task-management` module serves as a **universal, task-type-driven engine** across ACoreX. It powers everything from personal to-dos to collaborative project or workflow execution. Through the flexible `TaskType` contract, it enables modular reuse, customization, and platform-wide integration.
