Skip to content

Commit

Permalink
add api check thingy
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Schlecht committed Sep 15, 2023
1 parent ba6415d commit 0708ce4
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 36 deletions.
2 changes: 2 additions & 0 deletions lib/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ class InvenTreeAPI {
// Does the server support extra fields on stock adjustment actions?
bool get supportsStockAdjustExtraFields => isConnected() && apiVersion >= 133;

bool get supportsBarcodePOReceiveEndpoint => isConnected() && apiVersion >= 135;

// Are plugins enabled on the server?
bool _pluginsEnabled = false;

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,9 @@
"scanIntoLocationDetail": "Scan this item into location",
"@scanIntoLocationDetail": {},

"scanReceivedParts": "Scan Received Parts",
"@scanReceivedParts": {},

"search": "Search",
"@search": {
"description": "search"
Expand Down
26 changes: 14 additions & 12 deletions lib/widget/location_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,20 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
);
}

actions.add(
SpeedDialChild(
child: FaIcon(FontAwesomeIcons.rightToBracket, color: Colors.blue),
label: L10().scanReceivedItem,
onTap:() async {
scanBarcode(
context,
handler: POReceiveBarcodeHandler(location: location),
);
},
)
);
if (api.supportsBarcodePOReceiveEndpoint) {
actions.add(
SpeedDialChild(
child: Icon(Icons.barcode_reader),
label: L10().scanReceivedParts,
onTap:() async {
scanBarcode(
context,
handler: POReceiveBarcodeHandler(location: location),
);
},
)
);
}

// Scan this location into another one
if (InvenTreeStockLocation().canEdit) {
Expand Down
26 changes: 14 additions & 12 deletions lib/widget/purchase_order_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,20 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
List<SpeedDialChild> barcodeButtons(BuildContext context) {
List<SpeedDialChild> actions = [];

actions.add(
SpeedDialChild(
child: FaIcon(FontAwesomeIcons.rightToBracket, color: Colors.blue),
label: L10().scanReceivedItem,
onTap:() async {
scanBarcode(
context,
handler: POReceiveBarcodeHandler(purchaseOrder: order),
);
},
)
);
if (api.supportsBarcodePOReceiveEndpoint) {
actions.add(
SpeedDialChild(
child: Icon(Icons.barcode_reader),
label: L10().scanReceivedParts,
onTap:() async {
scanBarcode(
context,
handler: POReceiveBarcodeHandler(purchaseOrder: order),
);
},
)
);
}

return actions;
}
Expand Down
26 changes: 14 additions & 12 deletions lib/widget/purchase_order_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,20 @@ class _PurchaseOrderListWidgetState extends RefreshableState<PurchaseOrderListWi
List<SpeedDialChild> barcodeButtons(BuildContext context) {
List<SpeedDialChild> actions = [];

actions.add(
SpeedDialChild(
child: FaIcon(FontAwesomeIcons.rightToBracket, color: Colors.blue),
label: L10().scanReceivedItem,
onTap:() async {
scanBarcode(
context,
handler: POReceiveBarcodeHandler(),
);
},
)
);
if (api.supportsBarcodePOReceiveEndpoint) {
actions.add(
SpeedDialChild(
child: Icon(Icons.barcode_reader),
label: L10().scanReceivedParts,
onTap:() async {
scanBarcode(
context,
handler: POReceiveBarcodeHandler(),
);
},
)
);
}

return actions;
}
Expand Down

0 comments on commit 0708ce4

Please sign in to comment.