From 5dab11ee0cb077e96c1df2930941a26823a75a8c Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 6 Dec 2024 12:51:02 +1100 Subject: [PATCH] Bug fix for list filtering (#566) - Observe "tristate" values --- assets/release_notes.md | 2 ++ lib/widget/paginator.dart | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/assets/release_notes.md b/assets/release_notes.md index 93c8ad84..d1f0195a 100644 --- a/assets/release_notes.md +++ b/assets/release_notes.md @@ -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 --- diff --git a/lib/widget/paginator.dart b/lib/widget/paginator.dart index 44d30640..bc3df6d6 100644 --- a/lib/widget/paginator.dart +++ b/lib/widget/paginator.dart @@ -50,7 +50,9 @@ abstract class PaginatedSearchState extends Sta key = "${prefix}filter_${key}"; Map 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; @@ -59,7 +61,12 @@ abstract class PaginatedSearchState extends Sta // Set the boolean value of a particular boolean filter Future 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