mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-12 18:25:26 +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:
@ -1,5 +1,6 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
||||
|
||||
import "package:inventree/api.dart";
|
||||
import "package:inventree/helpers.dart";
|
||||
@ -32,14 +33,31 @@ class _BillOfMaterialsState extends RefreshableState<BillOfMaterialsWidget> {
|
||||
|
||||
final InvenTreePart part;
|
||||
|
||||
bool showFilterOptions = false;
|
||||
|
||||
@override
|
||||
String getAppBarTitle(BuildContext context) => L10().billOfMaterials;
|
||||
|
||||
@override
|
||||
List<Widget> getAppBarActions(BuildContext context) => [
|
||||
IconButton(
|
||||
icon: FaIcon(FontAwesomeIcons.filter),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
showFilterOptions = !showFilterOptions;
|
||||
});
|
||||
},
|
||||
)
|
||||
];
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
return PaginatedBomList({
|
||||
"part": part.pk.toString(),
|
||||
});
|
||||
return PaginatedBomList(
|
||||
{
|
||||
"part": part.pk.toString(),
|
||||
},
|
||||
showFilterOptions,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,26 +65,18 @@ class _BillOfMaterialsState extends RefreshableState<BillOfMaterialsWidget> {
|
||||
/*
|
||||
* Create a paginated widget displaying a list of BomItem objects
|
||||
*/
|
||||
class PaginatedBomList extends StatefulWidget {
|
||||
class PaginatedBomList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedBomList(this.filters, {this.onTotalChanged});
|
||||
|
||||
final Map<String, String> filters;
|
||||
|
||||
final Function(int)? onTotalChanged;
|
||||
const PaginatedBomList(Map<String, String> filters, bool showSearch) : super(filters: filters, showSearch: showSearch);
|
||||
|
||||
@override
|
||||
_PaginatedBomListState createState() => _PaginatedBomListState(filters, onTotalChanged);
|
||||
|
||||
|
||||
_PaginatedBomListState createState() => _PaginatedBomListState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedBomListState extends PaginatedSearchState<PaginatedBomList> {
|
||||
|
||||
_PaginatedBomListState(Map<String, String> filters, this.onTotalChanged) : super(filters);
|
||||
|
||||
Function(int)? onTotalChanged;
|
||||
_PaginatedBomListState() : super();
|
||||
|
||||
@override
|
||||
String get prefix => "bom_";
|
||||
@ -77,6 +87,14 @@ class _PaginatedBomListState extends PaginatedSearchState<PaginatedBomList> {
|
||||
"sub_part": L10().part,
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
"sub_part_assembly": {
|
||||
"label": L10().filterAssembly,
|
||||
"help_text": L10().filterAssemblyDetail,
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
|
Reference in New Issue
Block a user