diff --git a/flutter_front/lib/features/home/presentation/bloc/home_bloc.dart b/flutter_front/lib/features/home/presentation/bloc/home_bloc.dart index 247d6a7..c1b22c8 100644 --- a/flutter_front/lib/features/home/presentation/bloc/home_bloc.dart +++ b/flutter_front/lib/features/home/presentation/bloc/home_bloc.dart @@ -246,13 +246,16 @@ class HomeBloc extends Bloc { List? collapsedEquipment, Map? filterParams, }) { - final statuses = _getStatuses(equipment, chartData.data); + // Применяем фильтры к equipment + final filteredEquipment = equipment.filterEquipment(filterParams ?? {}); + + final statuses = _getStatuses(filteredEquipment, chartData.data); final maxTemperature = _getMaxTemperature(chartData); final workNum = statuses.values.where((status) => status == EquipmentStatus.work).length; return HomeLoaded( logo, - equipment, + filteredEquipment, chartData.data, chartData.settings, statuses, diff --git a/flutter_front/lib/shared/domain/entities/equipment/equipment_list_entity.dart b/flutter_front/lib/shared/domain/entities/equipment/equipment_list_entity.dart index 4a0c600..8be6005 100644 --- a/flutter_front/lib/shared/domain/entities/equipment/equipment_list_entity.dart +++ b/flutter_front/lib/shared/domain/entities/equipment/equipment_list_entity.dart @@ -31,4 +31,54 @@ class EquipmentListEntity { } const EquipmentListEntity({required this.equipment}); + + EquipmentListEntity filterEquipment(Map filters) { + if (filters.isEmpty) return this; + + List filteredEquipment = equipment.where((item) { + // Check name filter + if (filters.containsKey('name')) { + String nameFilter = filters['name'].toString().toLowerCase(); + if (!item.name.toLowerCase().contains(nameFilter)) { + return false; + } + } + + // Check location filter + if (filters.containsKey('location')) { + String locationFilter = filters['location'].toString().toLowerCase(); + if (!item.details.location.toLowerCase().contains(locationFilter)) { + return false; + } + } + + // Check group filter + if (filters.containsKey('group')) { + String groupFilter = filters['group'].toString().toLowerCase(); + if (!item.details.group.toLowerCase().contains(groupFilter)) { + return false; + } + } + + // Check year filter + if (filters.containsKey('year')) { + int yearFilter = int.parse(filters['year']); + if (item.details.year != yearFilter) { + return false; + } + } + + // Check status filter + if (filters.containsKey('status')) { + String statusFilter = filters['status'].toString().toLowerCase(); + if (!item.details.status.toLowerCase().contains(statusFilter)) { + return false; + } + } + + return true; + }).toList(); + + return EquipmentListEntity(equipment: filteredEquipment); + } } \ No newline at end of file