feat: Add TheTable form element

This commit is contained in:
2025-12-27 17:32:16 +01:00
parent 6fe20d3746
commit be9d2ec9d7
7 changed files with 291 additions and 3 deletions

View File

@@ -99,7 +99,7 @@ Application Form
└── Form Elements (FormElement)
├── id (UUID - generated by backend)
├── reference (string - custom key like "art_der_massnahme")
├── type (SELECT, CHECKBOX, RADIOBUTTON, TEXTFIELD, TEXTAREA, SWITCH, RICH_TEXT, DATE)
├── type (SELECT, CHECKBOX, RADIOBUTTON, TEXTFIELD, TEXTAREA, SWITCH, RICH_TEXT, DATE, TABLE)
├── title, description
├── options (FormOption[])
│ ├── value, label
@@ -369,6 +369,62 @@ Form elements can trigger the dynamic creation of full sections based on user in
- `useSectionSpawning`: Handles spawn trigger evaluation and template cloning
- `useClonableElements`: Handles element cloning with reference generation and deep cloning
### 12. Table Form Element
The TABLE form element type provides editable tabular data input with dynamic row management.
**Data Structure**:
Table data is stored using the existing `FormOptionDto` array:
- Each option represents a **column**
- `option.label` = column header
- `option.value` = JSON array of cell values for that column (e.g., `'["row1", "row2"]'`)
- Row count is determined by the JSON array length
**Example Configuration (YAML)**:
```yaml
- reference: module_overview_table
title: Module Overview
type: TABLE
options:
- value: '[]'
label: Modulname
processingPurpose: SYSTEM_OPERATION
employeeDataCategory: NON_CRITICAL
- value: '[]'
label: Beschreibung
processingPurpose: SYSTEM_OPERATION
employeeDataCategory: NON_CRITICAL
- value: '[]'
label: Verantwortlicher
processingPurpose: BUSINESS_PROCESS
employeeDataCategory: REVIEW_REQUIRED
```
**Frontend Behavior**:
- Uses Nuxt UI `UTable` component with custom cell slots
- Each cell renders a `UInput` for text entry
- Users can dynamically add/remove rows
- Component: `legalconsenthub/app/components/formelements/TheTable.vue`
**Backend Behavior**:
- PDF export renders table data as a LaTeX tabular environment
- Empty cells display "-" placeholder
- Handled in `ApplicationFormFormatService.renderTableValue()`
**Versioning**:
- Table data is fully versioned as part of form snapshots
- Column structure (headers) and row data are both preserved
**Future Extensibility**:
- Designed to support other cell types (dropdown, date picker) in future iterations
- Column type configuration can be added via option metadata
---
## Project Structure
@@ -749,6 +805,7 @@ act -n
- Verify these render correctly (with saved values):
- `TEXTFIELD`, `TEXTAREA`, `DATE`, `RICH_TEXT`
- `SELECT`, `RADIOBUTTON`, `CHECKBOX`, `SWITCH`
- `TABLE` (verify rows/columns render as LaTeX tabular)
- If you changed backend filtering or templating, ensure:
- Template sections (`isTemplate=true`) remain excluded from export
- Spawned sections (`isTemplate=false`, `spawnedFromElementReference` set) are included