jkg
This commit is contained in:
@@ -5,7 +5,8 @@ import 'package:flux/features/tickets/blocs/ticket_form_state.dart';
|
||||
import 'package:flux/features/tickets/models/ticket_model.dart';
|
||||
import 'package:flux/core/widgets/shared_forms/shared_customer_section.dart';
|
||||
import 'package:flux/core/widgets/shared_forms/shared_model_section.dart';
|
||||
import 'package:flux/core/widgets/shared_forms/shared_staff_section.dart'; // Il tuo widget agnostico dello staff
|
||||
import 'package:flux/core/widgets/shared_forms/shared_staff_section.dart';
|
||||
import 'package:flux/features/tickets/models/ticket_status_extension.dart'; // Il tuo widget agnostico dello staff
|
||||
|
||||
class TicketFormScreen extends StatefulWidget {
|
||||
final TicketModel? existingTicket;
|
||||
@@ -53,20 +54,26 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
||||
|
||||
// Sincronizza i controller con lo stato iniziale senza sovrascrivere se l'utente sta digitando
|
||||
void _syncTextControllers(TicketModel model) {
|
||||
if (_altPhoneCtrl.text.isEmpty)
|
||||
if (_altPhoneCtrl.text.isEmpty) {
|
||||
_altPhoneCtrl.text = model.alternativePhoneNumber ?? '';
|
||||
}
|
||||
if (_serialCtrl.text.isEmpty) _serialCtrl.text = model.targetSn ?? '';
|
||||
if (_requestCtrl.text.isEmpty) _requestCtrl.text = model.request ?? '';
|
||||
if (_accessoriesCtrl.text.isEmpty)
|
||||
if (_requestCtrl.text.isEmpty) _requestCtrl.text = model.request;
|
||||
if (_accessoriesCtrl.text.isEmpty) {
|
||||
_accessoriesCtrl.text = model.includedAccessories ?? '';
|
||||
if (_publicNotesCtrl.text.isEmpty)
|
||||
}
|
||||
if (_publicNotesCtrl.text.isEmpty) {
|
||||
_publicNotesCtrl.text = model.publicNotes ?? '';
|
||||
if (_internalNotesCtrl.text.isEmpty)
|
||||
}
|
||||
if (_internalNotesCtrl.text.isEmpty) {
|
||||
_internalNotesCtrl.text = model.internalNotes ?? '';
|
||||
if (_priceCtrl.text.isEmpty && model.customerPrice > 0)
|
||||
}
|
||||
if (_priceCtrl.text.isEmpty && model.customerPrice > 0) {
|
||||
_priceCtrl.text = model.customerPrice.toString();
|
||||
if (_costCtrl.text.isEmpty && model.internalCost > 0)
|
||||
}
|
||||
if (_costCtrl.text.isEmpty && model.internalCost > 0) {
|
||||
_costCtrl.text = model.internalCost.toString();
|
||||
}
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
@@ -143,10 +150,10 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
||||
padding: const EdgeInsets.only(right: 16.0),
|
||||
child: Chip(
|
||||
label: Text(
|
||||
ticket.status.name.toUpperCase(),
|
||||
ticket.ticketStatus!.name.toUpperCase(),
|
||||
style: const TextStyle(color: Colors.white, fontSize: 10),
|
||||
),
|
||||
backgroundColor: ticket.status.color,
|
||||
backgroundColor: ticket.ticketStatus.color,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -174,7 +181,7 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
||||
staffName: ticket.createdByName,
|
||||
onStaffSelected: (staff) =>
|
||||
context.read<TicketFormCubit>().updateCreator(
|
||||
staffId: staff.id,
|
||||
staffId: staff.id!,
|
||||
staffName: staff.name,
|
||||
),
|
||||
),
|
||||
@@ -254,7 +261,7 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: DropdownButtonFormField<TicketStatus>(
|
||||
value: ticket.status,
|
||||
value: ticket.ticketStatus,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Stato Attuale',
|
||||
),
|
||||
|
||||
@@ -192,8 +192,8 @@ class _TicketCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final statusColor = ticket.status?.color ?? Colors.grey;
|
||||
final statusIcon = ticket.status?.icon ?? Icons.help_outline;
|
||||
final statusColor = ticket.ticketStatus.color;
|
||||
final statusIcon = ticket.ticketStatus.icon;
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
|
||||
@@ -244,7 +244,7 @@ class _TicketCard extends StatelessWidget {
|
||||
Icon(statusIcon, size: 14, color: statusColor),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
ticket.status?.displayValue ?? 'N/D',
|
||||
ticket.ticketStatus.displayValue,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: statusColor,
|
||||
|
||||
Reference in New Issue
Block a user