Skip to content

Commit a889c4a

Browse files
Filter fix (#473)
* Add check for "null" top level locations and categories * Fix API - Top level location and category broken after API 174 - Ref: inventree/InvenTree#6536
1 parent 1d41d22 commit a889c4a

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

assets/release_notes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
### 0.14.2 - January 2024
1+
### 0.14.2 - February 2024
22
---
33

44
- Updated error reporting
5+
- Support for updated server API endpoints
6+
- Updated translations
57

68
### 0.14.1 - January 2024
79
---

lib/api.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ class InvenTreeAPI {
339339
// Does the server support allocating stock to sales order using barcodes?
340340
bool get supportsBarcodeSOAllocateEndpoint => isConnected() && apiVersion >= 160;
341341

342+
// Does the server support "null" top-level filtering for PartCategory and StockLocation endpoints?
343+
bool get supportsNullTopLevelFiltering => isConnected() && apiVersion < 174;
344+
342345
// Cached list of plugins (refreshed when we connect to the server)
343346
List<InvenTreePlugin> _plugins = [];
344347

lib/widget/part/category_display.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,21 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
200200
// Construct the "details" panel
201201
List<Widget> detailTiles() {
202202

203+
Map<String, String> filters = {};
204+
205+
int? parent = widget.category?.pk;
206+
207+
if (parent != null) {
208+
filters["parent"] = parent.toString();
209+
} else if (api.supportsNullTopLevelFiltering) {
210+
filters["parent"] = "null";
211+
}
212+
203213
List<Widget> tiles = <Widget>[
204214
getCategoryDescriptionCard(),
205215
Expanded(
206216
child: PaginatedPartCategoryList(
207-
{
208-
"parent": widget.category?.pk.toString() ?? "null"
209-
},
217+
filters,
210218
title: L10().subcategories,
211219
),
212220
flex: 10,

lib/widget/stock/location_display.dart

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,22 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
393393

394394
// Construct the "details" panel
395395
List<Widget> detailTiles() {
396+
397+
Map<String, String> filters = {};
398+
399+
int? parent = location?.pk;
400+
401+
if (parent != null) {
402+
filters["parent"] = parent.toString();
403+
} else if (api.supportsNullTopLevelFiltering) {
404+
filters["parent"] = "null";
405+
}
406+
396407
List<Widget> tiles = [
397408
locationDescriptionCard(),
398409
Expanded(
399410
child: PaginatedStockLocationList(
400-
{
401-
"parent": location?.pk.toString() ?? "null",
402-
},
411+
filters,
403412
title: L10().sublocations,
404413
),
405414
flex: 10,

0 commit comments

Comments
 (0)