mirror of
https://github.com/inventree/inventree-app.git
synced 2025-07-01 19:30:44 +00:00
Format Code and Add Format Checks to CI (#643)
* Remove unused lib/generated/i18n.dart * Use `fvm dart format .` * Add contributing guidelines * Enforce dart format * Add `dart format off` directive to generated files
This commit is contained in:
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
/*
|
||||
* Widget for displaying detail view of a single SalesOrderLineItem
|
||||
*/
|
||||
@ -22,21 +20,16 @@ import "package:inventree/l10.dart";
|
||||
import "package:inventree/helpers.dart";
|
||||
import "package:inventree/api_form.dart";
|
||||
|
||||
|
||||
class SoLineDetailWidget extends StatefulWidget {
|
||||
|
||||
const SoLineDetailWidget(this.item, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreeSOLineItem item;
|
||||
|
||||
@override
|
||||
_SOLineDetailWidgetState createState() => _SOLineDetailWidgetState();
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
|
||||
_SOLineDetailWidgetState();
|
||||
|
||||
InvenTreeSalesOrder? order;
|
||||
@ -51,10 +44,11 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
if (widget.item.canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
onPressed: () {
|
||||
_editLineItem(context);
|
||||
}),
|
||||
icon: Icon(TablerIcons.edit),
|
||||
onPressed: () {
|
||||
_editLineItem(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -62,7 +56,6 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
}
|
||||
|
||||
Future<void> _allocateStock(BuildContext context) async {
|
||||
|
||||
if (order == null) {
|
||||
return;
|
||||
}
|
||||
@ -73,12 +66,10 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
fields["stock_item"]?["filters"] = {
|
||||
"in_stock": true,
|
||||
"available": true,
|
||||
"part": widget.item.partId.toString()
|
||||
"part": widget.item.partId.toString(),
|
||||
};
|
||||
fields["quantity"]?["value"] = widget.item.unallocatedQuantity.toString();
|
||||
fields["shipment"]?["filters"] = {
|
||||
"order": order!.pk.toString()
|
||||
};
|
||||
fields["shipment"]?["filters"] = {"order": order!.pk.toString()};
|
||||
|
||||
launchApiForm(
|
||||
context,
|
||||
@ -89,9 +80,8 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
icon: TablerIcons.transition_right,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
Future<void> _editLineItem(BuildContext context) async {
|
||||
@ -109,13 +99,12 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().lineItemUpdated, success: true);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<SpeedDialChild> actionButtons(BuildContext context) {
|
||||
|
||||
List<SpeedDialChild> buttons = [];
|
||||
|
||||
if (order != null && order!.isOpen) {
|
||||
@ -125,8 +114,8 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
label: L10().allocateStock,
|
||||
onTap: () async {
|
||||
_allocateStock(context);
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -138,22 +127,21 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (order != null && order!.isOpen && InvenTreeSOLineItem().canCreate) {
|
||||
|
||||
if (api.supportsBarcodeSOAllocateEndpoint) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.transition_right),
|
||||
label: L10().allocateStock,
|
||||
onTap: () async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: SOAllocateStockHandler(
|
||||
salesOrder: order,
|
||||
lineItem: widget.item
|
||||
)
|
||||
);
|
||||
}
|
||||
)
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.transition_right),
|
||||
label: L10().allocateStock,
|
||||
onTap: () async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: SOAllocateStockHandler(
|
||||
salesOrder: order,
|
||||
lineItem: widget.item,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -193,8 +181,8 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
// Available quantity
|
||||
@ -202,8 +190,8 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
ListTile(
|
||||
title: Text(L10().availableStock),
|
||||
leading: Icon(TablerIcons.packages),
|
||||
trailing: Text(simpleNumberString(widget.item.availableStock))
|
||||
)
|
||||
trailing: Text(simpleNumberString(widget.item.availableStock)),
|
||||
),
|
||||
);
|
||||
|
||||
// Allocated quantity
|
||||
@ -215,10 +203,10 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
trailing: Text(
|
||||
widget.item.allocatedString,
|
||||
style: TextStyle(
|
||||
color: widget.item.isAllocated ? COLOR_SUCCESS : COLOR_WARNING
|
||||
)
|
||||
)
|
||||
)
|
||||
color: widget.item.isAllocated ? COLOR_SUCCESS : COLOR_WARNING,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Shipped quantity
|
||||
@ -229,11 +217,11 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
trailing: Text(
|
||||
widget.item.progressString,
|
||||
style: TextStyle(
|
||||
color: widget.item.isComplete ? COLOR_SUCCESS : COLOR_WARNING
|
||||
color: widget.item.isComplete ? COLOR_SUCCESS : COLOR_WARNING,
|
||||
),
|
||||
),
|
||||
leading: Icon(TablerIcons.truck)
|
||||
)
|
||||
leading: Icon(TablerIcons.truck),
|
||||
),
|
||||
);
|
||||
|
||||
// Reference
|
||||
@ -242,36 +230,36 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
ListTile(
|
||||
title: Text(L10().reference),
|
||||
subtitle: Text(widget.item.reference),
|
||||
leading: Icon(TablerIcons.hash)
|
||||
)
|
||||
leading: Icon(TablerIcons.hash),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Note
|
||||
if (widget.item.notes.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().notes),
|
||||
subtitle: Text(widget.item.notes),
|
||||
leading: Icon(TablerIcons.note),
|
||||
)
|
||||
ListTile(
|
||||
title: Text(L10().notes),
|
||||
subtitle: Text(widget.item.notes),
|
||||
leading: Icon(TablerIcons.note),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// External link
|
||||
if (widget.item.link.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().link),
|
||||
subtitle: Text(widget.item.link),
|
||||
leading: Icon(TablerIcons.link, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
await openLink(widget.item.link);
|
||||
},
|
||||
)
|
||||
ListTile(
|
||||
title: Text(L10().link),
|
||||
subtitle: Text(widget.item.link),
|
||||
leading: Icon(TablerIcons.link, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
await openLink(widget.item.link);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return tiles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user