refactor: Rename date parsing helper functions for consistency
This commit is contained in:
@@ -33,7 +33,6 @@ import 'services/update_service.dart';
|
|||||||
import 'views/widgets/common/update_dialog.dart';
|
import 'views/widgets/common/update_dialog.dart';
|
||||||
import 'config/api_config.dart';
|
import 'config/api_config.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'views/widgets/common/update_dialog.dart';
|
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ class AlertModel {
|
|||||||
|
|
||||||
factory AlertModel.fromMap(Map<String, dynamic> map, String id) {
|
factory AlertModel.fromMap(Map<String, dynamic> map, String id) {
|
||||||
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
||||||
DateTime _parseDate(dynamic value) {
|
DateTime parseDate(dynamic value) {
|
||||||
if (value == null) return DateTime.now();
|
if (value == null) return DateTime.now();
|
||||||
if (value is Timestamp) return value.toDate();
|
if (value is Timestamp) return value.toDate();
|
||||||
if (value is String) return DateTime.tryParse(value) ?? DateTime.now();
|
if (value is String) return DateTime.tryParse(value) ?? DateTime.now();
|
||||||
@@ -174,13 +174,13 @@ class AlertModel {
|
|||||||
eventId: map['eventId'],
|
eventId: map['eventId'],
|
||||||
equipmentId: map['equipmentId'],
|
equipmentId: map['equipmentId'],
|
||||||
createdByUserId: map['createdByUserId'] ?? map['createdBy'],
|
createdByUserId: map['createdByUserId'] ?? map['createdBy'],
|
||||||
createdAt: _parseDate(map['createdAt']),
|
createdAt: parseDate(map['createdAt']),
|
||||||
dueDate: map['dueDate'] != null ? _parseDate(map['dueDate']) : null,
|
dueDate: map['dueDate'] != null ? parseDate(map['dueDate']) : null,
|
||||||
actionUrl: map['actionUrl'],
|
actionUrl: map['actionUrl'],
|
||||||
isRead: map['isRead'] ?? false,
|
isRead: map['isRead'] ?? false,
|
||||||
isResolved: map['isResolved'] ?? false,
|
isResolved: map['isResolved'] ?? false,
|
||||||
resolution: map['resolution'],
|
resolution: map['resolution'],
|
||||||
resolvedAt: map['resolvedAt'] != null ? _parseDate(map['resolvedAt']) : null,
|
resolvedAt: map['resolvedAt'] != null ? parseDate(map['resolvedAt']) : null,
|
||||||
resolvedByUserId: map['resolvedByUserId'],
|
resolvedByUserId: map['resolvedByUserId'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ class ContainerModel {
|
|||||||
/// Factory depuis Firestore
|
/// Factory depuis Firestore
|
||||||
factory ContainerModel.fromMap(Map<String, dynamic> map, String id) {
|
factory ContainerModel.fromMap(Map<String, dynamic> map, String id) {
|
||||||
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
||||||
DateTime? _parseDate(dynamic value) {
|
DateTime? parseDate(dynamic value) {
|
||||||
if (value == null) return null;
|
if (value == null) return null;
|
||||||
if (value is Timestamp) return value.toDate();
|
if (value is Timestamp) return value.toDate();
|
||||||
if (value is String) return DateTime.tryParse(value);
|
if (value is String) return DateTime.tryParse(value);
|
||||||
@@ -270,8 +270,8 @@ class ContainerModel {
|
|||||||
equipmentIds: equipmentIds,
|
equipmentIds: equipmentIds,
|
||||||
eventId: map['eventId'],
|
eventId: map['eventId'],
|
||||||
notes: map['notes'],
|
notes: map['notes'],
|
||||||
createdAt: _parseDate(map['createdAt']) ?? DateTime.now(),
|
createdAt: parseDate(map['createdAt']) ?? DateTime.now(),
|
||||||
updatedAt: _parseDate(map['updatedAt']) ?? DateTime.now(),
|
updatedAt: parseDate(map['updatedAt']) ?? DateTime.now(),
|
||||||
history: history,
|
history: history,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -351,7 +351,7 @@ class ContainerHistoryEntry {
|
|||||||
|
|
||||||
factory ContainerHistoryEntry.fromMap(Map<String, dynamic> map) {
|
factory ContainerHistoryEntry.fromMap(Map<String, dynamic> map) {
|
||||||
// Helper pour parser la date
|
// Helper pour parser la date
|
||||||
DateTime _parseDate(dynamic value) {
|
DateTime parseDate(dynamic value) {
|
||||||
if (value == null) return DateTime.now();
|
if (value == null) return DateTime.now();
|
||||||
if (value is Timestamp) return value.toDate();
|
if (value is Timestamp) return value.toDate();
|
||||||
if (value is String) return DateTime.tryParse(value) ?? DateTime.now();
|
if (value is String) return DateTime.tryParse(value) ?? DateTime.now();
|
||||||
@@ -359,7 +359,7 @@ class ContainerHistoryEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ContainerHistoryEntry(
|
return ContainerHistoryEntry(
|
||||||
timestamp: _parseDate(map['timestamp']),
|
timestamp: parseDate(map['timestamp']),
|
||||||
action: map['action'] ?? '',
|
action: map['action'] ?? '',
|
||||||
equipmentId: map['equipmentId'],
|
equipmentId: map['equipmentId'],
|
||||||
previousValue: map['previousValue'],
|
previousValue: map['previousValue'],
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ class EquipmentModel {
|
|||||||
|
|
||||||
factory EquipmentModel.fromMap(Map<String, dynamic> map, String id) {
|
factory EquipmentModel.fromMap(Map<String, dynamic> map, String id) {
|
||||||
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
||||||
DateTime? _parseDate(dynamic value) {
|
DateTime? parseDate(dynamic value) {
|
||||||
if (value == null) return null;
|
if (value == null) return null;
|
||||||
if (value is Timestamp) return value.toDate();
|
if (value is Timestamp) return value.toDate();
|
||||||
if (value is String) return DateTime.tryParse(value);
|
if (value is String) return DateTime.tryParse(value);
|
||||||
@@ -416,13 +416,13 @@ class EquipmentModel {
|
|||||||
length: map['length']?.toDouble(),
|
length: map['length']?.toDouble(),
|
||||||
width: map['width']?.toDouble(),
|
width: map['width']?.toDouble(),
|
||||||
height: map['height']?.toDouble(),
|
height: map['height']?.toDouble(),
|
||||||
purchaseDate: _parseDate(map['purchaseDate']),
|
purchaseDate: parseDate(map['purchaseDate']),
|
||||||
nextMaintenanceDate: _parseDate(map['nextMaintenanceDate']),
|
nextMaintenanceDate: parseDate(map['nextMaintenanceDate']),
|
||||||
maintenanceIds: maintenanceIds,
|
maintenanceIds: maintenanceIds,
|
||||||
imageUrl: map['imageUrl'],
|
imageUrl: map['imageUrl'],
|
||||||
notes: map['notes'],
|
notes: map['notes'],
|
||||||
createdAt: _parseDate(map['createdAt']) ?? DateTime.now(),
|
createdAt: parseDate(map['createdAt']) ?? DateTime.now(),
|
||||||
updatedAt: _parseDate(map['updatedAt']) ?? DateTime.now(),
|
updatedAt: parseDate(map['updatedAt']) ?? DateTime.now(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ class EventModel {
|
|||||||
factory EventModel.fromMap(Map<String, dynamic> map, String id) {
|
factory EventModel.fromMap(Map<String, dynamic> map, String id) {
|
||||||
try {
|
try {
|
||||||
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
||||||
DateTime _parseDate(dynamic value, DateTime defaultValue) {
|
DateTime parseDate(dynamic value, DateTime defaultValue) {
|
||||||
if (value == null) return defaultValue;
|
if (value == null) return defaultValue;
|
||||||
if (value is Timestamp) return value.toDate();
|
if (value is Timestamp) return value.toDate();
|
||||||
if (value is String) return DateTime.tryParse(value) ?? defaultValue;
|
if (value is String) return DateTime.tryParse(value) ?? defaultValue;
|
||||||
@@ -370,8 +370,8 @@ class EventModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Gestion sécurisée des timestamps avec support ISO string
|
// Gestion sécurisée des timestamps avec support ISO string
|
||||||
final DateTime startDate = _parseDate(map['StartDateTime'], DateTime.now());
|
final DateTime startDate = parseDate(map['StartDateTime'], DateTime.now());
|
||||||
final DateTime endDate = _parseDate(map['EndDateTime'], startDate.add(const Duration(hours: 1)));
|
final DateTime endDate = parseDate(map['EndDateTime'], startDate.add(const Duration(hours: 1)));
|
||||||
|
|
||||||
// Gestion sécurisée des documents
|
// Gestion sécurisée des documents
|
||||||
final docsRaw = map['documents'] ?? [];
|
final docsRaw = map['documents'] ?? [];
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class MaintenanceModel {
|
|||||||
|
|
||||||
factory MaintenanceModel.fromMap(Map<String, dynamic> map, String id) {
|
factory MaintenanceModel.fromMap(Map<String, dynamic> map, String id) {
|
||||||
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
||||||
DateTime? _parseDate(dynamic value) {
|
DateTime? parseDate(dynamic value) {
|
||||||
if (value == null) return null;
|
if (value == null) return null;
|
||||||
if (value is Timestamp) return value.toDate();
|
if (value is Timestamp) return value.toDate();
|
||||||
if (value is String) return DateTime.tryParse(value);
|
if (value is String) return DateTime.tryParse(value);
|
||||||
@@ -76,15 +76,15 @@ class MaintenanceModel {
|
|||||||
id: id,
|
id: id,
|
||||||
equipmentIds: equipmentIds,
|
equipmentIds: equipmentIds,
|
||||||
type: maintenanceTypeFromString(map['type']),
|
type: maintenanceTypeFromString(map['type']),
|
||||||
scheduledDate: _parseDate(map['scheduledDate']) ?? DateTime.now(),
|
scheduledDate: parseDate(map['scheduledDate']) ?? DateTime.now(),
|
||||||
completedDate: _parseDate(map['completedDate']),
|
completedDate: parseDate(map['completedDate']),
|
||||||
name: map['name'] ?? '',
|
name: map['name'] ?? '',
|
||||||
description: map['description'] ?? '',
|
description: map['description'] ?? '',
|
||||||
performedBy: map['performedBy'],
|
performedBy: map['performedBy'],
|
||||||
cost: map['cost']?.toDouble(),
|
cost: map['cost']?.toDouble(),
|
||||||
notes: map['notes'],
|
notes: map['notes'],
|
||||||
createdAt: _parseDate(map['createdAt']) ?? DateTime.now(),
|
createdAt: parseDate(map['createdAt']) ?? DateTime.now(),
|
||||||
updatedAt: _parseDate(map['updatedAt']) ?? DateTime.now(),
|
updatedAt: parseDate(map['updatedAt']) ?? DateTime.now(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ class ContainerProvider with ChangeNotifier {
|
|||||||
Timer? _searchDebounceTimer;
|
Timer? _searchDebounceTimer;
|
||||||
|
|
||||||
// Liste paginée pour la page de gestion
|
// Liste paginée pour la page de gestion
|
||||||
List<ContainerModel> _paginatedContainers = [];
|
final List<ContainerModel> _paginatedContainers = [];
|
||||||
bool _hasMore = true;
|
bool _hasMore = true;
|
||||||
bool _isLoadingMore = false;
|
bool _isLoadingMore = false;
|
||||||
String? _lastVisible;
|
String? _lastVisible;
|
||||||
|
|
||||||
// Cache complet pour compatibilité
|
// Cache complet pour compatibilité
|
||||||
List<ContainerModel> _containers = [];
|
final List<ContainerModel> _containers = [];
|
||||||
|
|
||||||
// Filtres et recherche
|
// Filtres et recherche
|
||||||
ContainerType? _selectedType;
|
ContainerType? _selectedType;
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ class EquipmentProvider extends ChangeNotifier {
|
|||||||
Timer? _searchDebounceTimer;
|
Timer? _searchDebounceTimer;
|
||||||
|
|
||||||
// Liste paginée pour la page de gestion
|
// Liste paginée pour la page de gestion
|
||||||
List<EquipmentModel> _paginatedEquipment = [];
|
final List<EquipmentModel> _paginatedEquipment = [];
|
||||||
bool _hasMore = true;
|
bool _hasMore = true;
|
||||||
bool _isLoadingMore = false;
|
bool _isLoadingMore = false;
|
||||||
String? _lastVisible;
|
String? _lastVisible;
|
||||||
|
|
||||||
// Cache complet pour getEquipmentsByIds et compatibilité
|
// Cache complet pour getEquipmentsByIds et compatibilité
|
||||||
List<EquipmentModel> _equipment = [];
|
final List<EquipmentModel> _equipment = [];
|
||||||
List<String> _models = [];
|
List<String> _models = [];
|
||||||
List<String> _brands = [];
|
List<String> _brands = [];
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class EventProvider with ChangeNotifier {
|
|||||||
bool _lastCanViewAll = false;
|
bool _lastCanViewAll = false;
|
||||||
|
|
||||||
// Nouveau: Cache par mois pour le lazy loading
|
// Nouveau: Cache par mois pour le lazy loading
|
||||||
Map<String, List<EventModel>> _eventsByMonth = {}; // "2026-02" => [events]
|
final Map<String, List<EventModel>> _eventsByMonth = {}; // "2026-02" => [events]
|
||||||
String? _currentMonth; // Mois actuellement affiché
|
String? _currentMonth; // Mois actuellement affiché
|
||||||
|
|
||||||
List<EventModel> get events => _events;
|
List<EventModel> get events => _events;
|
||||||
@@ -88,7 +88,7 @@ class EventProvider with ChangeNotifier {
|
|||||||
_lastUserId = userId;
|
_lastUserId = userId;
|
||||||
_lastCanViewAll = canViewAllEvents;
|
_lastCanViewAll = canViewAllEvents;
|
||||||
|
|
||||||
print('Successfully loaded ${_events.length} events (${failedCount} failed)');
|
print('Successfully loaded ${_events.length} events ($failedCount failed)');
|
||||||
|
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@@ -176,7 +176,7 @@ class EventProvider with ChangeNotifier {
|
|||||||
_lastUserId = userId;
|
_lastUserId = userId;
|
||||||
_lastCanViewAll = canViewAllEvents;
|
_lastCanViewAll = canViewAllEvents;
|
||||||
|
|
||||||
print('[EventProvider] Successfully loaded ${monthEvents.length} events for $monthKey (${failedCount} failed)');
|
print('[EventProvider] Successfully loaded ${monthEvents.length} events for $monthKey ($failedCount failed)');
|
||||||
|
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class IcsExportService {
|
|||||||
Map<String, String>? optionNames,
|
Map<String, String>? optionNames,
|
||||||
}) async {
|
}) async {
|
||||||
final now = DateTime.now().toUtc();
|
final now = DateTime.now().toUtc();
|
||||||
final timestamp = DateFormat('yyyyMMddTHHmmss').format(now) + 'Z';
|
final timestamp = '${DateFormat('yyyyMMddTHHmmss').format(now)}Z';
|
||||||
|
|
||||||
// Récupérer les informations supplémentaires
|
// Récupérer les informations supplémentaires
|
||||||
final resolvedEventTypeName = eventTypeName ?? await _getEventTypeName(event.eventTypeId);
|
final resolvedEventTypeName = eventTypeName ?? await _getEventTypeName(event.eventTypeId);
|
||||||
@@ -238,7 +238,7 @@ END:VCALENDAR''';
|
|||||||
/// Formate une date au format ICS (yyyyMMddTHHmmssZ)
|
/// Formate une date au format ICS (yyyyMMddTHHmmssZ)
|
||||||
static String _formatDateForIcs(DateTime dateTime) {
|
static String _formatDateForIcs(DateTime dateTime) {
|
||||||
final utcDate = dateTime.toUtc();
|
final utcDate = dateTime.toUtc();
|
||||||
return DateFormat('yyyyMMddTHHmmss').format(utcDate) + 'Z';
|
return '${DateFormat('yyyyMMddTHHmmss').format(utcDate)}Z';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Échappe les caractères spéciaux pour le format ICS
|
/// Échappe les caractères spéciaux pour le format ICS
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'dart:typed_data';
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:pdf/pdf.dart';
|
import 'package:pdf/pdf.dart';
|
||||||
import 'package:pdf/widgets.dart' as pw;
|
import 'package:pdf/widgets.dart' as pw;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'dart:typed_data';
|
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:qr_flutter/qr_flutter.dart';
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class PerformanceMonitor {
|
|||||||
static void printSummary() {
|
static void printSummary() {
|
||||||
if (!_enabled || _results.isEmpty) return;
|
if (!_enabled || _results.isEmpty) return;
|
||||||
|
|
||||||
print('\n' + '=' * 60);
|
print('\n${'=' * 60}');
|
||||||
print('PERFORMANCE SUMMARY');
|
print('PERFORMANCE SUMMARY');
|
||||||
print('=' * 60);
|
print('=' * 60);
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ class PerformanceMonitor {
|
|||||||
Duration.zero,
|
Duration.zero,
|
||||||
(sum, duration) => sum + duration,
|
(sum, duration) => sum + duration,
|
||||||
);
|
);
|
||||||
print('${'=' * 60}');
|
print('=' * 60);
|
||||||
print('TOTAL: ${total.inMilliseconds}ms');
|
print('TOTAL: ${total.inMilliseconds}ms');
|
||||||
print('=' * 60 + '\n');
|
print('=' * 60 + '\n');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ class _ContainerFormPageState extends State<ContainerFormPage> {
|
|||||||
|
|
||||||
// Type
|
// Type
|
||||||
DropdownButtonFormField<ContainerType>(
|
DropdownButtonFormField<ContainerType>(
|
||||||
value: _selectedType,
|
initialValue: _selectedType,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Type de container *',
|
labelText: 'Type de container *',
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
@@ -194,7 +194,7 @@ class _ContainerFormPageState extends State<ContainerFormPage> {
|
|||||||
|
|
||||||
// Statut
|
// Statut
|
||||||
DropdownButtonFormField<EquipmentStatus>(
|
DropdownButtonFormField<EquipmentStatus>(
|
||||||
value: _selectedStatus,
|
initialValue: _selectedStatus,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Statut *',
|
labelText: 'Statut *',
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class _DataManagementPageState extends State<DataManagementPage> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
// Menu horizontal en mobile
|
// Menu horizontal en mobile
|
||||||
Container(
|
SizedBox(
|
||||||
height: 60,
|
height: 60,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ class _EquipmentFormPageState extends State<EquipmentFormPage> {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DropdownButtonFormField<EquipmentCategory>(
|
child: DropdownButtonFormField<EquipmentCategory>(
|
||||||
value: _selectedCategory,
|
initialValue: _selectedCategory,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Catégorie *',
|
labelText: 'Catégorie *',
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
@@ -299,7 +299,7 @@ class _EquipmentFormPageState extends State<EquipmentFormPage> {
|
|||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DropdownButtonFormField<EquipmentStatus>(
|
child: DropdownButtonFormField<EquipmentStatus>(
|
||||||
value: _selectedStatus,
|
initialValue: _selectedStatus,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Statut *',
|
labelText: 'Statut *',
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
|
|||||||
@@ -49,18 +49,18 @@ class _EventPreparationPageState extends State<EventPreparationPage> with Single
|
|||||||
late final DataService _dataService;
|
late final DataService _dataService;
|
||||||
late final QRCodeProcessingService _qrCodeService;
|
late final QRCodeProcessingService _qrCodeService;
|
||||||
|
|
||||||
Map<String, EquipmentModel> _equipmentCache = {};
|
final Map<String, EquipmentModel> _equipmentCache = {};
|
||||||
Map<String, ContainerModel> _containerCache = {};
|
final Map<String, ContainerModel> _containerCache = {};
|
||||||
Map<String, int> _returnedQuantities = {};
|
final Map<String, int> _returnedQuantities = {};
|
||||||
|
|
||||||
// État local des validations (non sauvegardé jusqu'à la validation finale)
|
// État local des validations (non sauvegardé jusqu'à la validation finale)
|
||||||
Map<String, bool> _localValidationState = {};
|
final Map<String, bool> _localValidationState = {};
|
||||||
|
|
||||||
// Gestion des quantités par étape
|
// Gestion des quantités par étape
|
||||||
Map<String, int> _quantitiesAtPreparation = {};
|
final Map<String, int> _quantitiesAtPreparation = {};
|
||||||
Map<String, int> _quantitiesAtLoading = {};
|
final Map<String, int> _quantitiesAtLoading = {};
|
||||||
Map<String, int> _quantitiesAtUnloading = {};
|
final Map<String, int> _quantitiesAtUnloading = {};
|
||||||
Map<String, int> _quantitiesAtReturn = {};
|
final Map<String, int> _quantitiesAtReturn = {};
|
||||||
|
|
||||||
bool _isLoading = true;
|
bool _isLoading = true;
|
||||||
bool _isValidating = false;
|
bool _isValidating = false;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:em2rp/utils/debug_log.dart';
|
|
||||||
import 'package:em2rp/utils/colors.dart';
|
import 'package:em2rp/utils/colors.dart';
|
||||||
import 'package:firebase_auth/firebase_auth.dart';
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ class EventDetailsDocuments extends StatelessWidget {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return Dialog(
|
return Dialog(
|
||||||
child: Container(
|
child: SizedBox(
|
||||||
width: MediaQuery.of(context).size.width * 0.9,
|
width: MediaQuery.of(context).size.width * 0.9,
|
||||||
height: MediaQuery.of(context).size.height * 0.8,
|
height: MediaQuery.of(context).size.height * 0.8,
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ class _UserFilterDropdownState extends State<UserFilterDropdown> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ class _EquipmentConflictDialogState extends State<EquipmentConflictDialog> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}),
|
||||||
|
|
||||||
// Boutons d'action par équipement
|
// Boutons d'action par équipement
|
||||||
if (!isRemoved)
|
if (!isRemoved)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class ContainerConflictInfo {
|
|||||||
if (status == ContainerConflictStatus.complete) {
|
if (status == ContainerConflictStatus.complete) {
|
||||||
return 'Tous les équipements sont déjà utilisés';
|
return 'Tous les équipements sont déjà utilisés';
|
||||||
}
|
}
|
||||||
return '${conflictingEquipmentIds.length}/${totalChildren} équipement(s) déjà utilisé(s)';
|
return '${conflictingEquipmentIds.length}/$totalChildren équipement(s) déjà utilisé(s)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,11 +94,11 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
|
|||||||
|
|
||||||
Map<String, SelectedItem> _selectedItems = {};
|
Map<String, SelectedItem> _selectedItems = {};
|
||||||
final ValueNotifier<int> _selectionChangeNotifier = ValueNotifier<int>(0); // Pour notifier les changements de sélection sans setState
|
final ValueNotifier<int> _selectionChangeNotifier = ValueNotifier<int>(0); // Pour notifier les changements de sélection sans setState
|
||||||
Map<String, int> _availableQuantities = {}; // Pour consommables
|
final Map<String, int> _availableQuantities = {}; // Pour consommables
|
||||||
Map<String, List<ContainerModel>> _recommendedContainers = {}; // Recommandations
|
final Map<String, List<ContainerModel>> _recommendedContainers = {}; // Recommandations
|
||||||
Map<String, List<AvailabilityConflict>> _equipmentConflicts = {}; // Conflits de disponibilité (détaillés)
|
final Map<String, List<AvailabilityConflict>> _equipmentConflicts = {}; // Conflits de disponibilité (détaillés)
|
||||||
Map<String, ContainerConflictInfo> _containerConflicts = {}; // Conflits des conteneurs
|
final Map<String, ContainerConflictInfo> _containerConflicts = {}; // Conflits des conteneurs
|
||||||
Set<String> _expandedContainers = {}; // Conteneurs dépliés dans la liste
|
final Set<String> _expandedContainers = {}; // Conteneurs dépliés dans la liste
|
||||||
|
|
||||||
// NOUVEAU : IDs en conflit récupérés en batch
|
// NOUVEAU : IDs en conflit récupérés en batch
|
||||||
Set<String> _conflictingEquipmentIds = {};
|
Set<String> _conflictingEquipmentIds = {};
|
||||||
@@ -119,12 +119,12 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
|
|||||||
bool _hasMoreContainers = true;
|
bool _hasMoreContainers = true;
|
||||||
String? _lastEquipmentId;
|
String? _lastEquipmentId;
|
||||||
String? _lastContainerId;
|
String? _lastContainerId;
|
||||||
List<EquipmentModel> _paginatedEquipments = [];
|
final List<EquipmentModel> _paginatedEquipments = [];
|
||||||
List<ContainerModel> _paginatedContainers = [];
|
final List<ContainerModel> _paginatedContainers = [];
|
||||||
|
|
||||||
// Cache pour éviter les rebuilds inutiles
|
// Cache pour éviter les rebuilds inutiles
|
||||||
List<ContainerModel> _cachedContainers = [];
|
final List<ContainerModel> _cachedContainers = [];
|
||||||
List<EquipmentModel> _cachedEquipment = [];
|
final List<EquipmentModel> _cachedEquipment = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -1047,7 +1047,7 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
|
|||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
),
|
),
|
||||||
child: Container(
|
child: SizedBox(
|
||||||
width: dialogWidth.clamp(600.0, 1200.0),
|
width: dialogWidth.clamp(600.0, 1200.0),
|
||||||
height: dialogHeight.clamp(500.0, 900.0),
|
height: dialogHeight.clamp(500.0, 900.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -1458,66 +1458,6 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Header de section repliable
|
|
||||||
Widget _buildCollapsibleSectionHeader(
|
|
||||||
String title,
|
|
||||||
IconData icon,
|
|
||||||
int count,
|
|
||||||
bool isExpanded,
|
|
||||||
Function(bool) onToggle,
|
|
||||||
) {
|
|
||||||
return InkWell(
|
|
||||||
onTap: () => onToggle(!isExpanded),
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: AppColors.rouge.withValues(alpha: 0.1),
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
border: Border.all(
|
|
||||||
color: AppColors.rouge.withValues(alpha: 0.3),
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
isExpanded ? Icons.keyboard_arrow_down : Icons.keyboard_arrow_right,
|
|
||||||
color: AppColors.rouge,
|
|
||||||
size: 24,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Icon(icon, color: AppColors.rouge, size: 20),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Text(
|
|
||||||
title,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: AppColors.rouge,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: AppColors.rouge,
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
'$count',
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 13,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildEquipmentCard(EquipmentModel equipment, {Key? key}) {
|
Widget _buildEquipmentCard(EquipmentModel equipment, {Key? key}) {
|
||||||
final isSelected = _selectedItems.containsKey(equipment.id);
|
final isSelected = _selectedItems.containsKey(equipment.id);
|
||||||
final isConsumable = equipment.category == EquipmentCategory.consumable ||
|
final isConsumable = equipment.category == EquipmentCategory.consumable ||
|
||||||
@@ -1809,7 +1749,7 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
|
|||||||
}) {
|
}) {
|
||||||
final displayQuantity = isSelected ? selectedItem.quantity : 0;
|
final displayQuantity = isSelected ? selectedItem.quantity : 0;
|
||||||
|
|
||||||
return Container(
|
return SizedBox(
|
||||||
width: 120,
|
width: 120,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -2369,7 +2309,7 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cache local pour les équipements des conteneurs
|
// Cache local pour les équipements des conteneurs
|
||||||
Map<String, List<String>> _containerEquipmentCache = {};
|
final Map<String, List<String>> _containerEquipmentCache = {};
|
||||||
|
|
||||||
Widget _buildSelectedContainerTile(String id, SelectedItem item) {
|
Widget _buildSelectedContainerTile(String id, SelectedItem item) {
|
||||||
final isExpanded = _expandedContainers.contains(id);
|
final isExpanded = _expandedContainers.contains(id);
|
||||||
@@ -2425,7 +2365,7 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
|
|||||||
return _buildSelectedChildEquipmentTile(equipmentId, childItem);
|
return _buildSelectedChildEquipmentTile(equipmentId, childItem);
|
||||||
}
|
}
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}).toList(),
|
}),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:em2rp/models/equipment_model.dart';
|
import 'package:em2rp/models/equipment_model.dart';
|
||||||
import 'package:em2rp/views/widgets/event/equipment_selection_dialog.dart';
|
|
||||||
|
|
||||||
/// Widget optimisé pour une card d'équipement qui ne rebuild que si nécessaire
|
/// Widget optimisé pour une card d'équipement qui ne rebuild que si nécessaire
|
||||||
class OptimizedEquipmentCard extends StatefulWidget {
|
class OptimizedEquipmentCard extends StatefulWidget {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import 'package:em2rp/services/data_service.dart';
|
|||||||
import 'package:em2rp/services/api_service.dart';
|
import 'package:em2rp/services/api_service.dart';
|
||||||
import 'package:em2rp/utils/colors.dart';
|
import 'package:em2rp/utils/colors.dart';
|
||||||
import 'package:em2rp/views/widgets/event/equipment_selection_dialog.dart';
|
import 'package:em2rp/views/widgets/event/equipment_selection_dialog.dart';
|
||||||
import 'package:em2rp/views/widgets/event/equipment_conflict_dialog.dart';
|
|
||||||
import 'package:em2rp/services/event_availability_service.dart';
|
import 'package:em2rp/services/event_availability_service.dart';
|
||||||
|
|
||||||
/// Section pour afficher et gérer le matériel assigné à un événement
|
/// Section pour afficher et gérer le matériel assigné à un événement
|
||||||
@@ -40,8 +39,8 @@ class _EventAssignedEquipmentSectionState extends State<EventAssignedEquipmentSe
|
|||||||
bool get _canAddMaterial => widget.startDate != null && widget.endDate != null;
|
bool get _canAddMaterial => widget.startDate != null && widget.endDate != null;
|
||||||
final EventAvailabilityService _availabilityService = EventAvailabilityService();
|
final EventAvailabilityService _availabilityService = EventAvailabilityService();
|
||||||
final DataService _dataService = DataService(FirebaseFunctionsApiService());
|
final DataService _dataService = DataService(FirebaseFunctionsApiService());
|
||||||
Map<String, EquipmentModel> _equipmentCache = {};
|
final Map<String, EquipmentModel> _equipmentCache = {};
|
||||||
Map<String, ContainerModel> _containerCache = {};
|
final Map<String, ContainerModel> _containerCache = {};
|
||||||
bool _isLoading = true;
|
bool _isLoading = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -491,7 +490,7 @@ class _EventAssignedEquipmentSectionState extends State<EventAssignedEquipmentSe
|
|||||||
...widget.assignedContainers.map((containerId) {
|
...widget.assignedContainers.map((containerId) {
|
||||||
final container = _containerCache[containerId];
|
final container = _containerCache[containerId];
|
||||||
return _buildContainerItem(container);
|
return _buildContainerItem(container);
|
||||||
}).toList(),
|
}),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -508,7 +507,7 @@ class _EventAssignedEquipmentSectionState extends State<EventAssignedEquipmentSe
|
|||||||
..._getStandaloneEquipment().map((eq) {
|
..._getStandaloneEquipment().map((eq) {
|
||||||
final equipment = _equipmentCache[eq.equipmentId];
|
final equipment = _equipmentCache[eq.equipmentId];
|
||||||
return _buildEquipmentItem(equipment, eq);
|
return _buildEquipmentItem(equipment, eq);
|
||||||
}).toList(),
|
}),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -597,7 +596,7 @@ class _EventAssignedEquipmentSectionState extends State<EventAssignedEquipmentSe
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:em2rp/models/event_type_model.dart';
|
import 'package:em2rp/models/event_type_model.dart';
|
||||||
import 'package:em2rp/views/widgets/event_form/price_ht_ttc_fields.dart';
|
import 'package:em2rp/views/widgets/event_form/price_ht_ttc_fields.dart';
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ class OptionSelectorWidget extends StatefulWidget {
|
|||||||
final bool isMobile;
|
final bool isMobile;
|
||||||
final String? eventType;
|
final String? eventType;
|
||||||
|
|
||||||
const OptionSelectorWidget({
|
const OptionSelectorWidget({super.key,
|
||||||
Key? key,
|
|
||||||
this.eventType,
|
this.eventType,
|
||||||
required this.selectedOptions,
|
required this.selectedOptions,
|
||||||
required this.onChanged,
|
required this.onChanged,
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ class _NotificationPreferencesWidgetState extends State<NotificationPreferencesW
|
|||||||
),
|
),
|
||||||
value: value,
|
value: value,
|
||||||
onChanged: _isSaving ? null : onChanged, // Désactiver pendant sauvegarde
|
onChanged: _isSaving ? null : onChanged, // Désactiver pendant sauvegarde
|
||||||
activeColor: Theme.of(context).primaryColor,
|
activeThumbColor: Theme.of(context).primaryColor,
|
||||||
inactiveThumbColor: Colors.grey.shade400, // Couleur visible quand OFF
|
inactiveThumbColor: Colors.grey.shade400, // Couleur visible quand OFF
|
||||||
inactiveTrackColor: Colors.grey.shade300, // Track visible quand OFF
|
inactiveTrackColor: Colors.grey.shade300, // Track visible quand OFF
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
|
|||||||
Reference in New Issue
Block a user