การลงทะเบียนโครงการ (Project Registration) - Workflow
Referenced Templates
- Location:
frontend/src/assets/templates/01-project-registration/ - Location:
frontend/src/assets/templates/02-pre-work-procedures/
Application Flow Diagram
The complete Safety App workflow showing all roles and document flow:
Open full size in new tab - Use Ctrl+scroll to zoom
The Project Registration workflow is the top section of the diagram (red border area). After project approval, the Work Permit workflow can begin.
Implementation Diagram (Dev Version)
The dev-version diagram shows the exact workflow states as implemented in code. This is the technical reference that always matches the codebase.
- SVG:
frontend/src/assets/workflows/project-registration-workflow-dev.svg - Draw.io:
frontend/src/assets/workflows/project-registration-workflow-dev.drawio.xml - States enum:
ProjectRegistrationWorkflowStatesinproject-registration-state-metadata.config.ts
Cell IDs in the dev-version SVG match state keys directly (e.g., data-cell-id="fill-in-project-info").
This makes it easy to update the diagram when workflow states change.
Workflow Diagram (Simplified)
The dashed line shows the optional skip path (planned feature). When a project already has a PO Number, the Work Owner can skip the Purchasing review and send directly to Contractor.
States
Phase 1: Project Information
| State | Thai Name | Description | Expected Role |
|---|---|---|---|
| Started | เริ่มต้น | Initial state (automatic transition) | - |
| FillInProjectInfo | กรอกข้อมูลโครงการ | Work Owner fills project details, contractor selection, dates | WorkOwner |
Phase 2: Purchasing Information
| State | Thai Name | Description | Expected Role |
|---|---|---|---|
| FillInPurchasingInfo | กรอกข้อมูลจัดซื้อ | Purchasing department fills PO number, budget, duration | Purchasing |
| ReviewPurchasingInfo | รีวิวข้อมูลจัดซื้อ | Work Owner reviews purchasing information | WorkOwner |
Phase 3: Contractor Acknowledgement
| State | Thai Name | Description | Expected Role |
|---|---|---|---|
| FillInPreWorkProceduresForm | รับทราบระเบียบปฏิบัติงาน | Contractor acknowledges work procedures | Contractor |
| ReviewPreWorkProceduresForm | รีวิวเอกสารระเบียบปฏิบัติงาน | Work Owner reviews contractor acknowledgement | WorkOwner |
Terminal States
| State | Thai Name | Description |
|---|---|---|
| Approved | อนุมัติ | Project approved - can proceed to Work Permit |
| Canceled | ยกเลิก | Project canceled |
| Completed | เสร็จสิ้น | Terminal state (internal) |
Commands
From FillInProjectInfo
| Command | Thai Name | To State | Assignee | Optional |
|---|---|---|---|---|
| RequestPurchasingInfo | ส่งไปจัดซื้อ | FillInPurchasingInfo | Purchasing | - |
| RequestPreWorkProceduresFormDirect | ส่งไปผู้รับเหมา | FillInPreWorkProceduresForm | Contractor | ✅ HasPONo |
| Cancel | ยกเลิกงาน | Canceled | - | - |
RequestPreWorkProceduresFormDirect is only available when the project has a PO Number (skip condition: HasPurchaseOrderNo). This allows Work Owner to bypass the Purchasing review phase.
From FillInPurchasingInfo
| Command | Thai Name | To State | Assignee |
|---|---|---|---|
| SubmitPurchasingInfo | ส่งกลับ | ReviewPurchasingInfo | WorkOwner |
From ReviewPurchasingInfo
| Command | Thai Name | To State | Assignee |
|---|---|---|---|
| RequestPurchasingInfo | ส่งไปจัดซื้อ | FillInPurchasingInfo | Purchasing |
| RequestPreWorkProceduresForm | ส่งไปผู้รับเหมา | FillInPreWorkProceduresForm | Contractor |
| Cancel | ยกเลิกงาน | Canceled | - |
From FillInPreWorkProceduresForm
| Command | Thai Name | To State | Assignee |
|---|---|---|---|
| SubmitPreWorkProceduresForm | รับทราบระเบียบปฏิบัติงาน | ReviewPreWorkProceduresForm | WorkOwner |
From ReviewPreWorkProceduresForm
| Command | Thai Name | To State | Assignee |
|---|---|---|---|
| Approve | อนุมัติ | Approved → Completed | - |
| RequestPurchasingInfo | ส่งไปจัดซื้อ | FillInPurchasingInfo | Purchasing |
| RequestPreWorkProceduresForm | ส่งไปผู้รับเหมา | FillInPreWorkProceduresForm | Contractor |
| Cancel | ยกเลิกงาน | Canceled | - |
Document Forms
| ID | Form | Thai Name | Description |
|---|---|---|---|
| 1 | ProjectRegistrationForm | แบบขอลงทะเบียนโครงการ | Main project registration form |
| 2 | PreWorkProceduresForm | เอกสารรับทราบระเบียบปฏิบัติงาน | Contractor acknowledgement form |
State-Documents Mapping
Each workflow state shows different documents in the UI.
| State | Documents Shown |
|---|---|
fill-in-project-info | Doc 1 (ProjectRegistrationForm) |
fill-in-purchasing-info | Doc 1 (ProjectRegistrationForm) |
review-purchasing-info | Doc 1 (ProjectRegistrationForm) |
fill-in-pre-work-procedures-form | Doc 1, Doc 2 (PreWorkProceduresForm) |
review-pre-work-procedures-form | Doc 1, Doc 2 |
approved | Doc 1, Doc 2 (all for reference) |
canceled | Doc 1, Doc 2 (all for reference) |
completed | Doc 1, Doc 2 (all for reference) |
Form Edit Permissions
Controls which roles can edit which documents at each state.
| State | ProjectRegistrationForm (Doc 1) | PreWorkProceduresForm (Doc 2) |
|---|---|---|
fill-in-project-info | ✅ WorkOwner editable | - |
fill-in-purchasing-info | ✅ Purchasing editable | - |
review-purchasing-info | ✅ WorkOwner editable | - |
fill-in-pre-work-procedures-form | 🔒 Locked (completed) | ✅ Contractor editable |
review-pre-work-procedures-form | 🔒 Locked | ✅ WorkOwner editable |
approved | 🔒 Locked (after approval) | 🔒 Locked (after approval) |
canceled | 🔒 Locked (after cancellation) | 🔒 Locked (after cancellation) |
completed | 🔒 Locked (after completion) | 🔒 Locked (after completion) |
Expected Role per State
Shows which role(s) should be acting at each workflow state. Used for the role indicator badge in the UI.
| State | Expected Role | Thai |
|---|---|---|
fill-in-project-info | WorkOwner | เจ้าของงาน |
fill-in-purchasing-info | Purchasing | จัดซื้อ |
review-purchasing-info | WorkOwner | เจ้าของงาน |
fill-in-pre-work-procedures-form | Contractor | ผู้รับเหมา |
review-pre-work-procedures-form | WorkOwner | เจ้าของงาน |
approved | (terminal) | - |
canceled | (terminal) | - |
Roles Involved
| Role | Thai Name | Responsibilities |
|---|---|---|
| WorkOwner | เจ้าของงาน | Creates project, selects contractor, reviews all submissions |
| Purchasing | จัดซื้อ | Fills PO information, budget details |
| Contractor | ผู้รับเหมา | Acknowledges work procedures |
Workflow Rules
Routing Flexibility
The Work Owner has flexibility in routing:
- Skip Purchasing (planned): If project already has PO Number, can skip Purchasing and send directly to Contractor
- Multiple Iterations: Can send back to Purchasing or Contractor multiple times for corrections
- Cancel Anytime: Can cancel from most states before final approval
State Transition Rules
| Rule | Description |
|---|---|
| Purchasing can be skipped | If project has PO Number, Work Owner can skip directly to Contractor |
| Purchasing optional on revision | After first review, can choose to skip Purchasing |
| Contractor must acknowledge | Before approval, Contractor must sign PreWorkProceduresForm |
| WorkOwner final approval | Only WorkOwner can approve or cancel |
Optional Command Configuration (Planned)
The workflow supports configurable optional commands that can be skipped based on conditions:
| Skip Condition | When Satisfied | Effect |
|---|---|---|
HasPurchaseOrderNo | Project.PurchaseOrderNo is not empty | Enable "Skip to Contractor" command |
HasPurchaseRequisitionNo | Project.PurchaseRequisitionNo is not empty | (Future use) |
UserChoice | Always | User can choose to skip (with confirmation) |
Optional commands are configured as properties on the TaskCommand entity:
OptionalConfig {
IsOptional: true
SkipCondition: HasPurchaseOrderNo
SkipToCommandKey: "request-pre-work-procedures-form"
SkipReasonTh: "ข้าม - มี PO No. แล้ว"
SkipReasonEn: "Skip - Already has PO No."
}
Relationship to Work Permit Workflow
Project Registration must be Approved before Work Permit can be created. Once approved, the project becomes available for Work Permit requests.
Source Code Reference
Backend Workflow:
backend/SafetyApp.Workflows.ProjectRegistration/ProjectRegistrationWorkflow.cs- States enum:
ProjectRegistrationWorkflowStates - Commands:
ProjectRegistrationWorkflowCommands
Key Methods:
GetState()- Returns current workflow stateGetCommands()- Returns available commands for current stateGetDocumentFormIds()- Returns document IDs for current stateGetFormEditPermissions()- Returns edit permissions per document per state
Testing Instructions
Test Scenarios
- Happy Path: FillInProjectInfo → FillInPurchasingInfo → ReviewPurchasingInfo → FillInPreWorkProcedures → ReviewPreWorkProcedures → Approved
- Skip Path (planned): FillInProjectInfo → FillInPreWorkProcedures (skip Purchasing) → ReviewPreWorkProcedures → Approved
- Cancel Early: FillInProjectInfo → Cancel
- Multiple Revisions: FillInProjectInfo → FillInPurchasingInfo → ReviewPurchasingInfo → FillInPurchasingInfo (revision) → ReviewPurchasingInfo → ...
- Direct to Contractor: After purchasing info complete, send directly to Contractor
Checklist
- WorkOwner can create project and fill info
- Purchasing can fill PO information
- WorkOwner can review and route to Purchasing or Contractor
- Contractor can acknowledge work procedures
- WorkOwner can approve or cancel
- Forms are locked/unlocked correctly per state
- Role badges show correct expected role