2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-12-03 18:59:50 +00:00

Modern Label printing (#724)

* Basic widget

* Redirect label printing action

* Refactor label printing code

* Construct form elements

* Refactor to allow re-use of forms

* Basic rendering of label printing form

* Remove dead code

* Pass custom handler through to form context

* Refactoring API forms:

- Allow custom pk field name
- Add callback when values change

* linting

* Dynamically rebuild form

* Handle nested fields

* Handle label printing status

* Run dart format

* Update release notes

* Remove unused var

* Enable close icon

* Handle initial plugin default value

* Store default values:

- Selected template (per label type)
- Selected printing plugin

* Dart format

* Fix dart linting

* use setter

* Just use a public field
This commit is contained in:
Oliver
2025-11-22 07:26:37 +11:00
committed by GitHub
parent e41842a31d
commit 13d95dd1b1
10 changed files with 425 additions and 368 deletions

View File

@@ -7,6 +7,7 @@ import "package:http/http.dart" as http;
import "package:http/io_client.dart";
import "package:intl/intl.dart";
import "package:inventree/main.dart";
import "package:inventree/widget/progress.dart";
import "package:one_context/one_context.dart";
import "package:open_filex/open_filex.dart";
import "package:cached_network_image/cached_network_image.dart";
@@ -912,6 +913,8 @@ class InvenTreeAPI {
var client = createClient(url, strictHttps: strictHttps);
showLoadingOverlay();
// Attempt to open a connection to the server
try {
_request = await client
@@ -953,6 +956,7 @@ class InvenTreeAPI {
await localFile.writeAsBytes(bytes);
if (openOnDownload) {
hideLoadingOverlay();
OpenFilex.open(local_path);
}
} else {
@@ -972,6 +976,8 @@ class InvenTreeAPI {
stackTrace,
);
}
hideLoadingOverlay();
}
/*
@@ -1085,8 +1091,15 @@ class InvenTreeAPI {
* We send this with the currently selected "locale",
* so that (hopefully) the field messages are correctly translated
*/
Future<APIResponse> options(String url) async {
HttpClientRequest? request = await apiRequest(url, "OPTIONS");
Future<APIResponse> options(
String url, {
Map<String, String> params = const {},
}) async {
HttpClientRequest? request = await apiRequest(
url,
"OPTIONS",
urlParams: params,
);
if (request == null) {
// Return an "invalid" APIResponse