mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-12 18:25:26 +00:00
Major overhaul of "paginated list" widget class
- Simplify implementation - Create mixin class for code reuse - Allow custom app-bar - Allow custom ordering / sorting options - Improve code commenting / readability
This commit is contained in:
@ -17,48 +17,6 @@ import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Widget for displaying a list of BomItems for the specified 'parent' Part instance
|
||||
*/
|
||||
class BomList extends StatefulWidget {
|
||||
|
||||
const BomList(this.parent);
|
||||
|
||||
final InvenTreePart parent;
|
||||
|
||||
@override
|
||||
_BomListState createState() => _BomListState(parent);
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _BomListState extends PaginatedState<BomList> {
|
||||
|
||||
_BomListState(this.parent);
|
||||
|
||||
final InvenTreePart parent;
|
||||
|
||||
@override
|
||||
String getAppBarTitle(BuildContext context) => L10().billOfMaterials;
|
||||
|
||||
@override
|
||||
String get prefix => "bom_";
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"quantity": L10().quantity,
|
||||
"sub_part": L10().part,
|
||||
};
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
return PaginatedBomList({
|
||||
"part": parent.pk.toString(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create a paginated widget displaying a list of BomItem objects
|
||||
*/
|
||||
@ -78,13 +36,23 @@ class PaginatedBomList extends StatefulWidget {
|
||||
|
||||
class _PaginatedBomListState extends PaginatedSearchState<PaginatedBomList> {
|
||||
|
||||
_PaginatedBomListState(Map<String, String> filters, this.onTotalChanged) : super(filters);
|
||||
_PaginatedBomListState(Map<String, String> filters, this.onTotalChanged) : super(filters, fullscreen: true);
|
||||
|
||||
Function(int)? onTotalChanged;
|
||||
|
||||
@override
|
||||
String get prefix => "bom_";
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"quantity": L10().quantity,
|
||||
"sub_part": L10().part,
|
||||
};
|
||||
|
||||
|
||||
@override
|
||||
String getAppBarTitle(BuildContext context) => L10().billOfMaterials;
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
|
Reference in New Issue
Block a user