mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Print label key (#491)
* We now use the plugin key for printing labels * Bump API version for modern label printing * Fix typo
This commit is contained in:
parent
9a6e1e6381
commit
541060aa03
@ -346,7 +346,7 @@ class InvenTreeAPI {
|
|||||||
bool get supportsCompanyActiveStatus => isConnected() && apiVersion >= 189;
|
bool get supportsCompanyActiveStatus => isConnected() && apiVersion >= 189;
|
||||||
|
|
||||||
// Does the server support the "modern" (consolidated) label printing API?
|
// Does the server support the "modern" (consolidated) label printing API?
|
||||||
bool get supportsModenLabelPrinting => isConnected() && apiVersion >= 197;
|
bool get supportsModernLabelPrinting => isConnected() && apiVersion >= 198;
|
||||||
|
|
||||||
// Cached list of plugins (refreshed when we connect to the server)
|
// Cached list of plugins (refreshed when we connect to the server)
|
||||||
List<InvenTreePlugin> _plugins = [];
|
List<InvenTreePlugin> _plugins = [];
|
||||||
|
@ -59,7 +59,7 @@ Future<void> selectAndPrintLabel(
|
|||||||
for (var plugin in plugins) {
|
for (var plugin in plugins) {
|
||||||
plugin_options.add({
|
plugin_options.add({
|
||||||
"display_name": plugin.humanName,
|
"display_name": plugin.humanName,
|
||||||
"value": InvenTreeAPI().supportsModenLabelPrinting ? plugin.pk : plugin.key
|
"value": plugin.key,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ Future<void> selectAndPrintLabel(
|
|||||||
|
|
||||||
showLoadingOverlay(context);
|
showLoadingOverlay(context);
|
||||||
|
|
||||||
if (InvenTreeAPI().supportsModenLabelPrinting) {
|
if (InvenTreeAPI().supportsModernLabelPrinting) {
|
||||||
|
|
||||||
// Modern label printing API uses a POST request to a single API endpoint.
|
// Modern label printing API uses a POST request to a single API endpoint.
|
||||||
await InvenTreeAPI().post(
|
await InvenTreeAPI().post(
|
||||||
@ -178,7 +178,7 @@ Future<List<Map<String, dynamic>>> getLabelTemplates(
|
|||||||
|
|
||||||
String url = "/label/template/";
|
String url = "/label/template/";
|
||||||
|
|
||||||
if (InvenTreeAPI().supportsModenLabelPrinting) {
|
if (InvenTreeAPI().supportsModernLabelPrinting) {
|
||||||
data["model_type"] = labelType;
|
data["model_type"] = labelType;
|
||||||
} else {
|
} else {
|
||||||
// Legacy label printing API endpoint
|
// Legacy label printing API endpoint
|
||||||
|
@ -250,8 +250,8 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
|
|
||||||
if (allowLabelPrinting) {
|
if (allowLabelPrinting) {
|
||||||
|
|
||||||
String model_type = api.supportsModenLabelPrinting ? InvenTreePart().MODEL_TYPE : "part";
|
String model_type = api.supportsModernLabelPrinting ? InvenTreePart().MODEL_TYPE : "part";
|
||||||
String item_key = api.supportsModenLabelPrinting ? "items" : "part";
|
String item_key = api.supportsModernLabelPrinting ? "items" : "part";
|
||||||
|
|
||||||
_labels = await getLabelTemplates(
|
_labels = await getLabelTemplates(
|
||||||
model_type,
|
model_type,
|
||||||
|
@ -249,8 +249,8 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
|||||||
|
|
||||||
if (widget.location != null) {
|
if (widget.location != null) {
|
||||||
|
|
||||||
String model_type = api.supportsModenLabelPrinting ? InvenTreeStockLocation().MODEL_TYPE : "location";
|
String model_type = api.supportsModernLabelPrinting ? InvenTreeStockLocation().MODEL_TYPE : "location";
|
||||||
String item_key = api.supportsModenLabelPrinting ? "items" : "location";
|
String item_key = api.supportsModernLabelPrinting ? "items" : "location";
|
||||||
|
|
||||||
_labels = await getLabelTemplates(
|
_labels = await getLabelTemplates(
|
||||||
model_type,
|
model_type,
|
||||||
|
@ -266,8 +266,8 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
// Request information on labels available for this stock item
|
// Request information on labels available for this stock item
|
||||||
if (allowLabelPrinting) {
|
if (allowLabelPrinting) {
|
||||||
|
|
||||||
String model_type = api.supportsModenLabelPrinting ? InvenTreeStockLocation().MODEL_TYPE : "stock";
|
String model_type = api.supportsModernLabelPrinting ? InvenTreeStockLocation().MODEL_TYPE : "stock";
|
||||||
String item_key = api.supportsModenLabelPrinting ? "items" : "item";
|
String item_key = api.supportsModernLabelPrinting ? "items" : "item";
|
||||||
|
|
||||||
// Clear the existing labels list
|
// Clear the existing labels list
|
||||||
_labels = await getLabelTemplates(
|
_labels = await getLabelTemplates(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user