Skip to content

Commit

Permalink
Bug fix for list filtering (#566)
Browse files Browse the repository at this point in the history
- Observe "tristate" values
  • Loading branch information
SchrodingersGat authored Dec 6, 2024
1 parent 707d251 commit 5dab11e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions assets/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- Provide "upload image" shortcut on Purchase Order detail view
- Provide "upload image" shortcut on Sales Order detail view
- Clearly indicate if a StockItem is unavailable
- Improved list filtering management
- Updated translations

### 0.16.5 - September 2024
---
Expand Down
11 changes: 9 additions & 2 deletions lib/widget/paginator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
key = "${prefix}filter_${key}";

Map<String, dynamic> opts = filterOptions[key] ?? {};
dynamic backup = opts["default"];

bool tristate = (opts["tristate"] ?? true) as bool;
dynamic backup = tristate ? null : opts["default"];
final result = await InvenTreeSettingsManager().getValue(key, backup);

return result;
Expand All @@ -59,7 +61,12 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
// Set the boolean value of a particular boolean filter
Future<void> setFilterValue(String key, dynamic value) async {
key = "${prefix}filter_${key}";
await InvenTreeSettingsManager().setValue(key, value);

if (value == null) {
await InvenTreeSettingsManager().removeValue(key);
} else {
await InvenTreeSettingsManager().setValue(key, value);
}
}

// Construct the boolean filter options for this list
Expand Down

0 comments on commit 5dab11e

Please sign in to comment.