TypeDialog/CHANGES.md
Jesús Pérez 6d045d62c9
feat(repeating-groups): implement duplicate detection across all backends
- Fix has_unique flag reading from field definition (was scanning fragment fields)
- Implement duplicate validation in CLI and TUI backends
- Add item counter update in Web backend after add/delete operations
- Refactor Web JavaScript: remove global constants, use closure-based state per group
- Store repeating group config in data-* attributes instead of global variables
- Update documentation and examples with unique = true attribute
- All backends now enforce unique items validation consistently
2025-12-21 11:38:14 +00:00

58 lines
2.3 KiB
Markdown

# Changes
## [Unreleased]
### Added
**RepeatingGroup Duplicate Detection**
- Implemented duplicate item validation across all backends (CLI, TUI, Web)
- Added `unique = true` attribute support to prevent duplicate items
- Added item counter display updates in Web backend
- New `is_duplicate()` function in CLI and TUI backends
**Web Backend Improvements**
- Refactored JavaScript: Replaced global constants with closure-based state management
- Added `render_global_repeating_group_script()` for generic repeating group handling
- Configuration stored in `data-*` attributes: `data-min-items`, `data-max-items`, `data-has-unique`, `data-unique-key`, `data-field-names`
- Live item counter updates after add/delete operations
- Single document-level event delegation for all repeating group interactions
**Documentation**
- Updated `docs/FIELD_TYPES.md` with unique validation details
- Updated `examples/README.md` with RepeatingGroup testing commands
- Added `docs/FIELD_TYPES.md` (new file)
- Updated example forms with `unique = true` attribute
### Fixed
- **CLI Backend**: Fixed validation of duplicate items in add/edit operations
- **TUI Backend**: Fixed validation of duplicate items with error overlay feedback
- **Web Backend**: Fixed `has_unique` flag reading from field definition (was incorrectly scanning fragment fields)
- **Web Backend**: Fixed item counter not updating when adding/deleting items
### Changed
**Architecture**
- Each repeating group now maintains independent state via closure
- Removed ~600 lines of dead code in Web JavaScript
- Event handling now context-aware (finds correct repeating group controller)
**Examples**
- `examples/05-fragments/array-trackers.toml`: Added `unique = true` to UDP and HTTP tracker arrays
- `examples/07-nickel-generation/arrays-form.toml`: Added `unique = true` to all RepeatingGroup fields
### Technical Notes
- Duplicate detection compares ALL field values when `unique = true`
- Works consistently across CLI, TUI, and Web backends
- Backwards compatible: repeating groups without `unique = true` unaffected
- max_items limit already enforced in all backends (no changes needed)
### Testing
- All 174 unit tests passing
- No clippy warnings
- Build verified with `--all-features` flag
- Manual testing in Web backend: duplicate detection working correctly
- Item counter updates verified on add/delete operations