fg
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flux/core/widgets/shared_forms/customer_section.dart';
|
||||
import 'package:flux/core/widgets/shared_forms/model_section.dart';
|
||||
import 'package:flux/core/widgets/shared_forms/shared_files_section.dart';
|
||||
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
|
||||
import 'package:flux/features/tickets/blocs/ticket_form_cubit.dart';
|
||||
import 'package:flux/features/tickets/blocs/ticket_form_state.dart';
|
||||
import 'package:flux/features/tickets/models/ticket_model.dart';
|
||||
@@ -99,6 +100,25 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<String?> _generateIdForQr() async {
|
||||
// 1. Validiamo i campi obbligatori (es. il cliente)
|
||||
if (!_formKey.currentState!.validate()) return null;
|
||||
|
||||
// 2. Sincronizziamo i testi scritti a mano nel Cubit
|
||||
_flushControllersToCubit();
|
||||
|
||||
// 3. Facciamo il salvataggio silenzioso
|
||||
final newId = await context.read<TicketFormCubit>().saveTicketDraft();
|
||||
|
||||
if (newId != null && context.mounted) {
|
||||
// 4. IL TOCCO DI CLASSE: Diciamo all'AttachmentsBloc che ora la pratica ha un ID!
|
||||
// Questo farà partire l'upload automatico di eventuali file "in bozza"
|
||||
context.read<AttachmentsBloc>().add(ParentEntitySavedEvent(newId));
|
||||
}
|
||||
|
||||
return newId;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
@@ -514,7 +534,12 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
||||
// ECCO LA MAGIA:
|
||||
SharedFilesSection(
|
||||
titleNameForUpload: ticket.customerName ?? 'Nuovo Ticket',
|
||||
onGenerateIdForQr: _generateIdForQr,
|
||||
),
|
||||
/* SharedAttachmentsSection(
|
||||
parentType: AttachmentParentType.ticket,
|
||||
parentId: ticket.id,
|
||||
), */
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user