feat: Refactor event equipment management with advanced selection and conflict detection
This commit introduces a complete overhaul of how equipment is assigned to events, focusing on an enhanced user experience, advanced selection capabilities, and robust conflict detection.
**Key Features & Enhancements:**
- **Advanced Equipment Selection UI (`EquipmentSelectionDialog`):**
- New full-screen dialog to select equipment and containers ("boîtes") for an event.
- Hierarchical view showing containers and a flat list of all individual equipment.
- Real-time search and filtering by equipment category.
- Side panel summarizing the current selection and providing recommendations for containers based on selected equipment.
- Supports quantity selection for consumables and cables.
- **Conflict Detection & Management (`EventAvailabilityService`):**
- A new service (`EventAvailabilityService`) checks for equipment availability against other events based on the selected date range.
- The selection dialog visually highlights equipment and containers with scheduling conflicts (e.g., already used, partially unavailable).
- A dedicated conflict resolution dialog (`EquipmentConflictDialog`) appears if conflicting items are selected, allowing the user to either remove them or force the assignment.
- **Integrated Event Form (`EventAssignedEquipmentSection`):**
- The event creation/editing form now includes a new section for managing assigned equipment.
- It clearly displays assigned containers and standalone equipment, showing the composition of each container.
- Integrates the new selection dialog, ensuring all assignments are checked for conflicts before being saved.
- **Event Preparation & Return Workflow (`EventPreparationPage`):**
- New page (`EventPreparationPage`) for managing the check-out (preparation) and check-in (return) of equipment for an event.
- Provides a checklist of all assigned equipment.
- Users can validate each item, with options to "validate all" or finalize with missing items.
- Includes a dialog (`MissingEquipmentDialog`) to handle discrepancies.
- Supports tracking returned quantities for consumables.
**Data Model and Other Changes:**
- The `EventModel` now includes `assignedContainers` to explicitly link containers to an event.
- `EquipmentAssociatedEventsSection` on the equipment detail page is now functional, displaying current, upcoming, and past events for that item.
- Added deployment and versioning scripts (`scripts/deploy.js`, `scripts/increment_version.js`, `scripts/toggle_env.js`) to automate the release process.
- Introduced an application version display in the main drawer (`AppVersion`).
This commit is contained in:
@@ -34,6 +34,8 @@ class EventFormController extends ChangeNotifier {
|
||||
List<Map<String, dynamic>> _selectedOptions = [];
|
||||
bool _formChanged = false;
|
||||
EventStatus _selectedStatus = EventStatus.waitingForApproval;
|
||||
List<EventEquipment> _assignedEquipment = [];
|
||||
List<String> _assignedContainers = [];
|
||||
|
||||
// Getters
|
||||
DateTime? get startDateTime => _startDateTime;
|
||||
@@ -49,6 +51,8 @@ class EventFormController extends ChangeNotifier {
|
||||
bool get isLoadingUsers => _isLoadingUsers;
|
||||
List<Map<String, String>> get uploadedFiles => _uploadedFiles;
|
||||
List<Map<String, dynamic>> get selectedOptions => _selectedOptions;
|
||||
List<EventEquipment> get assignedEquipment => _assignedEquipment;
|
||||
List<String> get assignedContainers => _assignedContainers;
|
||||
bool get formChanged => _formChanged;
|
||||
EventStatus get selectedStatus => _selectedStatus;
|
||||
|
||||
@@ -95,6 +99,8 @@ class EventFormController extends ChangeNotifier {
|
||||
addressController.text = event.address;
|
||||
_startDateTime = event.startDateTime;
|
||||
_endDateTime = event.endDateTime;
|
||||
_assignedEquipment = List<EventEquipment>.from(event.assignedEquipment);
|
||||
_assignedContainers = List<String>.from(event.assignedContainers);
|
||||
_selectedEventTypeId = event.eventTypeId.isNotEmpty ? event.eventTypeId : null;
|
||||
_selectedUserIds = event.workforce.map((ref) => ref.id).toList();
|
||||
_uploadedFiles = List<Map<String, String>>.from(event.documents);
|
||||
@@ -206,6 +212,13 @@ class EventFormController extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setAssignedEquipment(List<EventEquipment> equipment, List<String> containers) {
|
||||
_assignedEquipment = equipment;
|
||||
_assignedContainers = containers;
|
||||
_onAnyFieldChanged();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> pickAndUploadFiles() async {
|
||||
final result = await FilePicker.platform.pickFiles(allowMultiple: true, withData: true);
|
||||
if (result != null && result.files.isNotEmpty) {
|
||||
@@ -297,6 +310,10 @@ class EventFormController extends ChangeNotifier {
|
||||
documents: finalDocuments,
|
||||
options: _selectedOptions,
|
||||
status: _selectedStatus,
|
||||
assignedEquipment: _assignedEquipment,
|
||||
assignedContainers: _assignedContainers,
|
||||
preparationStatus: existingEvent.preparationStatus,
|
||||
returnStatus: existingEvent.returnStatus,
|
||||
);
|
||||
|
||||
await EventFormService.updateEvent(updatedEvent);
|
||||
@@ -335,6 +352,8 @@ class EventFormController extends ChangeNotifier {
|
||||
documents: _uploadedFiles,
|
||||
options: _selectedOptions,
|
||||
status: _selectedStatus,
|
||||
assignedContainers: _assignedContainers,
|
||||
assignedEquipment: _assignedEquipment,
|
||||
);
|
||||
|
||||
final eventId = await EventFormService.createEvent(newEvent);
|
||||
|
||||
Reference in New Issue
Block a user