mah....volare
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flux/core/enums_and_consts/consts.dart';
|
||||
import 'package:flux/core/utils/extensions.dart';
|
||||
import 'package:flux/features/attachments/models/attachment_model.dart';
|
||||
import 'package:flux/features/customers/models/customer_model.dart';
|
||||
import 'package:flux/features/master_data/providers/models/provider_model.dart';
|
||||
|
||||
enum OperationStatus {
|
||||
success('success', 'OK'),
|
||||
@@ -30,7 +31,6 @@ class OperationModel extends Equatable {
|
||||
final String type;
|
||||
final String? subType;
|
||||
final String? providerId;
|
||||
final String? providerDisplayName;
|
||||
final String? modelId;
|
||||
final String? modelDisplayName;
|
||||
final String? description;
|
||||
@@ -50,6 +50,7 @@ class OperationModel extends Equatable {
|
||||
final CustomerModel? customer;
|
||||
final String reference;
|
||||
final bool isBusiness;
|
||||
final ProviderModel? provider;
|
||||
|
||||
// ALLEGATI (Aggiunto)
|
||||
final List<AttachmentModel> attachments;
|
||||
@@ -60,7 +61,6 @@ class OperationModel extends Equatable {
|
||||
this.type = '',
|
||||
this.subType,
|
||||
this.providerId,
|
||||
this.providerDisplayName,
|
||||
this.modelId,
|
||||
this.modelDisplayName,
|
||||
this.description,
|
||||
@@ -81,6 +81,7 @@ class OperationModel extends Equatable {
|
||||
this.reference = '',
|
||||
this.attachments = const [],
|
||||
this.isBusiness = false,
|
||||
this.provider,
|
||||
});
|
||||
|
||||
OperationModel copyWith({
|
||||
@@ -88,8 +89,9 @@ class OperationModel extends Equatable {
|
||||
DateTime? createdAt,
|
||||
String? type,
|
||||
String? subType,
|
||||
String? providerId,
|
||||
String? providerDisplayName,
|
||||
// 🥷 TRUCCO APPLICATO ANCHE QUI:
|
||||
String? Function()? providerId,
|
||||
ProviderModel? Function()? provider,
|
||||
String? modelId,
|
||||
String? modelDisplayName,
|
||||
String? description,
|
||||
@@ -115,8 +117,10 @@ class OperationModel extends Equatable {
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
type: type ?? this.type,
|
||||
subType: subType ?? this.subType,
|
||||
providerId: providerId ?? this.providerId,
|
||||
providerDisplayName: providerDisplayName ?? this.providerDisplayName,
|
||||
// Se la funzione è passata, la eseguiamo (anche se ritorna null), altrimenti teniamo il vecchio
|
||||
providerId: providerId != null ? providerId() : this.providerId,
|
||||
provider: provider != null ? provider() : this.provider,
|
||||
|
||||
modelId: modelId ?? this.modelId,
|
||||
modelDisplayName: modelDisplayName ?? this.modelDisplayName,
|
||||
description: description ?? this.description,
|
||||
@@ -146,7 +150,7 @@ class OperationModel extends Equatable {
|
||||
type,
|
||||
subType,
|
||||
providerId,
|
||||
providerDisplayName,
|
||||
provider,
|
||||
modelId,
|
||||
modelDisplayName,
|
||||
description,
|
||||
@@ -185,8 +189,9 @@ class OperationModel extends Equatable {
|
||||
// I campi relazionali nullabili restano rigorosamente null!
|
||||
providerId: map['provider_id'] as String?,
|
||||
// MAGIA ANTI-CRASH: Usiamo ?['chiave'] per non far esplodere i join vuoti
|
||||
providerDisplayName: (map[Tables.providers]?['name'] as String?)
|
||||
?.myFormat(),
|
||||
provider: (map[Tables.providers] != null)
|
||||
? ProviderModel.fromMap(map[Tables.providers] as Map<String, dynamic>)
|
||||
: null,
|
||||
|
||||
modelId: map['model_id'] as String?,
|
||||
modelDisplayName: (map[Tables.models]?['name_with_brand'] as String?)
|
||||
|
||||
Reference in New Issue
Block a user