mirror of
https://github.com/inventree/inventree-app.git
synced 2025-12-04 03:09:56 +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:
@@ -49,6 +49,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
|
||||
// Linked data fields
|
||||
InvenTreePart? part;
|
||||
InvenTreeStockLocation? defaultLocation;
|
||||
InvenTreeSalesOrder? salesOrder;
|
||||
InvenTreeCompany? customer;
|
||||
|
||||
@@ -234,6 +235,23 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
|
||||
stockShowTests &= part?.isTrackable ?? false;
|
||||
|
||||
// Request default location
|
||||
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 test results (async)
|
||||
if (stockShowTests) {
|
||||
widget.item.getTestResults().then((value) {
|
||||
@@ -569,6 +587,21 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
if (defaultLocation != null &&
|
||||
defaultLocation?.pk != widget.item.locationId) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().locationDefault),
|
||||
subtitle: Text(defaultLocation!.pathstring),
|
||||
leading: Icon(TablerIcons.map_pin),
|
||||
trailing: LinkIcon(),
|
||||
onTap: () {
|
||||
defaultLocation?.goToDetailPage(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Quantity information
|
||||
if (widget.item.isSerialized()) {
|
||||
tiles.add(
|
||||
@@ -744,7 +777,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().lastStocktake),
|
||||
subtitle: Text(widget.item.stocktakeDateString),
|
||||
trailing: LargeText(widget.item.stocktakeDateString),
|
||||
leading: Icon(TablerIcons.calendar),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user