Service Report #010 In Review
Date: 2026-01-25
This report covers improvements to the Tool List Preparation workflow, including a new All Tasks administrative view and duplicate workflow prevention validation.
Feature Overview
| # | Feature | PR/Issue | Type | Status |
|---|---|---|---|---|
| 1 | All Tasks View | PR #321 | New Feature | 🔍 In Review |
| 2 | Duplicate Workflow Prevention | Internal | Enhancement | 🔍 In Review |
| 3 | Tool List Standard Patterns | PR #320 | Refactor | 🔍 In Review |
| 4 | Contractor Email Notification | Internal | Bug Fix | 🔍 In Review |
| 5 | Date/Time Picker Bug Fix | Internal | Bug Fix | 🔍 In Review |
| 6 | Task Type Selection UI | Internal | Enhancement | 🔍 In Review |
| 7 | Login Dev Note for Email Testing | Internal | Enhancement | 🔍 In Review |
1. All Tasks View
PR: #321 Thai Name: หน้าดูงานทั้งหมดสำหรับผู้ดูแลระบบ
Description: A new administrative view that shows all tasks across all users in the system. This allows Safety Officers and Administrators to see the complete task backlog, monitor workflow progress, and identify bottlenecks.
Location: Tasks > All Tasks (ดูงานทั้งหมด)
Features
| Feature | Description |
|---|---|
| Server-side Pagination | Loads 20 tasks at a time for performance |
| Filtering | Filter by task type (Project Registration, Tool List, JSA, etc.) |
| Search | Search by task reference number or project name |
| Sort | Sort by created date, last action time, or status |
| Role-based Access | Only visible to Admin and Safety Officer roles |
Access Control
| Role | Can Access |
|---|---|
| Admin | ✅ Yes |
| Safety Officer | ✅ Yes |
| Work Owner | ❌ No (only sees "My Tasks") |
| Contractor | ❌ No (only sees "My Tasks") |
| Purchasing | ❌ No (only sees "My Tasks") |
What to Test
| # | Test Case | Status |
|---|---|---|
| 1 | Login as Admin → Navigate to Tasks → See "All Tasks" option in sidebar | ⌛ Pending |
| 2 | Open All Tasks → See tasks from all users with pagination | ⌛ Pending |
| 3 | Use filter dropdown to filter by task type → Results update | ⌛ Pending |
| 4 | Login as Contractor → "All Tasks" option NOT visible | ⌛ Pending |
| 5 | Click on a task row → Navigate to task review page | ⌛ Pending |
2. Duplicate Workflow Prevention
Source: Internal Enhancement Thai Name: ป้องกันการสร้างงานซ้ำสำหรับโครงการเดียวกัน
Description: Added validation to prevent creating duplicate active workflows for the same project. When a user tries to create a Tool List or JSA Preparation workflow for a project that already has one active, the system shows a friendly error dialog with the existing task information and allows direct navigation to it.
Location: My Tasks > Create Task > Tool List Preparation / JSA Preparation
Validation Rules
| Workflow | Rule | Error Response |
|---|---|---|
| Project Registration | No validation | Always allowed |
| Tool List Preparation | One active per project | 409 Conflict with existing task info |
| JSA Preparation | One active per project | 409 Conflict with existing task info |
| Work Permit Request | Multiple allowed | No check needed |
| Training Enrollment | One active globally | Already implemented (Report #008) |
"Active" Definition: Only Status = Active (0) blocks creation. Closed, Cancelled, or Rejected tasks allow new creation.
Error Dialog
When a duplicate is detected, instead of a generic error toast, the system shows:
- Warning message explaining the issue
- The existing task card with task type, project name, assignee, and creation date
- "Go to Existing Task" button that navigates to the existing workflow
Backend Implementation
| Layer | File | Change |
|---|---|---|
| Backend | Error.cs | Added DuplicateActiveWorkflow error constant |
| Backend | TaskLifecycleService.cs | Added duplicate check before task creation |
| Backend | CreateTaskEndpoint.cs | Returns 409 Conflict with existing task info |
Frontend Implementation
| Layer | File | Change |
|---|---|---|
| Frontend | my-tasks.service.ts | Detects 409 Conflict, stores duplicate task info |
| Frontend | my-tasks.component.ts | Opens duplicate dialog on error |
| Frontend | duplicate-workflow-dialog.component.ts | New dialog showing existing task |
| Frontend | http-header.interceptor.ts | Added 409 to expected status codes (no debug dialog) |
What to Test
| # | Test Case | Status |
|---|---|---|
| 1 | Create Tool List for project A → Success | ⌛ Pending |
| 2 | Create another Tool List for project A → Error dialog shows with existing task | ⌛ Pending |
| 3 | Click "Go to Existing Task" → Navigates to the existing workflow | ⌛ Pending |
| 4 | Cancel/Close existing Tool List → Create new Tool List for project A → Success | ⌛ Pending |
| 5 | Create Tool List for project B → Success (different project allowed) | ⌛ Pending |
| 6 | Create Work Permit for project A (already has Tool List) → Success (multiple WP allowed) | ⌛ Pending |
| 7 | Debug error dialog does NOT appear for 409 responses | ⌛ Pending |
3. Tool List Standard Patterns
PR: #320 Thai Name: ปรับปรุง Tool List Workflow ให้เป็นมาตรฐานเดียวกับ Project Registration
Description: Refactored the Tool List Preparation workflow to follow the same standard patterns established in Project Registration. This includes consistent form validation, command button behavior, and document navigation patterns.
Location: Tool List Preparation Workflow (all states)
Standard Patterns Applied
| Pattern | Description |
|---|---|
| Form Validation | Contractor must add at least 1 tool before submitting |
| ValidationRequired Flag | Submit command requires valid form data |
| Validation UI Banner | Orange warning banner shows missing fields |
| Auto-Navigation | Users are taken directly to the relevant document form |
| Command Button Visibility | Commands hidden on document list, shown on document form |
Form Validation Rules
| Field | Rule | Error Message |
|---|---|---|
| Tool List | At least 1 tool required | "รายการเครื่องมืออย่างน้อย 1 รายการ" |
What to Test
| # | Test Case | Status |
|---|---|---|
| 1 | Open Tool List task as Contractor → Form opens automatically | ⌛ Pending |
| 2 | Empty tool list → Submit button disabled, orange warning shown | ⌛ Pending |
| 3 | Add 1 tool → Submit button enabled, warning hidden | ⌛ Pending |
| 4 | View document list → Command buttons hidden | ⌛ Pending |
| 5 | Open document form → Command buttons visible | ⌛ Pending |
Additional Fixes
Project Search for Contractors
Issue: Contractors could not see approved projects when creating Tool List workflows.
Root Cause: The SearchProjectsByPrNoEndpoint only returned projects where the current user was the Work Owner. Contractor users needed to see projects where their contractor company is assigned.
Fix: Updated the endpoint filter to include projects where:
- User is the Work Owner
- User's contractor company is assigned to the project
- User is the Contractor Supervisor or Coordinator on the project
| Layer | File | Change |
|---|---|---|
| Backend | SearchProjectsByPrNoEndpoint.cs | Expanded filter to include contractor-assigned projects |
4. Contractor Email Notification
Source: Internal Bug Fix Thai Name: แก้ไขอีเมลแจ้งเตือนไม่ส่งถึงผู้รับเหมา
Description: Fixed a bug where contractor users were not receiving email notifications when Tool List workflow was approved. Work Owner received the email, but the contractor (task creator) did not.
Location: Tool List Preparation Workflow > Approve command
Root Cause
The email notification system has a two-layer architecture:
- Workflow Activity Layer - Must call
SendNotificationEmailsAsync - TaskCommandService Layer - Must pass
notificationOptionsto the workflow service
The Tool List workflow was missing the connection in Layer 2 - TaskCommandService wasn't passing notificationOptions through to the workflow service.
Fix Applied
| Layer | File | Change |
|---|---|---|
| Backend | ToolListPreparationActivities.cs | Added SendNotificationEmailsAsync activity |
| Backend | ToolListPreparationWorkflow.cs | Call activity with notification options |
| Backend | IToolListPreparationWorkflowService.cs | Added notificationOptions parameter |
| Backend | ToolListPreparationWorkflowService.cs | Pass options through to workflow |
| Backend | TaskCommandService.cs | Pass notificationOptions to workflow service |
What to Test
| # | Test Case | Status |
|---|---|---|
| 1 | Contractor submits Tool List → Work Owner approves → Contractor receives email | ⌛ Pending |
| 2 | Check email at smtp.iotserver.in.th for contractor's email address | ⌛ Pending |
| 3 | Email contains task link and approval details | ⌛ Pending |
5. Date/Time Picker Bug Fix
Source: Internal Bug Fix Thai Name: แก้ไขข้อผิดพลาด Date/Time Picker
Description: Fixed JavaScript errors when using the date picker or time picker in the Tool List form. The error occurred because date values from the backend come as ISO strings, but the code expected Date objects.
Location: Tool List Preparation Workflow > Appointment Date/Time fields
Root Cause
- Backend JSON serializes date fields as ISO strings (e.g.,
"2026-01-25T10:30:00.000Z") - TypeScript interface declares type as
Date, but runtime value is actually astring - Calling
.getHours()or.getTime()on a string throws:getHours is not a function
Fix Applied
| Layer | File | Change |
|---|---|---|
| Frontend | tool-list-form.component.ts | Added toDate() helper to safely convert string → Date |
Helper Pattern:
private toDate(value: Date | string | null | undefined): Date | null {
if (!value) return null;
if (value instanceof Date) return value;
const date = new Date(value);
return isNaN(date.getTime()) ? null : date;
}
What to Test
| # | Test Case | Status |
|---|---|---|
| 1 | Open Tool List with existing appointment date → No JavaScript errors | ⌛ Pending |
| 2 | Change date in date picker → Time is preserved | ⌛ Pending |
| 3 | Change time in time picker → Date is preserved | ⌛ Pending |
| 4 | Save form → Refresh page → Date/time values persist correctly | ⌛ Pending |
6. Task Type Selection UI
Source: Internal Enhancement Thai Name: ปรับปรุง UI เลือกประเภทงาน
Description: Improved the task type selection dialog with clearer messaging about workflows that are still in development.
Location: My Tasks > Create Task > Task Type Selection Dialog
Changes
| Change | Before | After |
|---|---|---|
| Tool List note | "(อยู่ระหว่างพัฒนา)" | Removed (ready for testing) |
| JSA/Work Permit note | "(อยู่ระหว่างพัฒนา)" | "(อยู่ระหว่างพัฒนา อาจพบข้อผิดพลาด)" |
| Dev Note banner | Shown in dialog | Removed |
What to Test
| # | Test Case | Status |
|---|---|---|
| 1 | Open Create Task dialog → Tool List has no warning note | ⌛ Pending |
| 2 | JSA Preparation shows "(อยู่ระหว่างพัฒนา อาจพบข้อผิดพลาด)" | ⌛ Pending |
| 3 | Work Permit shows "(อยู่ระหว่างพัฒนา อาจพบข้อผิดพลาด)" | ⌛ Pending |
7. Login Dev Note for Email Testing
Source: Internal Enhancement Thai Name: เพิ่มหมายเหตุสำหรับทดสอบอีเมล
Description: Added a development note at the bottom of the login panel to inform testers about the email testing URL. This helps testers verify email notifications during development.
Location: Login Page (development mode only)
Features
| Feature | Description |
|---|---|
| Visibility | Only shown in development mode |
| Content | Link to smtp.iotserver.in.th for email testing |
| Styling | Purple dev note banner |
| i18n | Thai and English translations |
What to Test
| # | Test Case | Status |
|---|---|---|
| 1 | Open login page in dev mode → See "Dev Note" with email testing link | ⌛ Pending |
| 2 | Click link → Opens smtp.iotserver.in.th in new tab | ⌛ Pending |
| 3 | Switch to English → Text shows "Check email at" | ⌛ Pending |
Summary
| # | Feature | Type | Status |
|---|---|---|---|
| 1 | All Tasks View | New Feature | 🔍 In Review |
| 2 | Duplicate Workflow Prevention | Enhancement | 🔍 In Review |
| 3 | Tool List Standard Patterns | Refactor | 🔍 In Review |
| 4 | Project Search for Contractors | Bug Fix | 🔍 In Review |
| 5 | Contractor Email Notification | Bug Fix | 🔍 In Review |
| 6 | Date/Time Picker Bug Fix | Bug Fix | 🔍 In Review |
| 7 | Task Type Selection UI | Enhancement | 🔍 In Review |
| 8 | Login Dev Note for Email Testing | Enhancement | 🔍 In Review |