Skip to main content

Service Report #012 In Progress

Date: 2026-02-11


Work Permit Workflow - Testing & Improvements

The Work Permit (WP) workflow has been refactored to comply with standard workflow patterns (PR #372). This report consolidates all outstanding WP-related issues from MoM sessions for systematic testing and implementation.

Feature Overview

#FeaturePR/IssueTypeMoM SourceStatus
1Work Permit Workflow Testing#309Bug Fix2026-01-20 Pending
2Review Permit Type Selection Flow#161Enhancement2025-12-16 Pending
3Work Permit Missing Tabs (Tools, JSA, Project Info)#162Enhancement2025-12-16 Pending
4Worker Selection from Trained List#163Enhancement2025-12-16 Pending
5JSA Tab Listing with Tick Marks#164Enhancement2025-12-16 Pending
6Form Verification Against Original Documents#165Enhancement2025-12-16 Pending
7Work Permit Daily Closure Rules#191Enhancement2025-12-29 Pending
8System Isolate Completed Checkbox for WP Approval#338Enhancement2026-01-27 Pending
9Grouped Reference DocumentsInternalEnhancement-🔍 In Review
10Task Completion Timestamp FixInternalBug Fix-🔍 In Review
11Work Permit Stepper Fix (5 Steps)InternalBug Fix-🔍 In Review
12Reference Document OrderingInternalEnhancement-🔍 In Review
13PTW Form Layout RefactoringInternalEnhancement-🔍 In Review
14Work Permit Template SettingInternalEnhancement-🔍 In Review

1. Work Permit Workflow Testing

Issue: #309 Thai Name: ผู้รับเหมา: ทดสอบ Work permit ไม่ได้

MoM Quote:

"ผู้รับเหมา: ทดสอบ Work permit ไม่ได้"

Description: Contractor was unable to test the Work Permit workflow. The WP workflow has since been refactored to comply with standard workflow patterns (PR #372). This item requires end-to-end testing of the full WP workflow to confirm it works correctly.

Location: My Tasks → + สร้างงาน → การขอใบอนุญาตทำงาน

What to Test

#Test CaseStatus
1Contractor creates a new Work Permit task for an approved project Pending
2Work Permit form loads correctly with document sections Pending
3Contractor fills in the General Work Permit form Pending
4Contractor submits Work Permit for review Pending
5Work Owner receives and reviews the Work Permit Pending
6Safety Officer receives and reviews the Work Permit Pending
7Workspace Owner approves the Work Permit Pending
8Full workflow completes without errors Pending

2. Review Permit Type Selection Flow

Issue: #161 Thai Name: เรียงลำดับและตรวจสอบประเภทใบอนุญาต

MoM Quote:

"เนื่องจากมีการ เลือกประเภทใบอนุญาต ข้ามขึ้นตอนมา จึงพยายาม review ให้ก่อน"

Description: Review and fix the permit type selection flow:

  1. Reorder: put ใบอนุญาตปฏิบัติงานทั่วไป (General Work Permit) first (most frequently used)
  2. Fix typo: สะกด "อนุญาต" เป็น "อนุญาติ" ผิดหลายจุด
  3. Radiation work: use international radiation symbol
  4. Find standard icons for all permit types

Location: Work Permit form → Permit type selection

Requirements

#RequirementDescription
1Reorder permit typesใบอนุญาตปฏิบัติงานทั่วไป must be first
2Fix spelling"อนุญาติ" → "อนุญาต" (check all occurrences)
3Radiation symbolUse international radiation hazard symbol
4Standard iconsUse proper safety icons for each permit type

What to Test

#Test CaseStatus
1Open permit type selection → ใบอนุญาตปฏิบัติงานทั่วไป is listed first Pending
2Check all labels → No "อนุญาติ" typo anywhere Pending
3Radiation work type → Shows international radiation symbol Pending
4All permit types → Have appropriate standard icons Pending

3. Work Permit Missing Tabs (Tools, JSA, Project Info)

Issue: #162 Thai Name: การขอ Work Permit ขาด Tab เครื่องมือ, Tab JSA, และข้อมูลโครงการ

MoM Quote:

"การขอ Work Permit ขาด Tab เครื่องมือ, Tab JSA ที่ผ่านมา จาก flow ก่อนนี้ และขาด Tab ข้อมูลโครงการ (คล้ายตอน Task ลงทะเบียน)"

Description: The Work Permit task should display reference tabs/sections from prerequisite workflows:

  • Tool List (from approved Tool List Preparation task)
  • JSA (from approved JSA Preparation task)
  • Project Info (like the Project Registration form)

These tabs show data from the prerequisite workflows as read-only reference.

Location: My Tasks → Open Work Permit task → Document sections

Requirements

TabSourceAccess
Project InfoProject RegistrationRead-only reference
Tool ListTool List PreparationRead-only reference
JSAJSA PreparationRead-only reference

What to Test

#Test CaseStatus
1Open WP task → See Project Info section with 9 standard fields Pending
2Open WP task → See Tool List reference from approved Tool List task Pending
3Open WP task → See JSA reference from approved JSA task Pending
4All reference sections are read-only (no editing allowed) Pending

4. Worker Selection from Trained List

Issue: #163 Thai Name: รายชื่อต้องเลือกจากรายชื่อที่ผ่านการอบรมแล้ว

MoM Quote:

"รายชื่อ ต้องเลือก จากรายชื่อที่ผ่านการอบรมแล้ว ใน project นี้ โดย JSA ผูกกับชนิดของงาน และ เอกสารของแต่ละคน จะต้องตามมาหากเลือกคนเข้ามาใน Work Permit วันนั้น ๆ"

Description: When creating a daily Work Permit, worker selection must be limited to workers who have completed training for this project. Key relationships:

  1. JSA is linked to the type of work
  2. Each worker's documents must follow when selected for a Work Permit day

Location: My Tasks → Open Work Permit task → Manpower/Worker selection

Requirements

#RequirementDescription
1Filter by trained workersOnly show workers who passed training for this project
2JSA-work type linkJSA is linked to the type of work being performed
3Worker documents followWhen a worker is selected, their documents are included

What to Test

#Test CaseStatus
1Select workers for WP → Only trained workers from this project appear Pending
2Select a worker → Their documents are attached to the WP Pending
3Try to add untrained worker → Not possible (filtered out) Pending

5. JSA Tab Listing with Tick Marks

Issue: #164 Thai Name: Tab JSA แสดงเป็น Listing แล้ว Tick ได้

MoM Quote:

"Tab JSA ให้แสดงเป็น Listing ก่อน แล้ว Tick ได้ว่าใช้ หรือ ไม่ใช้ ใน Work Permit นี้ และสามารถ กดเข้าไปดูรายละเอียดของ JSA นั้นได้ [View only]"

Description: The JSA tab in Work Permit should show a list of available JSAs from the project. Users can tick which JSAs apply to this Work Permit and click to view JSA details (read-only).

Location: My Tasks → Open Work Permit task → JSA section

Requirements

#RequirementDescription
1JSA listingShow all approved JSAs from the project as a list
2Tick selectionAllow checking/unchecking which JSAs apply to this WP
3View detailsClick a JSA to view its details (read-only)

What to Test

#Test CaseStatus
1Open WP task → JSA section shows list of approved JSAs Pending
2Tick a JSA → It is marked as applicable for this WP Pending
3Untick a JSA → It is removed from this WP Pending
4Click a JSA → View full JSA details (read-only) Pending

6. Form Verification Against Original Documents

Issue: #165 Thai Name: ตรวจสอบแบบฟอร์มกับเอกสารต้นฉบับ

MoM Quote:

"ตรวจสอบเบื้องต้น แบบฟอร์มยังไม่ตรงกับ เอกสารต้นฉบับของแต่ละงาน จึงยังไม่ได้ตรวจสอบละเอียดในแต่ละ form"

Description: The Work Permit forms need to be verified against the original paper documents to ensure all fields and sections match. This requires a detailed comparison of each permit type form with its corresponding original document.

Location: My Tasks → Open Work Permit task → Each permit type form

What to Test

#Test CaseStatus
1General Work Permit form matches original document layout Pending
2All required fields from original document are present Pending
3Field labels match original document (Thai text) Pending
4Form sections are in correct order per original document Pending

7. Work Permit Daily Closure Rules

Issue: #191 Thai Name: การปิด Work Permit ต้องปิดทุกวัน

MoM Quote:

"การปิด Work Permit จะต้องปิดทุกวัน ส่วนการปิดงาน จะต้องไม่มี work permit ค้าง จึงจะปิดงานได้ จาก Diagram จะยังไม่เป็นการปิด work permit"

Description: Two business rules for Work Permit closure:

  1. Work Permits must be closed daily (every day's WP must be explicitly closed)
  2. Project closure is blocked if there are any open Work Permits remaining

Location: My Tasks → Work Permit task → Closure actions

Requirements

#RuleDescription
1Daily closureEach day's Work Permit must be explicitly closed at end of day
2Project closure guardCannot close the project if any Work Permits remain open

What to Test

#Test CaseStatus
1Open WP → End of day → Must close WP before next day Pending
2Try to close project with open WP → Blocked with error message Pending
3Close all WPs → Project closure allowed Pending

8. System Isolate Completed Checkbox for WP Approval

Issue: #338 Thai Name: เจ้าของพื้นที่: เพิ่ม checkbox "System Isolate Completed" ตอนอนุมัติ Work Permit

MoM Quote:

"เจ้าของพื้นที่: ที่จะอนุมัติ WP ในแต่ละวัน ตอน อนุมัติ จะมี check box [ ] System Isolate Completed"

Description: When the Workspace Owner approves a daily Work Permit, a "System Isolate Completed" checkbox must be checked before approval can proceed. This confirms that system isolation has been completed before work begins.

Location: My Tasks → Open Work Permit task → Workspace Owner approval

Requirements

#RequirementDescription
1Checkbox in approvalAdd "System Isolate Completed" checkbox to WP approval dialog
2Required for approvalCheckbox must be checked before Approve button is enabled

What to Test

#Test CaseStatus
1Workspace Owner opens WP approval → See "System Isolate Completed" checkbox Pending
2Checkbox unchecked → Approve button disabled Pending
3Check the checkbox → Approve button enabled Pending

Internal Improvements

The following improvements were made internally to improve system quality and maintainability.

9. Grouped Reference Documents

Thai Name: แสดงเอกสารอ้างอิงจาก Workflow อื่นแบบจัดกลุ่ม

Description: Work Permit, JSA Preparation, and Tool List Preparation tasks now show reference documents from prerequisite workflows in a grouped layout. Documents are grouped by source workflow type (e.g., "ขึ้นทะเบียนโครงการ", "จัดทำ JSA", "จัดทำรายการเครื่องมือ") with read-only access.

Location: My Tasks → Open any Work Permit / JSA / Tool List task → เอกสารอ้างอิง section

Behavior

WorkflowReference Documents Shown
Work PermitProject Registration (2 docs), JSA forms (with name + area), Tool List
JSA PreparationProject Registration (2 docs)
Tool List PreparationProject Registration (2 docs)
Project RegistrationNone (no prerequisites)

Key Features

FeatureDescription
Grouped by workflowDocuments grouped under source workflow name with count
JSA displayShows JSA work type name and area code (same as JSA Preparation view)
Read-onlyAll reference documents shown with "อ่านอย่างเดียว" badge
Approved timestampShows when the source task was completed
Click to viewClick any reference document to view full content (read-only)

What to Test

#Test CaseStatus
1Open WP task → See "เอกสารอ้างอิง" section with grouped documents🔍 In Review
2Project Registration group → Shows "แบบฟอร์มขึ้นทะเบียนโครงการ" and "ระเบียบปฏิบัติก่อนเข้ามาปฏิบัติงาน"🔍 In Review
3JSA group → Shows JSA names (e.g., "Hot Work") with area codes🔍 In Review
4Tool List group → Shows "รายการเครื่องมือ"🔍 In Review
5Click Project Registration reference → Shows form content (read-only)🔍 In Review
6Click JSA reference → Shows JSA content (read-only)🔍 In Review
7Click Tool List reference → Shows tool list content (read-only)🔍 In Review
8Approved timestamp shows on each reference document🔍 In Review

10. Task Completion Timestamp Fix

Thai Name: แก้ไขการบันทึกเวลาเสร็จสิ้นของงาน

Description: The CompletedAtUtc field was never being set when tasks reached terminal status (Closed, Cancelled, Rejected). This caused the approved timestamp on reference documents to not appear. Fixed by setting CompletedAtUtc in UpdateTaskStatusAsync() for all terminal statuses.

Location: System-wide (all workflow task completions)

Behavior

Task StatusCompletedAtUtc
ActiveNot set
ClosedSet to current time
CancelledSet to current time
RejectedSet to current time

What to Test

#Test CaseStatus
1Complete a Project Registration → CompletedAtUtc is set🔍 In Review
2Cancel a task → CompletedAtUtc is set🔍 In Review
3Reference docs from completed tasks show approved timestamp🔍 In Review

11. Work Permit Stepper Fix (5 Steps)

Thai Name: แก้ไข Stepper ใบขออนุญาตให้แสดงครบ 5 ขั้นตอน

Description: The workflow stepper (progress bar at the top of the task page) was only showing 3 steps (Fill Permit → SO Review → Done), which did not match the actual backend workflow with 7 active states. When the workflow reached states like Co-Review, Work In Progress, or Request Close, the stepper would incorrectly fall back to showing "Fill Permit" as the current step.

The stepper now correctly shows 5 steps matching the backend workflow:

Location: My Tasks → Open any Work Permit task → Stepper bar at top

Behavior

StepThai LabelWhen Active
1กรอกใบขออนุญาตContractor filling the permit form
2ตรวจสอบร่วมWO + SO + WAO co-review
3ปฏิบัติงานWork is in progress
4รอปิดงานPending closure approval
5เสร็จสิ้นWorkflow completed

Extension Review appears as a branch state with a return arrow (↩) pointing back to step 3 (ปฏิบัติงาน).

What to Test

#Test CaseStatus
1Open WP task at Fill Permit state → Stepper shows 5 steps, step 1 active (blue)🔍 In Review
2WP at Co-Review state → Step 1 green, step 2 active (blue)🔍 In Review
3WP at Work In Progress → Steps 1-2 green, step 3 active (blue)🔍 In Review
4WP at Extension Review → Steps 1-2 green, step 3 active with return arrow (↩)🔍 In Review
5WP at Request Close → Steps 1-3 green, step 4 active (blue)🔍 In Review
6WP Approved/Completed → All 5 steps green🔍 In Review
7WP Cancelled → Branch state indicator shown🔍 In Review
8WP Rejected → Branch state indicator shown🔍 In Review

12. Reference Document Ordering

Thai Name: เรียงลำดับเอกสารอ้างอิงโดย JSA และ Tool List แสดงก่อน Project Registration

Description: Reference documents in the Work Permit task were showing Project Registration first, followed by JSA and Tool List. Since JSA and Tool List documents are more directly relevant to the daily Work Permit, the ordering has been changed so they appear first. Project Registration (the foundation document) now appears last.

Location: My Tasks → Open Work Permit task → เอกสารอ้างอิง section

Behavior

BeforeAfter
1. ขึ้นทะเบียนโครงการ (2)1. จัดทำ JSA (N)
2. จัดทำ JSA (N)2. จัดทำรายการเครื่องมือ (1)
3. จัดทำรายการเครื่องมือ (1)3. ขึ้นทะเบียนโครงการ (2)

What to Test

#Test CaseStatus
1Open WP task → JSA section appears first in reference documents🔍 In Review
2Tool List section appears second🔍 In Review
3Project Registration section appears last🔍 In Review
4All reference documents still clickable and viewable (read-only)🔍 In Review

13. PTW Form Layout Refactoring

Thai Name: ปรับปรุงรูปแบบฟอร์มใบอนุญาตทำงานให้เป็นมาตรฐานเดียวกับ JSA

Description: All PTW (Permit to Work) form sections have been refactored from the legacy inline-edit/underline pattern to use Angular Material outlined form fields (mat-form-field appearance="outline"). This matches the JSA form standard. Project information section now shows data from the approved project (read-only), consistent with how JSA and Tool List display project data.

Location: My Tasks → Open Work Permit task → General Work Permit form (and all 8 permit types)

Changes

AreaBeforeAfter
Standalone text fieldsUnderline + pencil icon (inline-edit)Material outlined input (mat-form-field)
Standalone date fieldsinline-datepickerMaterial date picker (mat-form-field + matDatepicker)
Read-only modeSame underline style, disabledClean label + value span layout
Project info sectionEmpty (all dashes)Populated from project data (same as JSA)
Table cell fieldsNo changeNo change (still uses inline-edit in table cells)

Affected Parts

PartSectionFields Changed
Part 1: ContractorPermit DetailsPermit No., Date Issued, Supervisor, Email, Phone
Part 1: ContractorProject InfoAll 9 fields now from project context (read-only)
Part 2: Client (Check)Checklist reviewerReviewer name, Review date
Part 2: Client (Check)Work DescriptionTextarea
Part 3: AuthorizationPer phase (3 phases)Date, Start time, End time
Part 4: ExtensionPer extensionDate, Original end, New end, Reason
Part 5: CompletionInspection sectionInspection date, Inspector name, Remarks

What to Test

#Test CaseStatus
1Open WP task as Contractor → Part 1 shows project info (all 9 fields populated)🔍 In Review
2Part 1 editable fields (Permit No., Date Issued, Supervisor, Email, Phone) show as Material outlined inputs🔍 In Review
3Part 2 checklist table → remarks column still uses inline-edit (no change)🔍 In Review
4Part 2 Work Description → shows as Material outlined textarea🔍 In Review
5Part 3 Authorization → date picker and time fields show as Material outlined inputs🔍 In Review
6Part 4 Extension → date, time, reason fields show as Material outlined inputs🔍 In Review
7Part 5 Completion → date/inspector as Material outlined inputs, table remarks still inline-edit🔍 In Review
8Switch to read-only view (SO/WO) → all fields show as label + value (no input borders)🔍 In Review
9Auto-save works: text changes trigger debounced save, date selections trigger immediate save🔍 In Review
10Unsaved changes warning shows when navigating away with pending changes🔍 In Review

14. Work Permit Template Setting

Thai Name: ตั้งค่าต้นแบบใบอนุญาตปฏิบัติงาน (Checklist + PPE + Icon)

Description: Admin and Safety Officer can now manage work permit templates through a settings page. Each template defines the pre-work checklist items, PPE requirements, and icon that appear when creating a new work permit. The icon is used in the template list, preview dialog, and permit type selection dialog. Previously, checklist/PPE were hardcoded in the frontend and icons used a hardcoded mapping.

Location: Tools > กำหนดค่า > ต้นแบบใบอนุญาตปฏิบัติงาน

Key Capabilities

CapabilityDescription
Template managementCreate, edit, delete work permit templates
Icon pickerSelect Material Icon or Unicode/Emoji with live preview
Preview dialogView template details (icon, checklist, PPE) in read-only dialog
Checklist itemsDefine pre-work checklist items (Thai/English) per template
PPE itemsDefine PPE requirements with default checked option
Active/InactiveControl which templates are available when creating permits
Sort orderControl display order of templates
ValidationDialog shows row-by-row errors on save (same pattern as JSA approval)
Dynamic iconsPermit type selection dialog uses icon from template (not hardcoded)

What to Test

#Test CaseStatus
1Admin/SO can access the page from Tools menu🔍 In Review
2Other roles cannot see the menu card🔍 In Review
3Create new template with checklist and PPE items🔍 In Review
4Edit existing template — changes persist after save🔍 In Review
5Delete template with confirmation dialog🔍 In Review
6Save with empty name shows validation error dialog🔍 In Review
7Unsaved changes warning when navigating back🔍 In Review
8Search by keyword filters the template list🔍 In Review
9Select icon from Material Icon presets → Icon shows in list and preview🔍 In Review
10Select icon from Emoji presets (e.g., ☢) → Displays as Unicode text🔍 In Review
11Enter custom icon text → Live preview updates🔍 In Review
12Click preview button → Dialog shows template icon, checklist, and PPE🔍 In Review
13Permit type selection dialog → Uses icon from template setting🔍 In Review

Summary

#FeatureTypeMoMStatus
1Work Permit Workflow TestingBug Fix2026-01-20 Pending
2Review Permit Type Selection FlowEnhancement2025-12-16 Pending
3Work Permit Missing TabsEnhancement2025-12-16 Pending
4Worker Selection from Trained ListEnhancement2025-12-16 Pending
5JSA Tab Listing with Tick MarksEnhancement2025-12-16 Pending
6Form Verification Against Original DocumentsEnhancement2025-12-16 Pending
7Work Permit Daily Closure RulesEnhancement2025-12-29 Pending
8System Isolate Completed CheckboxEnhancement2026-01-27 Pending
9Grouped Reference DocumentsEnhancementInternal🔍 In Review
10Task Completion Timestamp FixBug FixInternal🔍 In Review
11Work Permit Stepper Fix (5 Steps)Bug FixInternal🔍 In Review
12Reference Document OrderingEnhancementInternal🔍 In Review
13PTW Form Layout RefactoringEnhancementInternal🔍 In Review
14Work Permit Template SettingEnhancementInternal🔍 In Review