mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-16 12:15:31 +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);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,7 @@ import "package:inventree/widget/progress.dart";
|
||||
import "package:inventree/widget/snacks.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
class CategoryDisplayWidget extends StatefulWidget {
|
||||
|
||||
const CategoryDisplayWidget(this.category, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreePartCategory? category;
|
||||
@ -24,9 +22,7 @@ class CategoryDisplayWidget extends StatefulWidget {
|
||||
_CategoryDisplayState createState() => _CategoryDisplayState();
|
||||
}
|
||||
|
||||
|
||||
class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
|
||||
_CategoryDisplayState();
|
||||
|
||||
@override
|
||||
@ -38,15 +34,13 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
|
||||
if (widget.category != null) {
|
||||
if (InvenTreePartCategory().canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editCategory,
|
||||
onPressed: () {
|
||||
_editCategoryDialog(context);
|
||||
},
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editCategory,
|
||||
onPressed: () {
|
||||
_editCategoryDialog(context);
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,25 +52,20 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (InvenTreePart().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.box),
|
||||
label: L10().partCreateDetail,
|
||||
onTap: _newPart,
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.box),
|
||||
label: L10().partCreateDetail,
|
||||
onTap: _newPart,
|
||||
));
|
||||
}
|
||||
|
||||
if (InvenTreePartCategory().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.sitemap),
|
||||
label: L10().categoryCreateDetail,
|
||||
onTap: () {
|
||||
_newCategory(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -90,14 +79,10 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
return;
|
||||
}
|
||||
|
||||
_cat.editForm(
|
||||
context,
|
||||
L10().editCategory,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().categoryUpdated, success: true);
|
||||
}
|
||||
);
|
||||
_cat.editForm(context, L10().editCategory, onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().categoryUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -107,7 +92,6 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
|
||||
@override
|
||||
Future<void> request(BuildContext context) async {
|
||||
|
||||
// Update the category
|
||||
if (widget.category != null) {
|
||||
final bool result = await widget.category?.reload() ?? false;
|
||||
@ -121,67 +105,60 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
Widget getCategoryDescriptionCard({bool extra = true}) {
|
||||
if (widget.category == null) {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
leading: Icon(TablerIcons.packages),
|
||||
title: Text(
|
||||
L10().partCategoryTopLevel,
|
||||
style: TextStyle(fontStyle: FontStyle.italic),
|
||||
)
|
||||
)
|
||||
);
|
||||
child: ListTile(
|
||||
leading: Icon(TablerIcons.packages),
|
||||
title: Text(
|
||||
L10().partCategoryTopLevel,
|
||||
style: TextStyle(fontStyle: FontStyle.italic),
|
||||
)));
|
||||
} else {
|
||||
|
||||
List<Widget> children = [
|
||||
ListTile(
|
||||
title: Text("${widget.category?.name}",
|
||||
style: TextStyle(fontWeight: FontWeight.bold)
|
||||
),
|
||||
subtitle: Text("${widget.category?.description}"),
|
||||
leading: widget.category!.customIcon != null ? Icon(widget.category!.customIcon) : Icon(TablerIcons.sitemap)
|
||||
),
|
||||
title: Text("${widget.category?.name}",
|
||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
subtitle: Text("${widget.category?.description}"),
|
||||
leading: widget.category!.customIcon != null
|
||||
? Icon(widget.category!.customIcon)
|
||||
: Icon(TablerIcons.sitemap)),
|
||||
];
|
||||
|
||||
if (extra) {
|
||||
children.add(
|
||||
ListTile(
|
||||
title: Text(L10().parentCategory),
|
||||
subtitle: Text("${widget.category?.parentPathString}"),
|
||||
leading: Icon(
|
||||
TablerIcons.arrow_move_up,
|
||||
color: COLOR_ACTION,
|
||||
),
|
||||
onTap: () async {
|
||||
children.add(ListTile(
|
||||
title: Text(L10().parentCategory),
|
||||
subtitle: Text("${widget.category?.parentPathString}"),
|
||||
leading: Icon(
|
||||
TablerIcons.arrow_move_up,
|
||||
color: COLOR_ACTION,
|
||||
),
|
||||
onTap: () async {
|
||||
int parentId = widget.category?.parentId ?? -1;
|
||||
|
||||
int parentId = widget.category?.parentId ?? -1;
|
||||
if (parentId < 0) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CategoryDisplayWidget(null)));
|
||||
} else {
|
||||
showLoadingOverlay();
|
||||
var cat = await InvenTreePartCategory().get(parentId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (parentId < 0) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
|
||||
} else {
|
||||
|
||||
showLoadingOverlay();
|
||||
var cat = await InvenTreePartCategory().get(parentId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (cat is InvenTreePartCategory) {
|
||||
cat.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
if (cat is InvenTreePartCategory) {
|
||||
cat.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
return Card(
|
||||
child: Column(
|
||||
children: children
|
||||
),
|
||||
child: Column(children: children),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
List<Widget> getTabIcons(BuildContext context) {
|
||||
|
||||
return [
|
||||
Tab(text: L10().details),
|
||||
Tab(text: L10().parts),
|
||||
@ -198,7 +175,6 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
|
||||
// Construct the "details" panel
|
||||
List<Widget> detailTiles() {
|
||||
|
||||
Map<String, String> filters = {};
|
||||
|
||||
int? parent = widget.category?.pk;
|
||||
@ -225,7 +201,6 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
|
||||
// Construct the "parts" panel
|
||||
List<Widget> partsTiles() {
|
||||
|
||||
Map<String, String> filters = {
|
||||
"category": widget.category?.pk.toString() ?? "null",
|
||||
};
|
||||
@ -239,50 +214,35 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
}
|
||||
|
||||
Future<void> _newCategory(BuildContext context) async {
|
||||
|
||||
int pk = widget.category?.pk ?? -1;
|
||||
|
||||
InvenTreePartCategory().createForm(
|
||||
context,
|
||||
L10().categoryCreate,
|
||||
data: {
|
||||
"parent": (pk > 0) ? pk : null,
|
||||
},
|
||||
onSuccess: (result) async {
|
||||
InvenTreePartCategory().createForm(context, L10().categoryCreate, data: {
|
||||
"parent": (pk > 0) ? pk : null,
|
||||
}, onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey("pk")) {
|
||||
var cat = InvenTreePartCategory.fromJson(data);
|
||||
cat.goToDetailPage(context).then((_) {
|
||||
refresh(context);
|
||||
});
|
||||
} else {
|
||||
if (data.containsKey("pk")) {
|
||||
var cat = InvenTreePartCategory.fromJson(data);
|
||||
cat.goToDetailPage(context).then((_) {
|
||||
refresh(context);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _newPart() async {
|
||||
|
||||
int pk = widget.category?.pk ?? -1;
|
||||
|
||||
InvenTreePart().createForm(
|
||||
context,
|
||||
L10().partCreate,
|
||||
data: {
|
||||
"category": (pk > 0) ? pk : null
|
||||
},
|
||||
onSuccess: (result) async {
|
||||
InvenTreePart().createForm(context, L10().partCreate,
|
||||
data: {"category": (pk > 0) ? pk : null}, onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey("pk")) {
|
||||
var part = InvenTreePart.fromJson(data);
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
if (data.containsKey("pk")) {
|
||||
var part = InvenTreePart.fromJson(data);
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -9,19 +9,15 @@ import "package:inventree/api.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
|
||||
class PartCategoryList extends StatefulWidget {
|
||||
|
||||
const PartCategoryList(this.filters);
|
||||
|
||||
final Map<String, String> filters;
|
||||
|
||||
@override
|
||||
_PartCategoryListState createState() => _PartCategoryListState();
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _PartCategoryListState extends RefreshableState<PartCategoryList> {
|
||||
|
||||
_PartCategoryListState();
|
||||
|
||||
@override
|
||||
@ -34,19 +30,20 @@ class _PartCategoryListState extends RefreshableState<PartCategoryList> {
|
||||
}
|
||||
|
||||
class PaginatedPartCategoryList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedPartCategoryList(Map<String, String> filters, {String title = ""}) : super(filters: filters, title: title);
|
||||
const PaginatedPartCategoryList(Map<String, String> filters,
|
||||
{String title = ""})
|
||||
: super(filters: filters, title: title);
|
||||
|
||||
@override
|
||||
String get searchTitle => title.isNotEmpty ? title : L10().partCategories;
|
||||
|
||||
@override
|
||||
_PaginatedPartCategoryListState createState() => _PaginatedPartCategoryListState();
|
||||
_PaginatedPartCategoryListState createState() =>
|
||||
_PaginatedPartCategoryListState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedPartCategoryListState extends PaginatedSearchState<PaginatedPartCategoryList> {
|
||||
|
||||
class _PaginatedPartCategoryListState
|
||||
extends PaginatedSearchState<PaginatedPartCategoryList> {
|
||||
// _PaginatedPartCategoryListState(Map<String, String> filters, bool searchEnabled) : super(filters, searchEnabled);
|
||||
|
||||
@override
|
||||
@ -54,17 +51,16 @@ class _PaginatedPartCategoryListState extends PaginatedSearchState<PaginatedPart
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
"cascade": {
|
||||
"default": false,
|
||||
"label": L10().includeSubcategories,
|
||||
"help_text": L10().includeSubcategoriesDetail,
|
||||
"tristate": false,
|
||||
}
|
||||
};
|
||||
"cascade": {
|
||||
"default": false,
|
||||
"label": L10().includeSubcategories,
|
||||
"help_text": L10().includeSubcategoriesDetail,
|
||||
"tristate": false,
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions {
|
||||
|
||||
Map<String, String> options = {
|
||||
"name": L10().name,
|
||||
"level": L10().level,
|
||||
@ -81,16 +77,16 @@ class _PaginatedPartCategoryListState extends PaginatedSearchState<PaginatedPart
|
||||
}
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
final page = await InvenTreePartCategory().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreePartCategory()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreePartCategory category = model as InvenTreePartCategory;
|
||||
|
||||
return ListTile(
|
||||
@ -103,4 +99,4 @@ class _PaginatedPartCategoryListState extends PaginatedSearchState<PaginatedPart
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,24 +27,19 @@ import "package:inventree/widget/snacks.dart";
|
||||
import "package:inventree/widget/stock/stock_list.dart";
|
||||
import "package:inventree/widget/company/supplier_part_list.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Widget for displaying a detail view of a single Part instance
|
||||
*/
|
||||
class PartDetailWidget extends StatefulWidget {
|
||||
|
||||
const PartDetailWidget(this.part, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreePart part;
|
||||
|
||||
@override
|
||||
_PartDisplayState createState() => _PartDisplayState(part);
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
|
||||
_PartDisplayState(this.part);
|
||||
|
||||
InvenTreePart part;
|
||||
@ -75,15 +70,12 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (InvenTreePart().canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editPart,
|
||||
onPressed: () {
|
||||
_editPartDialog(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editPart,
|
||||
onPressed: () {
|
||||
_editPartDialog(context);
|
||||
}));
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
@ -93,13 +85,8 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (InvenTreePart().canEdit) {
|
||||
actions.add(
|
||||
customBarcodeAction(
|
||||
context, this,
|
||||
widget.part.customBarcode, "part",
|
||||
widget.part.pk
|
||||
)
|
||||
);
|
||||
actions.add(customBarcodeAction(
|
||||
context, this, widget.part.customBarcode, "part", widget.part.pk));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -110,33 +97,22 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (InvenTreeStockItem().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.packages),
|
||||
label: L10().stockItemCreate,
|
||||
onTap: () {
|
||||
_newStockItem(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.packages),
|
||||
label: L10().stockItemCreate,
|
||||
onTap: () {
|
||||
_newStockItem(context);
|
||||
}));
|
||||
}
|
||||
|
||||
if (labels.isNotEmpty) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.printer),
|
||||
label: L10().printLabel,
|
||||
onTap: () async {
|
||||
selectAndPrintLabel(
|
||||
context,
|
||||
labels,
|
||||
widget.part.pk,
|
||||
"part",
|
||||
"part=${widget.part.pk}"
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
selectAndPrintLabel(context, labels, widget.part.pk, "part",
|
||||
"part=${widget.part.pk}");
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -153,14 +129,16 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
|
||||
@override
|
||||
Future<void> request(BuildContext context) async {
|
||||
|
||||
final bool result = await part.reload();
|
||||
|
||||
// Load page settings from local storage
|
||||
showPricing = await InvenTreeSettingsManager().getBool(INV_PART_SHOW_PRICING, true);
|
||||
showParameters = await InvenTreeSettingsManager().getBool(INV_PART_SHOW_PARAMETERS, true);
|
||||
showPricing =
|
||||
await InvenTreeSettingsManager().getBool(INV_PART_SHOW_PRICING, true);
|
||||
showParameters = await InvenTreeSettingsManager()
|
||||
.getBool(INV_PART_SHOW_PARAMETERS, true);
|
||||
showBom = await InvenTreeSettingsManager().getBool(INV_PART_SHOW_BOM, true);
|
||||
allowLabelPrinting = await InvenTreeSettingsManager().getBool(INV_ENABLE_LABEL_PRINTING, true);
|
||||
allowLabelPrinting = await InvenTreeSettingsManager()
|
||||
.getBool(INV_ENABLE_LABEL_PRINTING, true);
|
||||
|
||||
if (!result || part.pk == -1) {
|
||||
// Part could not be loaded, for some reason
|
||||
@ -211,11 +189,9 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
}
|
||||
|
||||
// Request the number of BOM items
|
||||
InvenTreePart().count(
|
||||
filters: {
|
||||
"in_bom_for": part.pk.toString(),
|
||||
}
|
||||
).then((int value) {
|
||||
InvenTreePart().count(filters: {
|
||||
"in_bom_for": part.pk.toString(),
|
||||
}).then((int value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
bomCount = value;
|
||||
@ -224,11 +200,9 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
});
|
||||
|
||||
// Request number of "used in" parts
|
||||
InvenTreeBomItem().count(
|
||||
filters: {
|
||||
"uses": part.pk.toString(),
|
||||
}
|
||||
).then((int value) {
|
||||
InvenTreeBomItem().count(filters: {
|
||||
"uses": part.pk.toString(),
|
||||
}).then((int value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
usedInCount = value;
|
||||
@ -237,11 +211,9 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
});
|
||||
|
||||
// Request the number of variant items
|
||||
InvenTreePart().count(
|
||||
filters: {
|
||||
"variant_of": part.pk.toString(),
|
||||
}
|
||||
).then((int value) {
|
||||
InvenTreePart().count(filters: {
|
||||
"variant_of": part.pk.toString(),
|
||||
}).then((int value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
variantCount = value;
|
||||
@ -253,16 +225,12 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
allowLabelPrinting &= api.supportsMixin("labels");
|
||||
|
||||
if (allowLabelPrinting) {
|
||||
|
||||
String model_type = api.supportsModernLabelPrinting ? InvenTreePart.MODEL_TYPE : "part";
|
||||
String model_type =
|
||||
api.supportsModernLabelPrinting ? InvenTreePart.MODEL_TYPE : "part";
|
||||
String item_key = api.supportsModernLabelPrinting ? "items" : "part";
|
||||
|
||||
_labels = await getLabelTemplates(
|
||||
model_type,
|
||||
{
|
||||
item_key: widget.part.pk.toString()
|
||||
}
|
||||
);
|
||||
model_type, {item_key: widget.part.pk.toString()});
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
@ -273,41 +241,33 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
}
|
||||
|
||||
void _editPartDialog(BuildContext context) {
|
||||
|
||||
part.editForm(
|
||||
context,
|
||||
L10().editPart,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().partEdited, success: true);
|
||||
}
|
||||
);
|
||||
part.editForm(context, L10().editPart, onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().partEdited, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
Widget headerTile() {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
title: Text(part.fullname),
|
||||
subtitle: Text(part.description),
|
||||
trailing: Text(
|
||||
part.stockString(),
|
||||
child: ListTile(
|
||||
title: Text(part.fullname),
|
||||
subtitle: Text(part.description),
|
||||
trailing: Text(part.stockString(),
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
)
|
||||
),
|
||||
leading: GestureDetector(
|
||||
)),
|
||||
leading: GestureDetector(
|
||||
child: api.getImage(part.thumbnail),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PartImageWidget(part)
|
||||
)
|
||||
).then((value) {
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PartImageWidget(part)))
|
||||
.then((value) {
|
||||
refresh(context);
|
||||
});
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -315,13 +275,10 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
* Build a list of tiles to display under the part description
|
||||
*/
|
||||
List<Widget> partTiles() {
|
||||
|
||||
List<Widget> tiles = [];
|
||||
|
||||
// Image / name / description
|
||||
tiles.add(
|
||||
headerTile()
|
||||
);
|
||||
tiles.add(headerTile());
|
||||
|
||||
if (loading) {
|
||||
tiles.add(progressIndicator());
|
||||
@ -329,31 +286,16 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
}
|
||||
|
||||
if (!part.isActive) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10().inactive,
|
||||
style: TextStyle(
|
||||
color: COLOR_DANGER
|
||||
)
|
||||
),
|
||||
subtitle: Text(
|
||||
L10().inactiveDetail,
|
||||
style: TextStyle(
|
||||
color: COLOR_DANGER
|
||||
)
|
||||
),
|
||||
leading: Icon(
|
||||
TablerIcons.exclamation_circle,
|
||||
color: COLOR_DANGER
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().inactive, style: TextStyle(color: COLOR_DANGER)),
|
||||
subtitle:
|
||||
Text(L10().inactiveDetail, style: TextStyle(color: COLOR_DANGER)),
|
||||
leading: Icon(TablerIcons.exclamation_circle, color: COLOR_DANGER),
|
||||
));
|
||||
}
|
||||
|
||||
if (parentPart != null) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().templatePart),
|
||||
subtitle: Text(parentPart!.fullname),
|
||||
leading: api.getImage(
|
||||
@ -363,68 +305,56 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
),
|
||||
onTap: () {
|
||||
parentPart?.goToDetailPage(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
// Category information
|
||||
if (part.categoryName.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().partCategory),
|
||||
subtitle: Text("${part.categoryName}"),
|
||||
leading: Icon(TablerIcons.sitemap, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
if (part.categoryId > 0) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().partCategory),
|
||||
subtitle: Text("${part.categoryName}"),
|
||||
leading: Icon(TablerIcons.sitemap, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
if (part.categoryId > 0) {
|
||||
showLoadingOverlay();
|
||||
var cat = await InvenTreePartCategory().get(part.categoryId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
showLoadingOverlay();
|
||||
var cat = await InvenTreePartCategory().get(part.categoryId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (cat is InvenTreePartCategory) {
|
||||
cat.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
if (cat is InvenTreePartCategory) {
|
||||
cat.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
));
|
||||
} else {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().partCategory),
|
||||
subtitle: Text(L10().partCategoryTopLevel),
|
||||
leading: Icon(TablerIcons.sitemap, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().partCategory),
|
||||
subtitle: Text(L10().partCategoryTopLevel),
|
||||
leading: Icon(TablerIcons.sitemap, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CategoryDisplayWidget(null)));
|
||||
},
|
||||
)
|
||||
);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Display number of "variant" parts if any exist
|
||||
if (variantCount > 0) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().variants),
|
||||
leading: Icon(TablerIcons.versions, color: COLOR_ACTION),
|
||||
trailing: Text(variantCount.toString()),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PartList(
|
||||
{
|
||||
"variant_of": part.pk.toString(),
|
||||
},
|
||||
title: L10().variants
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().variants),
|
||||
leading: Icon(TablerIcons.versions, color: COLOR_ACTION),
|
||||
trailing: Text(variantCount.toString()),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PartList({
|
||||
"variant_of": part.pk.toString(),
|
||||
}, title: L10().variants)));
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
tiles.add(
|
||||
@ -442,12 +372,9 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
);
|
||||
|
||||
if (showPricing && partPricing != null) {
|
||||
|
||||
String pricing = formatPriceRange(
|
||||
partPricing?.overallMin,
|
||||
partPricing?.overallMax,
|
||||
currency: partPricing?.currency
|
||||
);
|
||||
partPricing?.overallMin, partPricing?.overallMax,
|
||||
currency: partPricing?.currency);
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
@ -463,7 +390,8 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PartPricingWidget(part: part, partPricing: partPricing),
|
||||
builder: (context) =>
|
||||
PartPricingWidget(part: part, partPricing: partPricing),
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -473,173 +401,141 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
|
||||
// Tiles for "purchaseable" parts
|
||||
if (part.isPurchaseable) {
|
||||
|
||||
// On order
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().onOrder),
|
||||
subtitle: Text(L10().onOrderDetails),
|
||||
leading: Icon(TablerIcons.shopping_cart),
|
||||
trailing: Text("${part.onOrderString}"),
|
||||
onTap: () {
|
||||
// TODO - Order views
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().onOrder),
|
||||
subtitle: Text(L10().onOrderDetails),
|
||||
leading: Icon(TablerIcons.shopping_cart),
|
||||
trailing: Text("${part.onOrderString}"),
|
||||
onTap: () {
|
||||
// TODO - Order views
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Tiles for an "assembly" part
|
||||
if (part.isAssembly) {
|
||||
|
||||
if (showBom && bomCount > 0) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().billOfMaterials),
|
||||
leading: Icon(TablerIcons.list_tree, color: COLOR_ACTION),
|
||||
trailing: Text(bomCount.toString()),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) => BillOfMaterialsWidget(part, isParentComponent: true)
|
||||
));
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().billOfMaterials),
|
||||
leading: Icon(TablerIcons.list_tree, color: COLOR_ACTION),
|
||||
trailing: Text(bomCount.toString()),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
BillOfMaterialsWidget(part, isParentComponent: true)));
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
if (part.building > 0) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().building),
|
||||
leading: Icon(TablerIcons.tools),
|
||||
trailing: Text("${simpleNumberString(part.building)}"),
|
||||
onTap: () {
|
||||
// TODO
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().building),
|
||||
leading: Icon(TablerIcons.tools),
|
||||
trailing: Text("${simpleNumberString(part.building)}"),
|
||||
onTap: () {
|
||||
// TODO
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if (part.isComponent) {
|
||||
if (showBom && usedInCount > 0) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().usedIn),
|
||||
subtitle: Text(L10().usedInDetails),
|
||||
leading: Icon(TablerIcons.stack_2, color: COLOR_ACTION),
|
||||
trailing: Text(usedInCount.toString()),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => BillOfMaterialsWidget(part, isParentComponent: false)
|
||||
)
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => BillOfMaterialsWidget(part,
|
||||
isParentComponent: false)));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
// Keywords?
|
||||
if (part.keywords.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("${part.keywords}"),
|
||||
leading: Icon(TablerIcons.tags),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text("${part.keywords}"),
|
||||
leading: Icon(TablerIcons.tags),
|
||||
));
|
||||
}
|
||||
|
||||
// External link?
|
||||
if (part.link.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("${part.link}"),
|
||||
leading: Icon(TablerIcons.link, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
part.openLink();
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text("${part.link}"),
|
||||
leading: Icon(TablerIcons.link, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
part.openLink();
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Tiles for "component" part
|
||||
if (part.isComponent && part.usedInCount > 0) {
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().usedIn),
|
||||
subtitle: Text(L10().usedInDetails),
|
||||
leading: Icon(TablerIcons.sitemap),
|
||||
trailing: Text("${part.usedInCount}"),
|
||||
onTap: () {
|
||||
// TODO
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().usedIn),
|
||||
subtitle: Text(L10().usedInDetails),
|
||||
leading: Icon(TablerIcons.sitemap),
|
||||
trailing: Text("${part.usedInCount}"),
|
||||
onTap: () {
|
||||
// TODO
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
if (part.isPurchaseable) {
|
||||
|
||||
if (part.supplierCount > 0) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().suppliers),
|
||||
leading: Icon(TablerIcons.building_factory, color: COLOR_ACTION),
|
||||
trailing: Text("${part.supplierCount}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => SupplierPartList({
|
||||
"part": part.pk.toString()
|
||||
}))
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().suppliers),
|
||||
leading: Icon(TablerIcons.building_factory, color: COLOR_ACTION),
|
||||
trailing: Text("${part.supplierCount}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
SupplierPartList({"part": part.pk.toString()})));
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// Notes field
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().notes),
|
||||
leading: Icon(TablerIcons.note, color: COLOR_ACTION),
|
||||
trailing: Text(""),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => NotesWidget(part))
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().notes),
|
||||
leading: Icon(TablerIcons.note, color: COLOR_ACTION),
|
||||
trailing: Text(""),
|
||||
onTap: () {
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => NotesWidget(part)));
|
||||
},
|
||||
));
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().attachments),
|
||||
leading: Icon(TablerIcons.file, color: COLOR_ACTION),
|
||||
trailing: attachmentCount > 0 ? Text(attachmentCount.toString()) : null,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().attachments),
|
||||
leading: Icon(TablerIcons.file, color: COLOR_ACTION),
|
||||
trailing: attachmentCount > 0 ? Text(attachmentCount.toString()) : null,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AttachmentWidget(
|
||||
InvenTreePartAttachment(),
|
||||
part.pk,
|
||||
L10().part,
|
||||
part.canEdit
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
builder: (context) => AttachmentWidget(
|
||||
InvenTreePartAttachment(),
|
||||
part.pk,
|
||||
L10().part,
|
||||
part.canEdit)));
|
||||
},
|
||||
));
|
||||
|
||||
return tiles;
|
||||
|
||||
}
|
||||
|
||||
// Return tiles for each stock item
|
||||
@ -648,16 +544,16 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
|
||||
tiles.add(headerTile());
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10().stockItems,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
subtitle: part.stockItems.isEmpty ? Text(L10().stockItemsNotAvailable) : null,
|
||||
trailing: part.stockItems.isNotEmpty ? Text("${part.stockItems.length}") : null,
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(
|
||||
L10().stockItems,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
subtitle:
|
||||
part.stockItems.isEmpty ? Text(L10().stockItemsNotAvailable) : null,
|
||||
trailing:
|
||||
part.stockItems.isNotEmpty ? Text("${part.stockItems.length}") : null,
|
||||
));
|
||||
|
||||
return tiles;
|
||||
}
|
||||
@ -666,7 +562,6 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
* Launch a form to create a new StockItem for this part
|
||||
*/
|
||||
Future<void> _newStockItem(BuildContext context) async {
|
||||
|
||||
var fields = InvenTreeStockItem().formFields();
|
||||
|
||||
// Serial number cannot be directly edited here
|
||||
@ -677,9 +572,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
|
||||
int? default_location = part.defaultLocation;
|
||||
|
||||
Map<String, dynamic> data = {
|
||||
"part": part.pk.toString()
|
||||
};
|
||||
Map<String, dynamic> data = {"part": part.pk.toString()};
|
||||
|
||||
if (default_location != null) {
|
||||
data["location"] = default_location;
|
||||
@ -688,15 +581,18 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
if (part.isTrackable) {
|
||||
// read the next available serial number
|
||||
showLoadingOverlay();
|
||||
var response = await api.get("/api/part/${part.pk}/serial-numbers/", expectedStatusCode: null);
|
||||
var response = await api.get("/api/part/${part.pk}/serial-numbers/",
|
||||
expectedStatusCode: null);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (response.isValid() && response.statusCode == 200) {
|
||||
data["serial_numbers"] = response.data["next"] ?? response.data["latest"];
|
||||
data["serial_numbers"] =
|
||||
response.data["next"] ?? response.data["latest"];
|
||||
}
|
||||
|
||||
print("response: " + response.statusCode.toString() + response.data.toString());
|
||||
|
||||
print("response: " +
|
||||
response.statusCode.toString() +
|
||||
response.data.toString());
|
||||
} else {
|
||||
// Cannot set serial numbers for non-trackable parts
|
||||
fields.remove("serial_numbers");
|
||||
@ -704,29 +600,20 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
|
||||
print("data: ${data.toString()}");
|
||||
|
||||
InvenTreeStockItem().createForm(
|
||||
context,
|
||||
L10().stockItemCreate,
|
||||
fields: fields,
|
||||
data: data,
|
||||
onSuccess: (result) async {
|
||||
InvenTreeStockItem().createForm(context, L10().stockItemCreate,
|
||||
fields: fields, data: data, onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey("pk")) {
|
||||
var item = InvenTreeStockItem.fromJson(data);
|
||||
item.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (data.containsKey("pk")) {
|
||||
var item = InvenTreeStockItem.fromJson(data);
|
||||
item.goToDetailPage(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
List<Widget> getTabIcons(BuildContext context) {
|
||||
List<Widget> icons = [
|
||||
Tab(text: L10().details),
|
||||
Tab(text: L10().stock)
|
||||
];
|
||||
List<Widget> icons = [Tab(text: L10().details), Tab(text: L10().stock)];
|
||||
|
||||
if (showParameters) {
|
||||
icons.add(Tab(text: L10().parameters));
|
||||
@ -739,11 +626,10 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
List<Widget> getTabs(BuildContext context) {
|
||||
List<Widget> tabs = [
|
||||
SingleChildScrollView(
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
child: Column(
|
||||
children: partTiles(),
|
||||
)
|
||||
),
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
child: Column(
|
||||
children: partTiles(),
|
||||
)),
|
||||
PaginatedStockItemList({"part": part.pk.toString()})
|
||||
];
|
||||
|
||||
@ -753,5 +639,4 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
|
||||
return tabs;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,19 +11,15 @@ import "package:inventree/widget/snacks.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
|
||||
class PartImageWidget extends StatefulWidget {
|
||||
|
||||
const PartImageWidget(this.part, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreePart part;
|
||||
|
||||
@override
|
||||
_PartImageState createState() => _PartImageState(part);
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _PartImageState extends RefreshableState<PartImageWidget> {
|
||||
|
||||
_PartImageState(this.part);
|
||||
|
||||
final InvenTreePart part;
|
||||
@ -38,32 +34,24 @@ class _PartImageState extends RefreshableState<PartImageWidget> {
|
||||
|
||||
@override
|
||||
List<Widget> appBarActions(BuildContext context) {
|
||||
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (part.canEdit) {
|
||||
|
||||
// File upload
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.file_upload),
|
||||
onPressed: () async {
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.file_upload),
|
||||
onPressed: () async {
|
||||
FilePickerDialog.pickFile(onPicked: (File file) async {
|
||||
final result = await part.uploadImage(file);
|
||||
|
||||
FilePickerDialog.pickFile(
|
||||
onPicked: (File file) async {
|
||||
final result = await part.uploadImage(file);
|
||||
if (!result) {
|
||||
showSnackIcon(L10().uploadFailed, success: false);
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
showSnackIcon(L10().uploadFailed, success: false);
|
||||
}
|
||||
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
)
|
||||
);
|
||||
refresh(context);
|
||||
});
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -73,5 +61,4 @@ class _PartImageState extends RefreshableState<PartImageWidget> {
|
||||
Widget getBody(BuildContext context) {
|
||||
return InvenTreeAPI().getImage(part.image);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,7 @@ import "package:inventree/inventree/part.dart";
|
||||
import "package:inventree/widget/paginator.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
class PartList extends StatefulWidget {
|
||||
|
||||
const PartList(this.filters, {this.title = ""});
|
||||
|
||||
final String title;
|
||||
@ -22,9 +20,7 @@ class PartList extends StatefulWidget {
|
||||
_PartListState createState() => _PartListState(filters, title);
|
||||
}
|
||||
|
||||
|
||||
class _PartListState extends RefreshableState<PartList> {
|
||||
|
||||
_PartListState(this.filters, this.title);
|
||||
|
||||
final String title;
|
||||
@ -40,13 +36,11 @@ class _PartListState extends RefreshableState<PartList> {
|
||||
Widget getBody(BuildContext context) {
|
||||
return PaginatedPartList(filters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class PaginatedPartList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedPartList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedPartList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().parts;
|
||||
@ -55,9 +49,7 @@ class PaginatedPartList extends PaginatedSearchWidget {
|
||||
_PaginatedPartListState createState() => _PaginatedPartListState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedPartListState extends PaginatedSearchState<PaginatedPartList> {
|
||||
|
||||
_PaginatedPartListState() : super();
|
||||
|
||||
@override
|
||||
@ -65,74 +57,70 @@ class _PaginatedPartListState extends PaginatedSearchState<PaginatedPartList> {
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"name": L10().name,
|
||||
"in_stock": L10().stock,
|
||||
"IPN": L10().internalPartNumber,
|
||||
};
|
||||
"name": L10().name,
|
||||
"in_stock": L10().stock,
|
||||
"IPN": L10().internalPartNumber,
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
"cascade": {
|
||||
"default": true,
|
||||
"label": L10().includeSubcategories,
|
||||
"help_text": L10().includeSubcategoriesDetail,
|
||||
},
|
||||
"active": {
|
||||
"label": L10().filterActive,
|
||||
"help_text": L10().filterActiveDetail,
|
||||
"tristate": true,
|
||||
},
|
||||
"assembly": {
|
||||
"label": L10().filterAssembly,
|
||||
"help_text": L10().filterAssemblyDetail
|
||||
},
|
||||
"component": {
|
||||
"label": L10().filterComponent,
|
||||
"help_text": L10().filterComponentDetail,
|
||||
},
|
||||
"is_template": {
|
||||
"label": L10().filterTemplate,
|
||||
"help_text": L10().filterTemplateDetail
|
||||
},
|
||||
"trackable": {
|
||||
"label": L10().filterTrackable,
|
||||
"help_text": L10().filterTrackableDetail,
|
||||
},
|
||||
"virtual": {
|
||||
"label": L10().filterVirtual,
|
||||
"help_text": L10().filterVirtualDetail,
|
||||
},
|
||||
"has_stock": {
|
||||
"label": L10().filterInStock,
|
||||
"help_text": L10().filterInStockDetail,
|
||||
}
|
||||
};
|
||||
"cascade": {
|
||||
"default": true,
|
||||
"label": L10().includeSubcategories,
|
||||
"help_text": L10().includeSubcategoriesDetail,
|
||||
},
|
||||
"active": {
|
||||
"label": L10().filterActive,
|
||||
"help_text": L10().filterActiveDetail,
|
||||
"tristate": true,
|
||||
},
|
||||
"assembly": {
|
||||
"label": L10().filterAssembly,
|
||||
"help_text": L10().filterAssemblyDetail
|
||||
},
|
||||
"component": {
|
||||
"label": L10().filterComponent,
|
||||
"help_text": L10().filterComponentDetail,
|
||||
},
|
||||
"is_template": {
|
||||
"label": L10().filterTemplate,
|
||||
"help_text": L10().filterTemplateDetail
|
||||
},
|
||||
"trackable": {
|
||||
"label": L10().filterTrackable,
|
||||
"help_text": L10().filterTrackableDetail,
|
||||
},
|
||||
"virtual": {
|
||||
"label": L10().filterVirtual,
|
||||
"help_text": L10().filterVirtualDetail,
|
||||
},
|
||||
"has_stock": {
|
||||
"label": L10().filterInStock,
|
||||
"help_text": L10().filterInStockDetail,
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreePart().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page =
|
||||
await InvenTreePart().listPaginated(limit, offset, filters: params);
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreePart part = model as InvenTreePart;
|
||||
|
||||
return ListTile(
|
||||
title: Text(part.fullname),
|
||||
subtitle: Text(part.description),
|
||||
trailing: Text(
|
||||
part.stockString(),
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold
|
||||
)
|
||||
),
|
||||
trailing: Text(part.stockString(),
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
||||
leading: InvenTreeAPI().getThumbnail(part.thumbnail),
|
||||
onTap: () {
|
||||
part.goToDetailPage(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import "package:inventree/widget/refreshable_state.dart";
|
||||
* Widget for displaying a list of parameters associated with a given Part instance
|
||||
*/
|
||||
class PartParameterWidget extends StatefulWidget {
|
||||
|
||||
const PartParameterWidget(this.part);
|
||||
|
||||
final InvenTreePart part;
|
||||
@ -20,7 +19,6 @@ class PartParameterWidget extends StatefulWidget {
|
||||
_ParameterWidgetState createState() => _ParameterWidgetState();
|
||||
}
|
||||
|
||||
|
||||
class _ParameterWidgetState extends RefreshableState<PartParameterWidget> {
|
||||
_ParameterWidgetState();
|
||||
|
||||
@ -36,28 +34,20 @@ class _ParameterWidgetState extends RefreshableState<PartParameterWidget> {
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
|
||||
Map<String, String> filters = {
|
||||
"part": widget.part.pk.toString()
|
||||
};
|
||||
Map<String, String> filters = {"part": widget.part.pk.toString()};
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: PaginatedParameterList(filters)
|
||||
)
|
||||
],
|
||||
children: [Expanded(child: PaginatedParameterList(filters))],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Widget for displaying a paginated list of Part parameters
|
||||
*/
|
||||
class PaginatedParameterList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedParameterList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedParameterList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().parameters;
|
||||
@ -66,51 +56,43 @@ class PaginatedParameterList extends PaginatedSearchWidget {
|
||||
_PaginatedParameterState createState() => _PaginatedParameterState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedParameterState extends PaginatedSearchState<PaginatedParameterList> {
|
||||
|
||||
class _PaginatedParameterState
|
||||
extends PaginatedSearchState<PaginatedParameterList> {
|
||||
_PaginatedParameterState() : super();
|
||||
|
||||
@override
|
||||
String get prefix => "parameters_";
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
|
||||
};
|
||||
Map<String, String> get orderingOptions => {};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
// TODO
|
||||
};
|
||||
// TODO
|
||||
};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
final page = await InvenTreePartParameter().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreePartParameter()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
Future<void> editParameter(InvenTreePartParameter parameter) async {
|
||||
|
||||
// Checkbox values are handled separately
|
||||
if (parameter.is_checkbox) {
|
||||
return;
|
||||
} else {
|
||||
parameter.editForm(
|
||||
context,
|
||||
L10().editParameter,
|
||||
onSuccess: (data) async {
|
||||
updateSearchTerm();
|
||||
}
|
||||
);
|
||||
parameter.editForm(context, L10().editParameter, onSuccess: (data) async {
|
||||
updateSearchTerm();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreePartParameter parameter = model as InvenTreePartParameter;
|
||||
|
||||
String title = parameter.name;
|
||||
@ -123,27 +105,27 @@ class _PaginatedParameterState extends PaginatedSearchState<PaginatedParameterLi
|
||||
title: Text(title),
|
||||
subtitle: Text(parameter.description),
|
||||
trailing: parameter.is_checkbox
|
||||
? Switch(
|
||||
value: parameter.as_bool,
|
||||
onChanged: (bool value) {
|
||||
if (parameter.canEdit) {
|
||||
showLoadingOverlay();
|
||||
parameter.update(
|
||||
values: {
|
||||
"data": value.toString()
|
||||
? Switch(
|
||||
value: parameter.as_bool,
|
||||
onChanged: (bool value) {
|
||||
if (parameter.canEdit) {
|
||||
showLoadingOverlay();
|
||||
parameter.update(values: {"data": value.toString()}).then(
|
||||
(value) async {
|
||||
hideLoadingOverlay();
|
||||
updateSearchTerm();
|
||||
});
|
||||
}
|
||||
).then((value) async{
|
||||
hideLoadingOverlay();
|
||||
updateSearchTerm();
|
||||
});
|
||||
}
|
||||
},
|
||||
) : Text(parameter.value),
|
||||
onTap: parameter.is_checkbox ? null : () async {
|
||||
if (parameter.canEdit) {
|
||||
editParameter(parameter);
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
: Text(parameter.value),
|
||||
onTap: parameter.is_checkbox
|
||||
? null
|
||||
: () async {
|
||||
if (parameter.canEdit) {
|
||||
editParameter(parameter);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,9 @@ import "package:inventree/widget/refreshable_state.dart";
|
||||
import "package:inventree/helpers.dart";
|
||||
|
||||
class PartPricingWidget extends StatefulWidget {
|
||||
|
||||
const PartPricingWidget({Key? key, required this.part, required this.partPricing}) : super(key: key);
|
||||
const PartPricingWidget(
|
||||
{Key? key, required this.part, required this.partPricing})
|
||||
: super(key: key);
|
||||
final InvenTreePart part;
|
||||
final InvenTreePartPricing? partPricing;
|
||||
|
||||
@ -17,7 +18,6 @@ class PartPricingWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PartPricingWidgetState extends RefreshableState<PartPricingWidget> {
|
||||
|
||||
@override
|
||||
String getAppBarTitle() {
|
||||
return L10().partPricing;
|
||||
@ -25,174 +25,108 @@ class _PartPricingWidgetState extends RefreshableState<PartPricingWidget> {
|
||||
|
||||
@override
|
||||
List<Widget> getTiles(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [
|
||||
Card(
|
||||
child: ListTile(
|
||||
title: Text(widget.part.fullname),
|
||||
subtitle: Text(widget.part.description),
|
||||
leading: api.getThumbnail(widget.part.thumbnail)
|
||||
)
|
||||
),
|
||||
child: ListTile(
|
||||
title: Text(widget.part.fullname),
|
||||
subtitle: Text(widget.part.description),
|
||||
leading: api.getThumbnail(widget.part.thumbnail))),
|
||||
];
|
||||
|
||||
if (widget.partPricing == null) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().noPricingAvailable),
|
||||
subtitle: Text(L10().noPricingDataFound),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().noPricingAvailable),
|
||||
subtitle: Text(L10().noPricingDataFound),
|
||||
));
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
final pricing = widget.partPricing!;
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().currency),
|
||||
trailing: Text(pricing.currency),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().currency),
|
||||
trailing: Text(pricing.currency),
|
||||
));
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().priceRange),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.overallMin,
|
||||
pricing.overallMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().priceRange),
|
||||
trailing: Text(formatPriceRange(pricing.overallMin, pricing.overallMax,
|
||||
currency: pricing.currency)),
|
||||
));
|
||||
|
||||
if (pricing.overallMin != null) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().priceOverrideMin),
|
||||
trailing: Text(
|
||||
renderCurrency(pricing.overallMin, pricing.overrideMinCurrency)
|
||||
)
|
||||
)
|
||||
);
|
||||
trailing: Text(renderCurrency(
|
||||
pricing.overallMin, pricing.overrideMinCurrency))));
|
||||
}
|
||||
|
||||
if (pricing.overrideMax != null) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().priceOverrideMax),
|
||||
trailing: Text(
|
||||
renderCurrency(pricing.overallMax, pricing.overrideMaxCurrency)
|
||||
)
|
||||
)
|
||||
);
|
||||
trailing: Text(renderCurrency(
|
||||
pricing.overallMax, pricing.overrideMaxCurrency))));
|
||||
}
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().internalCost),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.internalCostMin,
|
||||
pricing.internalCostMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().internalCost),
|
||||
trailing: Text(formatPriceRange(
|
||||
pricing.internalCostMin, pricing.internalCostMax,
|
||||
currency: pricing.currency)),
|
||||
));
|
||||
|
||||
if (widget.part.isTemplate) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().variantCost),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.variantCostMin,
|
||||
pricing.variantCostMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().variantCost),
|
||||
trailing: Text(formatPriceRange(
|
||||
pricing.variantCostMin, pricing.variantCostMax,
|
||||
currency: pricing.currency)),
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.part.isAssembly) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().bomCost),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.bomCostMin,
|
||||
pricing.bomCostMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
trailing: Text(formatPriceRange(
|
||||
pricing.bomCostMin, pricing.bomCostMax,
|
||||
currency: pricing.currency))));
|
||||
}
|
||||
|
||||
if (widget.part.isPurchaseable) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().purchasePrice),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.purchaseCostMin,
|
||||
pricing.purchaseCostMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().purchasePrice),
|
||||
trailing: Text(formatPriceRange(
|
||||
pricing.purchaseCostMin, pricing.purchaseCostMax,
|
||||
currency: pricing.currency)),
|
||||
));
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().supplierPricing),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.supplierPriceMin,
|
||||
pricing.supplierPriceMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().supplierPricing),
|
||||
trailing: Text(formatPriceRange(
|
||||
pricing.supplierPriceMin, pricing.supplierPriceMax,
|
||||
currency: pricing.currency)),
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.part.isSalable) {
|
||||
tiles.add(Divider());
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().salePrice),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.salePriceMin,
|
||||
pricing.salePriceMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().salePrice),
|
||||
trailing: Text(formatPriceRange(
|
||||
pricing.salePriceMin, pricing.salePriceMax,
|
||||
currency: pricing.currency)),
|
||||
));
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().saleHistory),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.saleHistoryMin,
|
||||
pricing.saleHistoryMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().saleHistory),
|
||||
trailing: Text(formatPriceRange(
|
||||
pricing.saleHistoryMin, pricing.saleHistoryMax,
|
||||
currency: pricing.currency)),
|
||||
));
|
||||
}
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,19 +10,15 @@ import "package:inventree/inventree/company.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
class PartSupplierWidget extends StatefulWidget {
|
||||
|
||||
const PartSupplierWidget(this.part, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreePart part;
|
||||
|
||||
@override
|
||||
_PartSupplierState createState() => _PartSupplierState(part);
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _PartSupplierState extends RefreshableState<PartSupplierWidget> {
|
||||
|
||||
_PartSupplierState(this.part);
|
||||
|
||||
final InvenTreePart part;
|
||||
@ -46,7 +42,6 @@ class _PartSupplierState extends RefreshableState<PartSupplierWidget> {
|
||||
}
|
||||
|
||||
Widget _supplierPartTile(BuildContext context, int index) {
|
||||
|
||||
InvenTreeSupplierPart _part = _supplierParts[index];
|
||||
|
||||
return ListTile(
|
||||
@ -73,5 +68,4 @@ class _PartSupplierState extends RefreshableState<PartSupplierWidget> {
|
||||
itemBuilder: _supplierPartTile,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user