refactor: Ajout des sous-catégories et refonte de la gestion de l'appartenance
Cette mise à jour structurelle améliore la classification des équipements en introduisant la notion de sous-catégories et supprime la gestion directe de l'appartenance d'un équipement à une boîte (`parentBoxIds`). L'appartenance est désormais uniquement définie côté conteneur. Une nouvelle catégorie "Régie / Backline" est également ajoutée.
**Changements majeurs :**
- **Suppression de `parentBoxIds` sur `EquipmentModel` :**
- Le champ `parentBoxIds` a été retiré du modèle de données `EquipmentModel` et de toutes les logiques associées (création, mise à jour, copie).
- La responsabilité de lier un équipement à un conteneur est désormais exclusivement gérée par le `ContainerModel` via sa liste `equipmentIds`.
- La logique de synchronisation complexe dans `EquipmentFormPage` qui mettait à jour les conteneurs lors de la modification d'un équipement a été entièrement supprimée, simplifiant considérablement le code.
- Le sélecteur de boîtes parentes (`ParentBoxesSelector`) a été retiré du formulaire d'équipement.
- **Ajout des sous-catégories :**
- Un champ optionnel `subCategory` (String) a été ajouté au `EquipmentModel`.
- Le formulaire de création/modification d'équipement inclut désormais un nouveau champ "Sous-catégorie" avec autocomplétion.
- Ce champ est contextuel : il propose des suggestions basées sur les sous-catégories existantes pour la catégorie principale sélectionnée (ex: "Console", "Micro" pour la catégorie "Son").
- La sous-catégorie est maintenant affichée sur les fiches de détail des équipements et dans les listes de la page de gestion, améliorant la visibilité du classement.
**Nouvelle catégorie d'équipement :**
- Une nouvelle catégorie `backline` ("Régie / Backline") a été ajoutée à `EquipmentCategory` avec une icône (`Icons.piano`) et une couleur associée.
**Refactorisation et nettoyage :**
- Le `EquipmentProvider` et `EquipmentService` ont été mis à jour pour charger et filtrer les sous-catégories.
- De nombreuses instanciations d'un `EquipmentModel` vide (`dummy`) à travers l'application ont été nettoyées pour retirer la référence à `parentBoxIds`.
- **Version de l'application :**
- La version a été incrémentée à `1.0.4`.
This commit is contained in:
@@ -56,6 +56,7 @@ enum EquipmentCategory {
|
||||
consumable, // Consommable
|
||||
cable, // Câble
|
||||
vehicle, // Véhicule
|
||||
backline, // Régie / Backline
|
||||
other // Autre
|
||||
}
|
||||
|
||||
@@ -75,6 +76,8 @@ String equipmentCategoryToString(EquipmentCategory category) {
|
||||
return 'CABLE';
|
||||
case EquipmentCategory.vehicle:
|
||||
return 'VEHICLE';
|
||||
case EquipmentCategory.backline:
|
||||
return 'BACKLINE';
|
||||
case EquipmentCategory.other:
|
||||
return 'OTHER';
|
||||
case EquipmentCategory.effect:
|
||||
@@ -98,6 +101,8 @@ EquipmentCategory equipmentCategoryFromString(String? category) {
|
||||
return EquipmentCategory.cable;
|
||||
case 'VEHICLE':
|
||||
return EquipmentCategory.vehicle;
|
||||
case 'BACKLINE':
|
||||
return EquipmentCategory.backline;
|
||||
case 'EFFECT':
|
||||
return EquipmentCategory.effect;
|
||||
case 'OTHER':
|
||||
@@ -127,6 +132,8 @@ extension EquipmentCategoryExtension on EquipmentCategory {
|
||||
return 'Câble';
|
||||
case EquipmentCategory.vehicle:
|
||||
return 'Véhicule';
|
||||
case EquipmentCategory.backline:
|
||||
return 'Régie / Backline';
|
||||
case EquipmentCategory.other:
|
||||
return 'Autre';
|
||||
}
|
||||
@@ -151,6 +158,8 @@ extension EquipmentCategoryExtension on EquipmentCategory {
|
||||
return Icons.cable;
|
||||
case EquipmentCategory.vehicle:
|
||||
return Icons.local_shipping;
|
||||
case EquipmentCategory.backline:
|
||||
return Icons.piano;
|
||||
case EquipmentCategory.other:
|
||||
return Icons.more_horiz;
|
||||
}
|
||||
@@ -175,6 +184,8 @@ extension EquipmentCategoryExtension on EquipmentCategory {
|
||||
return Colors.grey;
|
||||
case EquipmentCategory.vehicle:
|
||||
return Colors.teal;
|
||||
case EquipmentCategory.backline:
|
||||
return Colors.indigo;
|
||||
case EquipmentCategory.other:
|
||||
return Colors.blueGrey;
|
||||
}
|
||||
@@ -193,6 +204,7 @@ extension EquipmentCategoryExtension on EquipmentCategory {
|
||||
case EquipmentCategory.effect:
|
||||
case EquipmentCategory.cable:
|
||||
case EquipmentCategory.vehicle:
|
||||
case EquipmentCategory.backline:
|
||||
case EquipmentCategory.other:
|
||||
return null;
|
||||
}
|
||||
@@ -312,6 +324,7 @@ class EquipmentModel {
|
||||
final String? brand; // Marque (indexé)
|
||||
final String? model; // Modèle (indexé)
|
||||
final EquipmentCategory category; // Catégorie
|
||||
final String? subCategory; // Sous-catégorie (indexé par catégorie)
|
||||
final EquipmentStatus status; // Statut actuel
|
||||
|
||||
// Prix (visible uniquement avec manage_equipment)
|
||||
@@ -323,8 +336,6 @@ class EquipmentModel {
|
||||
final int? availableQuantity; // Quantité disponible
|
||||
final int? criticalThreshold; // Seuil critique pour alerte
|
||||
|
||||
// Boîtes parentes (plusieurs possibles)
|
||||
final List<String> parentBoxIds; // IDs des boîtes contenant cet équipement
|
||||
|
||||
// Caractéristiques physiques
|
||||
final double? weight; // Poids (kg)
|
||||
@@ -354,13 +365,13 @@ class EquipmentModel {
|
||||
this.brand,
|
||||
this.model,
|
||||
required this.category,
|
||||
this.subCategory,
|
||||
this.status = EquipmentStatus.available,
|
||||
this.purchasePrice,
|
||||
this.rentalPrice,
|
||||
this.totalQuantity,
|
||||
this.availableQuantity,
|
||||
this.criticalThreshold,
|
||||
this.parentBoxIds = const [],
|
||||
this.weight,
|
||||
this.length,
|
||||
this.width,
|
||||
@@ -385,9 +396,6 @@ class EquipmentModel {
|
||||
}
|
||||
|
||||
// Gestion des listes
|
||||
final List<dynamic> parentBoxIdsRaw = map['parentBoxIds'] ?? [];
|
||||
final List<String> parentBoxIds = parentBoxIdsRaw.map((e) => e.toString()).toList();
|
||||
|
||||
final List<dynamic> maintenanceIdsRaw = map['maintenanceIds'] ?? [];
|
||||
final List<String> maintenanceIds = maintenanceIdsRaw.map((e) => e.toString()).toList();
|
||||
|
||||
@@ -397,13 +405,13 @@ class EquipmentModel {
|
||||
brand: map['brand'],
|
||||
model: map['model'],
|
||||
category: equipmentCategoryFromString(map['category']),
|
||||
subCategory: map['subCategory'],
|
||||
status: equipmentStatusFromString(map['status']),
|
||||
purchasePrice: map['purchasePrice']?.toDouble(),
|
||||
rentalPrice: map['rentalPrice']?.toDouble(),
|
||||
totalQuantity: map['totalQuantity']?.toInt(),
|
||||
availableQuantity: map['availableQuantity']?.toInt(),
|
||||
criticalThreshold: map['criticalThreshold']?.toInt(),
|
||||
parentBoxIds: parentBoxIds,
|
||||
weight: map['weight']?.toDouble(),
|
||||
length: map['length']?.toDouble(),
|
||||
width: map['width']?.toDouble(),
|
||||
@@ -424,13 +432,13 @@ class EquipmentModel {
|
||||
'brand': brand,
|
||||
'model': model,
|
||||
'category': equipmentCategoryToString(category),
|
||||
'subCategory': subCategory,
|
||||
'status': equipmentStatusToString(status),
|
||||
'purchasePrice': purchasePrice,
|
||||
'rentalPrice': rentalPrice,
|
||||
'totalQuantity': totalQuantity,
|
||||
'availableQuantity': availableQuantity,
|
||||
'criticalThreshold': criticalThreshold,
|
||||
'parentBoxIds': parentBoxIds,
|
||||
'weight': weight,
|
||||
'length': length,
|
||||
'width': width,
|
||||
@@ -452,13 +460,13 @@ class EquipmentModel {
|
||||
String? name,
|
||||
String? model,
|
||||
EquipmentCategory? category,
|
||||
String? subCategory,
|
||||
EquipmentStatus? status,
|
||||
double? purchasePrice,
|
||||
double? rentalPrice,
|
||||
int? totalQuantity,
|
||||
int? availableQuantity,
|
||||
int? criticalThreshold,
|
||||
List<String>? parentBoxIds,
|
||||
double? weight,
|
||||
double? length,
|
||||
double? width,
|
||||
@@ -478,13 +486,13 @@ class EquipmentModel {
|
||||
name: name ?? this.name,
|
||||
model: model ?? this.model,
|
||||
category: category ?? this.category,
|
||||
subCategory: subCategory ?? this.subCategory,
|
||||
status: status ?? this.status,
|
||||
purchasePrice: purchasePrice ?? this.purchasePrice,
|
||||
rentalPrice: rentalPrice ?? this.rentalPrice,
|
||||
totalQuantity: totalQuantity ?? this.totalQuantity,
|
||||
availableQuantity: availableQuantity ?? this.availableQuantity,
|
||||
criticalThreshold: criticalThreshold ?? this.criticalThreshold,
|
||||
parentBoxIds: parentBoxIds ?? this.parentBoxIds,
|
||||
weight: weight ?? this.weight,
|
||||
length: length ?? this.length,
|
||||
width: width ?? this.width,
|
||||
|
||||
Reference in New Issue
Block a user