Commit 35dcdf1
committed
# Commit: Add Dynamic Task Management to "Manage Tasks" Page
## Summary
Implemented functionality to dynamically fetch, render, and manage tasks on the "Manage Tasks" page using real-time interactions with the backend.
## Features
### 1. Fetch and Render Tasks
- Created an `async fetchTasks` function to fetch tasks from the database using a GET request.
- Rendered tasks dynamically with a `renderTasks` function, displaying:
- Task Priority
- Task Information (ID, Name, Assigned To, Status, Due Date)
- Action Buttons (View Details, Update Status, Remove Task).
### 2. Button Actions
#### **View Details**
- Added a fetch request to retrieve task details by Task ID.
- Placeholder functionality for displaying details in a popup/modal.
#### **Update Status**
- Added a PATCH request to update task statuses:
- Status transitions: `Active → Currently Working → Closed` or `Due → Currently Working → Closed`.
- Dynamically updated status without page reloads.
#### **Remove Task**
- Added a DELETE request to remove a task by Task ID.
- Automatically refreshes the page on successful deletion.
### 3. Dynamic Event Binding
- Created an `attachButtonEvents` function to dynamically bind event listeners to:
- "View Details" buttons.
- "Update Status" buttons.
- "Remove Task" buttons.
### 4. Dynamic Styling
- Added class-based styling for:
- Priority Labels: `low-priority`, `medium-priority`, `high-priority`.
- Status Labels: `active`, `currently-working`, `closed`.
- Designed visually appealing task cards for better user experience.
## Notes
- Improved modularity by isolating reusable functions and separating data fetching from rendering.
- Ensured real-time interaction with backend for all task operations.
- Prepared for future UI enhancements, such as modal-based task details.
## Impact
This update enables efficient task management by allowing dynamic interactions, improving the user experience, and ensuring scalability.
# Commit: Update API for Task Management with Enhanced Features
## Summary
Enhanced the task management API to handle fetching, deleting, and updating task statuses efficiently. The updates ensure better error handling, improved performance, and flexibility for frontend integrations.
---
## Updates and Features
### 1. **GET Request: Fetch Tasks**
- **Endpoint**: `/add-get-tasks.php?action=fetch`
- **Functionality**: Retrieves all tasks from the `Tasks` table, ordered by the `CreatedAt` field in descending order.
- **Response**:
- Success: Returns all tasks as an array.
- Failure: Returns an error message if no tasks are found or a database error occurs.
---
### 2. **DELETE Request: Remove Tasks**
- **Endpoint**: `/add-get-tasks.php?action=delete`
- **Functionality**:
- Deletes a specific task identified by its `TID`.
- Sanitized `TID` input with `htmlspecialchars` to enhance security.
- **Response**:
- Success: Confirms task deletion with a success message.
- Failure: Returns a descriptive error message for invalid `TID` or database errors.
---
### 3. **Task Status Update (PATCH/DELETE)**
- **Endpoint**: `/add-get-tasks.php?action=update_status`
- **Functionality**:
- Fetches the current `TaskStatus` for the task identified by its `TID`.
- Updates the status to the next logical step:
- `Active → Currently Working`
- `Currently Working → Closed`
- `Due → Currently Working`
- `Closed` remains unchanged.
- Handles invalid statuses gracefully.
- **Response**:
- Success: Confirms the update and returns the new status.
- Failure: Provides error details if the task is not found or a database error occurs.
---
### 4. **Error Handling**
- Added robust error handling for:
- Database connection issues.
- Missing or invalid `TID`.
- Unsupported actions or HTTP methods.
- Returns clear, actionable error messages in JSON format.
---
### 5. **Code Improvements**
- Ensured input sanitization using `htmlspecialchars` to prevent XSS vulnerabilities.
- Optimized queries with parameterized bindings to prevent SQL injection.
- Used PHP's `match` expression for concise status updates.
---
## Impact
- Improved security by validating and sanitizing inputs.
- Enhanced the API’s flexibility, making it easier for the frontend to integrate dynamic task management features.
- Ensured scalability by implementing logical status transitions and error-proof task deletions.1 parent 64959ff commit 35dcdf1
4 files changed
Lines changed: 259 additions & 81 deletions
File tree
- Assets
- Contents/Pages
- Processors
- Resources
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
| 397 | + | |
419 | 398 | | |
420 | 399 | | |
421 | 400 | | |
| |||
562 | 541 | | |
563 | 542 | | |
564 | 543 | | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
565 | 669 | | |
566 | 670 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | | - | |
100 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
101 | 109 | | |
102 | 110 | | |
103 | | - | |
| 111 | + | |
104 | 112 | | |
105 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
106 | 117 | | |
107 | 118 | | |
108 | | - | |
109 | | - | |
| 119 | + | |
| 120 | + | |
110 | 121 | | |
111 | 122 | | |
112 | | - | |
113 | | - | |
| 123 | + | |
| 124 | + | |
114 | 125 | | |
115 | 126 | | |
116 | | - | |
117 | | - | |
| 127 | + | |
| 128 | + | |
118 | 129 | | |
119 | 130 | | |
120 | | - | |
121 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
122 | 134 | | |
123 | 135 | | |
124 | | - | |
| 136 | + | |
125 | 137 | | |
| 138 | + | |
| 139 | + | |
126 | 140 | | |
127 | 141 | | |
128 | | - | |
129 | | - | |
| 142 | + | |
| 143 | + | |
130 | 144 | | |
131 | 145 | | |
132 | | - | |
133 | | - | |
| 146 | + | |
| 147 | + | |
134 | 148 | | |
135 | 149 | | |
136 | | - | |
137 | | - | |
| 150 | + | |
| 151 | + | |
138 | 152 | | |
139 | 153 | | |
140 | | - | |
141 | | - | |
| 154 | + | |
| 155 | + | |
142 | 156 | | |
143 | 157 | | |
144 | | - | |
145 | | - | |
| 158 | + | |
| 159 | + | |
146 | 160 | | |
147 | 161 | | |
148 | | - | |
149 | | - | |
| 162 | + | |
| 163 | + | |
150 | 164 | | |
151 | 165 | | |
152 | 166 | | |
| 167 | + | |
153 | 168 | | |
154 | 169 | | |
155 | 170 | | |
| |||
201 | 216 | | |
202 | 217 | | |
203 | 218 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
209 | 223 | | |
210 | 224 | | |
211 | 225 | | |
| |||
238 | 252 | | |
239 | 253 | | |
240 | 254 | | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
246 | 260 | | |
247 | 261 | | |
248 | 262 | | |
| |||
0 commit comments