251223:1649 On going update to 1.7.0: Refoctory drawing Module & document number Module
This commit is contained in:
@@ -13,3 +13,6 @@
|
||||
## TABLE shop_drawing_revisions
|
||||
- add title
|
||||
- add legacy_drawing_number VARCHAR(100) NULL COMMENT 'เลขที่เดิมของ Shop Drawing',
|
||||
## TABLE asbuilt_drawings
|
||||
## TABLE asbuilt_drawing_revisions
|
||||
## TABLE asbuilt_revision_shop_revisions_refs
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# Session History - 2025-12-23: Document Numbering Form Refactoring
|
||||
|
||||
## Objective
|
||||
Refactor and debug the "Test Number Generation" (Template Tester) form to support real API validation and master data integration.
|
||||
|
||||
## Key Changes
|
||||
|
||||
### 1. Frontend Refactoring (`template-tester.tsx`)
|
||||
- **Master Data Integration**: Replaced manual text inputs with `Select` components for Originator, Recipient, Document Type, and Discipline.
|
||||
- **Dynamic Data Hook**:
|
||||
- Integrated `useOrganizations`, `useCorrespondenceTypes`, and `useDisciplines`.
|
||||
- Fixed empty Discipline list by adding `useContracts` to fetch active contracts for the project and deriving `contractId` dynamically.
|
||||
- **API Integration**: Switched from mock `generateTestNumber` to backend `previewNumber` endpoint.
|
||||
- **UI Enhancements**:
|
||||
- Added "Default (All Types)" and "None" options to dropdowns.
|
||||
- Improved error feedback with a visible error card if generation fails.
|
||||
- **Type Safety**:
|
||||
- Resolved multiple lint errors (`Unexpected any`, missing properties).
|
||||
- Updated `SearchOrganizationDto` in `organization.dto.ts` to include `isActive`.
|
||||
|
||||
### 2. Backend API Harmonization
|
||||
- **DTO Updates**:
|
||||
- Refactored `PreviewNumberDto` to use `originatorId` and `typeId` (aligned with frontend naming).
|
||||
- Added `@Type(() => Number)` and `@IsInt()` to ensure proper payload transformation.
|
||||
- **Service Logic**:
|
||||
- Fixed `CounterService` mapping to correctly use the entity property `originatorId` instead of the DTO naming `originatorOrganizationId` in WHERE clauses and creation logic.
|
||||
- Updated `DocumentNumberingController` to map the new DTO properties.
|
||||
|
||||
### 3. Troubleshooting & Reversion
|
||||
- **Issue**: "Format Preview" was reported as missing.
|
||||
- **Action**: Attempted a property rename from `formatTemplate` to `formatString` across the frontend based on database column naming.
|
||||
- **Result**: This caused the entire Document Numbering page to fail (UI became empty) because the backend entity still uses the property name `formatTemplate`.
|
||||
- **Resolution**: Reverted all renaming changes back to `formatTemplate`. The initial "missing" issue was resolved by ensuring proper prop passing and data loading.
|
||||
|
||||
## Status
|
||||
- **Test Generation Form**: Fully functional and integrated with real master data.
|
||||
- **Preview API**: Validated and working with correct database mapping.
|
||||
- **Next Steps**: Monitor for any further data-specific generation errors (e.g., Template format parsing).
|
||||
|
||||
---
|
||||
**Reference Task**: [TASK-FE-017-document-numbering-refactor.md](../06-tasks/TASK-FE-017-document-numbering-refactor.md)
|
||||
38
specs/09-history/2025-12-23-frontend-refactor-v170.md
Normal file
38
specs/09-history/2025-12-23-frontend-refactor-v170.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# Session History: Frontend Refactoring for v1.7.0 Schema
|
||||
|
||||
**Date:** 2025-12-23
|
||||
**Objective:** Refactor frontend components and services to align with the v1.7.0 database schema and document numbering requirements.
|
||||
|
||||
## 1. Summary of Changes
|
||||
|
||||
### Frontend Refactoring
|
||||
- **`DrawingUploadForm` Refactor:**
|
||||
- Implemented dynamic validation validation schemas using Zod discriminated unions.
|
||||
- Added support for Contract Drawing fields: `mapCatId`, `volumePage`.
|
||||
- Added support for Shop/AsBuilt fields: `legacyDrawingNumber`, `revisionTitle`.
|
||||
- Added full support for `AS_BUILT` drawing type.
|
||||
- Dynamically passes `projectId` to context hooks.
|
||||
- **`DrawingList` & `DrawingCard`:**
|
||||
- Added `AS_BUILT` tab support.
|
||||
- Implemented conditional rendering for new columns (`Volume Page`, `Legacy No.`, `Rev. Title`).
|
||||
- **Service Layer Updates:**
|
||||
- Migrated `ContractDrawingService`, `ShopDrawingService`, and `AsbuiltDrawingService` to use `FormData` for all creation/upload methods to ensure correct binary file handling.
|
||||
- Updated Types to fully match backend DTOs.
|
||||
- **Documentation:**
|
||||
- Updated `task.md` and `walkthrough.md`.
|
||||
|
||||
## 2. Issues Encountered & Status
|
||||
|
||||
### Resolved
|
||||
- Fixed `Unexpected any` lint errors in `DrawingUploadForm` (mostly).
|
||||
- Resolved type mismatches in state identifiers.
|
||||
|
||||
### Known Issues (Pending Fix)
|
||||
- **Build Failure**: `pnpm build` failed in `frontend/app/(admin)/admin/numbering/[id]/page.tsx`.
|
||||
- **Error**: `Object literal may only specify known properties, and 'templateId' does not exist in type 'Partial<NumberingTemplate>'.`
|
||||
- **Location**: `numberingApi.saveTemplate({ ...data, templateId: parseInt(params.id) });`
|
||||
- **Cause**: The `saveTemplate` method likely expects a specific DTO that conflicts with the spread `...data` or the explicit `templateId` property assignment. This needs to be addressed in the next session.
|
||||
|
||||
## 3. Next Steps
|
||||
- Fix the build error in `admin/numbering/[id]/page.tsx`.
|
||||
- Proceed with full end-to-end testing of the drawing upload flows.
|
||||
Reference in New Issue
Block a user