Skip to main content

Service Report #010 In Review

Date: 2026-01-25


Tool List Workflow Improvements

This report covers improvements to the Tool List Preparation workflow, including a new All Tasks administrative view and duplicate workflow prevention validation.

Feature Overview

#FeaturePR/IssueTypeStatus
1All Tasks ViewPR #321New Feature🔍 In Review
2Duplicate Workflow PreventionInternalEnhancement🔍 In Review
3Tool List Standard PatternsPR #320Refactor🔍 In Review
4Contractor Email NotificationInternalBug Fix🔍 In Review
5Date/Time Picker Bug FixInternalBug Fix🔍 In Review
6Task Type Selection UIInternalEnhancement🔍 In Review
7Login Dev Note for Email TestingInternalEnhancement🔍 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

FeatureDescription
Server-side PaginationLoads 20 tasks at a time for performance
FilteringFilter by task type (Project Registration, Tool List, JSA, etc.)
SearchSearch by task reference number or project name
SortSort by created date, last action time, or status
Role-based AccessOnly visible to Admin and Safety Officer roles

Access Control

RoleCan 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 CaseStatus
1Login as Admin → Navigate to Tasks → See "All Tasks" option in sidebar Pending
2Open All Tasks → See tasks from all users with pagination Pending
3Use filter dropdown to filter by task type → Results update Pending
4Login as Contractor → "All Tasks" option NOT visible Pending
5Click 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

WorkflowRuleError Response
Project RegistrationNo validationAlways allowed
Tool List PreparationOne active per project409 Conflict with existing task info
JSA PreparationOne active per project409 Conflict with existing task info
Work Permit RequestMultiple allowedNo check needed
Training EnrollmentOne active globallyAlready 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

LayerFileChange
BackendError.csAdded DuplicateActiveWorkflow error constant
BackendTaskLifecycleService.csAdded duplicate check before task creation
BackendCreateTaskEndpoint.csReturns 409 Conflict with existing task info

Frontend Implementation

LayerFileChange
Frontendmy-tasks.service.tsDetects 409 Conflict, stores duplicate task info
Frontendmy-tasks.component.tsOpens duplicate dialog on error
Frontendduplicate-workflow-dialog.component.tsNew dialog showing existing task
Frontendhttp-header.interceptor.tsAdded 409 to expected status codes (no debug dialog)

What to Test

#Test CaseStatus
1Create Tool List for project A → Success Pending
2Create another Tool List for project A → Error dialog shows with existing task Pending
3Click "Go to Existing Task" → Navigates to the existing workflow Pending
4Cancel/Close existing Tool List → Create new Tool List for project A → Success Pending
5Create Tool List for project B → Success (different project allowed) Pending
6Create Work Permit for project A (already has Tool List) → Success (multiple WP allowed) Pending
7Debug 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

PatternDescription
Form ValidationContractor must add at least 1 tool before submitting
ValidationRequired FlagSubmit command requires valid form data
Validation UI BannerOrange warning banner shows missing fields
Auto-NavigationUsers are taken directly to the relevant document form
Command Button VisibilityCommands hidden on document list, shown on document form

Form Validation Rules

FieldRuleError Message
Tool ListAt least 1 tool required"รายการเครื่องมืออย่างน้อย 1 รายการ"

What to Test

#Test CaseStatus
1Open Tool List task as Contractor → Form opens automatically Pending
2Empty tool list → Submit button disabled, orange warning shown Pending
3Add 1 tool → Submit button enabled, warning hidden Pending
4View document list → Command buttons hidden Pending
5Open 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
LayerFileChange
BackendSearchProjectsByPrNoEndpoint.csExpanded 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:

  1. Workflow Activity Layer - Must call SendNotificationEmailsAsync
  2. TaskCommandService Layer - Must pass notificationOptions to 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

LayerFileChange
BackendToolListPreparationActivities.csAdded SendNotificationEmailsAsync activity
BackendToolListPreparationWorkflow.csCall activity with notification options
BackendIToolListPreparationWorkflowService.csAdded notificationOptions parameter
BackendToolListPreparationWorkflowService.csPass options through to workflow
BackendTaskCommandService.csPass notificationOptions to workflow service

What to Test

#Test CaseStatus
1Contractor submits Tool List → Work Owner approves → Contractor receives email Pending
2Check email at smtp.iotserver.in.th for contractor's email address Pending
3Email 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 a string
  • Calling .getHours() or .getTime() on a string throws: getHours is not a function

Fix Applied

LayerFileChange
Frontendtool-list-form.component.tsAdded 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 CaseStatus
1Open Tool List with existing appointment date → No JavaScript errors Pending
2Change date in date picker → Time is preserved Pending
3Change time in time picker → Date is preserved Pending
4Save 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

ChangeBeforeAfter
Tool List note"(อยู่ระหว่างพัฒนา)"Removed (ready for testing)
JSA/Work Permit note"(อยู่ระหว่างพัฒนา)""(อยู่ระหว่างพัฒนา อาจพบข้อผิดพลาด)"
Dev Note bannerShown in dialogRemoved

What to Test

#Test CaseStatus
1Open Create Task dialog → Tool List has no warning note Pending
2JSA Preparation shows "(อยู่ระหว่างพัฒนา อาจพบข้อผิดพลาด)" Pending
3Work 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

FeatureDescription
VisibilityOnly shown in development mode
ContentLink to smtp.iotserver.in.th for email testing
StylingPurple dev note banner
i18nThai and English translations

What to Test

#Test CaseStatus
1Open login page in dev mode → See "Dev Note" with email testing link Pending
2Click link → Opens smtp.iotserver.in.th in new tab Pending
3Switch to English → Text shows "Check email at" Pending

Summary

#FeatureTypeStatus
1All Tasks ViewNew Feature🔍 In Review
2Duplicate Workflow PreventionEnhancement🔍 In Review
3Tool List Standard PatternsRefactor🔍 In Review
4Project Search for ContractorsBug Fix🔍 In Review
5Contractor Email NotificationBug Fix🔍 In Review
6Date/Time Picker Bug FixBug Fix🔍 In Review
7Task Type Selection UIEnhancement🔍 In Review
8Login Dev Note for Email TestingEnhancement🔍 In Review