feat: add unit mapping functionality and confirmation dialog for unit changes in import process
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -206,6 +206,11 @@ class _EditDialogState extends State<EditDialog> {
|
||||
}
|
||||
|
||||
Future<void> _confirm() async {
|
||||
final originalUnit = widget.current.unit ?? widget.item.unit;
|
||||
final newUnit = _unitCtrl.text.trim().isEmpty ? originalUnit : _unitCtrl.text.trim();
|
||||
|
||||
await _confirmUnitChange(originalUnit!, newUnit);
|
||||
|
||||
if (_entryMode == ImportProductEntryMode.create) {
|
||||
final trimmedName = _newProductNameCtrl.text.trim();
|
||||
if (trimmedName.isEmpty) {
|
||||
@@ -281,6 +286,38 @@ class _EditDialogState extends State<EditDialog> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _confirmUnitChange(String originalUnit, String newUnit) async {
|
||||
if (originalUnit == newUnit) return;
|
||||
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Bekräfta enhetsändring'),
|
||||
content: Text(
|
||||
'Du försöker ändra enheten från "$originalUnit" till "$newUnit". Vill du fortsätta med denna ändring?',
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('Avbryt'),
|
||||
onPressed: () {
|
||||
_unitCtrl.text = originalUnit;
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Bekräfta'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// ── Build ──────────────────────────────────────────────────────────────────
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user