mirror of
https://github.com/inventree/inventree-app.git
synced 2026-04-25 19:03:25 +00:00
Build Order (#673)
* WIP * Remove debug msg * Add required roles * More roles * Fix refresh for BuildDetail widget * Add attachments widget * Translated text * Further updates * More translations * Form field updates * Cleanup * Code formatting * Fix duplicate import * formatting * Remove duplicate switch case * Update to match modern app * Improved required parts list * Filtering for build outputs * Display list of allocated stock items * Display source and destination locations * Fix typo * Add build orders to drawer * Fix hard-coded string * Set default filter value * Tweak build fields (remove "notes") * Fixes * Add "start_date" to build edit form * Disable editing of build line * Tweak build item / build detail views * Remove unused func * Remove unused import --------- Co-authored-by: Asterix\Oliver <oliver@currawongeng.com> Co-authored-by: Oliver Walters <oliver.henry.walters@gmail.com>
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
import "package:inventree/api.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
import "package:inventree/inventree/build.dart";
|
||||
import "package:inventree/inventree/model.dart";
|
||||
import "package:inventree/widget/paginator.dart";
|
||||
import "package:inventree/widget/build/build_item_detail.dart";
|
||||
import "package:inventree/widget/progress.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
class PaginatedBuildItemWidget extends StatefulWidget {
|
||||
const PaginatedBuildItemWidget(this.build, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreeBuildOrder build;
|
||||
|
||||
@override
|
||||
_PaginatedBuildItemWidgetState createState() =>
|
||||
_PaginatedBuildItemWidgetState();
|
||||
}
|
||||
|
||||
class _PaginatedBuildItemWidgetState
|
||||
extends RefreshableState<PaginatedBuildItemWidget> {
|
||||
_PaginatedBuildItemWidgetState();
|
||||
|
||||
@override
|
||||
String getAppBarTitle() {
|
||||
return L10().allocatedStock;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
Map<String, String> filters = {"build": widget.build.pk.toString()};
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: InvenTreeAPI().getThumbnail(
|
||||
widget.build.partDetail!.thumbnail,
|
||||
),
|
||||
title: Text(widget.build.reference),
|
||||
subtitle: Text(L10().allocatedStock),
|
||||
),
|
||||
Divider(thickness: 1.25),
|
||||
Expanded(child: PaginatedBuildItemList(filters)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Paginated widget class for displaying a list of build order item allocations
|
||||
*/
|
||||
class PaginatedBuildItemList extends PaginatedSearchWidget {
|
||||
const PaginatedBuildItemList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().allocatedStock;
|
||||
|
||||
@override
|
||||
_PaginatedBuildItemListState createState() => _PaginatedBuildItemListState();
|
||||
}
|
||||
|
||||
/*
|
||||
* State class for PaginatedBuildItemList
|
||||
*/
|
||||
class _PaginatedBuildItemListState
|
||||
extends PaginatedSearchState<PaginatedBuildItemList> {
|
||||
_PaginatedBuildItemListState() : super();
|
||||
|
||||
@override
|
||||
String get prefix => "build_item_";
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"stock_item": L10().stockItem,
|
||||
"quantity": L10().quantity,
|
||||
};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit,
|
||||
int offset,
|
||||
Map<String, String> params,
|
||||
) async {
|
||||
params["part_detail"] = "true";
|
||||
|
||||
final page = await InvenTreeBuildItem().listPaginated(
|
||||
limit,
|
||||
offset,
|
||||
filters: params,
|
||||
);
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
InvenTreeBuildItem item = model as InvenTreeBuildItem;
|
||||
|
||||
// Format the serialized data
|
||||
String info = "";
|
||||
|
||||
// Show serial number if available
|
||||
if (item.serialNumber.isNotEmpty) {
|
||||
info = "${L10().serialNumber}: ${item.serialNumber}";
|
||||
}
|
||||
// Show batch code if available
|
||||
else if (item.batchCode.isNotEmpty) {
|
||||
info = "${L10().batchCode}: ${item.batchCode}";
|
||||
}
|
||||
// Otherwise show location
|
||||
else if (item.locationName.isNotEmpty) {
|
||||
info = item.locationPath;
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
title: Text(item.partName),
|
||||
subtitle: Text(info),
|
||||
trailing: Text(
|
||||
item.quantity.toString(),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
leading: InvenTreeAPI().getThumbnail(item.partThumbnail),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
await item.reload();
|
||||
hideLoadingOverlay();
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => BuildItemDetailWidget(item)),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user