mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-16 20:25:26 +00:00
Format code
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
|
||||
@ -14,13 +13,13 @@ import "package:inventree/widget/paginator.dart";
|
||||
import "package:inventree/widget/progress.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Widget for displaying a Bill of Materials for a specified Part instance
|
||||
*/
|
||||
class BillOfMaterialsWidget extends StatefulWidget {
|
||||
|
||||
const BillOfMaterialsWidget(this.part, {this.isParentComponent = true, Key? key}) : super(key: key);
|
||||
const BillOfMaterialsWidget(this.part,
|
||||
{this.isParentComponent = true, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
final InvenTreePart part;
|
||||
|
||||
@ -46,19 +45,18 @@ class _BillOfMaterialsState extends RefreshableState<BillOfMaterialsWidget> {
|
||||
|
||||
@override
|
||||
List<Widget> appBarActions(BuildContext context) => [
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.filter),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
showFilterOptions = !showFilterOptions;
|
||||
});
|
||||
},
|
||||
)
|
||||
];
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.filter),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
showFilterOptions = !showFilterOptions;
|
||||
});
|
||||
},
|
||||
)
|
||||
];
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
|
||||
Map<String, String> filters = {};
|
||||
|
||||
if (widget.isParentComponent) {
|
||||
@ -72,7 +70,9 @@ class _BillOfMaterialsState extends RefreshableState<BillOfMaterialsWidget> {
|
||||
ListTile(
|
||||
leading: InvenTreeAPI().getThumbnail(widget.part.thumbnail),
|
||||
title: Text(widget.part.fullname),
|
||||
subtitle: Text(widget.isParentComponent ? L10().billOfMaterials : L10().usedInDetails),
|
||||
subtitle: Text(widget.isParentComponent
|
||||
? L10().billOfMaterials
|
||||
: L10().usedInDetails),
|
||||
trailing: Text(L10().quantity),
|
||||
),
|
||||
Divider(thickness: 1.25),
|
||||
@ -87,13 +87,13 @@ class _BillOfMaterialsState extends RefreshableState<BillOfMaterialsWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create a paginated widget displaying a list of BomItem objects
|
||||
*/
|
||||
class PaginatedBomList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedBomList(Map<String, String> filters, {this.isParentPart = true}) : super(filters: filters);
|
||||
const PaginatedBomList(Map<String, String> filters,
|
||||
{this.isParentPart = true})
|
||||
: super(filters: filters);
|
||||
|
||||
final bool isParentPart;
|
||||
|
||||
@ -104,9 +104,7 @@ class PaginatedBomList extends PaginatedSearchWidget {
|
||||
_PaginatedBomListState createState() => _PaginatedBomListState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedBomListState extends PaginatedSearchState<PaginatedBomList> {
|
||||
|
||||
_PaginatedBomListState() : super();
|
||||
|
||||
@override
|
||||
@ -114,32 +112,33 @@ class _PaginatedBomListState extends PaginatedSearchState<PaginatedBomList> {
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"quantity": L10().quantity,
|
||||
"sub_part": L10().part,
|
||||
};
|
||||
"quantity": L10().quantity,
|
||||
"sub_part": L10().part,
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
"sub_part_assembly": {
|
||||
"label": L10().filterAssembly,
|
||||
"help_text": L10().filterAssemblyDetail,
|
||||
}
|
||||
};
|
||||
"sub_part_assembly": {
|
||||
"label": L10().filterAssembly,
|
||||
"help_text": L10().filterAssemblyDetail,
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
final page = await InvenTreeBomItem().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page =
|
||||
await InvenTreeBomItem().listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreeBomItem bomItem = model as InvenTreeBomItem;
|
||||
|
||||
InvenTreePart? subPart = widget.isParentPart ? bomItem.subPart : bomItem.part;
|
||||
InvenTreePart? subPart =
|
||||
widget.isParentPart ? bomItem.subPart : bomItem.part;
|
||||
|
||||
String title = subPart?.fullname ?? "error - no name";
|
||||
|
||||
@ -151,16 +150,17 @@ class _PaginatedBomListState extends PaginatedSearchState<PaginatedBomList> {
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
leading: InvenTreeAPI().getThumbnail(subPart?.thumbnail ?? ""),
|
||||
onTap: subPart == null ? null : () async {
|
||||
onTap: subPart == null
|
||||
? null
|
||||
: () async {
|
||||
showLoadingOverlay();
|
||||
var part = await InvenTreePart().get(subPart.pk);
|
||||
hideLoadingOverlay();
|
||||
|
||||
showLoadingOverlay();
|
||||
var part = await InvenTreePart().get(subPart.pk);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user