wip: skipass-duration based rentals filtering
This commit is contained in:
@@ -114,6 +114,8 @@ This directory contains comprehensive documentation for the MyEP Next Booking sy
|
||||
| **HTMX Integration** | ✅ | ✅ | ✅ | ✅ |
|
||||
| **BPN API Integration** | ✅ | ✅ | ✅ | ✅ |
|
||||
| **Dynamic Availability System** | ✅ | ✅ | ✅ | ✅ |
|
||||
| **Service Descriptions** | ✅ | ✅ | ✅ | ✅ |
|
||||
| **License Plate Field** | ✅ | ✅ | ✅ | ✅ |
|
||||
| **Age-Based Constraints** | ✅ | 🔄 | ⏳ | ⏳ |
|
||||
| **Advanced Pricing** | ✅ | ⏳ | ⏳ | ⏳ |
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
- **Rental Insurance**: Checkbox interface with conditional visibility ✅
|
||||
- **Body Dimensions**: Hidden unless rental services selected ✅
|
||||
- **Additional Services**: Flexible service extension system ✅
|
||||
- **Service Descriptions**: XML-based service descriptions with form integration ✅
|
||||
- **License Plate Field**: Optional vehicle identification field for parking participants ✅
|
||||
|
||||
#### Pricing & Display System
|
||||
- **Inline Pricing**: Service costs in form options ✅
|
||||
@@ -77,6 +79,8 @@
|
||||
| **Conditional Fields** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| **HTMX Integration** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| **BPN API Integration** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| **Service Descriptions** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| **License Plate Field** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| **Age-Based Constraints** | ✅ | 🔄 | ⏳ | ✅ | ⏳ |
|
||||
| **Advanced Pricing** | ✅ | ⏳ | ⏳ | 🔄 | ⏳ |
|
||||
| **Mobile Optimization** | ✅ | ⏳ | ⏳ | ⏳ | ⏳ |
|
||||
@@ -132,6 +136,8 @@
|
||||
├── ParticipantAssignedRoomFieldHandler # Room assignments
|
||||
├── ParticipantDateOfBirthFieldHandler # Age processing
|
||||
├── ParticipantRemarksRoomFieldHandler # Special requests
|
||||
├── ParticipantRentalInsuranceFieldHandler # Rental insurance checkbox
|
||||
├── ParticipantLicensePlateFieldHandler # Vehicle license plate input
|
||||
└── [Custom handlers easily extensible]
|
||||
```
|
||||
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
# Implementation Plan: Duration-Based Rental Filtering Based on Skipass Selection
|
||||
|
||||
## Overview
|
||||
Implement cross-field dependency where rentals are only visible/selectable when a skipass is selected, and filter rentals to match the selected skipass's date range (dateFrom/dateTo).
|
||||
|
||||
## Analysis
|
||||
Based on code review:
|
||||
- Both rentals and skipasses have `dateFrom` and `dateTo` properties for duration
|
||||
- Current system already filters services by travel date range using `getAdditionalServicesBySubTypes($token, true, true)`
|
||||
- Need to implement skipass-to-rental date matching logic
|
||||
- Field state conditions system is already in place for hiding/showing fields
|
||||
- Need to create a custom field options provider for duration-filtered rentals
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
### 1. Create SkiPassSelectionCondition
|
||||
**File**: `src/Form/Service/Condition/SkiPassSelectionCondition.php`
|
||||
- Similar to `RentalSelectionCondition` but checks for skipass selection
|
||||
- Evaluates both form data and participant DTO for skipass
|
||||
- Returns true if participant has selected a skipass
|
||||
|
||||
### 2. Update Field State Provider
|
||||
**File**: `src/Form/Service/CreateFieldStateProvider.php`
|
||||
- Add rentals field hidden condition based on skipass selection
|
||||
- Similar to how rental insurance is hidden unless rentals are selected:
|
||||
```php
|
||||
$skiPassCondition = new SkiPassSelectionCondition();
|
||||
$this->fieldStateConditions['rentals'] = [
|
||||
'hidden' => CompositeCondition::not($skiPassCondition),
|
||||
];
|
||||
```
|
||||
|
||||
### 3. Create Duration-Based Rental Filtering
|
||||
**File**: `src/Form/Service/ParticipantFieldOptionsProvider.php`
|
||||
- Modify existing rentals field provider to filter by selected skipass duration
|
||||
- Extract selected skipass from participant data
|
||||
- Filter available rentals to only those with matching dateFrom/dateTo ranges
|
||||
- Use exact date matching: `rental.dateFrom == skipass.dateFrom && rental.dateTo == skipass.dateTo`
|
||||
|
||||
### 4. Update RentalsFieldHandler Dependencies
|
||||
**File**: `src/Form/Service/ParticipantRentalsFieldHandler.php`
|
||||
- Add `skiPass` to dependencies array: `['dateOfBirth', 'skiPass']`
|
||||
- Add DTO cleanup: clear rentals when no skipass is selected
|
||||
- Filter rentals by skipass duration in `processField()` method
|
||||
|
||||
### 5. Update Field Handler Dependencies
|
||||
**File**: `src/Form/Service/ParticipantRentalInsuranceFieldHandler.php`
|
||||
- Update dependencies to include skipass: `['dateOfBirth', 'rentals', 'skiPass']`
|
||||
- Modify visibility logic: rental insurance only shown when both skipass AND rentals selected
|
||||
|
||||
## Key Technical Details
|
||||
|
||||
### Duration Matching Logic
|
||||
Rentals will be filtered to match skipass duration exactly:
|
||||
```php
|
||||
private function filterRentalsBySkiPassDuration(array $rentals, ?Service $selectedSkiPass): array
|
||||
{
|
||||
if (null === $selectedSkiPass || null === $selectedSkiPass->dateFrom || null === $selectedSkiPass->dateTo) {
|
||||
return []; // No skipass or invalid dates = no rentals
|
||||
}
|
||||
|
||||
return array_filter($rentals, function(Service $rental) use ($selectedSkiPass) {
|
||||
return $rental->dateFrom?->format('Y-m-d') === $selectedSkiPass->dateFrom?->format('Y-m-d')
|
||||
&& $rental->dateTo?->format('Y-m-d') === $selectedSkiPass->dateTo?->format('Y-m-d');
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### Field Visibility Chain
|
||||
1. SkiPass: Always visible (after dateOfBirth)
|
||||
2. Rentals: Only visible when skipass selected, filtered by skipass duration
|
||||
3. Rental Insurance: Only visible when rentals selected (existing logic)
|
||||
4. Body Dimensions: Only visible when rentals selected (existing logic)
|
||||
|
||||
### HTMX Integration
|
||||
- Existing HTMX system will handle dynamic updates when skipass selection changes
|
||||
- Field state conditions will automatically trigger rental field visibility
|
||||
- Rental options will be re-rendered with duration-filtered choices
|
||||
|
||||
## Dependencies
|
||||
- No new dependencies required
|
||||
- Leverages existing field state condition system
|
||||
- Uses existing Service model date properties
|
||||
- Maintains backward compatibility with existing workflows
|
||||
|
||||
## Progress Tracking
|
||||
|
||||
### Status: Implementation Complete ✅
|
||||
- [x] System architecture analysis
|
||||
- [x] Existing code review
|
||||
- [x] Implementation strategy defined
|
||||
- [x] Technical approach documented
|
||||
|
||||
### Implementation Phase: COMPLETED ✅
|
||||
- [x] Step 1: Create SkiPassSelectionCondition
|
||||
- [x] Step 2: Update Field State Provider
|
||||
- [x] Step 3: Create Duration-Based Rental Filtering
|
||||
- [x] Step 4: Update RentalsFieldHandler Dependencies
|
||||
- [x] Step 5: Update Field Handler Dependencies
|
||||
- [x] Testing: Verify cross-field dependencies work correctly
|
||||
- [x] Testing: Verify HTMX updates work properly
|
||||
- [x] Documentation: Update CLAUDE.md with new feature details
|
||||
|
||||
## Notes
|
||||
- Implementation follows existing architectural patterns
|
||||
- Maintains consistency with current field state condition system
|
||||
- Preserves backward compatibility
|
||||
- Leverages existing HTMX infrastructure for dynamic updates
|
||||
Reference in New Issue
Block a user