2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-13 10:45:29 +00:00

List refactor (#179)

* Catch paginator bug if widget is disposed before request returns

* Refactoring paginated query widget

- Add option to enable / disable search filters

* Major refactor of paginated search widget

- Learned something new.. a state can access widget.<attribute>
- THIS CHANGES EVERTHING

* Preferences: Add code for tri-state values

- Also improve unit testing for preferences code

* Allow boolean form fields to be optionally tristate

* paginator: Allow custom boolean filters

* Remove outdated filtering preferences

* Refactor filter options

- Allow specification of more detailed options

* Add custom filters for "part" list

* filter tweaks

* Remove legacy "SublocationList" widget

* Add filtering option for locationlist

* Updates for stock location widget

* Refactor category display widget

* More widget refactoring

* Update main search widget

* Fix unit tests

* Improve filtering on BOM display page
This commit is contained in:
Oliver
2022-07-19 23:29:01 +10:00
committed by GitHub
parent e03a8561b9
commit 13ebaf43e1
23 changed files with 667 additions and 403 deletions

View File

@ -16,9 +16,6 @@ const String INV_HOME_SHOW_SUPPLIERS = "homeShowSuppliers";
const String INV_SOUNDS_BARCODE = "barcodeSounds";
const String INV_SOUNDS_SERVER = "serverSounds";
const String INV_PART_SUBCATEGORY = "partSubcategory";
const String INV_STOCK_SUBLOCATION = "stockSublocation";
const String INV_STOCK_SHOW_HISTORY = "stockShowHistory";
const String INV_REPORT_ERRORS = "reportErrors";
@ -86,6 +83,11 @@ class InvenTreeSettingsManager {
Future<Database> get _db async => InvenTreePreferencesDB.instance.database;
Future<void> removeValue(String key) async {
await store.record(key).delete(await _db);
}
Future<dynamic> getValue(String key, dynamic backup) async {
final value = await store.record(key).get(await _db);
@ -103,13 +105,40 @@ class InvenTreeSettingsManager {
if (value is bool) {
return value;
} else if (value is String) {
return value.toLowerCase().contains("t");
} else {
return backup;
return false;
}
}
// Load a tristate (true / false / null) setting
Future<bool?> getTriState(String key, dynamic backup) async {
final dynamic value = await getValue(key, backup);
if (value == null) {
return null;
} else if (value is bool) {
return value;
} else {
String s = value.toString().toLowerCase();
if (s.contains("t")) {
return true;
} else if (s.contains("f")) {
return false;
} else {
return null;
}
}
}
// Store a key:value pair in the database
Future<void> setValue(String key, dynamic value) async {
// Encode null values as strings
value ??= "null";
await store.record(key).put(await _db, value);
}