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:
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user