Ajout du choix des utilisateurs sur un événement. Ajout de fichiers dans un événement. (dropzone cassée)

This commit is contained in:
2025-05-26 22:10:40 +02:00
parent 82d77e2b8d
commit 49dffff1bf
1100 changed files with 157519 additions and 113 deletions

View File

@ -12,8 +12,11 @@ class EventModel {
final int disassemblyTime;
final String eventTypeId;
final String customerId;
final LatLng address;
final List<String> workforce;
final String address;
final double latitude;
final double longitude;
final List<DocumentReference> workforce;
final List<Map<String, String>> documents;
EventModel({
required this.id,
@ -27,15 +30,31 @@ class EventModel {
required this.eventTypeId,
required this.customerId,
required this.address,
required this.latitude,
required this.longitude,
required this.workforce,
required this.documents,
});
factory EventModel.fromMap(Map<String, dynamic> map, String id) {
final GeoPoint? geoPoint = map['Address'] as GeoPoint?;
final List<dynamic> workforceRefs = map['workforce'] ?? [];
final Timestamp? startTimestamp = map['StartDateTime'] as Timestamp?;
final Timestamp? endTimestamp = map['EndDateTime'] as Timestamp?;
final docsRaw = map['documents'] ?? [];
final docs = docsRaw is List
? docsRaw.map<Map<String, String>>((e) {
if (e is Map) {
return Map<String, String>.from(e as Map);
} else if (e is String) {
final fileName =
Uri.decodeComponent(e.split('/').last.split('?').first);
return {'name': fileName, 'url': e};
} else {
return {};
}
}).toList()
: <Map<String, String>>[];
return EventModel(
id: id,
name: map['Name'] ?? '',
@ -52,15 +71,11 @@ class EventModel {
customerId: map['customer'] is DocumentReference
? (map['customer'] as DocumentReference).id
: '',
address: geoPoint != null
? LatLng(geoPoint.latitude, geoPoint.longitude)
: const LatLng(0, 0),
workforce: workforceRefs.map((ref) {
if (ref is DocumentReference) {
return ref.id;
}
return ref.toString();
}).toList(),
address: map['Address'] ?? '',
latitude: (map['Latitude'] ?? 0.0).toDouble(),
longitude: (map['Longitude'] ?? 0.0).toDouble(),
workforce: workforceRefs.whereType<DocumentReference>().toList(),
documents: docs,
);
}
@ -75,8 +90,12 @@ class EventModel {
'DisassemblyTime': disassemblyTime,
'EventType': eventTypeId,
'customer': customerId,
'Address': GeoPoint(address.latitude, address.longitude),
'Address': address,
'Position': GeoPoint(latitude, longitude),
'Latitude': latitude,
'Longitude': longitude,
'workforce': workforce,
'documents': documents,
};
}
}