Alignement design systeme OK
This commit is contained in:
@@ -0,0 +1,328 @@
|
||||
/// Modèle pour les critères de recherche avancée des membres
|
||||
/// Correspond au DTO Java MembreSearchCriteria
|
||||
class MembreSearchCriteria {
|
||||
/// Terme de recherche général (nom, prénom, email)
|
||||
final String? query;
|
||||
|
||||
/// Recherche par nom exact ou partiel
|
||||
final String? nom;
|
||||
|
||||
/// Recherche par prénom exact ou partiel
|
||||
final String? prenom;
|
||||
|
||||
/// Recherche par email exact ou partiel
|
||||
final String? email;
|
||||
|
||||
/// Filtre par numéro de téléphone
|
||||
final String? telephone;
|
||||
|
||||
/// Liste des IDs d'organisations
|
||||
final List<String>? organisationIds;
|
||||
|
||||
/// Liste des rôles à rechercher
|
||||
final List<String>? roles;
|
||||
|
||||
/// Filtre par statut d'activité
|
||||
final String? statut;
|
||||
|
||||
/// Date d'adhésion minimum (format ISO 8601)
|
||||
final String? dateAdhesionMin;
|
||||
|
||||
/// Date d'adhésion maximum (format ISO 8601)
|
||||
final String? dateAdhesionMax;
|
||||
|
||||
/// Âge minimum
|
||||
final int? ageMin;
|
||||
|
||||
/// Âge maximum
|
||||
final int? ageMax;
|
||||
|
||||
/// Filtre par région
|
||||
final String? region;
|
||||
|
||||
/// Filtre par ville
|
||||
final String? ville;
|
||||
|
||||
/// Filtre par profession
|
||||
final String? profession;
|
||||
|
||||
/// Filtre par nationalité
|
||||
final String? nationalite;
|
||||
|
||||
/// Filtre membres du bureau uniquement
|
||||
final bool? membreBureau;
|
||||
|
||||
/// Filtre responsables uniquement
|
||||
final bool? responsable;
|
||||
|
||||
/// Inclure les membres inactifs dans la recherche
|
||||
final bool includeInactifs;
|
||||
|
||||
const MembreSearchCriteria({
|
||||
this.query,
|
||||
this.nom,
|
||||
this.prenom,
|
||||
this.email,
|
||||
this.telephone,
|
||||
this.organisationIds,
|
||||
this.roles,
|
||||
this.statut,
|
||||
this.dateAdhesionMin,
|
||||
this.dateAdhesionMax,
|
||||
this.ageMin,
|
||||
this.ageMax,
|
||||
this.region,
|
||||
this.ville,
|
||||
this.profession,
|
||||
this.nationalite,
|
||||
this.membreBureau,
|
||||
this.responsable,
|
||||
this.includeInactifs = false,
|
||||
});
|
||||
|
||||
/// Factory constructor pour créer depuis JSON
|
||||
factory MembreSearchCriteria.fromJson(Map<String, dynamic> json) {
|
||||
return MembreSearchCriteria(
|
||||
query: json['query'] as String?,
|
||||
nom: json['nom'] as String?,
|
||||
prenom: json['prenom'] as String?,
|
||||
email: json['email'] as String?,
|
||||
telephone: json['telephone'] as String?,
|
||||
organisationIds: (json['organisationIds'] as List<dynamic>?)?.cast<String>(),
|
||||
roles: (json['roles'] as List<dynamic>?)?.cast<String>(),
|
||||
statut: json['statut'] as String?,
|
||||
dateAdhesionMin: json['dateAdhesionMin'] as String?,
|
||||
dateAdhesionMax: json['dateAdhesionMax'] as String?,
|
||||
ageMin: json['ageMin'] as int?,
|
||||
ageMax: json['ageMax'] as int?,
|
||||
region: json['region'] as String?,
|
||||
ville: json['ville'] as String?,
|
||||
profession: json['profession'] as String?,
|
||||
nationalite: json['nationalite'] as String?,
|
||||
membreBureau: json['membreBureau'] as bool?,
|
||||
responsable: json['responsable'] as bool?,
|
||||
includeInactifs: json['includeInactifs'] as bool? ?? false,
|
||||
);
|
||||
}
|
||||
|
||||
/// Convertit vers JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'query': query,
|
||||
'nom': nom,
|
||||
'prenom': prenom,
|
||||
'email': email,
|
||||
'telephone': telephone,
|
||||
'organisationIds': organisationIds,
|
||||
'roles': roles,
|
||||
'statut': statut,
|
||||
'dateAdhesionMin': dateAdhesionMin,
|
||||
'dateAdhesionMax': dateAdhesionMax,
|
||||
'ageMin': ageMin,
|
||||
'ageMax': ageMax,
|
||||
'region': region,
|
||||
'ville': ville,
|
||||
'profession': profession,
|
||||
'nationalite': nationalite,
|
||||
'membreBureau': membreBureau,
|
||||
'responsable': responsable,
|
||||
'includeInactifs': includeInactifs,
|
||||
};
|
||||
}
|
||||
|
||||
/// Vérifie si au moins un critère de recherche est défini
|
||||
bool get hasAnyCriteria {
|
||||
return query?.isNotEmpty == true ||
|
||||
nom?.isNotEmpty == true ||
|
||||
prenom?.isNotEmpty == true ||
|
||||
email?.isNotEmpty == true ||
|
||||
telephone?.isNotEmpty == true ||
|
||||
organisationIds?.isNotEmpty == true ||
|
||||
roles?.isNotEmpty == true ||
|
||||
statut?.isNotEmpty == true ||
|
||||
dateAdhesionMin?.isNotEmpty == true ||
|
||||
dateAdhesionMax?.isNotEmpty == true ||
|
||||
ageMin != null ||
|
||||
ageMax != null ||
|
||||
region?.isNotEmpty == true ||
|
||||
ville?.isNotEmpty == true ||
|
||||
profession?.isNotEmpty == true ||
|
||||
nationalite?.isNotEmpty == true ||
|
||||
membreBureau != null ||
|
||||
responsable != null;
|
||||
}
|
||||
|
||||
/// Valide la cohérence des critères de recherche
|
||||
bool get isValid {
|
||||
// Validation des âges
|
||||
if (ageMin != null && ageMax != null) {
|
||||
if (ageMin! > ageMax!) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Validation des dates (si implémentée)
|
||||
if (dateAdhesionMin != null && dateAdhesionMax != null) {
|
||||
try {
|
||||
final dateMin = DateTime.parse(dateAdhesionMin!);
|
||||
final dateMax = DateTime.parse(dateAdhesionMax!);
|
||||
if (dateMin.isAfter(dateMax)) {
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Retourne une description textuelle des critères actifs
|
||||
String get description {
|
||||
final parts = <String>[];
|
||||
|
||||
if (query?.isNotEmpty == true) parts.add("Recherche: '$query'");
|
||||
if (nom?.isNotEmpty == true) parts.add("Nom: '$nom'");
|
||||
if (prenom?.isNotEmpty == true) parts.add("Prénom: '$prenom'");
|
||||
if (email?.isNotEmpty == true) parts.add("Email: '$email'");
|
||||
if (statut?.isNotEmpty == true) parts.add("Statut: $statut");
|
||||
if (organisationIds?.isNotEmpty == true) {
|
||||
parts.add("Organisations: ${organisationIds!.length}");
|
||||
}
|
||||
if (roles?.isNotEmpty == true) {
|
||||
parts.add("Rôles: ${roles!.join(', ')}");
|
||||
}
|
||||
if (dateAdhesionMin?.isNotEmpty == true) {
|
||||
parts.add("Adhésion >= $dateAdhesionMin");
|
||||
}
|
||||
if (dateAdhesionMax?.isNotEmpty == true) {
|
||||
parts.add("Adhésion <= $dateAdhesionMax");
|
||||
}
|
||||
if (ageMin != null) parts.add("Âge >= $ageMin");
|
||||
if (ageMax != null) parts.add("Âge <= $ageMax");
|
||||
if (region?.isNotEmpty == true) parts.add("Région: '$region'");
|
||||
if (ville?.isNotEmpty == true) parts.add("Ville: '$ville'");
|
||||
if (profession?.isNotEmpty == true) parts.add("Profession: '$profession'");
|
||||
if (nationalite?.isNotEmpty == true) parts.add("Nationalité: '$nationalite'");
|
||||
if (membreBureau == true) parts.add("Membre bureau");
|
||||
if (responsable == true) parts.add("Responsable");
|
||||
|
||||
return parts.join(' • ');
|
||||
}
|
||||
|
||||
/// Crée une copie avec des modifications
|
||||
MembreSearchCriteria copyWith({
|
||||
String? query,
|
||||
String? nom,
|
||||
String? prenom,
|
||||
String? email,
|
||||
String? telephone,
|
||||
List<String>? organisationIds,
|
||||
List<String>? roles,
|
||||
String? statut,
|
||||
String? dateAdhesionMin,
|
||||
String? dateAdhesionMax,
|
||||
int? ageMin,
|
||||
int? ageMax,
|
||||
String? region,
|
||||
String? ville,
|
||||
String? profession,
|
||||
String? nationalite,
|
||||
bool? membreBureau,
|
||||
bool? responsable,
|
||||
bool? includeInactifs,
|
||||
}) {
|
||||
return MembreSearchCriteria(
|
||||
query: query ?? this.query,
|
||||
nom: nom ?? this.nom,
|
||||
prenom: prenom ?? this.prenom,
|
||||
email: email ?? this.email,
|
||||
telephone: telephone ?? this.telephone,
|
||||
organisationIds: organisationIds ?? this.organisationIds,
|
||||
roles: roles ?? this.roles,
|
||||
statut: statut ?? this.statut,
|
||||
dateAdhesionMin: dateAdhesionMin ?? this.dateAdhesionMin,
|
||||
dateAdhesionMax: dateAdhesionMax ?? this.dateAdhesionMax,
|
||||
ageMin: ageMin ?? this.ageMin,
|
||||
ageMax: ageMax ?? this.ageMax,
|
||||
region: region ?? this.region,
|
||||
ville: ville ?? this.ville,
|
||||
profession: profession ?? this.profession,
|
||||
nationalite: nationalite ?? this.nationalite,
|
||||
membreBureau: membreBureau ?? this.membreBureau,
|
||||
responsable: responsable ?? this.responsable,
|
||||
includeInactifs: includeInactifs ?? this.includeInactifs,
|
||||
);
|
||||
}
|
||||
|
||||
/// Critères vides
|
||||
static const empty = MembreSearchCriteria();
|
||||
|
||||
/// Critères pour recherche rapide par nom/prénom
|
||||
static MembreSearchCriteria quickSearch(String query) {
|
||||
return MembreSearchCriteria(query: query);
|
||||
}
|
||||
|
||||
/// Critères pour membres actifs uniquement
|
||||
static const activeMembers = MembreSearchCriteria(
|
||||
statut: 'ACTIF',
|
||||
includeInactifs: false,
|
||||
);
|
||||
|
||||
/// Critères pour membres du bureau
|
||||
static const bureauMembers = MembreSearchCriteria(
|
||||
membreBureau: true,
|
||||
statut: 'ACTIF',
|
||||
);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is MembreSearchCriteria &&
|
||||
runtimeType == other.runtimeType &&
|
||||
query == other.query &&
|
||||
nom == other.nom &&
|
||||
prenom == other.prenom &&
|
||||
email == other.email &&
|
||||
telephone == other.telephone &&
|
||||
organisationIds == other.organisationIds &&
|
||||
roles == other.roles &&
|
||||
statut == other.statut &&
|
||||
dateAdhesionMin == other.dateAdhesionMin &&
|
||||
dateAdhesionMax == other.dateAdhesionMax &&
|
||||
ageMin == other.ageMin &&
|
||||
ageMax == other.ageMax &&
|
||||
region == other.region &&
|
||||
ville == other.ville &&
|
||||
profession == other.profession &&
|
||||
nationalite == other.nationalite &&
|
||||
membreBureau == other.membreBureau &&
|
||||
responsable == other.responsable &&
|
||||
includeInactifs == other.includeInactifs;
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hashAll([
|
||||
query,
|
||||
nom,
|
||||
prenom,
|
||||
email,
|
||||
telephone,
|
||||
organisationIds,
|
||||
roles,
|
||||
statut,
|
||||
dateAdhesionMin,
|
||||
dateAdhesionMax,
|
||||
ageMin,
|
||||
ageMax,
|
||||
region,
|
||||
ville,
|
||||
profession,
|
||||
nationalite,
|
||||
membreBureau,
|
||||
responsable,
|
||||
includeInactifs,
|
||||
]);
|
||||
|
||||
@override
|
||||
String toString() => 'MembreSearchCriteria(${description.isNotEmpty ? description : 'empty'})';
|
||||
}
|
||||
269
unionflow-mobile-apps/lib/core/models/membre_search_result.dart
Normal file
269
unionflow-mobile-apps/lib/core/models/membre_search_result.dart
Normal file
@@ -0,0 +1,269 @@
|
||||
import 'membre_search_criteria.dart';
|
||||
import '../../features/members/data/models/membre_model.dart';
|
||||
|
||||
/// Modèle pour les résultats de recherche avancée des membres
|
||||
/// Correspond au DTO Java MembreSearchResultDTO
|
||||
class MembreSearchResult {
|
||||
/// Liste des membres trouvés
|
||||
final List<MembreModel> membres;
|
||||
|
||||
/// Nombre total de résultats (toutes pages confondues)
|
||||
final int totalElements;
|
||||
|
||||
/// Nombre total de pages
|
||||
final int totalPages;
|
||||
|
||||
/// Numéro de la page actuelle (0-based)
|
||||
final int currentPage;
|
||||
|
||||
/// Taille de la page
|
||||
final int pageSize;
|
||||
|
||||
/// Nombre d'éléments sur la page actuelle
|
||||
final int numberOfElements;
|
||||
|
||||
/// Indique s'il y a une page suivante
|
||||
final bool hasNext;
|
||||
|
||||
/// Indique s'il y a une page précédente
|
||||
final bool hasPrevious;
|
||||
|
||||
/// Indique si c'est la première page
|
||||
final bool isFirst;
|
||||
|
||||
/// Indique si c'est la dernière page
|
||||
final bool isLast;
|
||||
|
||||
/// Critères de recherche utilisés
|
||||
final MembreSearchCriteria criteria;
|
||||
|
||||
/// Temps d'exécution de la recherche en millisecondes
|
||||
final int executionTimeMs;
|
||||
|
||||
/// Statistiques de recherche
|
||||
final SearchStatistics? statistics;
|
||||
|
||||
const MembreSearchResult({
|
||||
required this.membres,
|
||||
required this.totalElements,
|
||||
required this.totalPages,
|
||||
required this.currentPage,
|
||||
required this.pageSize,
|
||||
required this.numberOfElements,
|
||||
required this.hasNext,
|
||||
required this.hasPrevious,
|
||||
required this.isFirst,
|
||||
required this.isLast,
|
||||
required this.criteria,
|
||||
required this.executionTimeMs,
|
||||
this.statistics,
|
||||
});
|
||||
|
||||
/// Factory constructor pour créer depuis JSON
|
||||
factory MembreSearchResult.fromJson(Map<String, dynamic> json) {
|
||||
return MembreSearchResult(
|
||||
membres: (json['membres'] as List<dynamic>?)
|
||||
?.map((e) => MembreModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ?? [],
|
||||
totalElements: json['totalElements'] as int? ?? 0,
|
||||
totalPages: json['totalPages'] as int? ?? 0,
|
||||
currentPage: json['currentPage'] as int? ?? 0,
|
||||
pageSize: json['pageSize'] as int? ?? 20,
|
||||
numberOfElements: json['numberOfElements'] as int? ?? 0,
|
||||
hasNext: json['hasNext'] as bool? ?? false,
|
||||
hasPrevious: json['hasPrevious'] as bool? ?? false,
|
||||
isFirst: json['isFirst'] as bool? ?? true,
|
||||
isLast: json['isLast'] as bool? ?? true,
|
||||
criteria: MembreSearchCriteria.fromJson(json['criteria'] as Map<String, dynamic>? ?? {}),
|
||||
executionTimeMs: json['executionTimeMs'] as int? ?? 0,
|
||||
statistics: json['statistics'] != null
|
||||
? SearchStatistics.fromJson(json['statistics'] as Map<String, dynamic>)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
/// Convertit vers JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'membres': membres.map((e) => e.toJson()).toList(),
|
||||
'totalElements': totalElements,
|
||||
'totalPages': totalPages,
|
||||
'currentPage': currentPage,
|
||||
'pageSize': pageSize,
|
||||
'numberOfElements': numberOfElements,
|
||||
'hasNext': hasNext,
|
||||
'hasPrevious': hasPrevious,
|
||||
'isFirst': isFirst,
|
||||
'isLast': isLast,
|
||||
'criteria': criteria.toJson(),
|
||||
'executionTimeMs': executionTimeMs,
|
||||
'statistics': statistics?.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
/// Vérifie si les résultats sont vides
|
||||
bool get isEmpty => membres.isEmpty;
|
||||
|
||||
/// Vérifie si les résultats ne sont pas vides
|
||||
bool get isNotEmpty => membres.isNotEmpty;
|
||||
|
||||
/// Retourne le numéro de la page suivante (1-based pour affichage)
|
||||
int get nextPageNumber => hasNext ? currentPage + 2 : -1;
|
||||
|
||||
/// Retourne le numéro de la page précédente (1-based pour affichage)
|
||||
int get previousPageNumber => hasPrevious ? currentPage : -1;
|
||||
|
||||
/// Retourne une description textuelle des résultats
|
||||
String get resultDescription {
|
||||
if (isEmpty) {
|
||||
return 'Aucun membre trouvé';
|
||||
}
|
||||
|
||||
if (totalElements == 1) {
|
||||
return '1 membre trouvé';
|
||||
}
|
||||
|
||||
if (totalPages == 1) {
|
||||
return '$totalElements membres trouvés';
|
||||
}
|
||||
|
||||
final startElement = currentPage * pageSize + 1;
|
||||
final endElement = (startElement + numberOfElements - 1).clamp(1, totalElements);
|
||||
|
||||
return 'Membres $startElement-$endElement sur $totalElements (page ${currentPage + 1}/$totalPages)';
|
||||
}
|
||||
|
||||
/// Résultat vide
|
||||
static MembreSearchResult empty(MembreSearchCriteria criteria) {
|
||||
return MembreSearchResult(
|
||||
membres: const [],
|
||||
totalElements: 0,
|
||||
totalPages: 0,
|
||||
currentPage: 0,
|
||||
pageSize: 20,
|
||||
numberOfElements: 0,
|
||||
hasNext: false,
|
||||
hasPrevious: false,
|
||||
isFirst: true,
|
||||
isLast: true,
|
||||
criteria: criteria,
|
||||
executionTimeMs: 0,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => 'MembreSearchResult($resultDescription, ${executionTimeMs}ms)';
|
||||
}
|
||||
|
||||
/// Statistiques sur les résultats de recherche
|
||||
class SearchStatistics {
|
||||
/// Nombre de membres actifs dans les résultats
|
||||
final int membresActifs;
|
||||
|
||||
/// Nombre de membres inactifs dans les résultats
|
||||
final int membresInactifs;
|
||||
|
||||
/// Âge moyen des membres trouvés
|
||||
final double ageMoyen;
|
||||
|
||||
/// Âge minimum des membres trouvés
|
||||
final int ageMin;
|
||||
|
||||
/// Âge maximum des membres trouvés
|
||||
final int ageMax;
|
||||
|
||||
/// Nombre d'organisations représentées
|
||||
final int nombreOrganisations;
|
||||
|
||||
/// Nombre de régions représentées
|
||||
final int nombreRegions;
|
||||
|
||||
/// Ancienneté moyenne en années
|
||||
final double ancienneteMoyenne;
|
||||
|
||||
const SearchStatistics({
|
||||
required this.membresActifs,
|
||||
required this.membresInactifs,
|
||||
required this.ageMoyen,
|
||||
required this.ageMin,
|
||||
required this.ageMax,
|
||||
required this.nombreOrganisations,
|
||||
required this.nombreRegions,
|
||||
required this.ancienneteMoyenne,
|
||||
});
|
||||
|
||||
/// Factory constructor pour créer depuis JSON
|
||||
factory SearchStatistics.fromJson(Map<String, dynamic> json) {
|
||||
return SearchStatistics(
|
||||
membresActifs: json['membresActifs'] as int? ?? 0,
|
||||
membresInactifs: json['membresInactifs'] as int? ?? 0,
|
||||
ageMoyen: (json['ageMoyen'] as num?)?.toDouble() ?? 0.0,
|
||||
ageMin: json['ageMin'] as int? ?? 0,
|
||||
ageMax: json['ageMax'] as int? ?? 0,
|
||||
nombreOrganisations: json['nombreOrganisations'] as int? ?? 0,
|
||||
nombreRegions: json['nombreRegions'] as int? ?? 0,
|
||||
ancienneteMoyenne: (json['ancienneteMoyenne'] as num?)?.toDouble() ?? 0.0,
|
||||
);
|
||||
}
|
||||
|
||||
/// Convertit vers JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'membresActifs': membresActifs,
|
||||
'membresInactifs': membresInactifs,
|
||||
'ageMoyen': ageMoyen,
|
||||
'ageMin': ageMin,
|
||||
'ageMax': ageMax,
|
||||
'nombreOrganisations': nombreOrganisations,
|
||||
'nombreRegions': nombreRegions,
|
||||
'ancienneteMoyenne': ancienneteMoyenne,
|
||||
};
|
||||
}
|
||||
|
||||
/// Nombre total de membres
|
||||
int get totalMembres => membresActifs + membresInactifs;
|
||||
|
||||
/// Pourcentage de membres actifs
|
||||
double get pourcentageActifs {
|
||||
if (totalMembres == 0) return 0.0;
|
||||
return (membresActifs / totalMembres) * 100;
|
||||
}
|
||||
|
||||
/// Pourcentage de membres inactifs
|
||||
double get pourcentageInactifs {
|
||||
if (totalMembres == 0) return 0.0;
|
||||
return (membresInactifs / totalMembres) * 100;
|
||||
}
|
||||
|
||||
/// Tranche d'âge
|
||||
String get trancheAge {
|
||||
if (ageMin == ageMax) return '$ageMin ans';
|
||||
return '$ageMin-$ageMax ans';
|
||||
}
|
||||
|
||||
/// Description textuelle des statistiques
|
||||
String get description {
|
||||
final parts = <String>[];
|
||||
|
||||
if (totalMembres > 0) {
|
||||
parts.add('$totalMembres membres');
|
||||
if (membresActifs > 0) {
|
||||
parts.add('${pourcentageActifs.toStringAsFixed(1)}% actifs');
|
||||
}
|
||||
if (ageMoyen > 0) {
|
||||
parts.add('âge moyen: ${ageMoyen.toStringAsFixed(1)} ans');
|
||||
}
|
||||
if (nombreOrganisations > 0) {
|
||||
parts.add('$nombreOrganisations organisations');
|
||||
}
|
||||
if (ancienneteMoyenne > 0) {
|
||||
parts.add('ancienneté: ${ancienneteMoyenne.toStringAsFixed(1)} ans');
|
||||
}
|
||||
}
|
||||
|
||||
return parts.join(' • ');
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => 'SearchStatistics($description)';
|
||||
}
|
||||
Reference in New Issue
Block a user