feat: merge branche IA (beta) - Intégration assistant IA logisticien Gemini

This commit is contained in:
ElPoyo
2026-05-25 23:35:40 +02:00
15 changed files with 3394 additions and 163 deletions
@@ -222,7 +222,7 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
}
}
/// Initialise la sélection avec le matériel déjà assigné
/// Initialise la slection avec le matriel dj assign
Future<void> _initializeAlreadyAssigned() async {
final Map<String, SelectedItem> initialSelection = {};
@@ -304,7 +304,7 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
try {
final result = await _dataService.getEquipmentsPaginated(
limit: 25,
limit: 50,
startAfter: _lastEquipmentId,
searchQuery: _searchQuery.isNotEmpty ? _searchQuery : null,
category: _selectedCategory != null
@@ -331,7 +331,7 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
DebugLog.info(
'[EquipmentSelectionDialog] Loaded ${newEquipments.length} equipments, total: ${_paginatedEquipments.length}, hasMore: $_hasMoreEquipments');
// Charger les quantités pour les consommables/câbles de cette page
// Charger les quantites pour les consommables/cbles de cette page
await _loadAvailableQuantities(newEquipments);
// Si la liste ne peut pas scroller, précharger la page suivante.
@@ -354,7 +354,7 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
try {
final result = await _dataService.getContainersPaginated(
limit: 25,
limit: 50,
startAfter: _lastContainerId,
searchQuery: _searchQuery.isNotEmpty ? _searchQuery : null,
category: _selectedCategory?.name, // Filtre par catégorie d'équipements
@@ -421,7 +421,7 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
DebugLog.info(
'[EquipmentSelectionDialog] Cached ${allEquipmentsToCache.length} equipment(s) from containers, total cache: ${_cachedEquipment.length}');
// Mettre à jour les statuts de conflit pour les nouveaux containers
// Mettre jour les statuts de conflit pour les nouveaux containers
await _updateContainerConflictStatus();
// Si la liste ne peut pas scroller, précharger la page suivante.
@@ -454,6 +454,40 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
}
}
void _checkIfMoreItemsNeeded() {
if (!mounted || _isLoadingMore) return;
int visibleItems = 0;
if (_displayType == SelectionType.equipment) {
visibleItems = _paginatedEquipments.where((eq) {
return _showConflictingItems || !_conflictingEquipmentIds.contains(eq.id);
}).length;
if (visibleItems < 15 && _hasMoreEquipments) {
_loadNextEquipmentPage();
} else if (_scrollController.hasClients && _scrollController.position.maxScrollExtent <= 0 && _hasMoreEquipments) {
_loadNextEquipmentPage();
}
} else {
visibleItems = _paginatedContainers.where((container) {
if (!_showConflictingItems) {
if (_conflictingContainerIds.contains(container.id)) return false;
final hasConflictingChildren = container.equipmentIds.any(
(eqId) => _conflictingEquipmentIds.contains(eqId),
);
if (hasConflictingChildren) return false;
}
return true;
}).length;
if (visibleItems < 15 && _hasMoreContainers) {
_loadNextContainerPage();
} else if (_scrollController.hasClients && _scrollController.position.maxScrollExtent <= 0 && _hasMoreContainers) {
_loadNextContainerPage();
}
}
}
@override
void dispose() {
_searchController.dispose();
@@ -1539,7 +1573,8 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
),
),
),
],
],
),
);
},
);