2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-07-30 17:21:28 +00:00

Improve error management for label printing (#588)

- Handle empty label
- Handle empty printer
This commit is contained in:
Oliver
2024-12-23 10:36:36 +11:00
committed by GitHub
parent bc44b99d43
commit d84f76d482
3 changed files with 39 additions and 0 deletions

View File

@@ -982,6 +982,7 @@ Future<void> launchApiForm(
Map<String, dynamic> modelData = const {},
String method = "PATCH",
Function(Map<String, dynamic>)? onSuccess,
bool Function(Map<String, dynamic>)? validate,
Function? onCancel,
IconData icon = TablerIcons.device_floppy
}) async {
@@ -1071,6 +1072,7 @@ Future<void> launchApiForm(
formFields,
method,
onSuccess: onSuccess,
validate: validate,
fileField: fileField,
icon: icon,
))
@@ -1088,6 +1090,7 @@ class APIFormWidget extends StatefulWidget {
{
Key? key,
this.onSuccess,
this.validate,
this.fileField = "",
this.icon = TablerIcons.device_floppy,
}
@@ -1111,6 +1114,8 @@ class APIFormWidget extends StatefulWidget {
final Function(Map<String, dynamic>)? onSuccess;
final bool Function(Map<String, dynamic>)? validate;
@override
_APIFormWidgetState createState() => _APIFormWidgetState();
@@ -1401,6 +1406,12 @@ class _APIFormWidgetState extends State<APIFormWidget> {
}
}
}
final bool isValid = widget.validate?.call(data) ?? true;
if (!isValid) {
return;
}
// Run custom onSuccess function
var successFunc = widget.onSuccess;