2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 10:15:32 +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

@ -1,11 +1,11 @@
import "package:flutter/material.dart";
import "package:font_awesome_flutter/font_awesome_flutter.dart";
import "package:inventree/inventree/model.dart";
import "package:inventree/inventree/stock.dart";
import "package:inventree/widget/paginator.dart";
import "package:inventree/widget/refreshable_state.dart";
import "package:inventree/l10.dart";
import "package:inventree/preferences.dart";
import "package:inventree/widget/stock_detail.dart";
import "package:inventree/api.dart";
@ -27,30 +27,42 @@ class _StockListState extends RefreshableState<StockItemList> {
final Map<String, String> filters;
bool showFilterOptions = false;
@override
String getAppBarTitle(BuildContext context) => L10().stockItems;
@override
List<Widget> getAppBarActions(BuildContext context) => [
IconButton(
icon: FaIcon(FontAwesomeIcons.filter),
onPressed: () async {
setState(() {
showFilterOptions = !showFilterOptions;
});
},
)
];
@override
Widget getBody(BuildContext context) {
return PaginatedStockItemList(filters);
return PaginatedStockItemList(filters, showFilterOptions);
}
}
class PaginatedStockItemList extends StatefulWidget {
class PaginatedStockItemList extends PaginatedSearchWidget {
const PaginatedStockItemList(this.filters);
final Map<String, String> filters;
const PaginatedStockItemList(Map<String, String> filters, bool showSearch) : super(filters: filters, showSearch: showSearch);
@override
_PaginatedStockItemListState createState() => _PaginatedStockItemListState(filters);
_PaginatedStockItemListState createState() => _PaginatedStockItemListState();
}
class _PaginatedStockItemListState extends PaginatedSearchState<PaginatedStockItemList> {
_PaginatedStockItemListState(Map<String, String> filters) : super(filters);
_PaginatedStockItemListState() : super();
@override
String get prefix => "stock_";
@ -66,14 +78,23 @@ class _PaginatedStockItemListState extends PaginatedSearchState<PaginatedStockIt
"stocktake_date": L10().lastStocktake,
};
@override
Map<String, Map<String, dynamic>> get filterOptions => {
"cascade": {
"default": false,
"label": L10().includeSublocations,
"help_text": L10().includeSublocationsDetail,
"tristate": false,
},
"serialized": {
"label": L10().filterSerialized,
"help_text": L10().filterSerializedDetail,
}
};
@override
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
// Do we include stock items from sub-locations?
final bool cascade = await InvenTreeSettingsManager().getBool(INV_STOCK_SUBLOCATION, true);
params["cascade"] = "${cascade}";
final page = await InvenTreeStockItem().listPaginated(
limit,
offset,