This commit is contained in:
2026-05-19 16:00:40 +02:00
parent 364474471c
commit 8a1b582f4e
5 changed files with 62 additions and 47 deletions

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flux/core/widgets/shared_forms/attachments_section.dart';
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
import 'package:flux/features/operations/blocs/operation_form_cubit.dart';
import 'package:flux/features/operations/models/operation_model.dart';
@@ -39,7 +40,7 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
'Energy',
'Fin',
'Entertainment',
'Custom',
'Altro',
];
bool _isInitialized = false;
@@ -113,9 +114,10 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
Future<String?> _generateIdForQr() async {
if (!_formKey.currentState!.validate()) return null;
_flushControllersToCubit();
// Lo leggiamo pulito pulito dal context, perché c'è!
final attachmentsBloc = context.read<AttachmentsBloc>();
// Assicurati che questo metodo esista nel Cubit (come per il Ticket)
final newId = await context.read<OperationFormCubit>().saveOperationDraft();
if (newId != null && context.mounted) {
attachmentsBloc.add(ParentEntitySavedEvent(newId));
@@ -602,8 +604,10 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
icon: Icons.attach_file,
themeColor: Colors.deepPurple,
children: [
SharedFilesSection(
titleNameForUpload: state.operation.customer?.name ?? 'Nuova Pratica',
SharedAttachmentsSection(
parentType: AttachmentParentType.operation,
parentId: state.operation.id,
titleForUpload: state.operation.customer?.name ?? 'Nuova Pratica',
onGenerateIdForQr: _generateIdForQr,
),
],