mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 03:26:24 +00:00
Default location (#715)
* Fix async loading of parent part - Don't block render while fetching data * Display default location on part detail page * Use pathstring instead of name * Update release notes * Display in stock detail too * dart format
This commit is contained in:
parent
0eedf25d11
commit
ed7d73b9c0
5 changed files with 87 additions and 12 deletions
|
|
@ -47,6 +47,8 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||
|
||||
InvenTreePart? parentPart;
|
||||
|
||||
InvenTreeStockLocation? defaultLocation;
|
||||
|
||||
int parameterCount = 0;
|
||||
|
||||
bool allowLabelPrinting = false;
|
||||
|
|
@ -177,16 +179,35 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||
// If the part points to a parent "template" part, request that too
|
||||
int? templatePartId = part.variantOf;
|
||||
|
||||
if (templatePartId == null) {
|
||||
parentPart = null;
|
||||
} else {
|
||||
final result = await InvenTreePart().get(templatePartId);
|
||||
|
||||
if (result != null && result is InvenTreePart) {
|
||||
parentPart = result;
|
||||
} else {
|
||||
if (templatePartId != null) {
|
||||
InvenTreePart().get(templatePartId).then((value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
parentPart = value as InvenTreePart?;
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (mounted) {
|
||||
setState(() {
|
||||
parentPart = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Is there a default location specified for this part?
|
||||
int? defaultLocationId = part.defaultLocation;
|
||||
|
||||
if (defaultLocationId != null) {
|
||||
InvenTreeStockLocation().get(defaultLocationId).then((value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
defaultLocation = value as InvenTreeStockLocation?;
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (mounted) {
|
||||
setState(() {
|
||||
defaultLocation = null;
|
||||
});
|
||||
}
|
||||
|
||||
// Request part test templates
|
||||
|
|
@ -414,6 +435,20 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||
),
|
||||
);
|
||||
|
||||
if (defaultLocation != null) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().locationDefault),
|
||||
subtitle: Text(defaultLocation!.pathstring),
|
||||
leading: Icon(TablerIcons.map_pin),
|
||||
trailing: LinkIcon(),
|
||||
onTap: () {
|
||||
defaultLocation?.goToDetailPage(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (showPricing && partPricing != null) {
|
||||
String pricing = formatPriceRange(
|
||||
partPricing?.overallMin,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue