fix operations e tasks
This commit is contained in:
@@ -273,7 +273,6 @@ class OperationFormCubit extends Cubit<OperationFormState> {
|
||||
|
||||
final updatedOperation = current.copyWith(
|
||||
// Se newProvider è null, passiamo una funzione che ritorna null per sbiancare i campi!
|
||||
providerId: () => newProvider?.id,
|
||||
provider: () => newProvider,
|
||||
);
|
||||
|
||||
@@ -379,7 +378,6 @@ class OperationFormCubit extends Cubit<OperationFormState> {
|
||||
defaultDate, // Impostiamo la scadenza di default se calcolata
|
||||
// 🥷 APPLICHIAMO IL TRUCCO NINJA DELLE FUNZIONI
|
||||
// Se targetProvider è null, le funzioni ritorneranno null sbiancando il DB!
|
||||
providerId: () => targetProvider?.id,
|
||||
provider: () => targetProvider,
|
||||
|
||||
// Nota: Per azzerare davvero questi due, ricordati in futuro di applicare
|
||||
|
||||
@@ -59,7 +59,7 @@ class OperationsRepository {
|
||||
*,
|
||||
${Tables.customers}(*),
|
||||
${Tables.stores}(name),
|
||||
${Tables.providers}(name, color_hex),
|
||||
${Tables.providers}(*),
|
||||
${Tables.models}(name_with_brand),
|
||||
${Tables.staffMembers}(name),
|
||||
${Tables.attachments}(*)
|
||||
|
||||
@@ -30,7 +30,6 @@ class OperationModel extends Equatable {
|
||||
final DateTime? createdAt;
|
||||
final String type;
|
||||
final String? subType;
|
||||
final String? providerId;
|
||||
final String? modelId;
|
||||
final String? modelDisplayName;
|
||||
final String? description;
|
||||
@@ -60,7 +59,6 @@ class OperationModel extends Equatable {
|
||||
this.createdAt,
|
||||
this.type = '',
|
||||
this.subType,
|
||||
this.providerId,
|
||||
this.modelId,
|
||||
this.modelDisplayName,
|
||||
this.description,
|
||||
@@ -90,7 +88,6 @@ class OperationModel extends Equatable {
|
||||
String? type,
|
||||
String? subType,
|
||||
// 🥷 TRUCCO APPLICATO ANCHE QUI:
|
||||
String? Function()? providerId,
|
||||
ProviderModel? Function()? provider,
|
||||
String? modelId,
|
||||
String? modelDisplayName,
|
||||
@@ -118,7 +115,6 @@ class OperationModel extends Equatable {
|
||||
type: type ?? this.type,
|
||||
subType: subType ?? this.subType,
|
||||
// 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,
|
||||
@@ -149,7 +145,6 @@ class OperationModel extends Equatable {
|
||||
createdAt,
|
||||
type,
|
||||
subType,
|
||||
providerId,
|
||||
provider,
|
||||
modelId,
|
||||
modelDisplayName,
|
||||
@@ -187,8 +182,6 @@ class OperationModel extends Equatable {
|
||||
subType: map['sub_type'] as String?,
|
||||
|
||||
// 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
|
||||
provider: (map[Tables.providers] != null)
|
||||
? ProviderModel.fromMap(map[Tables.providers] as Map<String, dynamic>)
|
||||
: null,
|
||||
@@ -243,7 +236,7 @@ class OperationModel extends Equatable {
|
||||
if (id != null) 'id': id,
|
||||
'type': type,
|
||||
'sub_type': subType,
|
||||
'provider_id': providerId,
|
||||
'provider_id': provider?.id,
|
||||
'model_id': modelId,
|
||||
'description': description,
|
||||
if (expirationDate != null)
|
||||
|
||||
@@ -571,7 +571,7 @@ class _RichOperationCard extends StatelessWidget {
|
||||
),
|
||||
|
||||
// Tag Gestore (Agganciato dinamicamente al displayColor generato dall'esadecimale del DB!)
|
||||
if (operation.providerId != null)
|
||||
if (operation.provider != null)
|
||||
_MiniChip(
|
||||
label: operation.provider?.name ?? 'Gestore',
|
||||
color:
|
||||
|
||||
@@ -138,13 +138,13 @@ class OperationDetailsSection extends StatelessWidget {
|
||||
: 'Nessun gestore selezionato',
|
||||
style: TextStyle(
|
||||
color:
|
||||
(currentOp?.providerId == null ||
|
||||
currentOp!.providerId!.isEmpty)
|
||||
(currentOp?.provider == null ||
|
||||
currentOp!.provider!.name.isEmpty)
|
||||
? Colors.grey
|
||||
: null,
|
||||
fontWeight:
|
||||
(currentOp?.providerId == null ||
|
||||
currentOp!.providerId!.isEmpty)
|
||||
(currentOp?.provider == null ||
|
||||
currentOp!.provider!.name.isEmpty)
|
||||
? FontWeight.normal
|
||||
: FontWeight.bold,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user