maremma maiala impestata, buonissima base dopo ultra refactor
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -210,12 +210,40 @@ class OperationsCubit extends Cubit<OperationsState> {
|
||||
.toList();
|
||||
}
|
||||
|
||||
void updateField({String? customerId, String? customerDisplayName}) {
|
||||
// --- GESTIONE DELLO STATO DEL FORM IN TEMPO REALE ---
|
||||
void updateOperationFields({
|
||||
String? customerId,
|
||||
String? customerDisplayName,
|
||||
String? type,
|
||||
String? providerId,
|
||||
String? subtype,
|
||||
DateTime? expirationDate,
|
||||
int? quantity,
|
||||
// Aggiungiamo questi flag per forzare la pulizia dei campi quando cambi tipo
|
||||
bool clearProvider = false,
|
||||
bool clearType = false,
|
||||
bool clearSubtype = false,
|
||||
bool clearExpiration = false,
|
||||
}) {
|
||||
if (state.currentOperation == null) return;
|
||||
final updated = state.currentOperation!.copyWith(
|
||||
|
||||
final current = state.currentOperation!;
|
||||
|
||||
// Creiamo il modello aggiornato
|
||||
// ATTENZIONE: adatta questa logica in base a come è scritto il tuo copyWith!
|
||||
final updated = current.copyWith(
|
||||
customerId: customerId,
|
||||
customerDisplayName: customerDisplayName,
|
||||
type: clearType ? null : type,
|
||||
subtype: clearSubtype ? null : subtype,
|
||||
expirationDate: clearExpiration ? null : expirationDate,
|
||||
// Se clearProvider è true, forziamo una stringa vuota (o null se il tuo modello lo supporta)
|
||||
providerId: clearProvider ? null : (providerId ?? current.providerId),
|
||||
// Idem per subtype e date.
|
||||
// Se expirationDate è nullabile nel copyWith, dovresti poterlo gestire
|
||||
quantity: quantity ?? current.quantity,
|
||||
);
|
||||
|
||||
emit(state.copyWith(currentOperation: updated));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user