mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-16 12:15:31 +00:00
Format code
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
|
||||
import "dart:io";
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
@ -17,7 +16,6 @@ import "package:inventree/widget/progress.dart";
|
||||
import "package:inventree/widget/snacks.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
/*
|
||||
* A generic widget for displaying a list of attachments.
|
||||
*
|
||||
@ -25,8 +23,9 @@ import "package:inventree/widget/refreshable_state.dart";
|
||||
* we pass a subclassed instance of the InvenTreeAttachment model.
|
||||
*/
|
||||
class AttachmentWidget extends StatefulWidget {
|
||||
|
||||
const AttachmentWidget(this.attachmentClass, this.modelId, this.imagePrefix, this.hasUploadPermission) : super();
|
||||
const AttachmentWidget(this.attachmentClass, this.modelId, this.imagePrefix,
|
||||
this.hasUploadPermission)
|
||||
: super();
|
||||
|
||||
final InvenTreeAttachment attachmentClass;
|
||||
final int modelId;
|
||||
@ -37,9 +36,7 @@ class AttachmentWidget extends StatefulWidget {
|
||||
_AttachmentWidgetState createState() => _AttachmentWidgetState();
|
||||
}
|
||||
|
||||
|
||||
class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
||||
|
||||
_AttachmentWidgetState();
|
||||
|
||||
List<InvenTreeAttachment> attachments = [];
|
||||
@ -53,42 +50,37 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
||||
|
||||
return [
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.camera),
|
||||
onPressed: () async {
|
||||
widget.attachmentClass.uploadImage(
|
||||
widget.modelId,
|
||||
prefix: widget.imagePrefix,
|
||||
);
|
||||
FilePickerDialog.pickImageFromCamera().then((File? file) {
|
||||
upload(context, file).then((_) {
|
||||
refresh(context);
|
||||
icon: Icon(TablerIcons.camera),
|
||||
onPressed: () async {
|
||||
widget.attachmentClass.uploadImage(
|
||||
widget.modelId,
|
||||
prefix: widget.imagePrefix,
|
||||
);
|
||||
FilePickerDialog.pickImageFromCamera().then((File? file) {
|
||||
upload(context, file).then((_) {
|
||||
refresh(context);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
),
|
||||
}),
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.file_upload),
|
||||
onPressed: () async {
|
||||
FilePickerDialog.pickFileFromDevice().then((File? file) {
|
||||
upload(context, file).then((_) {
|
||||
refresh(context);
|
||||
icon: Icon(TablerIcons.file_upload),
|
||||
onPressed: () async {
|
||||
FilePickerDialog.pickFileFromDevice().then((File? file) {
|
||||
upload(context, file).then((_) {
|
||||
refresh(context);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
)
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
Future<void> upload(BuildContext context, File? file) async {
|
||||
|
||||
if (file == null) return;
|
||||
|
||||
showLoadingOverlay();
|
||||
|
||||
final bool result = await widget.attachmentClass.uploadAttachment(
|
||||
file,
|
||||
widget.modelId
|
||||
);
|
||||
final bool result =
|
||||
await widget.attachmentClass.uploadAttachment(file, widget.modelId);
|
||||
|
||||
hideLoadingOverlay();
|
||||
|
||||
@ -101,82 +93,69 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
||||
refresh(context);
|
||||
}
|
||||
|
||||
|
||||
Future<void> editAttachment(BuildContext context, InvenTreeAttachment attachment) async
|
||||
{
|
||||
attachment.editForm(context, L10().editAttachment).then((result) => {
|
||||
refresh(context)
|
||||
});
|
||||
Future<void> editAttachment(
|
||||
BuildContext context, InvenTreeAttachment attachment) async {
|
||||
attachment
|
||||
.editForm(context, L10().editAttachment)
|
||||
.then((result) => {refresh(context)});
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete the specified attachment
|
||||
*/
|
||||
Future<void> deleteAttachment(BuildContext context, InvenTreeAttachment attachment) async {
|
||||
|
||||
Future<void> deleteAttachment(
|
||||
BuildContext context, InvenTreeAttachment attachment) async {
|
||||
final bool result = await attachment.delete();
|
||||
|
||||
showSnackIcon(
|
||||
result ? L10().deleteSuccess : L10().deleteFailed,
|
||||
success: result
|
||||
);
|
||||
showSnackIcon(result ? L10().deleteSuccess : L10().deleteFailed,
|
||||
success: result);
|
||||
|
||||
refresh(context);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Display an option context menu for the selected attachment
|
||||
*/
|
||||
Future<void> showOptionsMenu(BuildContext context, InvenTreeAttachment attachment) async {
|
||||
|
||||
OneContext().showDialog(
|
||||
builder: (BuildContext ctx) {
|
||||
return SimpleDialog(
|
||||
title: Text(L10().attachments),
|
||||
children: [
|
||||
Divider(),
|
||||
SimpleDialogOption(
|
||||
onPressed: () async {
|
||||
OneContext().popDialog();
|
||||
editAttachment(context, attachment);
|
||||
},
|
||||
child: ListTile(
|
||||
title: Text(L10().edit),
|
||||
leading: Icon(TablerIcons.edit),
|
||||
)
|
||||
),
|
||||
SimpleDialogOption(
|
||||
onPressed: () async {
|
||||
OneContext().popDialog();
|
||||
deleteAttachment(context, attachment);
|
||||
},
|
||||
child: ListTile(
|
||||
title: Text(L10().delete),
|
||||
leading: Icon(TablerIcons.trash, color: COLOR_DANGER),
|
||||
)
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
);
|
||||
Future<void> showOptionsMenu(
|
||||
BuildContext context, InvenTreeAttachment attachment) async {
|
||||
OneContext().showDialog(builder: (BuildContext ctx) {
|
||||
return SimpleDialog(title: Text(L10().attachments), children: [
|
||||
Divider(),
|
||||
SimpleDialogOption(
|
||||
onPressed: () async {
|
||||
OneContext().popDialog();
|
||||
editAttachment(context, attachment);
|
||||
},
|
||||
child: ListTile(
|
||||
title: Text(L10().edit),
|
||||
leading: Icon(TablerIcons.edit),
|
||||
)),
|
||||
SimpleDialogOption(
|
||||
onPressed: () async {
|
||||
OneContext().popDialog();
|
||||
deleteAttachment(context, attachment);
|
||||
},
|
||||
child: ListTile(
|
||||
title: Text(L10().delete),
|
||||
leading: Icon(TablerIcons.trash, color: COLOR_DANGER),
|
||||
))
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> request(BuildContext context) async {
|
||||
|
||||
Map<String, String> filters = {};
|
||||
|
||||
if (InvenTreeAPI().supportsModernAttachments) {
|
||||
filters["model_type"] = widget.attachmentClass.REF_MODEL_TYPE;
|
||||
filters["model_id"] = widget.modelId.toString();
|
||||
} else {
|
||||
filters[widget.attachmentClass.REFERENCE_FIELD] = widget.modelId.toString();
|
||||
filters[widget.attachmentClass.REFERENCE_FIELD] =
|
||||
widget.modelId.toString();
|
||||
}
|
||||
|
||||
await widget.attachmentClass.list(
|
||||
filters: filters
|
||||
).then((var results) {
|
||||
await widget.attachmentClass.list(filters: filters).then((var results) {
|
||||
attachments.clear();
|
||||
|
||||
for (var result in results) {
|
||||
@ -186,18 +165,15 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
||||
}
|
||||
});
|
||||
|
||||
setState(() {
|
||||
});
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
List<Widget> getTiles(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [];
|
||||
|
||||
// An "attachment" can either be a file, or a URL
|
||||
for (var attachment in attachments) {
|
||||
|
||||
if (attachment.filename.isNotEmpty) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(attachment.filename),
|
||||
@ -208,13 +184,11 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
||||
await attachment.downloadAttachment();
|
||||
hideLoadingOverlay();
|
||||
},
|
||||
onLongPress: () {
|
||||
onLongPress: () {
|
||||
showOptionsMenu(context, attachment);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
else if (attachment.link.isNotEmpty) {
|
||||
} else if (attachment.link.isNotEmpty) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(attachment.link),
|
||||
subtitle: Text(attachment.comment),
|
||||
@ -225,7 +199,7 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
||||
await launchUrl(uri);
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
onLongPress: () {
|
||||
showOptionsMenu(context, attachment);
|
||||
},
|
||||
));
|
||||
|
@ -6,7 +6,6 @@ import "package:flutter/material.dart";
|
||||
* Long-pressing on this will return the user to the home screen
|
||||
*/
|
||||
Widget backButton(BuildContext context, GlobalKey<ScaffoldState> key) {
|
||||
|
||||
return GestureDetector(
|
||||
onLongPress: () {
|
||||
// Display the menu
|
||||
@ -21,4 +20,4 @@ Widget backButton(BuildContext context, GlobalKey<ScaffoldState> key) {
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -16,24 +16,19 @@ import "package:inventree/widget/refreshable_state.dart";
|
||||
import "package:inventree/widget/snacks.dart";
|
||||
import "package:inventree/widget/company/supplier_part_list.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Widget for displaying detail view of a single Company instance
|
||||
*/
|
||||
class CompanyDetailWidget extends StatefulWidget {
|
||||
|
||||
const CompanyDetailWidget(this.company, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreeCompany company;
|
||||
|
||||
@override
|
||||
_CompanyDetailState createState() => _CompanyDetailState();
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
|
||||
_CompanyDetailState();
|
||||
|
||||
int supplierPartCount = 0;
|
||||
@ -59,17 +54,14 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (InvenTreeCompany().canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().companyEdit,
|
||||
onPressed: () {
|
||||
editCompany(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().companyEdit,
|
||||
onPressed: () {
|
||||
editCompany(context);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
@ -79,22 +71,20 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
|
||||
if (widget.company.isCustomer && InvenTreeSalesOrder().canCreate) {
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.truck),
|
||||
label: L10().salesOrderCreate,
|
||||
onTap: () async {
|
||||
_createSalesOrder(context);
|
||||
}
|
||||
));
|
||||
child: Icon(TablerIcons.truck),
|
||||
label: L10().salesOrderCreate,
|
||||
onTap: () async {
|
||||
_createSalesOrder(context);
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.company.isSupplier && InvenTreePurchaseOrder().canCreate) {
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.shopping_cart),
|
||||
label: L10().purchaseOrderCreate,
|
||||
onTap: () async {
|
||||
_createPurchaseOrder(context);
|
||||
}
|
||||
));
|
||||
child: Icon(TablerIcons.shopping_cart),
|
||||
label: L10().purchaseOrderCreate,
|
||||
onTap: () async {
|
||||
_createPurchaseOrder(context);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -108,19 +98,15 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
|
||||
fields["customer"]?["value"] = widget.company.pk;
|
||||
|
||||
InvenTreeSalesOrder().createForm(
|
||||
context,
|
||||
L10().salesOrderCreate,
|
||||
fields: fields,
|
||||
onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
InvenTreeSalesOrder().createForm(context, L10().salesOrderCreate,
|
||||
fields: fields, onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey("pk")) {
|
||||
var order = InvenTreeSalesOrder.fromJson(data);
|
||||
order.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (data.containsKey("pk")) {
|
||||
var order = InvenTreeSalesOrder.fromJson(data);
|
||||
order.goToDetailPage(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _createPurchaseOrder(BuildContext context) async {
|
||||
@ -131,19 +117,15 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
|
||||
fields["supplier"]?["value"] = widget.company.pk;
|
||||
|
||||
InvenTreePurchaseOrder().createForm(
|
||||
context,
|
||||
L10().purchaseOrderCreate,
|
||||
fields: fields,
|
||||
onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
InvenTreePurchaseOrder().createForm(context, L10().purchaseOrderCreate,
|
||||
fields: fields, onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey("pk")) {
|
||||
var order = InvenTreePurchaseOrder.fromJson(data);
|
||||
order.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (data.containsKey("pk")) {
|
||||
var order = InvenTreePurchaseOrder.fromJson(data);
|
||||
order.goToDetailPage(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -156,23 +138,22 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
return;
|
||||
}
|
||||
|
||||
outstandingPurchaseOrders = widget.company.isSupplier ?
|
||||
await InvenTreePurchaseOrder().count(filters: {
|
||||
"supplier": widget.company.pk.toString(),
|
||||
"outstanding": "true"
|
||||
}) : 0;
|
||||
outstandingPurchaseOrders = widget.company.isSupplier
|
||||
? await InvenTreePurchaseOrder().count(filters: {
|
||||
"supplier": widget.company.pk.toString(),
|
||||
"outstanding": "true"
|
||||
})
|
||||
: 0;
|
||||
|
||||
outstandingSalesOrders = widget.company.isCustomer
|
||||
? await InvenTreeSalesOrder().count(filters: {
|
||||
"customer": widget.company.pk.toString(),
|
||||
"outstanding": "true"
|
||||
})
|
||||
: 0;
|
||||
|
||||
outstandingSalesOrders = widget.company.isCustomer ?
|
||||
await InvenTreeSalesOrder().count(filters: {
|
||||
"customer": widget.company.pk.toString(),
|
||||
"outstanding": "true"
|
||||
}) : 0;
|
||||
|
||||
InvenTreeSupplierPart().count(
|
||||
filters: {
|
||||
"supplier": widget.company.pk.toString()
|
||||
}
|
||||
).then((value) {
|
||||
filters: {"supplier": widget.company.pk.toString()}).then((value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
supplierPartCount = value;
|
||||
@ -180,8 +161,9 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
}
|
||||
});
|
||||
|
||||
InvenTreeCompanyAttachment().countAttachments(widget.company.pk)
|
||||
.then((value) {
|
||||
InvenTreeCompanyAttachment()
|
||||
.countAttachments(widget.company.pk)
|
||||
.then((value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
attachmentCount = value;
|
||||
@ -190,16 +172,12 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
});
|
||||
}
|
||||
|
||||
Future <void> editCompany(BuildContext context) async {
|
||||
|
||||
widget.company.editForm(
|
||||
context,
|
||||
L10().companyEdit,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().companyUpdated, success: true);
|
||||
}
|
||||
);
|
||||
Future<void> editCompany(BuildContext context) async {
|
||||
widget.company.editForm(context, L10().companyEdit,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().companyUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
@ -207,7 +185,6 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
*/
|
||||
@override
|
||||
List<Widget> getTiles(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [];
|
||||
|
||||
bool sep = false;
|
||||
@ -221,63 +198,49 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
));
|
||||
|
||||
if (!widget.company.active) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10().inactive,
|
||||
style: TextStyle(
|
||||
color: COLOR_DANGER
|
||||
)
|
||||
),
|
||||
subtitle: Text(
|
||||
L10().inactiveCompany,
|
||||
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().inactiveCompany, style: TextStyle(color: COLOR_DANGER)),
|
||||
leading: Icon(TablerIcons.exclamation_circle, color: COLOR_DANGER),
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.company.website.isNotEmpty) {
|
||||
tiles.add(ListTile(
|
||||
title: Text("${widget.company.website}"),
|
||||
leading: Icon(TablerIcons.globe, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
openLink(widget.company.website);
|
||||
},
|
||||
));
|
||||
if (widget.company.website.isNotEmpty) {
|
||||
tiles.add(ListTile(
|
||||
title: Text("${widget.company.website}"),
|
||||
leading: Icon(TablerIcons.globe, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
openLink(widget.company.website);
|
||||
},
|
||||
));
|
||||
|
||||
sep = true;
|
||||
}
|
||||
sep = true;
|
||||
}
|
||||
|
||||
if (widget.company.email.isNotEmpty) {
|
||||
tiles.add(ListTile(
|
||||
title: Text("${widget.company.email}"),
|
||||
leading: Icon(TablerIcons.at, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
openLink("mailto:${widget.company.email}");
|
||||
},
|
||||
));
|
||||
if (widget.company.email.isNotEmpty) {
|
||||
tiles.add(ListTile(
|
||||
title: Text("${widget.company.email}"),
|
||||
leading: Icon(TablerIcons.at, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
openLink("mailto:${widget.company.email}");
|
||||
},
|
||||
));
|
||||
|
||||
sep = true;
|
||||
}
|
||||
sep = true;
|
||||
}
|
||||
|
||||
if (widget.company.phone.isNotEmpty) {
|
||||
tiles.add(ListTile(
|
||||
title: Text("${widget.company.phone}"),
|
||||
leading: Icon(TablerIcons.phone, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
openLink("tel:${widget.company.phone}");
|
||||
},
|
||||
));
|
||||
if (widget.company.phone.isNotEmpty) {
|
||||
tiles.add(ListTile(
|
||||
title: Text("${widget.company.phone}"),
|
||||
leading: Icon(TablerIcons.phone, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
openLink("tel:${widget.company.phone}");
|
||||
},
|
||||
));
|
||||
|
||||
sep = true;
|
||||
}
|
||||
sep = true;
|
||||
}
|
||||
|
||||
// External link
|
||||
if (widget.company.link.isNotEmpty) {
|
||||
@ -297,46 +260,31 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
}
|
||||
|
||||
if (widget.company.isSupplier) {
|
||||
|
||||
if (supplierPartCount > 0) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().supplierParts),
|
||||
leading: Icon(TablerIcons.building, color: COLOR_ACTION),
|
||||
trailing: Text(supplierPartCount.toString()),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SupplierPartList({
|
||||
"supplier": widget.company.pk.toString()
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SupplierPartList(
|
||||
{"supplier": widget.company.pk.toString()})));
|
||||
}));
|
||||
}
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().purchaseOrders),
|
||||
leading: Icon(TablerIcons.shopping_cart, color: COLOR_ACTION),
|
||||
trailing: Text("${outstandingPurchaseOrders}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PurchaseOrderListWidget(
|
||||
filters: {
|
||||
"supplier": "${widget.company.pk}"
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PurchaseOrderListWidget(
|
||||
filters: {"supplier": "${widget.company.pk}"})));
|
||||
}));
|
||||
|
||||
// TODO: Display "supplied parts" count (click through to list of supplier parts)
|
||||
/*
|
||||
@ -355,25 +303,17 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
}
|
||||
|
||||
if (widget.company.isCustomer) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().salesOrders),
|
||||
leading: Icon(TablerIcons.truck, color: COLOR_ACTION),
|
||||
trailing: Text("${outstandingSalesOrders}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SalesOrderListWidget(
|
||||
filters: {
|
||||
"customer": widget.company.pk.toString()
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SalesOrderListWidget(
|
||||
filters: {"customer": widget.company.pk.toString()})));
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.company.notes.isNotEmpty) {
|
||||
@ -384,27 +324,21 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
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(
|
||||
InvenTreeCompanyAttachment(),
|
||||
widget.company.pk,
|
||||
widget.company.name,
|
||||
InvenTreeCompany().canEdit
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
));
|
||||
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(
|
||||
InvenTreeCompanyAttachment(),
|
||||
widget.company.pk,
|
||||
widget.company.name,
|
||||
InvenTreeCompany().canEdit)));
|
||||
}));
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_speed_dial/flutter_speed_dial.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
@ -12,13 +11,12 @@ import "package:inventree/inventree/model.dart";
|
||||
import "package:inventree/widget/paginator.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Widget for displaying a filterable list of Company instances
|
||||
*/
|
||||
class CompanyListWidget extends StatefulWidget {
|
||||
|
||||
const CompanyListWidget(this.title, this.filters, {Key? key}) : super(key: key);
|
||||
const CompanyListWidget(this.title, this.filters, {Key? key})
|
||||
: super(key: key);
|
||||
|
||||
final String title;
|
||||
|
||||
@ -28,29 +26,22 @@ class CompanyListWidget extends StatefulWidget {
|
||||
_CompanyListWidgetState createState() => _CompanyListWidgetState();
|
||||
}
|
||||
|
||||
|
||||
class _CompanyListWidgetState extends RefreshableState<CompanyListWidget> {
|
||||
|
||||
_CompanyListWidgetState();
|
||||
|
||||
@override
|
||||
String getAppBarTitle() => widget.title;
|
||||
|
||||
Future<void> _addCompany(BuildContext context) async {
|
||||
InvenTreeCompany().createForm(context, L10().companyAdd,
|
||||
data: widget.filters, onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
InvenTreeCompany().createForm(
|
||||
context,
|
||||
L10().companyAdd,
|
||||
data: widget.filters,
|
||||
onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey("pk")) {
|
||||
var company = InvenTreeCompany.fromJson(data);
|
||||
company.goToDetailPage(context);
|
||||
}
|
||||
if (data.containsKey("pk")) {
|
||||
var company = InvenTreeCompany.fromJson(data);
|
||||
company.goToDetailPage(context);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -58,15 +49,12 @@ class _CompanyListWidgetState extends RefreshableState<CompanyListWidget> {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (InvenTreeAPI().checkPermission("company", "add")) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().companyAdd,
|
||||
onTap: () {
|
||||
_addCompany(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().companyAdd,
|
||||
onTap: () {
|
||||
_addCompany(context);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -76,12 +64,11 @@ class _CompanyListWidgetState extends RefreshableState<CompanyListWidget> {
|
||||
Widget getBody(BuildContext context) {
|
||||
return PaginatedCompanyList(widget.title, widget.filters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PaginatedCompanyList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedCompanyList(this.companyTitle, Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedCompanyList(this.companyTitle, Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
final String companyTitle;
|
||||
|
||||
@ -93,12 +80,10 @@ class PaginatedCompanyList extends PaginatedSearchWidget {
|
||||
}
|
||||
|
||||
class _CompanyListState extends PaginatedSearchState<PaginatedCompanyList> {
|
||||
|
||||
_CompanyListState() : super();
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions {
|
||||
|
||||
Map<String, Map<String, dynamic>> filters = {};
|
||||
|
||||
if (InvenTreeAPI().supportsCompanyActiveStatus) {
|
||||
@ -113,16 +98,16 @@ class _CompanyListState extends PaginatedSearchState<PaginatedCompanyList> {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
final page = await InvenTreeCompany().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page =
|
||||
await InvenTreeCompany().listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreeCompany company = model as InvenTreeCompany;
|
||||
|
||||
return ListTile(
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_speed_dial/flutter_speed_dial.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
@ -19,19 +18,18 @@ import "package:url_launcher/url_launcher.dart";
|
||||
* Detail widget for viewing a single ManufacturerPart instance
|
||||
*/
|
||||
class ManufacturerPartDetailWidget extends StatefulWidget {
|
||||
|
||||
const ManufacturerPartDetailWidget(this.manufacturerPart, {Key? key})
|
||||
: super(key: key);
|
||||
|
||||
final InvenTreeManufacturerPart manufacturerPart;
|
||||
|
||||
@override
|
||||
_ManufacturerPartDisplayState createState() => _ManufacturerPartDisplayState();
|
||||
_ManufacturerPartDisplayState createState() =>
|
||||
_ManufacturerPartDisplayState();
|
||||
}
|
||||
|
||||
|
||||
class _ManufacturerPartDisplayState extends RefreshableState<ManufacturerPartDetailWidget> {
|
||||
|
||||
class _ManufacturerPartDisplayState
|
||||
extends RefreshableState<ManufacturerPartDetailWidget> {
|
||||
_ManufacturerPartDisplayState();
|
||||
|
||||
@override
|
||||
@ -48,14 +46,11 @@ class _ManufacturerPartDisplayState extends RefreshableState<ManufacturerPartDet
|
||||
}
|
||||
|
||||
Future<void> editManufacturerPart(BuildContext context) async {
|
||||
widget.manufacturerPart.editForm(
|
||||
context,
|
||||
L10().manufacturerPartEdit,
|
||||
widget.manufacturerPart.editForm(context, L10().manufacturerPartEdit,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().itemUpdated, success: true);
|
||||
}
|
||||
);
|
||||
refresh(context);
|
||||
showSnackIcon(L10().itemUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -72,15 +67,12 @@ class _ManufacturerPartDisplayState extends RefreshableState<ManufacturerPartDet
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (widget.manufacturerPart.canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().edit,
|
||||
onPressed: () {
|
||||
editManufacturerPart(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().edit,
|
||||
onPressed: () {
|
||||
editManufacturerPart(context);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -99,79 +91,69 @@ class _ManufacturerPartDisplayState extends RefreshableState<ManufacturerPartDet
|
||||
}
|
||||
|
||||
// Internal Part
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().internalPart),
|
||||
subtitle: Text(widget.manufacturerPart.partName),
|
||||
leading: Icon(TablerIcons.box, color: COLOR_ACTION),
|
||||
trailing: InvenTreeAPI().getThumbnail(widget.manufacturerPart.partImage),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
final part = await InvenTreePart().get(widget.manufacturerPart.partId);
|
||||
hideLoadingOverlay();
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().internalPart),
|
||||
subtitle: Text(widget.manufacturerPart.partName),
|
||||
leading: Icon(TablerIcons.box, color: COLOR_ACTION),
|
||||
trailing: InvenTreeAPI().getThumbnail(widget.manufacturerPart.partImage),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
final part = await InvenTreePart().get(widget.manufacturerPart.partId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
));
|
||||
|
||||
// Manufacturer details
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().manufacturer),
|
||||
subtitle: Text(widget.manufacturerPart.manufacturerName),
|
||||
leading: Icon(TablerIcons.building_factory_2, color: COLOR_ACTION),
|
||||
trailing: InvenTreeAPI().getThumbnail(widget.manufacturerPart.manufacturerImage),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
var supplier = await InvenTreeCompany().get(widget.manufacturerPart.manufacturerId);
|
||||
hideLoadingOverlay();
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().manufacturer),
|
||||
subtitle: Text(widget.manufacturerPart.manufacturerName),
|
||||
leading: Icon(TablerIcons.building_factory_2, color: COLOR_ACTION),
|
||||
trailing: InvenTreeAPI()
|
||||
.getThumbnail(widget.manufacturerPart.manufacturerImage),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
var supplier = await InvenTreeCompany()
|
||||
.get(widget.manufacturerPart.manufacturerId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (supplier is InvenTreeCompany) {
|
||||
supplier.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
if (supplier is InvenTreeCompany) {
|
||||
supplier.goToDetailPage(context);
|
||||
}
|
||||
}));
|
||||
|
||||
// MPN (part number)
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().manufacturerPartNumber),
|
||||
subtitle: Text(widget.manufacturerPart.MPN),
|
||||
leading: Icon(TablerIcons.hash),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().manufacturerPartNumber),
|
||||
subtitle: Text(widget.manufacturerPart.MPN),
|
||||
leading: Icon(TablerIcons.hash),
|
||||
));
|
||||
|
||||
// Description
|
||||
if (widget.manufacturerPart.description.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().description),
|
||||
subtitle: Text(widget.manufacturerPart.description),
|
||||
leading: Icon(TablerIcons.info_circle),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().description),
|
||||
subtitle: Text(widget.manufacturerPart.description),
|
||||
leading: Icon(TablerIcons.info_circle),
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.manufacturerPart.link.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(widget.manufacturerPart.link),
|
||||
leading: Icon(TablerIcons.link, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
var uri = Uri.tryParse(widget.manufacturerPart.link);
|
||||
if (uri != null && await canLaunchUrl(uri)) {
|
||||
await launchUrl(uri);
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(widget.manufacturerPart.link),
|
||||
leading: Icon(TablerIcons.link, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
var uri = Uri.tryParse(widget.manufacturerPart.link);
|
||||
if (uri != null && await canLaunchUrl(uri)) {
|
||||
await launchUrl(uri);
|
||||
}
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,13 +17,12 @@ import "package:inventree/widget/refreshable_state.dart";
|
||||
import "package:inventree/widget/snacks.dart";
|
||||
import "package:inventree/widget/company/manufacturer_part_detail.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Detail widget for viewing a single SupplierPart instance
|
||||
*/
|
||||
class SupplierPartDetailWidget extends StatefulWidget {
|
||||
|
||||
const SupplierPartDetailWidget(this.supplierPart, {Key? key}) : super(key: key);
|
||||
const SupplierPartDetailWidget(this.supplierPart, {Key? key})
|
||||
: super(key: key);
|
||||
|
||||
final InvenTreeSupplierPart supplierPart;
|
||||
|
||||
@ -31,9 +30,8 @@ class SupplierPartDetailWidget extends StatefulWidget {
|
||||
_SupplierPartDisplayState createState() => _SupplierPartDisplayState();
|
||||
}
|
||||
|
||||
|
||||
class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidget> {
|
||||
|
||||
class _SupplierPartDisplayState
|
||||
extends RefreshableState<SupplierPartDetailWidget> {
|
||||
_SupplierPartDisplayState();
|
||||
|
||||
@override
|
||||
@ -43,14 +41,11 @@ class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidge
|
||||
* Launch a form to edit the current SupplierPart instance
|
||||
*/
|
||||
Future<void> editSupplierPart(BuildContext context) async {
|
||||
widget.supplierPart.editForm(
|
||||
context,
|
||||
L10().supplierPartEdit,
|
||||
widget.supplierPart.editForm(context, L10().supplierPartEdit,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().supplierPartUpdated, success: true);
|
||||
}
|
||||
);
|
||||
refresh(context);
|
||||
showSnackIcon(L10().supplierPartUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -58,14 +53,12 @@ class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidge
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (widget.supplierPart.canEdit) {
|
||||
actions.add(
|
||||
customBarcodeAction(
|
||||
context, this,
|
||||
actions.add(customBarcodeAction(
|
||||
context,
|
||||
this,
|
||||
widget.supplierPart.customBarcode,
|
||||
"supplierpart",
|
||||
widget.supplierPart.pk
|
||||
)
|
||||
);
|
||||
widget.supplierPart.pk));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -76,15 +69,12 @@ class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidge
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (widget.supplierPart.canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().edit,
|
||||
onPressed: () {
|
||||
editSupplierPart(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().edit,
|
||||
onPressed: () {
|
||||
editSupplierPart(context);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -92,7 +82,8 @@ class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidge
|
||||
|
||||
@override
|
||||
Future<void> request(BuildContext context) async {
|
||||
final bool result = widget.supplierPart.pk > 0 && await widget.supplierPart.reload();
|
||||
final bool result =
|
||||
widget.supplierPart.pk > 0 && await widget.supplierPart.reload();
|
||||
|
||||
if (!result) {
|
||||
Navigator.of(context).pop();
|
||||
@ -112,152 +103,131 @@ class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidge
|
||||
}
|
||||
|
||||
// Internal Part
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().internalPart),
|
||||
subtitle: Text(widget.supplierPart.partName),
|
||||
leading: Icon(TablerIcons.box, color: COLOR_ACTION),
|
||||
trailing: InvenTreeAPI().getThumbnail(widget.supplierPart.partImage),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
final part = await InvenTreePart().get(widget.supplierPart.partId);
|
||||
hideLoadingOverlay();
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().internalPart),
|
||||
subtitle: Text(widget.supplierPart.partName),
|
||||
leading: Icon(TablerIcons.box, color: COLOR_ACTION),
|
||||
trailing: InvenTreeAPI().getThumbnail(widget.supplierPart.partImage),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
final part = await InvenTreePart().get(widget.supplierPart.partId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
));
|
||||
|
||||
if (!widget.supplierPart.active) {
|
||||
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),
|
||||
));
|
||||
}
|
||||
|
||||
// Supplier details
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().supplier),
|
||||
subtitle: Text(widget.supplierPart.supplierName),
|
||||
leading: Icon(TablerIcons.building, color: COLOR_ACTION),
|
||||
trailing: InvenTreeAPI().getThumbnail(widget.supplierPart.supplierImage),
|
||||
trailing:
|
||||
InvenTreeAPI().getThumbnail(widget.supplierPart.supplierImage),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
var supplier = await InvenTreeCompany().get(widget.supplierPart.supplierId);
|
||||
var supplier =
|
||||
await InvenTreeCompany().get(widget.supplierPart.supplierId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (supplier is InvenTreeCompany) {
|
||||
supplier.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
|
||||
// SKU (part number)
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().supplierPartNumber),
|
||||
subtitle: Text(widget.supplierPart.SKU),
|
||||
leading: Icon(TablerIcons.hash),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().supplierPartNumber),
|
||||
subtitle: Text(widget.supplierPart.SKU),
|
||||
leading: Icon(TablerIcons.hash),
|
||||
));
|
||||
|
||||
// Manufacturer information
|
||||
if (widget.supplierPart.manufacturerPartId > 0) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().manufacturer),
|
||||
subtitle: Text(widget.supplierPart.manufacturerName),
|
||||
leading: Icon(TablerIcons.building_factory_2, color: COLOR_ACTION),
|
||||
trailing: InvenTreeAPI().getThumbnail(widget.supplierPart.manufacturerImage),
|
||||
trailing: InvenTreeAPI()
|
||||
.getThumbnail(widget.supplierPart.manufacturerImage),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
var supplier = await InvenTreeCompany().get(widget.supplierPart.manufacturerId);
|
||||
var supplier = await InvenTreeCompany()
|
||||
.get(widget.supplierPart.manufacturerId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (supplier is InvenTreeCompany) {
|
||||
supplier.goToDetailPage(context);
|
||||
}
|
||||
}));
|
||||
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().manufacturerPartNumber),
|
||||
subtitle: Text(widget.supplierPart.MPN),
|
||||
leading: Icon(TablerIcons.hash, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
var manufacturerPart = await InvenTreeManufacturerPart()
|
||||
.get(widget.supplierPart.manufacturerPartId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (manufacturerPart is InvenTreeManufacturerPart) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
ManufacturerPartDetailWidget(manufacturerPart)));
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().manufacturerPartNumber),
|
||||
subtitle: Text(widget.supplierPart.MPN),
|
||||
leading: Icon(TablerIcons.hash, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
var manufacturerPart = await InvenTreeManufacturerPart().get(widget.supplierPart.manufacturerPartId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (manufacturerPart is InvenTreeManufacturerPart) {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) => ManufacturerPartDetailWidget(manufacturerPart)
|
||||
));
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Packaging
|
||||
if (widget.supplierPart.packaging.isNotEmpty || widget.supplierPart.pack_quantity.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().packaging),
|
||||
subtitle: widget.supplierPart.packaging.isNotEmpty ? Text(widget.supplierPart.packaging) : null,
|
||||
leading: Icon(TablerIcons.package),
|
||||
trailing: widget.supplierPart.pack_quantity.isNotEmpty ? Text(widget.supplierPart.pack_quantity) : null,
|
||||
)
|
||||
);
|
||||
if (widget.supplierPart.packaging.isNotEmpty ||
|
||||
widget.supplierPart.pack_quantity.isNotEmpty) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().packaging),
|
||||
subtitle: widget.supplierPart.packaging.isNotEmpty
|
||||
? Text(widget.supplierPart.packaging)
|
||||
: null,
|
||||
leading: Icon(TablerIcons.package),
|
||||
trailing: widget.supplierPart.pack_quantity.isNotEmpty
|
||||
? Text(widget.supplierPart.pack_quantity)
|
||||
: null,
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.supplierPart.link.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(widget.supplierPart.link),
|
||||
leading: Icon(TablerIcons.link, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
var uri = Uri.tryParse(widget.supplierPart.link);
|
||||
if (uri != null && await canLaunchUrl(uri)) {
|
||||
await launchUrl(uri);
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(widget.supplierPart.link),
|
||||
leading: Icon(TablerIcons.link, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
var uri = Uri.tryParse(widget.supplierPart.link);
|
||||
if (uri != null && await canLaunchUrl(uri)) {
|
||||
await launchUrl(uri);
|
||||
}
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.supplierPart.note.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(widget.supplierPart.note),
|
||||
leading: Icon(TablerIcons.pencil),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(widget.supplierPart.note),
|
||||
leading: Icon(TablerIcons.pencil),
|
||||
));
|
||||
}
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,10 @@ import "package:inventree/widget/paginator.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
import "package:inventree/widget/company/supplier_part_detail.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Widget for displaying a list of Supplier Part instances
|
||||
*/
|
||||
class SupplierPartList extends StatefulWidget {
|
||||
|
||||
const SupplierPartList(this.filters);
|
||||
|
||||
final Map<String, String> filters;
|
||||
@ -24,9 +22,7 @@ class SupplierPartList extends StatefulWidget {
|
||||
_SupplierPartListState createState() => _SupplierPartListState();
|
||||
}
|
||||
|
||||
|
||||
class _SupplierPartListState extends RefreshableState<SupplierPartList> {
|
||||
|
||||
@override
|
||||
String getAppBarTitle() => L10().supplierParts;
|
||||
|
||||
@ -34,25 +30,22 @@ class _SupplierPartListState extends RefreshableState<SupplierPartList> {
|
||||
Widget getBody(BuildContext context) {
|
||||
return PaginatedSupplierPartList(widget.filters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class PaginatedSupplierPartList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedSupplierPartList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedSupplierPartList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().supplierParts;
|
||||
|
||||
@override
|
||||
_PaginatedSupplierPartListState createState() => _PaginatedSupplierPartListState();
|
||||
|
||||
_PaginatedSupplierPartListState createState() =>
|
||||
_PaginatedSupplierPartListState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedSupplierPartListState extends PaginatedSearchState<PaginatedSupplierPartList> {
|
||||
|
||||
class _PaginatedSupplierPartListState
|
||||
extends PaginatedSearchState<PaginatedSupplierPartList> {
|
||||
_PaginatedSupplierPartListState() : super();
|
||||
|
||||
@override
|
||||
@ -63,7 +56,6 @@ class _PaginatedSupplierPartListState extends PaginatedSearchState<PaginatedSupp
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions {
|
||||
|
||||
Map<String, Map<String, dynamic>> filters = {};
|
||||
|
||||
if (InvenTreeAPI().supportsCompanyActiveStatus) {
|
||||
@ -78,8 +70,10 @@ class _PaginatedSupplierPartListState extends PaginatedSearchState<PaginatedSupp
|
||||
}
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreeSupplierPart().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreeSupplierPart()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
return page;
|
||||
}
|
||||
|
||||
@ -94,12 +88,10 @@ class _PaginatedSupplierPartListState extends PaginatedSearchState<PaginatedSupp
|
||||
trailing: InvenTreeAPI().getThumbnail(supplierPart.partImage),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SupplierPartDetailWidget(supplierPart)
|
||||
)
|
||||
);
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SupplierPartDetailWidget(supplierPart)));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,61 +9,58 @@ import "package:inventree/l10.dart";
|
||||
import "package:inventree/preferences.dart";
|
||||
import "package:inventree/widget/snacks.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Launch a dialog allowing the user to select from a list of options
|
||||
*/
|
||||
Future<void> choiceDialog(String title, List<Widget> items, {Function? onSelected}) async {
|
||||
|
||||
Future<void> choiceDialog(String title, List<Widget> items,
|
||||
{Function? onSelected}) async {
|
||||
List<Widget> choices = [];
|
||||
|
||||
for (int idx = 0; idx < items.length; idx++) {
|
||||
choices.add(
|
||||
GestureDetector(
|
||||
child: items[idx],
|
||||
onTap: () {
|
||||
OneContext().popDialog();
|
||||
if (onSelected != null) {
|
||||
onSelected(idx);
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
choices.add(GestureDetector(
|
||||
child: items[idx],
|
||||
onTap: () {
|
||||
OneContext().popDialog();
|
||||
if (onSelected != null) {
|
||||
onSelected(idx);
|
||||
}
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
if (!hasContext()) {
|
||||
return;
|
||||
}
|
||||
|
||||
OneContext().showDialog(
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(title),
|
||||
content: SingleChildScrollView(
|
||||
OneContext().showDialog(builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(title),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: choices,
|
||||
)
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(L10().cancel),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
children: choices,
|
||||
)),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(L10().cancel),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Display a "confirmation" dialog allowing the user to accept or reject an action
|
||||
*/
|
||||
Future<void> confirmationDialog(String title, String text, {Color? color, IconData icon = TablerIcons.help_circle, String? acceptText, String? rejectText, Function? onAccept, Function? onReject}) async {
|
||||
|
||||
Future<void> confirmationDialog(String title, String text,
|
||||
{Color? color,
|
||||
IconData icon = TablerIcons.help_circle,
|
||||
String? acceptText,
|
||||
String? rejectText,
|
||||
Function? onAccept,
|
||||
Function? onReject}) async {
|
||||
String _accept = acceptText ?? L10().ok;
|
||||
String _reject = rejectText ?? L10().cancel;
|
||||
|
||||
@ -71,9 +68,8 @@ Future<void> confirmationDialog(String title, String text, {Color? color, IconDa
|
||||
return;
|
||||
}
|
||||
|
||||
OneContext().showDialog(
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
OneContext().showDialog(builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
iconColor: color,
|
||||
title: ListTile(
|
||||
title: Text(title, style: TextStyle(color: color)),
|
||||
@ -82,16 +78,15 @@ Future<void> confirmationDialog(String title, String text, {Color? color, IconDa
|
||||
content: text.isEmpty ? Text(text) : null,
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(_reject),
|
||||
onPressed: () {
|
||||
// Close this dialog
|
||||
Navigator.pop(context);
|
||||
child: Text(_reject),
|
||||
onPressed: () {
|
||||
// Close this dialog
|
||||
Navigator.pop(context);
|
||||
|
||||
if (onReject != null) {
|
||||
onReject();
|
||||
}
|
||||
}
|
||||
),
|
||||
if (onReject != null) {
|
||||
onReject();
|
||||
}
|
||||
}),
|
||||
TextButton(
|
||||
child: Text(_accept),
|
||||
onPressed: () {
|
||||
@ -103,13 +98,10 @@ Future<void> confirmationDialog(String title, String text, {Color? color, IconDa
|
||||
}
|
||||
},
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
);
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Construct an error dialog showing information to the user
|
||||
*
|
||||
@ -117,68 +109,56 @@ Future<void> confirmationDialog(String title, String text, {Color? color, IconDa
|
||||
* @description = Simple string description of error
|
||||
* @data = Error response (e.g from server)
|
||||
*/
|
||||
Future<void> showErrorDialog(String title, {String description = "", APIResponse? response, IconData icon = TablerIcons.exclamation_circle, Function? onDismissed}) async {
|
||||
|
||||
Future<void> showErrorDialog(String title,
|
||||
{String description = "",
|
||||
APIResponse? response,
|
||||
IconData icon = TablerIcons.exclamation_circle,
|
||||
Function? onDismissed}) async {
|
||||
List<Widget> children = [];
|
||||
|
||||
if (description.isNotEmpty) {
|
||||
children.add(
|
||||
ListTile(
|
||||
title: Text(description),
|
||||
)
|
||||
);
|
||||
children.add(ListTile(
|
||||
title: Text(description),
|
||||
));
|
||||
} else if (response != null) {
|
||||
// Look for extra error information in the provided APIResponse object
|
||||
switch (response.statusCode) {
|
||||
case 400: // Bad request (typically bad input)
|
||||
case 400: // Bad request (typically bad input)
|
||||
if (response.data is Map<String, dynamic>) {
|
||||
|
||||
for (String field in response.asMap().keys) {
|
||||
|
||||
dynamic error = response.data[field];
|
||||
|
||||
if (error is List) {
|
||||
for (int ii = 0; ii < error.length; ii++) {
|
||||
children.add(
|
||||
ListTile(
|
||||
title: Text(field),
|
||||
subtitle: Text(error[ii].toString()),
|
||||
)
|
||||
);
|
||||
children.add(ListTile(
|
||||
title: Text(field),
|
||||
subtitle: Text(error[ii].toString()),
|
||||
));
|
||||
}
|
||||
} else {
|
||||
children.add(
|
||||
ListTile(
|
||||
title: Text(field),
|
||||
subtitle: Text(response.data[field].toString()),
|
||||
)
|
||||
);
|
||||
children.add(ListTile(
|
||||
title: Text(field),
|
||||
subtitle: Text(response.data[field].toString()),
|
||||
));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
children.add(
|
||||
ListTile(
|
||||
children.add(ListTile(
|
||||
title: Text(L10().responseInvalid),
|
||||
subtitle: Text(response.data.toString())
|
||||
)
|
||||
);
|
||||
subtitle: Text(response.data.toString())));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Unhandled server response
|
||||
children.add(
|
||||
ListTile(
|
||||
title: Text(L10().statusCode),
|
||||
subtitle: Text(response.statusCode.toString()),
|
||||
)
|
||||
);
|
||||
children.add(ListTile(
|
||||
title: Text(L10().statusCode),
|
||||
subtitle: Text(response.statusCode.toString()),
|
||||
));
|
||||
|
||||
children.add(
|
||||
ListTile(
|
||||
title: Text(L10().responseData),
|
||||
subtitle: Text(response.data.toString()),
|
||||
)
|
||||
);
|
||||
children.add(ListTile(
|
||||
title: Text(L10().responseData),
|
||||
subtitle: Text(response.data.toString()),
|
||||
));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -188,15 +168,15 @@ Future<void> showErrorDialog(String title, {String description = "", APIResponse
|
||||
return;
|
||||
}
|
||||
|
||||
OneContext().showDialog(
|
||||
builder: (context) => SimpleDialog(
|
||||
title: ListTile(
|
||||
title: Text(title),
|
||||
leading: Icon(icon),
|
||||
),
|
||||
children: children
|
||||
)
|
||||
).then((value) {
|
||||
OneContext()
|
||||
.showDialog(
|
||||
builder: (context) => SimpleDialog(
|
||||
title: ListTile(
|
||||
title: Text(title),
|
||||
leading: Icon(icon),
|
||||
),
|
||||
children: children))
|
||||
.then((value) {
|
||||
if (onDismissed != null) {
|
||||
onDismissed();
|
||||
}
|
||||
@ -206,8 +186,8 @@ Future<void> showErrorDialog(String title, {String description = "", APIResponse
|
||||
/*
|
||||
* Display a message indicating the nature of a server / API error
|
||||
*/
|
||||
Future<void> showServerError(String url, String title, String description) async {
|
||||
|
||||
Future<void> showServerError(
|
||||
String url, String title, String description) async {
|
||||
if (!hasContext()) {
|
||||
return;
|
||||
}
|
||||
@ -222,7 +202,8 @@ Future<void> showServerError(String url, String title, String description) async
|
||||
}
|
||||
|
||||
// Play a sound
|
||||
final bool tones = await InvenTreeSettingsManager().getValue(INV_SOUNDS_SERVER, true) as bool;
|
||||
final bool tones = await InvenTreeSettingsManager()
|
||||
.getValue(INV_SOUNDS_SERVER, true) as bool;
|
||||
|
||||
if (tones) {
|
||||
playAudioFile("sounds/server_error.mp3");
|
||||
@ -230,25 +211,16 @@ Future<void> showServerError(String url, String title, String description) async
|
||||
|
||||
description += "\nURL: $url";
|
||||
|
||||
showSnackIcon(
|
||||
title,
|
||||
success: false,
|
||||
actionText: L10().details,
|
||||
onAction: () {
|
||||
showErrorDialog(
|
||||
title,
|
||||
description: description,
|
||||
icon: TablerIcons.server
|
||||
);
|
||||
}
|
||||
);
|
||||
showSnackIcon(title, success: false, actionText: L10().details, onAction: () {
|
||||
showErrorDialog(title, description: description, icon: TablerIcons.server);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Displays an error indicating that the server returned an unexpected status code
|
||||
*/
|
||||
Future<void> showStatusCodeError(String url, int status, {String details=""}) async {
|
||||
|
||||
Future<void> showStatusCodeError(String url, int status,
|
||||
{String details = ""}) async {
|
||||
String msg = statusCodeToString(status);
|
||||
String extra = url + "\n" + "${L10().statusCode}: ${status}";
|
||||
|
||||
@ -264,7 +236,6 @@ Future<void> showStatusCodeError(String url, int status, {String details=""}) as
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Provide a human-readable descriptor for a particular error code
|
||||
*/
|
||||
@ -299,7 +270,6 @@ String statusCodeToString(int status) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Displays a message indicating that the server timed out on a certain request
|
||||
*/
|
||||
|
@ -16,12 +16,10 @@ import "package:inventree/widget/notifications.dart";
|
||||
import "package:inventree/widget/order/purchase_order_list.dart";
|
||||
import "package:inventree/widget/stock/location_display.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Custom "drawer" widget for the InvenTree app.
|
||||
*/
|
||||
class InvenTreeDrawer extends StatelessWidget {
|
||||
|
||||
const InvenTreeDrawer(this.context);
|
||||
|
||||
final BuildContext context;
|
||||
@ -52,10 +50,8 @@ class InvenTreeDrawer extends StatelessWidget {
|
||||
_closeDrawer();
|
||||
|
||||
if (_checkConnection()) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null))
|
||||
);
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,10 +60,8 @@ class InvenTreeDrawer extends StatelessWidget {
|
||||
_closeDrawer();
|
||||
|
||||
if (_checkConnection()) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => LocationDisplayWidget(null))
|
||||
);
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => LocationDisplayWidget(null)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,12 +73,10 @@ class InvenTreeDrawer extends StatelessWidget {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SalesOrderListWidget(filters: {})
|
||||
)
|
||||
);
|
||||
builder: (context) => SalesOrderListWidget(filters: {})));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Load "purchase orders" page
|
||||
void _purchaseOrders() {
|
||||
_closeDrawer();
|
||||
@ -93,9 +85,7 @@ class InvenTreeDrawer extends StatelessWidget {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PurchaseOrderListWidget(filters: {})
|
||||
)
|
||||
);
|
||||
builder: (context) => PurchaseOrderListWidget(filters: {})));
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +102,8 @@ class InvenTreeDrawer extends StatelessWidget {
|
||||
// Load settings widget
|
||||
void _settings() {
|
||||
_closeDrawer();
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeSettingsWidget()));
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => InvenTreeSettingsWidget()));
|
||||
}
|
||||
|
||||
// Construct list of tiles to display in the "drawer" menu
|
||||
@ -132,43 +123,35 @@ class InvenTreeDrawer extends StatelessWidget {
|
||||
tiles.add(Divider());
|
||||
|
||||
if (InvenTreePart().canView) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().parts),
|
||||
leading: Icon(TablerIcons.box, color: COLOR_ACTION),
|
||||
onTap: _parts,
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().parts),
|
||||
leading: Icon(TablerIcons.box, color: COLOR_ACTION),
|
||||
onTap: _parts,
|
||||
));
|
||||
}
|
||||
|
||||
if (InvenTreeStockLocation().canView) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().stock),
|
||||
leading: Icon(TablerIcons.package, color: COLOR_ACTION),
|
||||
onTap: _stock,
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().stock),
|
||||
leading: Icon(TablerIcons.package, color: COLOR_ACTION),
|
||||
onTap: _stock,
|
||||
));
|
||||
}
|
||||
|
||||
if (InvenTreePurchaseOrder().canView) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().purchaseOrders),
|
||||
leading: Icon(TablerIcons.shopping_cart, color: COLOR_ACTION),
|
||||
onTap: _purchaseOrders,
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().purchaseOrders),
|
||||
leading: Icon(TablerIcons.shopping_cart, color: COLOR_ACTION),
|
||||
onTap: _purchaseOrders,
|
||||
));
|
||||
}
|
||||
|
||||
if (InvenTreeSalesOrder().canView) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().salesOrders),
|
||||
leading: Icon(TablerIcons.truck_delivery, color: COLOR_ACTION),
|
||||
onTap: _salesOrders,
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().salesOrders),
|
||||
leading: Icon(TablerIcons.truck_delivery, color: COLOR_ACTION),
|
||||
onTap: _salesOrders,
|
||||
));
|
||||
}
|
||||
|
||||
if (tiles.length > 2) {
|
||||
@ -177,55 +160,44 @@ class InvenTreeDrawer extends StatelessWidget {
|
||||
|
||||
int notification_count = InvenTreeAPI().notification_counter;
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
leading: Icon(TablerIcons.bell, color: COLOR_ACTION),
|
||||
trailing: notification_count > 0 ? Text(notification_count.toString()) : null,
|
||||
title: Text(L10().notifications),
|
||||
onTap: _notifications,
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
leading: Icon(TablerIcons.bell, color: COLOR_ACTION),
|
||||
trailing:
|
||||
notification_count > 0 ? Text(notification_count.toString()) : null,
|
||||
title: Text(L10().notifications),
|
||||
onTap: _notifications,
|
||||
));
|
||||
|
||||
tiles.add(Divider());
|
||||
|
||||
bool darkMode = AdaptiveTheme.of(context).mode.isDark;
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
onTap: () {
|
||||
AdaptiveTheme.of(context).toggleThemeMode();
|
||||
_closeDrawer();
|
||||
},
|
||||
title: Text(L10().colorScheme),
|
||||
subtitle: Text(L10().colorSchemeDetail),
|
||||
leading: Icon(
|
||||
TablerIcons.sun_moon,
|
||||
color: COLOR_ACTION
|
||||
),
|
||||
leading: Icon(TablerIcons.sun_moon, color: COLOR_ACTION),
|
||||
trailing: Icon(
|
||||
darkMode ? TablerIcons.moon : TablerIcons.sun,
|
||||
)
|
||||
)
|
||||
);
|
||||
)));
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().settings),
|
||||
leading: Icon(Icons.settings, color: COLOR_ACTION),
|
||||
onTap: _settings,
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().settings),
|
||||
leading: Icon(Icons.settings, color: COLOR_ACTION),
|
||||
onTap: _settings,
|
||||
));
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Drawer(
|
||||
return Drawer(
|
||||
child: ListView(
|
||||
children: drawerTiles(context),
|
||||
)
|
||||
);
|
||||
children: drawerTiles(context),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -9,11 +9,8 @@ import "package:one_context/one_context.dart";
|
||||
|
||||
import "package:inventree/l10.dart";
|
||||
|
||||
|
||||
class FilePickerDialog {
|
||||
|
||||
static Future<File?> pickImageFromCamera() async {
|
||||
|
||||
final picker = ImagePicker();
|
||||
|
||||
final pickedImage = await picker.pickImage(source: ImageSource.camera);
|
||||
@ -26,7 +23,6 @@ class FilePickerDialog {
|
||||
}
|
||||
|
||||
static Future<File?> pickImageFromGallery() async {
|
||||
|
||||
final picker = ImagePicker();
|
||||
|
||||
final pickedImage = await picker.pickImage(source: ImageSource.gallery);
|
||||
@ -39,7 +35,6 @@ class FilePickerDialog {
|
||||
}
|
||||
|
||||
static Future<File?> pickFileFromDevice() async {
|
||||
|
||||
final FilePickerResult? result = await FilePicker.platform.pickFiles();
|
||||
|
||||
if (result != null) {
|
||||
@ -54,8 +49,11 @@ class FilePickerDialog {
|
||||
}
|
||||
|
||||
// Present a dialog to pick a file, either from local file system or from camera
|
||||
static Future<void> pickFile({String message = "", bool allowImages = true, bool allowFiles = true, Function(File)? onPicked}) async {
|
||||
|
||||
static Future<void> pickFile(
|
||||
{String message = "",
|
||||
bool allowImages = true,
|
||||
bool allowFiles = true,
|
||||
Function(File)? onPicked}) async {
|
||||
String title = "";
|
||||
|
||||
if (allowImages && !allowFiles) {
|
||||
@ -65,48 +63,38 @@ class FilePickerDialog {
|
||||
}
|
||||
|
||||
// Construct actions
|
||||
List<Widget> actions = [
|
||||
|
||||
];
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (message.isNotEmpty) {
|
||||
actions.add(
|
||||
ListTile(
|
||||
title: Text(message)
|
||||
)
|
||||
);
|
||||
actions.add(ListTile(title: Text(message)));
|
||||
}
|
||||
|
||||
actions.add(
|
||||
SimpleDialogOption(
|
||||
child: ListTile(
|
||||
leading: Icon(TablerIcons.arrow_up),
|
||||
title: Text(allowFiles ? L10().selectFile : L10().selectImage),
|
||||
),
|
||||
onPressed: () async {
|
||||
actions.add(SimpleDialogOption(
|
||||
child: ListTile(
|
||||
leading: Icon(TablerIcons.arrow_up),
|
||||
title: Text(allowFiles ? L10().selectFile : L10().selectImage),
|
||||
),
|
||||
onPressed: () async {
|
||||
// Close the dialog
|
||||
OneContext().popDialog();
|
||||
|
||||
// Close the dialog
|
||||
OneContext().popDialog();
|
||||
File? file;
|
||||
if (allowFiles) {
|
||||
file = await pickFileFromDevice();
|
||||
} else {
|
||||
file = await pickImageFromGallery();
|
||||
}
|
||||
|
||||
File? file;
|
||||
if (allowFiles) {
|
||||
file = await pickFileFromDevice();
|
||||
} else {
|
||||
file = await pickImageFromGallery();
|
||||
if (file != null) {
|
||||
if (onPicked != null) {
|
||||
onPicked(file);
|
||||
}
|
||||
|
||||
if (file != null) {
|
||||
if (onPicked != null) {
|
||||
onPicked(file);
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
},
|
||||
));
|
||||
|
||||
if (allowImages) {
|
||||
actions.add(
|
||||
SimpleDialogOption(
|
||||
actions.add(SimpleDialogOption(
|
||||
child: ListTile(
|
||||
leading: Icon(TablerIcons.camera),
|
||||
title: Text(L10().takePicture),
|
||||
@ -122,100 +110,99 @@ class FilePickerDialog {
|
||||
onPicked(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
OneContext().showDialog(
|
||||
builder: (context) {
|
||||
return SimpleDialog(
|
||||
title: Text(title),
|
||||
children: actions,
|
||||
);
|
||||
}
|
||||
);
|
||||
OneContext().showDialog(builder: (context) {
|
||||
return SimpleDialog(
|
||||
title: Text(title),
|
||||
children: actions,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class CheckBoxField extends FormField<bool> {
|
||||
CheckBoxField({
|
||||
String? label,
|
||||
bool? initial = false,
|
||||
bool tristate = false,
|
||||
Function(bool?)? onSaved,
|
||||
TextStyle? labelStyle,
|
||||
String? helperText,
|
||||
TextStyle? helperStyle,
|
||||
}) :
|
||||
super(
|
||||
onSaved: onSaved,
|
||||
initialValue: initial,
|
||||
builder: (FormFieldState<bool> state) {
|
||||
|
||||
return CheckboxListTile(
|
||||
title: label != null ? Text(label, style: labelStyle) : null,
|
||||
value: state.value,
|
||||
tristate: tristate,
|
||||
onChanged: state.didChange,
|
||||
subtitle: helperText != null ? Text(helperText, style: helperStyle) : null,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
);
|
||||
}
|
||||
);
|
||||
String? label,
|
||||
bool? initial = false,
|
||||
bool tristate = false,
|
||||
Function(bool?)? onSaved,
|
||||
TextStyle? labelStyle,
|
||||
String? helperText,
|
||||
TextStyle? helperStyle,
|
||||
}) : super(
|
||||
onSaved: onSaved,
|
||||
initialValue: initial,
|
||||
builder: (FormFieldState<bool> state) {
|
||||
return CheckboxListTile(
|
||||
title: label != null ? Text(label, style: labelStyle) : null,
|
||||
value: state.value,
|
||||
tristate: tristate,
|
||||
onChanged: state.didChange,
|
||||
subtitle: helperText != null
|
||||
? Text(helperText, style: helperStyle)
|
||||
: null,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
class StringField extends TextFormField {
|
||||
StringField(
|
||||
{String label = "",
|
||||
String? hint,
|
||||
String? initial,
|
||||
Function(String?)? onSaved,
|
||||
Function(String?)? validator,
|
||||
bool allowEmpty = false,
|
||||
bool isEnabled = true})
|
||||
: super(
|
||||
decoration: InputDecoration(
|
||||
labelText: allowEmpty ? label : label + "*", hintText: hint),
|
||||
initialValue: initial,
|
||||
onSaved: onSaved,
|
||||
enabled: isEnabled,
|
||||
validator: (value) {
|
||||
if (!allowEmpty && value != null && value.isEmpty) {
|
||||
return L10().valueCannotBeEmpty;
|
||||
}
|
||||
|
||||
StringField({String label = "", String? hint, String? initial, Function(String?)? onSaved, Function(String?)? validator, bool allowEmpty = false, bool isEnabled = true}) :
|
||||
super(
|
||||
decoration: InputDecoration(
|
||||
labelText: allowEmpty ? label : label + "*",
|
||||
hintText: hint
|
||||
),
|
||||
initialValue: initial,
|
||||
onSaved: onSaved,
|
||||
enabled: isEnabled,
|
||||
validator: (value) {
|
||||
if (!allowEmpty && value != null && value.isEmpty) {
|
||||
return L10().valueCannotBeEmpty;
|
||||
}
|
||||
if (validator != null) {
|
||||
return validator(value) as String?;
|
||||
}
|
||||
|
||||
if (validator != null) {
|
||||
return validator(value) as String?;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Helper class for quantity values
|
||||
*/
|
||||
class QuantityField extends TextFormField {
|
||||
QuantityField(
|
||||
{String label = "",
|
||||
String hint = "",
|
||||
double? max,
|
||||
TextEditingController? controller})
|
||||
: super(
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
hintText: hint,
|
||||
),
|
||||
controller: controller,
|
||||
keyboardType:
|
||||
TextInputType.numberWithOptions(signed: false, decimal: true),
|
||||
validator: (value) {
|
||||
if (value != null && value.isEmpty) return L10().quantityEmpty;
|
||||
|
||||
QuantityField({String label = "", String hint = "", double? max, TextEditingController? controller}) :
|
||||
super(
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
hintText: hint,
|
||||
),
|
||||
controller: controller,
|
||||
keyboardType: TextInputType.numberWithOptions(signed: false, decimal: true),
|
||||
validator: (value) {
|
||||
double quantity = double.tryParse(value.toString()) ?? 0;
|
||||
|
||||
if (value != null && value.isEmpty) return L10().quantityEmpty;
|
||||
if (quantity <= 0) return L10().quantityPositive;
|
||||
if ((max != null) && (quantity > max))
|
||||
return "Quantity must not exceed ${max}";
|
||||
|
||||
double quantity = double.tryParse(value.toString()) ?? 0;
|
||||
|
||||
if (quantity <= 0) return L10().quantityPositive;
|
||||
if ((max != null) && (quantity > max)) return "Quantity must not exceed ${max}";
|
||||
|
||||
return null;
|
||||
},
|
||||
);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -26,18 +26,15 @@ import "package:inventree/widget/snacks.dart";
|
||||
import "package:inventree/widget/spinner.dart";
|
||||
import "package:inventree/widget/company/company_list.dart";
|
||||
|
||||
|
||||
class InvenTreeHomePage extends StatefulWidget {
|
||||
|
||||
const InvenTreeHomePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_InvenTreeHomePageState createState() => _InvenTreeHomePageState();
|
||||
}
|
||||
|
||||
|
||||
class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetProperties {
|
||||
|
||||
class _InvenTreeHomePageState extends State<InvenTreeHomePage>
|
||||
with BaseWidgetProperties {
|
||||
_InvenTreeHomePageState() : super() {
|
||||
// Load display settings
|
||||
_loadSettings();
|
||||
@ -46,7 +43,6 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
_loadProfile();
|
||||
|
||||
InvenTreeAPI().registerCallback(() {
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
// Reload the widget
|
||||
@ -70,37 +66,31 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
void _showParts(BuildContext context) {
|
||||
if (!InvenTreeAPI().checkConnection()) return;
|
||||
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
|
||||
}
|
||||
|
||||
void _showStarredParts(BuildContext context) {
|
||||
if (!InvenTreeAPI().checkConnection()) return;
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PartList({
|
||||
"starred": "true"
|
||||
})
|
||||
)
|
||||
);
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => PartList({"starred": "true"})));
|
||||
}
|
||||
|
||||
void _showStock(BuildContext context) {
|
||||
if (!InvenTreeAPI().checkConnection()) return;
|
||||
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(null)));
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => LocationDisplayWidget(null)));
|
||||
}
|
||||
|
||||
void _showPurchaseOrders(BuildContext context) {
|
||||
if (!InvenTreeAPI().checkConnection()) return;
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PurchaseOrderListWidget(filters: {})
|
||||
)
|
||||
);
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PurchaseOrderListWidget(filters: {})));
|
||||
}
|
||||
|
||||
void _showSalesOrders(BuildContext context) {
|
||||
@ -109,15 +99,17 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SalesOrderListWidget(filters: {})
|
||||
)
|
||||
);
|
||||
builder: (context) => SalesOrderListWidget(filters: {})));
|
||||
}
|
||||
|
||||
void _showSuppliers(BuildContext context) {
|
||||
if (!InvenTreeAPI().checkConnection()) return;
|
||||
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CompanyListWidget(L10().suppliers, {"is_supplier": "true"})));
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
CompanyListWidget(L10().suppliers, {"is_supplier": "true"})));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -131,39 +123,47 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
void _showCustomers(BuildContext context) {
|
||||
if (!InvenTreeAPI().checkConnection()) return;
|
||||
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CompanyListWidget(L10().customers, {"is_customer": "true"})));
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
CompanyListWidget(L10().customers, {"is_customer": "true"})));
|
||||
}
|
||||
|
||||
void _selectProfile() {
|
||||
Navigator.push(
|
||||
context, MaterialPageRoute(builder: (context) => InvenTreeSelectServerWidget())
|
||||
).then((context) {
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => InvenTreeSelectServerWidget()))
|
||||
.then((context) {
|
||||
// Once we return
|
||||
_loadProfile();
|
||||
});
|
||||
}
|
||||
|
||||
Future <void> _loadSettings() async {
|
||||
Future<void> _loadSettings() async {
|
||||
homeShowSubscribed = await InvenTreeSettingsManager()
|
||||
.getValue(INV_HOME_SHOW_SUBSCRIBED, true) as bool;
|
||||
homeShowPo = await InvenTreeSettingsManager()
|
||||
.getValue(INV_HOME_SHOW_PO, true) as bool;
|
||||
homeShowSo = await InvenTreeSettingsManager()
|
||||
.getValue(INV_HOME_SHOW_SO, true) as bool;
|
||||
homeShowManufacturers = await InvenTreeSettingsManager()
|
||||
.getValue(INV_HOME_SHOW_MANUFACTURERS, true) as bool;
|
||||
homeShowCustomers = await InvenTreeSettingsManager()
|
||||
.getValue(INV_HOME_SHOW_CUSTOMERS, true) as bool;
|
||||
homeShowSuppliers = await InvenTreeSettingsManager()
|
||||
.getValue(INV_HOME_SHOW_SUPPLIERS, true) as bool;
|
||||
|
||||
homeShowSubscribed = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_SUBSCRIBED, true) as bool;
|
||||
homeShowPo = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_PO, true) as bool;
|
||||
homeShowSo = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_SO, true) as bool;
|
||||
homeShowManufacturers = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_MANUFACTURERS, true) as bool;
|
||||
homeShowCustomers = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_CUSTOMERS, true) as bool;
|
||||
homeShowSuppliers = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_SUPPLIERS, true) as bool;
|
||||
|
||||
setState(() {
|
||||
});
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
Future <void> _loadProfile() async {
|
||||
|
||||
Future<void> _loadProfile() async {
|
||||
_profile = await UserProfileDBManager().getSelectedProfile();
|
||||
|
||||
// A valid profile was loaded!
|
||||
if (_profile != null) {
|
||||
if (!InvenTreeAPI().isConnected() && !InvenTreeAPI().isConnecting()) {
|
||||
|
||||
// Attempt server connection
|
||||
InvenTreeAPI().connectToServer(_profile!).then((result) {
|
||||
if (mounted) {
|
||||
@ -176,8 +176,11 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
Widget _listTile(BuildContext context, String label, IconData icon, {Function()? callback, String role = "", String permission = "", Widget? trailing}) {
|
||||
|
||||
Widget _listTile(BuildContext context, String label, IconData icon,
|
||||
{Function()? callback,
|
||||
String role = "",
|
||||
String permission = "",
|
||||
Widget? trailing}) {
|
||||
bool connected = InvenTreeAPI().isConnected();
|
||||
|
||||
bool allowed = true;
|
||||
@ -188,25 +191,20 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
|
||||
return GestureDetector(
|
||||
child: Card(
|
||||
margin: EdgeInsets.all(5),
|
||||
child: Align(
|
||||
child: ListTile(
|
||||
leading: Icon(
|
||||
icon,
|
||||
size: 32,
|
||||
color: connected && allowed ? COLOR_ACTION : Colors.grey
|
||||
),
|
||||
title: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 20
|
||||
margin: EdgeInsets.all(5),
|
||||
child: Align(
|
||||
child: ListTile(
|
||||
leading: Icon(icon,
|
||||
size: 32,
|
||||
color: connected && allowed ? COLOR_ACTION : Colors.grey),
|
||||
title: Text(
|
||||
label,
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
trailing: trailing,
|
||||
),
|
||||
trailing: trailing,
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
)
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
)),
|
||||
onTap: () {
|
||||
if (!allowed) {
|
||||
showSnackIcon(
|
||||
@ -228,7 +226,6 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
* Constructs a list of tiles for the main screen
|
||||
*/
|
||||
List<Widget> getListTiles(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [];
|
||||
|
||||
// Parts
|
||||
@ -245,61 +242,42 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
|
||||
// Starred parts
|
||||
if (homeShowSubscribed && InvenTreePart().canView) {
|
||||
tiles.add(_listTile(
|
||||
context,
|
||||
L10().partsStarred,
|
||||
TablerIcons.bell,
|
||||
callback: () {
|
||||
_showStarredParts(context);
|
||||
}
|
||||
));
|
||||
tiles.add(_listTile(context, L10().partsStarred, TablerIcons.bell,
|
||||
callback: () {
|
||||
_showStarredParts(context);
|
||||
}));
|
||||
}
|
||||
|
||||
// Stock button
|
||||
if (InvenTreeStockItem().canView) {
|
||||
tiles.add(_listTile(
|
||||
context,
|
||||
L10().stock,
|
||||
TablerIcons.package,
|
||||
callback: () {
|
||||
_showStock(context);
|
||||
}
|
||||
));
|
||||
tiles.add(
|
||||
_listTile(context, L10().stock, TablerIcons.package, callback: () {
|
||||
_showStock(context);
|
||||
}));
|
||||
}
|
||||
|
||||
// Purchase orders
|
||||
if (homeShowPo && InvenTreePurchaseOrder().canView) {
|
||||
tiles.add(_listTile(
|
||||
context,
|
||||
L10().purchaseOrders,
|
||||
TablerIcons.shopping_cart,
|
||||
callback: () {
|
||||
_showPurchaseOrders(context);
|
||||
}
|
||||
));
|
||||
tiles.add(
|
||||
_listTile(context, L10().purchaseOrders, TablerIcons.shopping_cart,
|
||||
callback: () {
|
||||
_showPurchaseOrders(context);
|
||||
}));
|
||||
}
|
||||
|
||||
if (homeShowSo && InvenTreeSalesOrder().canView) {
|
||||
tiles.add(_listTile(
|
||||
context,
|
||||
L10().salesOrders,
|
||||
TablerIcons.truck_delivery,
|
||||
callback: () {
|
||||
_showSalesOrders(context);
|
||||
}
|
||||
));
|
||||
context, L10().salesOrders, TablerIcons.truck_delivery, callback: () {
|
||||
_showSalesOrders(context);
|
||||
}));
|
||||
}
|
||||
|
||||
// Suppliers
|
||||
if (homeShowSuppliers && InvenTreePurchaseOrder().canView) {
|
||||
tiles.add(_listTile(
|
||||
context,
|
||||
L10().suppliers,
|
||||
TablerIcons.building,
|
||||
tiles.add(_listTile(context, L10().suppliers, TablerIcons.building,
|
||||
callback: () {
|
||||
_showSuppliers(context);
|
||||
}
|
||||
));
|
||||
_showSuppliers(context);
|
||||
}));
|
||||
}
|
||||
|
||||
// TODO: Add these tiles back in once the features are fleshed out
|
||||
@ -320,14 +298,10 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
*/
|
||||
// Customers
|
||||
if (homeShowCustomers) {
|
||||
tiles.add(_listTile(
|
||||
context,
|
||||
L10().customers,
|
||||
TablerIcons.building_store,
|
||||
tiles.add(_listTile(context, L10().customers, TablerIcons.building_store,
|
||||
callback: () {
|
||||
_showCustomers(context);
|
||||
}
|
||||
));
|
||||
_showCustomers(context);
|
||||
}));
|
||||
}
|
||||
|
||||
return tiles;
|
||||
@ -338,10 +312,10 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
* display a connection status widget
|
||||
*/
|
||||
Widget _connectionStatusWidget(BuildContext context) {
|
||||
|
||||
String? serverAddress = InvenTreeAPI().serverAddress;
|
||||
bool validAddress = serverAddress != null;
|
||||
bool connecting = !InvenTreeAPI().isConnected() && InvenTreeAPI().isConnecting();
|
||||
bool connecting =
|
||||
!InvenTreeAPI().isConnected() && InvenTreeAPI().isConnecting();
|
||||
|
||||
Widget leading = Icon(TablerIcons.exclamation_circle, color: COLOR_DANGER);
|
||||
Widget trailing = Icon(TablerIcons.server, color: COLOR_ACTION);
|
||||
@ -357,25 +331,23 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
}
|
||||
|
||||
return Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Spacer(),
|
||||
Image.asset(
|
||||
"assets/image/logo_transparent.png",
|
||||
color: Colors.white.withValues(alpha: 0.05),
|
||||
colorBlendMode: BlendMode.modulate,
|
||||
scale: 0.5,
|
||||
),
|
||||
Spacer(),
|
||||
ListTile(
|
||||
title: Text(title),
|
||||
subtitle: Text(subtitle),
|
||||
trailing: trailing,
|
||||
leading: leading,
|
||||
onTap: _selectProfile,
|
||||
)
|
||||
]
|
||||
),
|
||||
child: Column(children: [
|
||||
Spacer(),
|
||||
Image.asset(
|
||||
"assets/image/logo_transparent.png",
|
||||
color: Colors.white.withValues(alpha: 0.05),
|
||||
colorBlendMode: BlendMode.modulate,
|
||||
scale: 0.5,
|
||||
),
|
||||
Spacer(),
|
||||
ListTile(
|
||||
title: Text(title),
|
||||
subtitle: Text(subtitle),
|
||||
trailing: trailing,
|
||||
leading: leading,
|
||||
onTap: _selectProfile,
|
||||
)
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
@ -384,7 +356,6 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
*/
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
|
||||
if (!InvenTreeAPI().isConnected()) {
|
||||
return _connectionStatusWidget(context);
|
||||
}
|
||||
@ -398,7 +369,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
int hTiles = smallScreen ? 1 : 2;
|
||||
double aspect = smallScreen ? 5 : 3;
|
||||
double padding = smallScreen ? 2 : 10;
|
||||
|
||||
|
||||
return GridView.count(
|
||||
crossAxisCount: w > h ? vTiles : hTiles,
|
||||
children: getListTiles(context),
|
||||
@ -408,12 +379,10 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
mainAxisSpacing: padding,
|
||||
padding: EdgeInsets.all(padding),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
var connected = InvenTreeAPI().isConnected();
|
||||
var connecting = !connected && InvenTreeAPI().isConnecting();
|
||||
|
||||
@ -426,7 +395,9 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
TablerIcons.server,
|
||||
color: connected ? COLOR_SUCCESS : (connecting ? COLOR_PROGRESS: COLOR_DANGER),
|
||||
color: connected
|
||||
? COLOR_SUCCESS
|
||||
: (connecting ? COLOR_PROGRESS : COLOR_DANGER),
|
||||
),
|
||||
onPressed: _selectProfile,
|
||||
)
|
||||
@ -434,7 +405,9 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
),
|
||||
drawer: InvenTreeDrawer(context),
|
||||
body: getBody(context),
|
||||
bottomNavigationBar: InvenTreeAPI().isConnected() ? buildBottomAppBar(context, homeKey) : null,
|
||||
bottomNavigationBar: InvenTreeAPI().isConnected()
|
||||
? buildBottomAppBar(context, homeKey)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import "package:inventree/widget/refreshable_state.dart";
|
||||
import "package:flutter_markdown/flutter_markdown.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
|
||||
|
||||
/*
|
||||
* A widget for displaying the notes associated with a given model.
|
||||
* We need to pass in the following parameters:
|
||||
@ -14,7 +13,6 @@ import "package:inventree/l10.dart";
|
||||
* - Title for the app bar
|
||||
*/
|
||||
class NotesWidget extends StatefulWidget {
|
||||
|
||||
const NotesWidget(this.model, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreeModel model;
|
||||
@ -23,12 +21,10 @@ class NotesWidget extends StatefulWidget {
|
||||
_NotesState createState() => _NotesState();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class representing the state of the NotesWidget
|
||||
*/
|
||||
class _NotesState extends RefreshableState<NotesWidget> {
|
||||
|
||||
_NotesState();
|
||||
|
||||
@override
|
||||
@ -41,30 +37,21 @@ class _NotesState extends RefreshableState<NotesWidget> {
|
||||
|
||||
@override
|
||||
List<Widget> appBarActions(BuildContext context) {
|
||||
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (widget.model.canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().edit,
|
||||
onPressed: () {
|
||||
widget.model.editForm(
|
||||
context,
|
||||
L10().editNotes,
|
||||
fields: {
|
||||
"notes": {
|
||||
"multiline": true,
|
||||
}
|
||||
},
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
widget.model.editForm(context, L10().editNotes, fields: {
|
||||
"notes": {
|
||||
"multiline": true,
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
}, onSuccess: (data) async {
|
||||
refresh(context);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -77,5 +64,4 @@ class _NotesState extends RefreshableState<NotesWidget> {
|
||||
data: widget.model.notes,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
@ -8,17 +7,12 @@ import "package:inventree/inventree/model.dart";
|
||||
import "package:inventree/inventree/notification.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
class NotificationWidget extends StatefulWidget {
|
||||
|
||||
@override
|
||||
_NotificationState createState() => _NotificationState();
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _NotificationState extends RefreshableState<NotificationWidget> {
|
||||
|
||||
_NotificationState() : super();
|
||||
|
||||
List<InvenTreeNotification> notifications = [];
|
||||
@ -29,8 +23,7 @@ class _NotificationState extends RefreshableState<NotificationWidget> {
|
||||
String getAppBarTitle() => L10().notifications;
|
||||
|
||||
@override
|
||||
Future<void> request (BuildContext context) async {
|
||||
|
||||
Future<void> request(BuildContext context) async {
|
||||
final results = await InvenTreeNotification().list();
|
||||
|
||||
notifications.clear();
|
||||
@ -45,8 +38,8 @@ class _NotificationState extends RefreshableState<NotificationWidget> {
|
||||
/*
|
||||
* Dismiss an individual notification entry (mark it as "read")
|
||||
*/
|
||||
Future<void> dismissNotification(BuildContext context, InvenTreeNotification notification) async {
|
||||
|
||||
Future<void> dismissNotification(
|
||||
BuildContext context, InvenTreeNotification notification) async {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
isDismissing = true;
|
||||
@ -71,36 +64,34 @@ class _NotificationState extends RefreshableState<NotificationWidget> {
|
||||
*/
|
||||
@override
|
||||
List<Widget> getTiles(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [];
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10().notifications,
|
||||
),
|
||||
subtitle: notifications.isEmpty ? Text(L10().notificationsEmpty) : null,
|
||||
leading: notifications.isEmpty ? Icon(TablerIcons.bell_exclamation) : Icon(TablerIcons.bell),
|
||||
trailing: Text("${notifications.length}"),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(
|
||||
L10().notifications,
|
||||
),
|
||||
subtitle: notifications.isEmpty ? Text(L10().notificationsEmpty) : null,
|
||||
leading: notifications.isEmpty
|
||||
? Icon(TablerIcons.bell_exclamation)
|
||||
: Icon(TablerIcons.bell),
|
||||
trailing: Text("${notifications.length}"),
|
||||
));
|
||||
|
||||
for (var notification in notifications) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(notification.name),
|
||||
subtitle: Text(notification.message),
|
||||
trailing: IconButton(
|
||||
icon: Icon(TablerIcons.bookmark),
|
||||
onPressed: isDismissing ? null : () async {
|
||||
dismissNotification(context, notification);
|
||||
},
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(notification.name),
|
||||
subtitle: Text(notification.message),
|
||||
trailing: IconButton(
|
||||
icon: Icon(TablerIcons.bookmark),
|
||||
onPressed: isDismissing
|
||||
? null
|
||||
: () async {
|
||||
dismissNotification(context, notification);
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
return tiles;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import "package:inventree/widget/snacks.dart";
|
||||
|
||||
import "package:inventree/inventree/orders.dart";
|
||||
|
||||
|
||||
class ExtraLineDetailWidget extends StatefulWidget {
|
||||
const ExtraLineDetailWidget(this.item, {Key? key}) : super(key: key);
|
||||
|
||||
@ -18,8 +17,8 @@ class ExtraLineDetailWidget extends StatefulWidget {
|
||||
_ExtraLineDetailWidgetState createState() => _ExtraLineDetailWidgetState();
|
||||
}
|
||||
|
||||
class _ExtraLineDetailWidgetState extends RefreshableState<ExtraLineDetailWidget> {
|
||||
|
||||
class _ExtraLineDetailWidgetState
|
||||
extends RefreshableState<ExtraLineDetailWidget> {
|
||||
_ExtraLineDetailWidgetState();
|
||||
|
||||
@override
|
||||
@ -30,14 +29,11 @@ class _ExtraLineDetailWidgetState extends RefreshableState<ExtraLineDetailWidget
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (widget.item.canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
onPressed: () {
|
||||
_editLineItem(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -53,60 +49,44 @@ class _ExtraLineDetailWidgetState extends RefreshableState<ExtraLineDetailWidget
|
||||
Future<void> _editLineItem(BuildContext context) async {
|
||||
var fields = widget.item.formFields();
|
||||
|
||||
widget.item.editForm(
|
||||
context,
|
||||
L10().editLineItem,
|
||||
fields: fields,
|
||||
widget.item.editForm(context, L10().editLineItem, fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().lineItemUpdated, success: true);
|
||||
}
|
||||
);
|
||||
refresh(context);
|
||||
showSnackIcon(L10().lineItemUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
List<Widget> getTiles(BuildContext context) {
|
||||
List<Widget> tiles = [];
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().reference),
|
||||
trailing: Text(widget.item.reference),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().reference),
|
||||
trailing: Text(widget.item.reference),
|
||||
));
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().description),
|
||||
trailing: Text(widget.item.description),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().description),
|
||||
trailing: Text(widget.item.description),
|
||||
));
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().quantity),
|
||||
trailing: Text(widget.item.quantity.toString()),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().quantity),
|
||||
trailing: Text(widget.item.quantity.toString()),
|
||||
));
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().unitPrice),
|
||||
trailing: Text(
|
||||
renderCurrency(widget.item.price, widget.item.priceCurrency)
|
||||
)
|
||||
)
|
||||
);
|
||||
renderCurrency(widget.item.price, widget.item.priceCurrency))));
|
||||
|
||||
if (widget.item.notes.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().notes),
|
||||
subtitle: Text(widget.item.notes),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().notes),
|
||||
subtitle: Text(widget.item.notes),
|
||||
));
|
||||
}
|
||||
|
||||
return tiles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,41 +9,36 @@ import "package:inventree/widget/paginator.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
import "package:inventree/widget/snacks.dart";
|
||||
|
||||
|
||||
class POExtraLineListWidget extends StatefulWidget {
|
||||
|
||||
const POExtraLineListWidget(this.order, {this.filters = const {}, Key? key}) : super(key: key);
|
||||
const POExtraLineListWidget(this.order, {this.filters = const {}, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
final InvenTreePurchaseOrder order;
|
||||
|
||||
final Map<String, String> filters;
|
||||
|
||||
@override
|
||||
_PurchaseOrderExtraLineListWidgetState createState() => _PurchaseOrderExtraLineListWidgetState();
|
||||
_PurchaseOrderExtraLineListWidgetState createState() =>
|
||||
_PurchaseOrderExtraLineListWidgetState();
|
||||
}
|
||||
|
||||
class _PurchaseOrderExtraLineListWidgetState extends RefreshableState<POExtraLineListWidget> {
|
||||
|
||||
class _PurchaseOrderExtraLineListWidgetState
|
||||
extends RefreshableState<POExtraLineListWidget> {
|
||||
_PurchaseOrderExtraLineListWidgetState();
|
||||
|
||||
@override
|
||||
String getAppBarTitle() => L10().extraLineItems;
|
||||
|
||||
Future<void> _addLineItem(BuildContext context) async {
|
||||
|
||||
var fields = InvenTreePOExtraLineItem().formFields();
|
||||
|
||||
fields["order"]?["value"] = widget.order.pk;
|
||||
|
||||
InvenTreePOExtraLineItem().createForm(
|
||||
context,
|
||||
L10().lineItemAdd,
|
||||
fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().lineItemUpdated, success: true);
|
||||
}
|
||||
);
|
||||
InvenTreePOExtraLineItem().createForm(context, L10().lineItemAdd,
|
||||
fields: fields, onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().lineItemUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -51,15 +46,12 @@ class _PurchaseOrderExtraLineListWidgetState extends RefreshableState<POExtraLin
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (widget.order.canEdit) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().lineItemAdd,
|
||||
onTap: () {
|
||||
_addLineItem(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -71,35 +63,35 @@ class _PurchaseOrderExtraLineListWidgetState extends RefreshableState<POExtraLin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PaginatedPOExtraLineList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedPOExtraLineList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedPOExtraLineList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().extraLineItems;
|
||||
|
||||
@override
|
||||
_PaginatedPOExtraLineListState createState() => _PaginatedPOExtraLineListState();
|
||||
|
||||
_PaginatedPOExtraLineListState createState() =>
|
||||
_PaginatedPOExtraLineListState();
|
||||
}
|
||||
|
||||
class _PaginatedPOExtraLineListState extends PaginatedSearchState<PaginatedPOExtraLineList> {
|
||||
|
||||
class _PaginatedPOExtraLineListState
|
||||
extends PaginatedSearchState<PaginatedPOExtraLineList> {
|
||||
_PaginatedPOExtraLineListState() : super();
|
||||
|
||||
@override
|
||||
String get prefix => "po_extra_line_";
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreePOExtraLineItem().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreePOExtraLineItem()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreePOExtraLineItem line = model as InvenTreePOExtraLineItem;
|
||||
|
||||
return ListTile(
|
||||
@ -113,4 +105,4 @@ class _PaginatedPOExtraLineListState extends PaginatedSearchState<PaginatedPOExt
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,22 +21,18 @@ import "package:inventree/widget/company/supplier_part_detail.dart";
|
||||
* Widget for displaying detail view of a single PurchaseOrderLineItem
|
||||
*/
|
||||
class POLineDetailWidget extends StatefulWidget {
|
||||
|
||||
const POLineDetailWidget(this.item, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreePOLineItem item;
|
||||
|
||||
@override
|
||||
_POLineDetailWidgetState createState() => _POLineDetailWidgetState();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* State for the POLineDetailWidget
|
||||
*/
|
||||
class _POLineDetailWidgetState extends RefreshableState<POLineDetailWidget> {
|
||||
|
||||
_POLineDetailWidgetState();
|
||||
|
||||
InvenTreeStockLocation? destination;
|
||||
@ -49,14 +45,12 @@ class _POLineDetailWidgetState extends RefreshableState<POLineDetailWidget> {
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (widget.item.canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
onPressed: () {
|
||||
_editLineItem(context);
|
||||
},
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
onPressed: () {
|
||||
_editLineItem(context);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -69,15 +63,12 @@ class _POLineDetailWidgetState extends RefreshableState<POLineDetailWidget> {
|
||||
if (widget.item.canCreate) {
|
||||
// Receive items
|
||||
if (!widget.item.isComplete) {
|
||||
buttons.add(
|
||||
SpeedDialChild(
|
||||
buttons.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.transition_right, color: Colors.blue),
|
||||
label: L10().receiveItem,
|
||||
onTap: () async {
|
||||
receiveLineItem(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +80,9 @@ class _POLineDetailWidgetState extends RefreshableState<POLineDetailWidget> {
|
||||
await widget.item.reload();
|
||||
|
||||
if (widget.item.destinationId > 0) {
|
||||
InvenTreeStockLocation().get(widget.item.destinationId).then((InvenTreeModel? loc) {
|
||||
InvenTreeStockLocation()
|
||||
.get(widget.item.destinationId)
|
||||
.then((InvenTreeModel? loc) {
|
||||
if (mounted) {
|
||||
if (loc != null && loc is InvenTreeStockLocation) {
|
||||
setState(() {
|
||||
@ -109,75 +102,68 @@ class _POLineDetailWidgetState extends RefreshableState<POLineDetailWidget> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Callback to edit this line item
|
||||
Future<void> _editLineItem(BuildContext context) async {
|
||||
var fields = widget.item.formFields();
|
||||
|
||||
widget.item.editForm(
|
||||
context,
|
||||
L10().editLineItem,
|
||||
fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().lineItemUpdated, success: true);
|
||||
}
|
||||
);
|
||||
widget.item.editForm(context, L10().editLineItem, fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().lineItemUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
// Launch a form to 'receive' this line item
|
||||
// Launch a form to 'receive' this line item
|
||||
Future<void> receiveLineItem(BuildContext context) async {
|
||||
widget.item.receive(
|
||||
context,
|
||||
onSuccess: () => {
|
||||
showSnackIcon(L10().receivedItem, success: true),
|
||||
refresh(context)
|
||||
}
|
||||
);
|
||||
widget.item.receive(context,
|
||||
onSuccess: () => {
|
||||
showSnackIcon(L10().receivedItem, success: true),
|
||||
refresh(context)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
List<Widget> getTiles(BuildContext context) {
|
||||
List<Widget> tiles = [];
|
||||
|
||||
// Reference to the part
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().internalPart),
|
||||
subtitle: Text(widget.item.partName),
|
||||
leading: Icon(TablerIcons.box, color: COLOR_ACTION),
|
||||
trailing: api.getThumbnail(widget.item.partImage),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
var part = await InvenTreePart().get(widget.item.partId);
|
||||
hideLoadingOverlay();
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().internalPart),
|
||||
subtitle: Text(widget.item.partName),
|
||||
leading: Icon(TablerIcons.box, color: COLOR_ACTION),
|
||||
trailing: api.getThumbnail(widget.item.partImage),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
var part = await InvenTreePart().get(widget.item.partId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
));
|
||||
|
||||
// Reference to the supplier part
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().supplierPart),
|
||||
subtitle: Text(widget.item.SKU),
|
||||
leading: Icon(TablerIcons.building, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
var part = await InvenTreeSupplierPart().get(widget.item.supplierPartId);
|
||||
hideLoadingOverlay();
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().supplierPart),
|
||||
subtitle: Text(widget.item.SKU),
|
||||
leading: Icon(TablerIcons.building, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
var part =
|
||||
await InvenTreeSupplierPart().get(widget.item.supplierPartId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (part is InvenTreeSupplierPart) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => SupplierPartDetailWidget(part)));
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
if (part is InvenTreeSupplierPart) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SupplierPartDetailWidget(part)));
|
||||
}
|
||||
},
|
||||
));
|
||||
|
||||
// Destination
|
||||
if (destination != null) {
|
||||
@ -185,75 +171,57 @@ class _POLineDetailWidgetState extends RefreshableState<POLineDetailWidget> {
|
||||
title: Text(L10().destination),
|
||||
subtitle: Text(destination!.name),
|
||||
leading: Icon(TablerIcons.map_pin, color: COLOR_ACTION),
|
||||
onTap: () => {
|
||||
destination!.goToDetailPage(context)
|
||||
}
|
||||
));
|
||||
onTap: () => {destination!.goToDetailPage(context)}));
|
||||
}
|
||||
|
||||
// Received quantity
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().received),
|
||||
subtitle: ProgressBar(widget.item.progressRatio),
|
||||
trailing: Text(
|
||||
widget.item.progressString,
|
||||
style: TextStyle(
|
||||
color: widget.item.isComplete ? COLOR_SUCCESS: COLOR_WARNING
|
||||
)
|
||||
),
|
||||
leading: Icon(TablerIcons.progress),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().received),
|
||||
subtitle: ProgressBar(widget.item.progressRatio),
|
||||
trailing: Text(widget.item.progressString,
|
||||
style: TextStyle(
|
||||
color: widget.item.isComplete ? COLOR_SUCCESS : COLOR_WARNING)),
|
||||
leading: Icon(TablerIcons.progress),
|
||||
));
|
||||
|
||||
// Reference
|
||||
if (widget.item.reference.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().reference),
|
||||
subtitle: Text(widget.item.reference),
|
||||
leading: Icon(TablerIcons.hash),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().reference),
|
||||
subtitle: Text(widget.item.reference),
|
||||
leading: Icon(TablerIcons.hash),
|
||||
));
|
||||
}
|
||||
|
||||
// Pricing information
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().unitPrice),
|
||||
leading: Icon(TablerIcons.currency_dollar),
|
||||
trailing: Text(
|
||||
renderCurrency(widget.item.purchasePrice, widget.item.purchasePriceCurrency)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().unitPrice),
|
||||
leading: Icon(TablerIcons.currency_dollar),
|
||||
trailing: Text(renderCurrency(
|
||||
widget.item.purchasePrice, widget.item.purchasePriceCurrency)),
|
||||
));
|
||||
|
||||
// Note
|
||||
if (widget.item.notes.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().notes),
|
||||
subtitle: Text(widget.item.notes),
|
||||
leading: Icon(TablerIcons.note),
|
||||
)
|
||||
);
|
||||
tiles.add(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);
|
||||
},
|
||||
)
|
||||
);
|
||||
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);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,22 +16,21 @@ import "package:inventree/widget/progress.dart";
|
||||
* Paginated widget class for displaying a list of purchase order line items
|
||||
*/
|
||||
class PaginatedPOLineList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedPOLineList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedPOLineList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().lineItems;
|
||||
|
||||
@override
|
||||
_PaginatedPOLineListState createState() => _PaginatedPOLineListState();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* State class for PaginatedPOLineList
|
||||
*/
|
||||
class _PaginatedPOLineListState extends PaginatedSearchState<PaginatedPOLineList> {
|
||||
|
||||
class _PaginatedPOLineListState
|
||||
extends PaginatedSearchState<PaginatedPOLineList> {
|
||||
_PaginatedPOLineListState() : super();
|
||||
|
||||
@override
|
||||
@ -39,29 +38,30 @@ class _PaginatedPOLineListState extends PaginatedSearchState<PaginatedPOLineList
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"part": L10().part,
|
||||
"SKU": L10().sku,
|
||||
"quantity": L10().quantity,
|
||||
};
|
||||
"part": L10().part,
|
||||
"SKU": L10().sku,
|
||||
"quantity": L10().quantity,
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
"pending": {
|
||||
"label": L10().outstanding,
|
||||
"help_text": L10().outstandingOrderDetail,
|
||||
"tristate": true,
|
||||
},
|
||||
"received": {
|
||||
"label": L10().received,
|
||||
"help_text": L10().receivedFilterDetail,
|
||||
"tristate": true,
|
||||
}
|
||||
};
|
||||
"pending": {
|
||||
"label": L10().outstanding,
|
||||
"help_text": L10().outstandingOrderDetail,
|
||||
"tristate": true,
|
||||
},
|
||||
"received": {
|
||||
"label": L10().received,
|
||||
"help_text": L10().receivedFilterDetail,
|
||||
"tristate": true,
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
final page = await InvenTreePOLineItem().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreePOLineItem()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
return page;
|
||||
}
|
||||
|
||||
@ -71,24 +71,29 @@ class _PaginatedPOLineListState extends PaginatedSearchState<PaginatedPOLineList
|
||||
InvenTreeSupplierPart? supplierPart = item.supplierPart;
|
||||
|
||||
if (supplierPart != null) {
|
||||
|
||||
return ListTile(
|
||||
title: Text(supplierPart.SKU),
|
||||
subtitle: Text(item.partName),
|
||||
trailing: Text(item.progressString, style: TextStyle(color: item.isComplete ? COLOR_SUCCESS : COLOR_WARNING)),
|
||||
trailing: Text(item.progressString,
|
||||
style: TextStyle(
|
||||
color: item.isComplete ? COLOR_SUCCESS : COLOR_WARNING)),
|
||||
leading: InvenTreeAPI().getThumbnail(supplierPart.partImage),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
await item.reload();
|
||||
hideLoadingOverlay();
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => POLineDetailWidget(item)));
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => POLineDetailWidget(item)));
|
||||
},
|
||||
);
|
||||
} else {
|
||||
// Return an error tile
|
||||
return ListTile(
|
||||
title: Text(L10().error),
|
||||
subtitle: Text("supplier part not defined", style: TextStyle(color: COLOR_DANGER)),
|
||||
subtitle: Text("supplier part not defined",
|
||||
style: TextStyle(color: COLOR_DANGER)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import "package:inventree/widget/order/po_extra_line_list.dart";
|
||||
import "package:inventree/widget/stock/location_display.dart";
|
||||
import "package:inventree/widget/order/po_line_list.dart";
|
||||
|
||||
|
||||
import "package:inventree/widget/attachment_widget.dart";
|
||||
import "package:inventree/widget/notes_widget.dart";
|
||||
import "package:inventree/widget/progress.dart";
|
||||
@ -27,13 +26,11 @@ import "package:inventree/widget/snacks.dart";
|
||||
import "package:inventree/widget/stock/stock_list.dart";
|
||||
import "package:inventree/preferences.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Widget for viewing a single PurchaseOrder instance
|
||||
*/
|
||||
class PurchaseOrderDetailWidget extends StatefulWidget {
|
||||
|
||||
const PurchaseOrderDetailWidget(this.order, {Key? key}): super(key: key);
|
||||
const PurchaseOrderDetailWidget(this.order, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreePurchaseOrder order;
|
||||
|
||||
@ -41,11 +38,10 @@ class PurchaseOrderDetailWidget extends StatefulWidget {
|
||||
_PurchaseOrderDetailState createState() => _PurchaseOrderDetailState();
|
||||
}
|
||||
|
||||
|
||||
class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidget> {
|
||||
|
||||
class _PurchaseOrderDetailState
|
||||
extends RefreshableState<PurchaseOrderDetailWidget> {
|
||||
_PurchaseOrderDetailState();
|
||||
|
||||
|
||||
List<InvenTreePOLineItem> lines = [];
|
||||
int extraLineCount = 0;
|
||||
|
||||
@ -73,15 +69,12 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (widget.order.canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().purchaseOrderEdit,
|
||||
onPressed: () {
|
||||
editOrder(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -92,51 +85,38 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (showCameraShortcut && widget.order.canEdit) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.camera, color: Colors.blue),
|
||||
label: L10().takePicture,
|
||||
onTap: () async {
|
||||
_uploadImage(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.camera, color: Colors.blue),
|
||||
label: L10().takePicture,
|
||||
onTap: () async {
|
||||
_uploadImage(context);
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.order.canCreate) {
|
||||
if (widget.order.isPending) {
|
||||
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().lineItemAdd,
|
||||
onTap: () async {
|
||||
_addLineItem(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.send, color: Colors.blue),
|
||||
label: L10().issueOrder,
|
||||
onTap: () async {
|
||||
_issueOrder(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.order.isOpen) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_x, color: Colors.red),
|
||||
label: L10().cancelOrder,
|
||||
onTap: () async {
|
||||
_cancelOrder(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,67 +125,53 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
|
||||
/// Add a new line item to this order
|
||||
Future<void> _addLineItem(BuildContext context) async {
|
||||
|
||||
var fields = InvenTreePOLineItem().formFields();
|
||||
|
||||
// Update part field definition
|
||||
fields["part"]?["hidden"] = false;
|
||||
fields["part"]?["filters"] = {
|
||||
"supplier": widget.order.supplierId
|
||||
};
|
||||
fields["part"]?["filters"] = {"supplier": widget.order.supplierId};
|
||||
|
||||
fields["order"]?["value"] = widget.order.pk;
|
||||
|
||||
InvenTreePOLineItem().createForm(
|
||||
context,
|
||||
L10().lineItemAdd,
|
||||
fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().lineItemUpdated, success: true);
|
||||
}
|
||||
);
|
||||
InvenTreePOLineItem().createForm(context, L10().lineItemAdd, fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().lineItemUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
/// Upload an image against the current PurchaseOrder
|
||||
Future<void> _uploadImage(BuildContext context) async {
|
||||
|
||||
InvenTreePurchaseOrderAttachment().uploadImage(
|
||||
widget.order.pk,
|
||||
prefix: widget.order.reference,
|
||||
).then((result) => refresh(context));
|
||||
InvenTreePurchaseOrderAttachment()
|
||||
.uploadImage(
|
||||
widget.order.pk,
|
||||
prefix: widget.order.reference,
|
||||
)
|
||||
.then((result) => refresh(context));
|
||||
}
|
||||
|
||||
/// Issue this order
|
||||
Future<void> _issueOrder(BuildContext context) async {
|
||||
|
||||
confirmationDialog(
|
||||
L10().issueOrder, "",
|
||||
icon: TablerIcons.send,
|
||||
color: Colors.blue,
|
||||
acceptText: L10().issue,
|
||||
onAccept: () async {
|
||||
widget.order.issueOrder().then((dynamic) {
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
);
|
||||
confirmationDialog(L10().issueOrder, "",
|
||||
icon: TablerIcons.send,
|
||||
color: Colors.blue,
|
||||
acceptText: L10().issue, onAccept: () async {
|
||||
widget.order.issueOrder().then((dynamic) {
|
||||
refresh(context);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// Cancel this order
|
||||
Future<void> _cancelOrder(BuildContext context) async {
|
||||
|
||||
confirmationDialog(
|
||||
L10().cancelOrder, "",
|
||||
icon: TablerIcons.circle_x,
|
||||
color: Colors.red,
|
||||
acceptText: L10().cancel,
|
||||
onAccept: () async {
|
||||
widget.order.cancelOrder().then((dynamic) {
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
);
|
||||
confirmationDialog(L10().cancelOrder, "",
|
||||
icon: TablerIcons.circle_x,
|
||||
color: Colors.red,
|
||||
acceptText: L10().cancel, onAccept: () async {
|
||||
widget.order.cancelOrder().then((dynamic) {
|
||||
refresh(context);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -213,25 +179,22 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (api.supportsBarcodePOReceiveEndpoint && widget.order.isPlaced) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(Icons.barcode_reader),
|
||||
label: L10().scanReceivedParts,
|
||||
onTap:() async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: POReceiveBarcodeHandler(purchaseOrder: widget.order),
|
||||
).then((value) {
|
||||
refresh(context);
|
||||
});
|
||||
},
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(Icons.barcode_reader),
|
||||
label: L10().scanReceivedParts,
|
||||
onTap: () async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: POReceiveBarcodeHandler(purchaseOrder: widget.order),
|
||||
).then((value) {
|
||||
refresh(context);
|
||||
});
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.order.isPending && api.supportsBarcodePOAddLineEndpoint) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: COLOR_SUCCESS),
|
||||
label: L10().lineItemAdd,
|
||||
onTap: () async {
|
||||
@ -239,15 +202,12 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
context,
|
||||
handler: POAllocateBarcodeHandler(purchaseOrder: widget.order),
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Future<void> request(BuildContext context) async {
|
||||
await widget.order.reload();
|
||||
@ -256,8 +216,11 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
|
||||
lines = await widget.order.getLineItems();
|
||||
|
||||
showCameraShortcut = await InvenTreeSettingsManager().getBool(INV_PO_SHOW_CAMERA, true);
|
||||
supportProjectCodes = api.supportsProjectCodes && await api.getGlobalBooleanSetting("PROJECT_CODES_ENABLED", backup: true);
|
||||
showCameraShortcut =
|
||||
await InvenTreeSettingsManager().getBool(INV_PO_SHOW_CAMERA, true);
|
||||
supportProjectCodes = api.supportsProjectCodes &&
|
||||
await api.getGlobalBooleanSetting("PROJECT_CODES_ENABLED",
|
||||
backup: true);
|
||||
|
||||
completedLines = 0;
|
||||
|
||||
@ -267,7 +230,9 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
}
|
||||
}
|
||||
|
||||
InvenTreePurchaseOrderAttachment().countAttachments(widget.order.pk).then((int value) {
|
||||
InvenTreePurchaseOrderAttachment()
|
||||
.countAttachments(widget.order.pk)
|
||||
.then((int value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
attachmentCount = value;
|
||||
@ -275,8 +240,11 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
}
|
||||
});
|
||||
|
||||
if (api.supportsPurchaseOrderDestination && widget.order.destinationId > 0) {
|
||||
InvenTreeStockLocation().get(widget.order.destinationId).then((InvenTreeModel? loc) {
|
||||
if (api.supportsPurchaseOrderDestination &&
|
||||
widget.order.destinationId > 0) {
|
||||
InvenTreeStockLocation()
|
||||
.get(widget.order.destinationId)
|
||||
.then((InvenTreeModel? loc) {
|
||||
if (mounted) {
|
||||
if (loc != null && loc is InvenTreeStockLocation) {
|
||||
setState(() {
|
||||
@ -298,7 +266,8 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
}
|
||||
|
||||
// Count number of "extra line items" against this order
|
||||
InvenTreePOExtraLineItem().count(filters: {"order": widget.order.pk.toString() }).then((int value) {
|
||||
InvenTreePOExtraLineItem().count(
|
||||
filters: {"order": widget.order.pk.toString()}).then((int value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
extraLineCount = value;
|
||||
@ -308,7 +277,7 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
}
|
||||
|
||||
// Edit the currently displayed PurchaseOrder
|
||||
Future <void> editOrder(BuildContext context) async {
|
||||
Future<void> editOrder(BuildContext context) async {
|
||||
var fields = widget.order.formFields();
|
||||
|
||||
// Cannot edit supplier field from here
|
||||
@ -324,39 +293,30 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
fields.remove("project_code");
|
||||
}
|
||||
|
||||
widget.order.editForm(
|
||||
context,
|
||||
L10().purchaseOrderEdit,
|
||||
fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().purchaseOrderUpdated, success: true);
|
||||
}
|
||||
);
|
||||
widget.order.editForm(context, L10().purchaseOrderEdit, fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().purchaseOrderUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
Widget headerTile(BuildContext context) {
|
||||
|
||||
InvenTreeCompany? supplier = widget.order.supplier;
|
||||
|
||||
return Card(
|
||||
child: ListTile(
|
||||
title: Text(widget.order.reference),
|
||||
subtitle: Text(widget.order.description),
|
||||
leading: supplier == null ? null : api.getThumbnail(supplier.thumbnail),
|
||||
trailing: Text(
|
||||
api.PurchaseOrderStatus.label(widget.order.status),
|
||||
style: TextStyle(
|
||||
color: api.PurchaseOrderStatus.color(widget.order.status)
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
title: Text(widget.order.reference),
|
||||
subtitle: Text(widget.order.description),
|
||||
leading:
|
||||
supplier == null ? null : api.getThumbnail(supplier.thumbnail),
|
||||
trailing: Text(
|
||||
api.PurchaseOrderStatus.label(widget.order.status),
|
||||
style: TextStyle(
|
||||
color: api.PurchaseOrderStatus.color(widget.order.status)),
|
||||
)));
|
||||
}
|
||||
|
||||
List<Widget> orderTiles(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [];
|
||||
|
||||
InvenTreeCompany? supplier = widget.order.supplier;
|
||||
@ -366,7 +326,8 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
if (supportProjectCodes && widget.order.hasProjectCode) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().projectCode),
|
||||
subtitle: Text("${widget.order.projectCode} - ${widget.order.projectCodeDescription}"),
|
||||
subtitle: Text(
|
||||
"${widget.order.projectCode} - ${widget.order.projectCodeDescription}"),
|
||||
leading: Icon(TablerIcons.list),
|
||||
));
|
||||
}
|
||||
@ -393,21 +354,21 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
// Order destination
|
||||
if (destination != null) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().destination),
|
||||
subtitle: Text(destination!.name),
|
||||
leading: Icon(TablerIcons.map_pin, color: COLOR_ACTION),
|
||||
onTap: () => {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => LocationDisplayWidget(destination)
|
||||
)
|
||||
)
|
||||
}
|
||||
));
|
||||
title: Text(L10().destination),
|
||||
subtitle: Text(destination!.name),
|
||||
leading: Icon(TablerIcons.map_pin, color: COLOR_ACTION),
|
||||
onTap: () => {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
LocationDisplayWidget(destination)))
|
||||
}));
|
||||
}
|
||||
|
||||
Color lineColor = completedLines < widget.order.lineItemCount ? COLOR_WARNING : COLOR_SUCCESS;
|
||||
Color lineColor = completedLines < widget.order.lineItemCount
|
||||
? COLOR_WARNING
|
||||
: COLOR_SUCCESS;
|
||||
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().lineItems),
|
||||
@ -416,7 +377,8 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
maximum: widget.order.lineItemCount.toDouble(),
|
||||
),
|
||||
leading: Icon(TablerIcons.clipboard_check),
|
||||
trailing: Text("${completedLines} / ${widget.order.lineItemCount}", style: TextStyle(color: lineColor)),
|
||||
trailing: Text("${completedLines} / ${widget.order.lineItemCount}",
|
||||
style: TextStyle(color: lineColor)),
|
||||
));
|
||||
|
||||
// Extra line items
|
||||
@ -426,20 +388,18 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
trailing: Text(extraLineCount.toString()),
|
||||
onTap: () => {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => POExtraLineListWidget(widget.order, filters: {"order": widget.order.pk.toString()})
|
||||
)
|
||||
)
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => POExtraLineListWidget(widget.order,
|
||||
filters: {"order": widget.order.pk.toString()})))
|
||||
},
|
||||
));
|
||||
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().totalPrice),
|
||||
leading: Icon(TablerIcons.currency_dollar),
|
||||
trailing: Text(
|
||||
renderCurrency(widget.order.totalPrice, widget.order.totalPriceCurrency)
|
||||
),
|
||||
trailing: Text(renderCurrency(
|
||||
widget.order.totalPrice, widget.order.totalPriceCurrency)),
|
||||
));
|
||||
|
||||
if (widget.order.issueDate.isNotEmpty) {
|
||||
@ -475,54 +435,44 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
}
|
||||
|
||||
// Responsible "owner"
|
||||
if (widget.order.responsibleName.isNotEmpty && widget.order.responsibleLabel.isNotEmpty) {
|
||||
if (widget.order.responsibleName.isNotEmpty &&
|
||||
widget.order.responsibleLabel.isNotEmpty) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().responsible),
|
||||
leading: Icon(widget.order.responsibleLabel == "group" ? TablerIcons.users : TablerIcons.user),
|
||||
trailing: Text(widget.order.responsibleName)
|
||||
));
|
||||
title: Text(L10().responsible),
|
||||
leading: Icon(widget.order.responsibleLabel == "group"
|
||||
? TablerIcons.users
|
||||
: TablerIcons.user),
|
||||
trailing: Text(widget.order.responsibleName)));
|
||||
}
|
||||
|
||||
// Notes tile
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().notes),
|
||||
leading: Icon(TablerIcons.note, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => NotesWidget(widget.order)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().notes),
|
||||
leading: Icon(TablerIcons.note, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => NotesWidget(widget.order)));
|
||||
},
|
||||
));
|
||||
|
||||
// Attachments
|
||||
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(
|
||||
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(
|
||||
InvenTreePurchaseOrderAttachment(),
|
||||
widget.order.pk,
|
||||
widget.order.reference,
|
||||
widget.order.canEdit
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
widget.order.canEdit)));
|
||||
},
|
||||
));
|
||||
|
||||
return tiles;
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
@ -533,7 +483,7 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
Tab(text: L10().received)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
List<Widget> getTabs(BuildContext context) {
|
||||
return [
|
||||
|
@ -16,18 +16,18 @@ import "package:inventree/inventree/purchase_order.dart";
|
||||
* Widget class for displaying a list of Purchase Orders
|
||||
*/
|
||||
class PurchaseOrderListWidget extends StatefulWidget {
|
||||
|
||||
const PurchaseOrderListWidget({this.filters = const {}, Key? key}) : super(key: key);
|
||||
const PurchaseOrderListWidget({this.filters = const {}, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
final Map<String, String> filters;
|
||||
|
||||
@override
|
||||
_PurchaseOrderListWidgetState createState() => _PurchaseOrderListWidgetState();
|
||||
_PurchaseOrderListWidgetState createState() =>
|
||||
_PurchaseOrderListWidgetState();
|
||||
}
|
||||
|
||||
|
||||
class _PurchaseOrderListWidgetState extends RefreshableState<PurchaseOrderListWidget> {
|
||||
|
||||
class _PurchaseOrderListWidgetState
|
||||
extends RefreshableState<PurchaseOrderListWidget> {
|
||||
_PurchaseOrderListWidgetState();
|
||||
|
||||
@override
|
||||
@ -38,15 +38,12 @@ class _PurchaseOrderListWidgetState extends RefreshableState<PurchaseOrderListWi
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (InvenTreePurchaseOrder().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus),
|
||||
label: L10().purchaseOrderCreate,
|
||||
onTap: () {
|
||||
_createPurchaseOrder(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -59,19 +56,15 @@ class _PurchaseOrderListWidgetState extends RefreshableState<PurchaseOrderListWi
|
||||
// Cannot set contact until company is locked in
|
||||
fields.remove("contact");
|
||||
|
||||
InvenTreePurchaseOrder().createForm(
|
||||
context,
|
||||
L10().purchaseOrderCreate,
|
||||
fields: fields,
|
||||
onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
InvenTreePurchaseOrder().createForm(context, L10().purchaseOrderCreate,
|
||||
fields: fields, onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey("pk")) {
|
||||
var order = InvenTreePurchaseOrder.fromJson(data);
|
||||
order.goToDetailPage(context);
|
||||
}
|
||||
if (data.containsKey("pk")) {
|
||||
var order = InvenTreePurchaseOrder.fromJson(data);
|
||||
order.goToDetailPage(context);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -79,18 +72,16 @@ class _PurchaseOrderListWidgetState extends RefreshableState<PurchaseOrderListWi
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (api.supportsBarcodePOReceiveEndpoint) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(Icons.barcode_reader),
|
||||
label: L10().scanReceivedParts,
|
||||
onTap:() async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: POReceiveBarcodeHandler(),
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(Icons.barcode_reader),
|
||||
label: L10().scanReceivedParts,
|
||||
onTap: () async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: POReceiveBarcodeHandler(),
|
||||
);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -102,22 +93,20 @@ class _PurchaseOrderListWidgetState extends RefreshableState<PurchaseOrderListWi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PaginatedPurchaseOrderList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedPurchaseOrderList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedPurchaseOrderList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().purchaseOrders;
|
||||
|
||||
@override
|
||||
_PaginatedPurchaseOrderListState createState() => _PaginatedPurchaseOrderListState();
|
||||
|
||||
_PaginatedPurchaseOrderListState createState() =>
|
||||
_PaginatedPurchaseOrderListState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedPurchaseOrderListState extends PaginatedSearchState<PaginatedPurchaseOrderList> {
|
||||
|
||||
class _PaginatedPurchaseOrderListState
|
||||
extends PaginatedSearchState<PaginatedPurchaseOrderList> {
|
||||
_PaginatedPurchaseOrderListState() : super();
|
||||
|
||||
@override
|
||||
@ -125,51 +114,53 @@ class _PaginatedPurchaseOrderListState extends PaginatedSearchState<PaginatedPur
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"reference": L10().reference,
|
||||
"supplier__name": L10().supplier,
|
||||
"status": L10().status,
|
||||
"target_date": L10().targetDate,
|
||||
};
|
||||
"reference": L10().reference,
|
||||
"supplier__name": L10().supplier,
|
||||
"status": L10().status,
|
||||
"target_date": L10().targetDate,
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
"outstanding": {
|
||||
"label": L10().outstanding,
|
||||
"help_text": L10().outstandingOrderDetail,
|
||||
"tristate": true,
|
||||
},
|
||||
"overdue": {
|
||||
"label": L10().overdue,
|
||||
"help_text": L10().overdueDetail,
|
||||
"tristate": true,
|
||||
},
|
||||
"assigned_to_me": {
|
||||
"label": L10().assignedToMe,
|
||||
"help_text": L10().assignedToMeDetail,
|
||||
"tristate": true,
|
||||
}
|
||||
};
|
||||
"outstanding": {
|
||||
"label": L10().outstanding,
|
||||
"help_text": L10().outstandingOrderDetail,
|
||||
"tristate": true,
|
||||
},
|
||||
"overdue": {
|
||||
"label": L10().overdue,
|
||||
"help_text": L10().overdueDetail,
|
||||
"tristate": true,
|
||||
},
|
||||
"assigned_to_me": {
|
||||
"label": L10().assignedToMe,
|
||||
"help_text": L10().assignedToMeDetail,
|
||||
"tristate": true,
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
await InvenTreeAPI().PurchaseOrderStatus.load();
|
||||
final page = await InvenTreePurchaseOrder().listPaginated(limit, offset, filters: params);
|
||||
final page = await InvenTreePurchaseOrder()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreePurchaseOrder order = model as InvenTreePurchaseOrder;
|
||||
|
||||
InvenTreeCompany? supplier = order.supplier;
|
||||
|
||||
|
||||
return ListTile(
|
||||
title: Text(order.reference),
|
||||
subtitle: Text(order.description),
|
||||
leading: supplier == null ? null : InvenTreeAPI().getThumbnail(supplier.thumbnail),
|
||||
leading: supplier == null
|
||||
? null
|
||||
: InvenTreeAPI().getThumbnail(supplier.thumbnail),
|
||||
trailing: Text(
|
||||
InvenTreeAPI().PurchaseOrderStatus.label(order.status),
|
||||
style: TextStyle(
|
||||
@ -181,4 +172,4 @@ class _PaginatedPurchaseOrderListState extends PaginatedSearchState<PaginatedPur
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_speed_dial/flutter_speed_dial.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
@ -25,7 +24,6 @@ import "package:inventree/widget/progress.dart";
|
||||
* Widget for viewing a single SalesOrder instance
|
||||
*/
|
||||
class SalesOrderDetailWidget extends StatefulWidget {
|
||||
|
||||
const SalesOrderDetailWidget(this.order, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreeSalesOrder order;
|
||||
@ -34,9 +32,7 @@ class SalesOrderDetailWidget extends StatefulWidget {
|
||||
_SalesOrderDetailState createState() => _SalesOrderDetailState();
|
||||
}
|
||||
|
||||
|
||||
class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
|
||||
_SalesOrderDetailState();
|
||||
|
||||
List<InvenTreeSOLineItem> lines = [];
|
||||
@ -62,14 +58,12 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (widget.order.canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
onPressed: () {
|
||||
editOrder(context);
|
||||
},
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
onPressed: () {
|
||||
editOrder(context);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -77,21 +71,15 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
|
||||
// Add a new shipment against this sales order
|
||||
Future<void> _addShipment(BuildContext context) async {
|
||||
|
||||
var fields = InvenTreeSalesOrderShipment().formFields();
|
||||
|
||||
fields["order"]?["value"] = widget.order.pk;
|
||||
fields["order"]?["hidden"] = true;
|
||||
|
||||
InvenTreeSalesOrderShipment().createForm(
|
||||
context,
|
||||
L10().shipmentAdd,
|
||||
fields: fields,
|
||||
onSuccess: (result) async {
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
|
||||
InvenTreeSalesOrderShipment().createForm(context, L10().shipmentAdd,
|
||||
fields: fields, onSuccess: (result) async {
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
|
||||
// Add a new line item to this sales order
|
||||
@ -101,54 +89,44 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
fields["order"]?["value"] = widget.order.pk;
|
||||
fields["order"]?["hidden"] = true;
|
||||
|
||||
InvenTreeSOLineItem().createForm(
|
||||
context,
|
||||
L10().lineItemAdd,
|
||||
fields: fields,
|
||||
InvenTreeSOLineItem().createForm(context, L10().lineItemAdd, fields: fields,
|
||||
onSuccess: (result) async {
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
|
||||
/// Upload an image for this order
|
||||
Future<void> _uploadImage(BuildContext context) async {
|
||||
InvenTreeSalesOrderAttachment().uploadImage(
|
||||
widget.order.pk,
|
||||
prefix: widget.order.reference,
|
||||
).then((result) => refresh(context));
|
||||
InvenTreeSalesOrderAttachment()
|
||||
.uploadImage(
|
||||
widget.order.pk,
|
||||
prefix: widget.order.reference,
|
||||
)
|
||||
.then((result) => refresh(context));
|
||||
}
|
||||
|
||||
/// Issue this order
|
||||
Future<void> _issueOrder(BuildContext context) async {
|
||||
|
||||
confirmationDialog(
|
||||
L10().issueOrder, "",
|
||||
confirmationDialog(L10().issueOrder, "",
|
||||
icon: TablerIcons.send,
|
||||
color: Colors.blue,
|
||||
acceptText: L10().issue,
|
||||
onAccept: () async {
|
||||
widget.order.issueOrder().then((dynamic) {
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
);
|
||||
acceptText: L10().issue, onAccept: () async {
|
||||
widget.order.issueOrder().then((dynamic) {
|
||||
refresh(context);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// Cancel this order
|
||||
Future<void> _cancelOrder(BuildContext context) async {
|
||||
|
||||
confirmationDialog(
|
||||
L10().cancelOrder, "",
|
||||
confirmationDialog(L10().cancelOrder, "",
|
||||
icon: TablerIcons.circle_x,
|
||||
color: Colors.red,
|
||||
acceptText: L10().cancel,
|
||||
onAccept: () async {
|
||||
await widget.order.cancelOrder().then((dynamic) {
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
);
|
||||
acceptText: L10().cancel, onAccept: () async {
|
||||
await widget.order.cancelOrder().then((dynamic) {
|
||||
refresh(context);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -156,62 +134,48 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (showCameraShortcut && widget.order.canEdit) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.camera, color: Colors.blue),
|
||||
label: L10().takePicture,
|
||||
onTap: () async {
|
||||
_uploadImage(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.camera, color: Colors.blue),
|
||||
label: L10().takePicture,
|
||||
onTap: () async {
|
||||
_uploadImage(context);
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.order.isPending) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.send, color: Colors.blue),
|
||||
label: L10().issueOrder,
|
||||
onTap: () async {
|
||||
_issueOrder(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.send, color: Colors.blue),
|
||||
label: L10().issueOrder,
|
||||
onTap: () async {
|
||||
_issueOrder(context);
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.order.isOpen) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_x, color: Colors.red),
|
||||
label: L10().cancelOrder,
|
||||
onTap: () async {
|
||||
_cancelOrder(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_x, color: Colors.red),
|
||||
label: L10().cancelOrder,
|
||||
onTap: () async {
|
||||
_cancelOrder(context);
|
||||
}));
|
||||
}
|
||||
|
||||
// Add line item
|
||||
if ((widget.order.isPending || widget.order.isInProgress) && InvenTreeSOLineItem().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
if ((widget.order.isPending || widget.order.isInProgress) &&
|
||||
InvenTreeSOLineItem().canCreate) {
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().lineItemAdd,
|
||||
onTap: () async {
|
||||
_addLineItem(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().shipmentAdd,
|
||||
onTap: () async {
|
||||
_addShipment(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -221,9 +185,9 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
List<SpeedDialChild> barcodeButtons(BuildContext context) {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if ((widget.order.isInProgress || widget.order.isPending) && InvenTreeSOLineItem().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
if ((widget.order.isInProgress || widget.order.isPending) &&
|
||||
InvenTreeSOLineItem().canCreate) {
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(Icons.barcode_reader),
|
||||
label: L10().lineItemAdd,
|
||||
onTap: () async {
|
||||
@ -231,25 +195,18 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
context,
|
||||
handler: SOAddItemBarcodeHandler(salesOrder: widget.order),
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
|
||||
if (api.supportsBarcodeSOAllocateEndpoint) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.transition_right),
|
||||
label: L10().allocateStock,
|
||||
onTap: () async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: SOAllocateStockHandler(
|
||||
salesOrder: widget.order,
|
||||
)
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
scanBarcode(context,
|
||||
handler: SOAllocateStockHandler(
|
||||
salesOrder: widget.order,
|
||||
));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,10 +218,15 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
await widget.order.reload();
|
||||
await api.SalesOrderStatus.load();
|
||||
|
||||
supportsProjectCodes = api.supportsProjectCodes && await api.getGlobalBooleanSetting("PROJECT_CODES_ENABLED", backup: true);
|
||||
showCameraShortcut = await InvenTreeSettingsManager().getBool(INV_SO_SHOW_CAMERA, true);
|
||||
supportsProjectCodes = api.supportsProjectCodes &&
|
||||
await api.getGlobalBooleanSetting("PROJECT_CODES_ENABLED",
|
||||
backup: true);
|
||||
showCameraShortcut =
|
||||
await InvenTreeSettingsManager().getBool(INV_SO_SHOW_CAMERA, true);
|
||||
|
||||
InvenTreeSalesOrderAttachment().countAttachments(widget.order.pk).then((int value) {
|
||||
InvenTreeSalesOrderAttachment()
|
||||
.countAttachments(widget.order.pk)
|
||||
.then((int value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
attachmentCount = value;
|
||||
@ -273,7 +235,8 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
});
|
||||
|
||||
// Count number of "extra line items" against this order
|
||||
InvenTreeSOExtraLineItem().count(filters: {"order": widget.order.pk.toString() }).then((int value) {
|
||||
InvenTreeSOExtraLineItem().count(
|
||||
filters: {"order": widget.order.pk.toString()}).then((int value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
extraLineCount = value;
|
||||
@ -298,15 +261,11 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
fields.remove("project_code");
|
||||
}
|
||||
|
||||
widget.order.editForm(
|
||||
context,
|
||||
L10().salesOrderEdit,
|
||||
fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().salesOrderUpdated, success: true);
|
||||
}
|
||||
);
|
||||
widget.order.editForm(context, L10().salesOrderEdit, fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().salesOrderUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
// Construct header tile
|
||||
@ -314,45 +273,40 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
InvenTreeCompany? customer = widget.order.customer;
|
||||
|
||||
return Card(
|
||||
child: ListTile(
|
||||
title: Text(widget.order.reference),
|
||||
subtitle: Text(widget.order.description),
|
||||
leading: customer == null ? null : api.getThumbnail(customer.thumbnail),
|
||||
trailing: Text(
|
||||
api.SalesOrderStatus.label(widget.order.status),
|
||||
style: TextStyle(
|
||||
color: api.SalesOrderStatus.color(widget.order.status)
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
child: ListTile(
|
||||
title: Text(widget.order.reference),
|
||||
subtitle: Text(widget.order.description),
|
||||
leading: customer == null ? null : api.getThumbnail(customer.thumbnail),
|
||||
trailing: Text(
|
||||
api.SalesOrderStatus.label(widget.order.status),
|
||||
style:
|
||||
TextStyle(color: api.SalesOrderStatus.color(widget.order.status)),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
List<Widget> orderTiles(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [
|
||||
headerTile(context)
|
||||
];
|
||||
List<Widget> tiles = [headerTile(context)];
|
||||
|
||||
InvenTreeCompany? customer = widget.order.customer;
|
||||
|
||||
if (supportsProjectCodes && widget.order.hasProjectCode) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().projectCode),
|
||||
subtitle: Text("${widget.order.projectCode} - ${widget.order.projectCodeDescription}"),
|
||||
subtitle: Text(
|
||||
"${widget.order.projectCode} - ${widget.order.projectCodeDescription}"),
|
||||
leading: Icon(TablerIcons.list),
|
||||
));
|
||||
}
|
||||
|
||||
if (customer != null) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().customer),
|
||||
subtitle: Text(customer.name),
|
||||
leading: Icon(TablerIcons.user, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
customer.goToDetailPage(context);
|
||||
}
|
||||
));
|
||||
title: Text(L10().customer),
|
||||
subtitle: Text(customer.name),
|
||||
leading: Icon(TablerIcons.user, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
customer.goToDetailPage(context);
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.order.customerReference.isNotEmpty) {
|
||||
@ -367,12 +321,12 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().lineItems),
|
||||
subtitle: ProgressBar(
|
||||
widget.order.completedLineItemCount.toDouble(),
|
||||
maximum: widget.order.lineItemCount.toDouble()
|
||||
),
|
||||
subtitle: ProgressBar(widget.order.completedLineItemCount.toDouble(),
|
||||
maximum: widget.order.lineItemCount.toDouble()),
|
||||
leading: Icon(TablerIcons.clipboard_check),
|
||||
trailing: Text("${widget.order.completedLineItemCount} / ${widget.order.lineItemCount}", style: TextStyle(color: lineColor)),
|
||||
trailing: Text(
|
||||
"${widget.order.completedLineItemCount} / ${widget.order.lineItemCount}",
|
||||
style: TextStyle(color: lineColor)),
|
||||
));
|
||||
|
||||
// Extra line items
|
||||
@ -384,9 +338,8 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SOExtraLineListWidget(widget.order, filters: {"order": widget.order.pk.toString()})
|
||||
)
|
||||
)
|
||||
builder: (context) => SOExtraLineListWidget(widget.order,
|
||||
filters: {"order": widget.order.pk.toString()})))
|
||||
},
|
||||
));
|
||||
|
||||
@ -394,12 +347,12 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
if (widget.order.shipmentCount > 0) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().shipments),
|
||||
subtitle: ProgressBar(
|
||||
widget.order.completedShipmentCount.toDouble(),
|
||||
maximum: widget.order.shipmentCount.toDouble()
|
||||
),
|
||||
subtitle: ProgressBar(widget.order.completedShipmentCount.toDouble(),
|
||||
maximum: widget.order.shipmentCount.toDouble()),
|
||||
leading: Icon(TablerIcons.truck_delivery),
|
||||
trailing: Text("${widget.order.completedShipmentCount} / ${widget.order.shipmentCount}", style: TextStyle(color: lineColor)),
|
||||
trailing: Text(
|
||||
"${widget.order.completedShipmentCount} / ${widget.order.shipmentCount}",
|
||||
style: TextStyle(color: lineColor)),
|
||||
));
|
||||
}
|
||||
|
||||
@ -430,51 +383,42 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
}
|
||||
|
||||
// Responsible "owner"
|
||||
if (widget.order.responsibleName.isNotEmpty && widget.order.responsibleLabel.isNotEmpty) {
|
||||
if (widget.order.responsibleName.isNotEmpty &&
|
||||
widget.order.responsibleLabel.isNotEmpty) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().responsible),
|
||||
leading: Icon(widget.order.responsibleLabel == "group" ? TablerIcons.users : TablerIcons.user),
|
||||
trailing: Text(widget.order.responsibleName)
|
||||
));
|
||||
leading: Icon(widget.order.responsibleLabel == "group"
|
||||
? TablerIcons.users
|
||||
: TablerIcons.user),
|
||||
trailing: Text(widget.order.responsibleName)));
|
||||
}
|
||||
|
||||
// Notes tile
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().notes),
|
||||
leading: Icon(TablerIcons.note, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => NotesWidget(widget.order)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().notes),
|
||||
leading: Icon(TablerIcons.note, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => NotesWidget(widget.order)));
|
||||
},
|
||||
));
|
||||
|
||||
// Attachments
|
||||
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(
|
||||
InvenTreeSalesOrderAttachment(),
|
||||
widget.order.pk,
|
||||
widget.order.reference,
|
||||
widget.order.canEdit
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
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(
|
||||
InvenTreeSalesOrderAttachment(),
|
||||
widget.order.pk,
|
||||
widget.order.reference,
|
||||
widget.order.canEdit)));
|
||||
},
|
||||
));
|
||||
|
||||
return tiles;
|
||||
}
|
||||
@ -496,5 +440,4 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
PaginatedSOShipmentList({"order": widget.order.pk.toString()}),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_speed_dial/flutter_speed_dial.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
@ -12,20 +11,18 @@ import "package:inventree/api.dart";
|
||||
import "package:inventree/inventree/company.dart";
|
||||
import "package:inventree/inventree/model.dart";
|
||||
|
||||
|
||||
class SalesOrderListWidget extends StatefulWidget {
|
||||
|
||||
const SalesOrderListWidget({this.filters = const {}, Key? key}) : super(key: key);
|
||||
const SalesOrderListWidget({this.filters = const {}, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
final Map<String, String> filters;
|
||||
|
||||
@override
|
||||
_SalesOrderListWidgetState createState() => _SalesOrderListWidgetState();
|
||||
|
||||
}
|
||||
|
||||
class _SalesOrderListWidgetState extends RefreshableState<SalesOrderListWidget> {
|
||||
|
||||
class _SalesOrderListWidgetState
|
||||
extends RefreshableState<SalesOrderListWidget> {
|
||||
_SalesOrderListWidgetState();
|
||||
|
||||
@override
|
||||
@ -36,15 +33,12 @@ class _SalesOrderListWidgetState extends RefreshableState<SalesOrderListWidget>
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (InvenTreeSalesOrder().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus),
|
||||
label: L10().salesOrderCreate,
|
||||
onTap: () {
|
||||
_createSalesOrder(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus),
|
||||
label: L10().salesOrderCreate,
|
||||
onTap: () {
|
||||
_createSalesOrder(context);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -57,19 +51,15 @@ class _SalesOrderListWidgetState extends RefreshableState<SalesOrderListWidget>
|
||||
// Cannot set contact until company is locked in
|
||||
fields.remove("contact");
|
||||
|
||||
InvenTreeSalesOrder().createForm(
|
||||
context,
|
||||
L10().salesOrderCreate,
|
||||
fields: fields,
|
||||
onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
InvenTreeSalesOrder().createForm(context, L10().salesOrderCreate,
|
||||
fields: fields, onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey("pk")) {
|
||||
var order = InvenTreeSalesOrder.fromJson(data);
|
||||
order.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (data.containsKey("pk")) {
|
||||
var order = InvenTreeSalesOrder.fromJson(data);
|
||||
order.goToDetailPage(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -82,25 +72,22 @@ class _SalesOrderListWidgetState extends RefreshableState<SalesOrderListWidget>
|
||||
Widget getBody(BuildContext context) {
|
||||
return PaginatedSalesOrderList(widget.filters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class PaginatedSalesOrderList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedSalesOrderList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedSalesOrderList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().salesOrders;
|
||||
|
||||
@override
|
||||
_PaginatedSalesOrderListState createState() => _PaginatedSalesOrderListState();
|
||||
|
||||
_PaginatedSalesOrderListState createState() =>
|
||||
_PaginatedSalesOrderListState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedSalesOrderListState extends PaginatedSearchState<PaginatedSalesOrderList> {
|
||||
|
||||
class _PaginatedSalesOrderListState
|
||||
extends PaginatedSearchState<PaginatedSalesOrderList> {
|
||||
_PaginatedSalesOrderListState() : super();
|
||||
|
||||
@override
|
||||
@ -108,62 +95,59 @@ class _PaginatedSalesOrderListState extends PaginatedSearchState<PaginatedSalesO
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"reference": L10().reference,
|
||||
"status": L10().status,
|
||||
"target_date": L10().targetDate,
|
||||
"customer__name": L10().customer,
|
||||
};
|
||||
"reference": L10().reference,
|
||||
"status": L10().status,
|
||||
"target_date": L10().targetDate,
|
||||
"customer__name": L10().customer,
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
"outstanding": {
|
||||
"label": L10().outstanding,
|
||||
"help_text": L10().outstandingOrderDetail,
|
||||
"tristate": true,
|
||||
},
|
||||
"overdue": {
|
||||
"label": L10().overdue,
|
||||
"help_text": L10().overdueDetail,
|
||||
"tristate": true,
|
||||
},
|
||||
"assigned_to_me": {
|
||||
"label": L10().assignedToMe,
|
||||
"help_text": L10().assignedToMeDetail,
|
||||
"tristate": true,
|
||||
}
|
||||
};
|
||||
"outstanding": {
|
||||
"label": L10().outstanding,
|
||||
"help_text": L10().outstandingOrderDetail,
|
||||
"tristate": true,
|
||||
},
|
||||
"overdue": {
|
||||
"label": L10().overdue,
|
||||
"help_text": L10().overdueDetail,
|
||||
"tristate": true,
|
||||
},
|
||||
"assigned_to_me": {
|
||||
"label": L10().assignedToMe,
|
||||
"help_text": L10().assignedToMeDetail,
|
||||
"tristate": true,
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
await InvenTreeAPI().SalesOrderStatus.load();
|
||||
final page = await InvenTreeSalesOrder().listPaginated(limit, offset, filters: params);
|
||||
final page = await InvenTreeSalesOrder()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreeSalesOrder order = model as InvenTreeSalesOrder;
|
||||
|
||||
InvenTreeCompany? customer = order.customer;
|
||||
|
||||
return ListTile(
|
||||
title: Text(order.reference),
|
||||
subtitle: Text(order.description),
|
||||
leading: customer == null ? null : InvenTreeAPI().getThumbnail(customer.thumbnail),
|
||||
trailing: Text(
|
||||
InvenTreeAPI().SalesOrderStatus.label(order.status),
|
||||
style: TextStyle(
|
||||
color: InvenTreeAPI().SalesOrderStatus.color(order.status),
|
||||
)
|
||||
),
|
||||
onTap: () async {
|
||||
order.goToDetailPage(context);
|
||||
}
|
||||
);
|
||||
|
||||
title: Text(order.reference),
|
||||
subtitle: Text(order.description),
|
||||
leading: customer == null
|
||||
? null
|
||||
: InvenTreeAPI().getThumbnail(customer.thumbnail),
|
||||
trailing: Text(InvenTreeAPI().SalesOrderStatus.label(order.status),
|
||||
style: TextStyle(
|
||||
color: InvenTreeAPI().SalesOrderStatus.color(order.status),
|
||||
)),
|
||||
onTap: () async {
|
||||
order.goToDetailPage(context);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -11,41 +11,36 @@ import "package:inventree/widget/paginator.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
import "package:inventree/widget/snacks.dart";
|
||||
|
||||
|
||||
class SOExtraLineListWidget extends StatefulWidget {
|
||||
|
||||
const SOExtraLineListWidget(this.order, {this.filters = const {}, Key? key}) : super(key: key);
|
||||
const SOExtraLineListWidget(this.order, {this.filters = const {}, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
final InvenTreeSalesOrder order;
|
||||
|
||||
final Map<String, String> filters;
|
||||
|
||||
@override
|
||||
_SalesOrderExtraLineListWidgetState createState() => _SalesOrderExtraLineListWidgetState();
|
||||
_SalesOrderExtraLineListWidgetState createState() =>
|
||||
_SalesOrderExtraLineListWidgetState();
|
||||
}
|
||||
|
||||
class _SalesOrderExtraLineListWidgetState extends RefreshableState<SOExtraLineListWidget> {
|
||||
|
||||
class _SalesOrderExtraLineListWidgetState
|
||||
extends RefreshableState<SOExtraLineListWidget> {
|
||||
_SalesOrderExtraLineListWidgetState();
|
||||
|
||||
@override
|
||||
String getAppBarTitle() => L10().extraLineItems;
|
||||
|
||||
Future<void> _addLineItem(BuildContext context) async {
|
||||
|
||||
var fields = InvenTreeSOExtraLineItem().formFields();
|
||||
|
||||
fields["order"]?["value"] = widget.order.pk;
|
||||
|
||||
InvenTreeSOExtraLineItem().createForm(
|
||||
context,
|
||||
L10().lineItemAdd,
|
||||
fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().lineItemUpdated, success: true);
|
||||
}
|
||||
);
|
||||
InvenTreeSOExtraLineItem().createForm(context, L10().lineItemAdd,
|
||||
fields: fields, onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().lineItemUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -53,15 +48,12 @@ class _SalesOrderExtraLineListWidgetState extends RefreshableState<SOExtraLineLi
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (widget.order.canEdit) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().lineItemAdd,
|
||||
onTap: () {
|
||||
_addLineItem(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().lineItemAdd,
|
||||
onTap: () {
|
||||
_addLineItem(context);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -73,35 +65,35 @@ class _SalesOrderExtraLineListWidgetState extends RefreshableState<SOExtraLineLi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PaginatedSOExtraLineList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedSOExtraLineList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedSOExtraLineList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().extraLineItems;
|
||||
|
||||
@override
|
||||
_PaginatedSOExtraLineListState createState() => _PaginatedSOExtraLineListState();
|
||||
|
||||
_PaginatedSOExtraLineListState createState() =>
|
||||
_PaginatedSOExtraLineListState();
|
||||
}
|
||||
|
||||
class _PaginatedSOExtraLineListState extends PaginatedSearchState<PaginatedSOExtraLineList> {
|
||||
|
||||
class _PaginatedSOExtraLineListState
|
||||
extends PaginatedSearchState<PaginatedSOExtraLineList> {
|
||||
_PaginatedSOExtraLineListState() : super();
|
||||
|
||||
@override
|
||||
String get prefix => "so_extra_line_";
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreeSOExtraLineItem().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreeSOExtraLineItem()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreeSOExtraLineItem line = model as InvenTreeSOExtraLineItem;
|
||||
|
||||
return ListTile(
|
||||
@ -115,4 +107,4 @@ class _PaginatedSOExtraLineListState extends PaginatedSearchState<PaginatedSOExt
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
@ -62,7 +55,6 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
}
|
||||
|
||||
Future<void> _allocateStock(BuildContext context) async {
|
||||
|
||||
if (order == null) {
|
||||
return;
|
||||
}
|
||||
@ -76,22 +68,13 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
"part": widget.item.partId.toString()
|
||||
};
|
||||
fields["quantity"]?["value"] = widget.item.unallocatedQuantity.toString();
|
||||
fields["shipment"]?["filters"] = {
|
||||
"order": order!.pk.toString()
|
||||
};
|
||||
|
||||
launchApiForm(
|
||||
context,
|
||||
L10().allocateStock,
|
||||
order!.allocate_url,
|
||||
fields,
|
||||
method: "POST",
|
||||
icon: TablerIcons.transition_right,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
fields["shipment"]?["filters"] = {"order": order!.pk.toString()};
|
||||
|
||||
launchApiForm(context, L10().allocateStock, order!.allocate_url, fields,
|
||||
method: "POST",
|
||||
icon: TablerIcons.transition_right, onSuccess: (data) async {
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _editLineItem(BuildContext context) async {
|
||||
@ -102,32 +85,24 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
fields["part"]?["hidden"] = true;
|
||||
}
|
||||
|
||||
widget.item.editForm(
|
||||
context,
|
||||
L10().editLineItem,
|
||||
fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().lineItemUpdated, success: true);
|
||||
}
|
||||
);
|
||||
widget.item.editForm(context, L10().editLineItem, fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().lineItemUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
List<SpeedDialChild> actionButtons(BuildContext context) {
|
||||
|
||||
List<SpeedDialChild> buttons = [];
|
||||
|
||||
if (order != null && order!.isOpen) {
|
||||
buttons.add(
|
||||
SpeedDialChild(
|
||||
buttons.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.transition_right, color: Colors.blue),
|
||||
label: L10().allocateStock,
|
||||
onTap: () async {
|
||||
_allocateStock(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
return buttons;
|
||||
@ -138,23 +113,15 @@ 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,
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.transition_right),
|
||||
label: L10().allocateStock,
|
||||
onTap: () async {
|
||||
scanBarcode(context,
|
||||
handler: SOAllocateStockHandler(
|
||||
salesOrder: order,
|
||||
lineItem: widget.item
|
||||
)
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
salesOrder: order, lineItem: widget.item));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,8 +146,7 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
List<Widget> tiles = [];
|
||||
|
||||
// Reference to the part
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().part),
|
||||
subtitle: Text(widget.item.partName),
|
||||
leading: Icon(TablerIcons.box, color: COLOR_ACTION),
|
||||
@ -193,85 +159,64 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
|
||||
// Available quantity
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().availableStock),
|
||||
leading: Icon(TablerIcons.packages),
|
||||
trailing: Text(simpleNumberString(widget.item.availableStock))
|
||||
)
|
||||
);
|
||||
trailing: Text(simpleNumberString(widget.item.availableStock))));
|
||||
|
||||
// Allocated quantity
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
leading: Icon(TablerIcons.clipboard_check),
|
||||
title: Text(L10().allocated),
|
||||
subtitle: ProgressBar(widget.item.allocatedRatio),
|
||||
trailing: Text(
|
||||
widget.item.allocatedString,
|
||||
style: TextStyle(
|
||||
color: widget.item.isAllocated ? COLOR_SUCCESS : COLOR_WARNING
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
trailing: Text(widget.item.allocatedString,
|
||||
style: TextStyle(
|
||||
color:
|
||||
widget.item.isAllocated ? COLOR_SUCCESS : COLOR_WARNING))));
|
||||
|
||||
// Shipped quantity
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().shipped),
|
||||
subtitle: ProgressBar(widget.item.progressRatio),
|
||||
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
|
||||
if (widget.item.reference.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(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),
|
||||
)
|
||||
);
|
||||
tiles.add(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);
|
||||
},
|
||||
)
|
||||
);
|
||||
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);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
return tiles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,28 +9,26 @@ import "package:inventree/api.dart";
|
||||
import "package:inventree/app_colors.dart";
|
||||
import "package:inventree/widget/progress.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Paginated widget class for displaying a list of sales order line items
|
||||
*/
|
||||
|
||||
class PaginatedSOLineList extends PaginatedSearchWidget {
|
||||
const PaginatedSOLineList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedSOLineList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().lineItems;
|
||||
|
||||
@override
|
||||
_PaginatedSOLineListState createState() => _PaginatedSOLineListState();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* State class for PaginatedSOLineList
|
||||
*/
|
||||
class _PaginatedSOLineListState extends PaginatedSearchState<PaginatedSOLineList> {
|
||||
|
||||
class _PaginatedSOLineListState
|
||||
extends PaginatedSearchState<PaginatedSOLineList> {
|
||||
_PaginatedSOLineListState() : super();
|
||||
|
||||
@override
|
||||
@ -38,18 +36,18 @@ class _PaginatedSOLineListState extends PaginatedSearchState<PaginatedSOLineList
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"part": L10().part,
|
||||
"quantity": L10().quantity,
|
||||
};
|
||||
"part": L10().part,
|
||||
"quantity": L10().quantity,
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
|
||||
};
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreeSOLineItem().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreeSOLineItem()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
return page;
|
||||
}
|
||||
|
||||
@ -60,27 +58,27 @@ class _PaginatedSOLineListState extends PaginatedSearchState<PaginatedSOLineList
|
||||
|
||||
if (part != null) {
|
||||
return ListTile(
|
||||
title: Text(part.name),
|
||||
subtitle: Text(part.description),
|
||||
leading: InvenTreeAPI().getThumbnail(part.thumbnail),
|
||||
trailing: Text(item.progressString, style: TextStyle(color: item.isComplete ? COLOR_SUCCESS : COLOR_WARNING)),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
await item.reload();
|
||||
hideLoadingOverlay();
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SoLineDetailWidget(item))
|
||||
);
|
||||
}
|
||||
);
|
||||
title: Text(part.name),
|
||||
subtitle: Text(part.description),
|
||||
leading: InvenTreeAPI().getThumbnail(part.thumbnail),
|
||||
trailing: Text(item.progressString,
|
||||
style: TextStyle(
|
||||
color: item.isComplete ? COLOR_SUCCESS : COLOR_WARNING)),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
await item.reload();
|
||||
hideLoadingOverlay();
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SoLineDetailWidget(item)));
|
||||
});
|
||||
} else {
|
||||
return ListTile(
|
||||
title: Text(L10().error),
|
||||
subtitle: Text("Missing part detail", style: TextStyle(color: COLOR_DANGER)),
|
||||
subtitle:
|
||||
Text("Missing part detail", style: TextStyle(color: COLOR_DANGER)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
import "package:inventree/app_colors.dart";
|
||||
@ -9,19 +8,19 @@ import "package:inventree/inventree/model.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
|
||||
class PaginatedSOShipmentList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedSOShipmentList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedSOShipmentList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().shipments;
|
||||
|
||||
@override
|
||||
_PaginatedSOShipmentListState createState() => _PaginatedSOShipmentListState();
|
||||
_PaginatedSOShipmentListState createState() =>
|
||||
_PaginatedSOShipmentListState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedSOShipmentListState extends PaginatedSearchState<PaginatedSOShipmentList> {
|
||||
|
||||
class _PaginatedSOShipmentListState
|
||||
extends PaginatedSearchState<PaginatedSOShipmentList> {
|
||||
_PaginatedSOShipmentListState() : super();
|
||||
|
||||
@override
|
||||
@ -34,22 +33,23 @@ class _PaginatedSOShipmentListState extends PaginatedSearchState<PaginatedSOShip
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreeSalesOrderShipment().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreeSalesOrderShipment()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreeSalesOrderShipment shipment = model as InvenTreeSalesOrderShipment;
|
||||
|
||||
return ListTile(
|
||||
title: Text(shipment.reference),
|
||||
subtitle: Text(shipment.tracking_number),
|
||||
leading: shipment.shipped ? Icon(TablerIcons.calendar_check, color: COLOR_SUCCESS) : Icon(TablerIcons.calendar_cancel, color: COLOR_WARNING),
|
||||
trailing: shipment.shipped ? Text(shipment.shipment_date ?? "") : null
|
||||
);
|
||||
|
||||
title: Text(shipment.reference),
|
||||
subtitle: Text(shipment.tracking_number),
|
||||
leading: shipment.shipped
|
||||
? Icon(TablerIcons.calendar_check, color: COLOR_SUCCESS)
|
||||
: Icon(TablerIcons.calendar_cancel, color: COLOR_WARNING),
|
||||
trailing: shipment.shipped ? Text(shipment.shipment_date ?? "") : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,12 +15,10 @@ import "package:inventree/preferences.dart";
|
||||
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Abstract base widget class for rendering a PaginatedSearchState
|
||||
*/
|
||||
abstract class PaginatedSearchWidget extends StatefulWidget {
|
||||
|
||||
const PaginatedSearchWidget({this.filters = const {}, this.title = ""});
|
||||
|
||||
final String title;
|
||||
@ -30,12 +28,11 @@ abstract class PaginatedSearchWidget extends StatefulWidget {
|
||||
final Map<String, String> filters;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Generic stateful widget for displaying paginated data retrieved via the API
|
||||
*/
|
||||
abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends State<T> with BaseWidgetProperties {
|
||||
|
||||
abstract class PaginatedSearchState<T extends PaginatedSearchWidget>
|
||||
extends State<T> with BaseWidgetProperties {
|
||||
static const _pageSize = 25;
|
||||
|
||||
bool showSearchWidget = false;
|
||||
@ -73,7 +70,6 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
|
||||
// Construct the boolean filter options for this list
|
||||
Future<Map<String, String>> constructFilters() async {
|
||||
|
||||
Map<String, String> f = {};
|
||||
|
||||
for (String k in filterOptions.keys) {
|
||||
@ -95,7 +91,8 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
|
||||
// Return the selected ordering "field" for this list widget
|
||||
Future<String> orderingField() async {
|
||||
dynamic field = await InvenTreeSettingsManager().getValue("${prefix}ordering_field", null);
|
||||
dynamic field = await InvenTreeSettingsManager()
|
||||
.getValue("${prefix}ordering_field", null);
|
||||
|
||||
if (field != null && orderingOptions.containsKey(field.toString())) {
|
||||
// A valid ordering field has been found
|
||||
@ -110,7 +107,8 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
|
||||
// Return the selected ordering "order" ("+" or "-") for this list widget
|
||||
Future<String> orderingOrder() async {
|
||||
dynamic order = await InvenTreeSettingsManager().getValue("${prefix}ordering_order", "+");
|
||||
dynamic order = await InvenTreeSettingsManager()
|
||||
.getValue("${prefix}ordering_order", "+");
|
||||
|
||||
return order == "+" ? "+" : "-";
|
||||
}
|
||||
@ -137,10 +135,8 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
// Construct the 'ordering' options
|
||||
List<Map<String, dynamic>> _opts = [];
|
||||
|
||||
orderingOptions.forEach((k, v) => _opts.add({
|
||||
"value": k.toString(),
|
||||
"display_name": v.toString()
|
||||
}));
|
||||
orderingOptions.forEach((k, v) =>
|
||||
_opts.add({"value": k.toString(), "display_name": v.toString()}));
|
||||
|
||||
if (_field == null && _opts.isNotEmpty) {
|
||||
_field = _opts.first["value"];
|
||||
@ -161,12 +157,12 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
"value": _order,
|
||||
"choices": [
|
||||
{
|
||||
"value": "+",
|
||||
"display_name": "Ascending",
|
||||
"value": "+",
|
||||
"display_name": "Ascending",
|
||||
},
|
||||
{
|
||||
"value": "-",
|
||||
"display_name": "Descending",
|
||||
"value": "-",
|
||||
"display_name": "Descending",
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -212,31 +208,25 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
}
|
||||
|
||||
// Launch an interactive form for the user to select options
|
||||
launchApiForm(
|
||||
context,
|
||||
L10().filteringOptions,
|
||||
"",
|
||||
fields,
|
||||
icon: TablerIcons.circle_check,
|
||||
onSuccess: (Map<String, dynamic> data) async {
|
||||
launchApiForm(context, L10().filteringOptions, "", fields,
|
||||
icon: TablerIcons.circle_check,
|
||||
onSuccess: (Map<String, dynamic> data) async {
|
||||
// Extract data from the processed form
|
||||
String f = (data["ordering_field"] ?? _field) as String;
|
||||
String o = (data["ordering_order"] ?? _order) as String;
|
||||
|
||||
// Extract data from the processed form
|
||||
String f = (data["ordering_field"] ?? _field) as String;
|
||||
String o = (data["ordering_order"] ?? _order) as String;
|
||||
// Save values to settings
|
||||
await InvenTreeSettingsManager().setValue("${prefix}ordering_field", f);
|
||||
await InvenTreeSettingsManager().setValue("${prefix}ordering_order", o);
|
||||
|
||||
// Save values to settings
|
||||
await InvenTreeSettingsManager().setValue("${prefix}ordering_field", f);
|
||||
await InvenTreeSettingsManager().setValue("${prefix}ordering_order", o);
|
||||
|
||||
// Save boolean fields
|
||||
for (String key in filterOptions.keys) {
|
||||
await setFilterValue(key, data[key]);
|
||||
}
|
||||
|
||||
// Refresh data from the server
|
||||
_pagingController.refresh();
|
||||
// Save boolean fields
|
||||
for (String key in filterOptions.keys) {
|
||||
await setFilterValue(key, data[key]);
|
||||
}
|
||||
);
|
||||
|
||||
// Refresh data from the server
|
||||
_pagingController.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
// Search query term
|
||||
@ -245,7 +235,6 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
int resultCount = 0;
|
||||
|
||||
String resultsString() {
|
||||
|
||||
if (resultCount <= 0) {
|
||||
return noResultsText;
|
||||
} else {
|
||||
@ -260,7 +249,8 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
Timer? _debounceTimer;
|
||||
|
||||
// Pagination controller
|
||||
final PagingController<int, InvenTreeModel> _pagingController = PagingController(firstPageKey: 0);
|
||||
final PagingController<int, InvenTreeModel> _pagingController =
|
||||
PagingController(firstPageKey: 0);
|
||||
|
||||
void refresh() {
|
||||
_pagingController.refresh();
|
||||
@ -286,8 +276,8 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
* Each implementing class must override this function,
|
||||
* and return an InvenTreePageResponse object with the correct data format
|
||||
*/
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
// Default implementation returns null - must be overridden
|
||||
return null;
|
||||
}
|
||||
@ -301,7 +291,6 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
|
||||
// Include user search term
|
||||
if (searchTerm.isNotEmpty) {
|
||||
|
||||
String _search = searchTerm;
|
||||
|
||||
// Include original search in search test
|
||||
@ -329,11 +318,7 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
params.addAll(f);
|
||||
}
|
||||
|
||||
final page = await requestPage(
|
||||
_pageSize,
|
||||
pageKey,
|
||||
params
|
||||
);
|
||||
final page = await requestPage(_pageSize, pageKey, params);
|
||||
|
||||
// We may have disposed of the widget while the request was in progress
|
||||
// If this is the case, abort
|
||||
@ -350,7 +335,7 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
|
||||
if (page != null) {
|
||||
for (var result in page.results) {
|
||||
items.add(result);
|
||||
items.add(result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -369,14 +354,14 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
|
||||
sentryReportError(
|
||||
"paginator.fetchPage",
|
||||
error, stackTrace,
|
||||
error,
|
||||
stackTrace,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Callback function when the search term is updated
|
||||
void updateSearchTerm() {
|
||||
|
||||
if (searchTerm == searchController.text) {
|
||||
// No change
|
||||
return;
|
||||
@ -410,7 +395,6 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
// Function to construct a single paginated item
|
||||
// Must be overridden in an implementing subclass
|
||||
Widget buildItem(BuildContext context, InvenTreeModel item) {
|
||||
|
||||
// This method must be overridden by the child class
|
||||
return ListTile(
|
||||
title: Text("*** UNIMPLEMENTED ***"),
|
||||
@ -423,8 +407,7 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
String get noResultsText => L10().noResults;
|
||||
|
||||
@override
|
||||
Widget build (BuildContext context) {
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> children = [
|
||||
buildTitleWidget(context),
|
||||
Divider(),
|
||||
@ -434,29 +417,23 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
children.add(buildSearchInput(context));
|
||||
}
|
||||
|
||||
children.add(
|
||||
Expanded(
|
||||
child: CustomScrollView(
|
||||
shrinkWrap: true,
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
scrollDirection: Axis.vertical,
|
||||
slivers: <Widget>[
|
||||
PagedSliverList.separated(
|
||||
pagingController: _pagingController,
|
||||
builderDelegate: PagedChildBuilderDelegate<InvenTreeModel>(
|
||||
itemBuilder: (ctx, item, index) {
|
||||
return buildItem(ctx, item);
|
||||
},
|
||||
noItemsFoundIndicatorBuilder: (context) {
|
||||
return NoResultsWidget(noResultsText);
|
||||
}
|
||||
),
|
||||
separatorBuilder: (context, item) => const Divider(height: 1),
|
||||
)
|
||||
]
|
||||
children.add(Expanded(
|
||||
child: CustomScrollView(
|
||||
shrinkWrap: true,
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
scrollDirection: Axis.vertical,
|
||||
slivers: <Widget>[
|
||||
PagedSliverList.separated(
|
||||
pagingController: _pagingController,
|
||||
builderDelegate: PagedChildBuilderDelegate<InvenTreeModel>(
|
||||
itemBuilder: (ctx, item, index) {
|
||||
return buildItem(ctx, item);
|
||||
}, noItemsFoundIndicatorBuilder: (context) {
|
||||
return NoResultsWidget(noResultsText);
|
||||
}),
|
||||
separatorBuilder: (context, item) => const Divider(height: 1),
|
||||
)
|
||||
)
|
||||
);
|
||||
])));
|
||||
|
||||
return RefreshIndicator(
|
||||
child: Column(
|
||||
@ -473,18 +450,16 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
* Build the title widget for this list
|
||||
*/
|
||||
Widget buildTitleWidget(BuildContext context) {
|
||||
|
||||
const double icon_size = 32;
|
||||
|
||||
List<Widget> _icons = [];
|
||||
|
||||
if (filterOptions.isNotEmpty || orderingOptions.isNotEmpty) {
|
||||
_icons.add(IconButton(
|
||||
onPressed: () async {
|
||||
_setOrderingOptions(context);
|
||||
},
|
||||
icon: Icon(Icons.filter_alt, size: icon_size)
|
||||
));
|
||||
onPressed: () async {
|
||||
_setOrderingOptions(context);
|
||||
},
|
||||
icon: Icon(Icons.filter_alt, size: icon_size)));
|
||||
}
|
||||
|
||||
_icons.add(IconButton(
|
||||
@ -493,8 +468,8 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
showSearchWidget = !showSearchWidget;
|
||||
});
|
||||
},
|
||||
icon: Icon(showSearchWidget ? Icons.zoom_out : Icons.search, size: icon_size)
|
||||
));
|
||||
icon: Icon(showSearchWidget ? Icons.zoom_out : Icons.search,
|
||||
size: icon_size)));
|
||||
|
||||
// _icons.add(IconButton(
|
||||
// onPressed: () async {
|
||||
@ -512,9 +487,7 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
),
|
||||
subtitle: Text(
|
||||
"${L10().results}: ${resultCount}",
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic
|
||||
),
|
||||
style: TextStyle(fontStyle: FontStyle.italic),
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@ -528,41 +501,40 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
|
||||
*/
|
||||
Widget buildSearchInput(BuildContext context) {
|
||||
return ListTile(
|
||||
trailing: GestureDetector(
|
||||
child: Icon(
|
||||
searchController.text.isEmpty ? TablerIcons.search : TablerIcons.backspace,
|
||||
color: searchController.text.isNotEmpty ? COLOR_DANGER : COLOR_ACTION,
|
||||
trailing: GestureDetector(
|
||||
child: Icon(
|
||||
searchController.text.isEmpty
|
||||
? TablerIcons.search
|
||||
: TablerIcons.backspace,
|
||||
color:
|
||||
searchController.text.isNotEmpty ? COLOR_DANGER : COLOR_ACTION,
|
||||
),
|
||||
onTap: () {
|
||||
if (searchController.text.isNotEmpty) {
|
||||
searchController.clear();
|
||||
}
|
||||
updateSearchTerm();
|
||||
},
|
||||
),
|
||||
onTap: () {
|
||||
if (searchController.text.isNotEmpty) {
|
||||
searchController.clear();
|
||||
}
|
||||
updateSearchTerm();
|
||||
},
|
||||
),
|
||||
title: TextFormField(
|
||||
controller: searchController,
|
||||
onChanged: (value) {
|
||||
updateSearchTerm();
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
hintText: L10().search,
|
||||
),
|
||||
)
|
||||
);
|
||||
title: TextFormField(
|
||||
controller: searchController,
|
||||
onChanged: (value) {
|
||||
updateSearchTerm();
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
hintText: L10().search,
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class NoResultsWidget extends StatelessWidget {
|
||||
|
||||
const NoResultsWidget(this.description);
|
||||
|
||||
final String description;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return ListTile(
|
||||
title: Text(
|
||||
description,
|
||||
@ -571,5 +543,4 @@ class NoResultsWidget extends StatelessWidget {
|
||||
leading: Icon(TablerIcons.exclamation_circle, color: COLOR_WARNING),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
|
||||
@ -14,13 +13,13 @@ import "package:inventree/widget/paginator.dart";
|
||||
import "package:inventree/widget/progress.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Widget for displaying a Bill of Materials for a specified Part instance
|
||||
*/
|
||||
class BillOfMaterialsWidget extends StatefulWidget {
|
||||
|
||||
const BillOfMaterialsWidget(this.part, {this.isParentComponent = true, Key? key}) : super(key: key);
|
||||
const BillOfMaterialsWidget(this.part,
|
||||
{this.isParentComponent = true, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
final InvenTreePart part;
|
||||
|
||||
@ -46,19 +45,18 @@ class _BillOfMaterialsState extends RefreshableState<BillOfMaterialsWidget> {
|
||||
|
||||
@override
|
||||
List<Widget> appBarActions(BuildContext context) => [
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.filter),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
showFilterOptions = !showFilterOptions;
|
||||
});
|
||||
},
|
||||
)
|
||||
];
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.filter),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
showFilterOptions = !showFilterOptions;
|
||||
});
|
||||
},
|
||||
)
|
||||
];
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
|
||||
Map<String, String> filters = {};
|
||||
|
||||
if (widget.isParentComponent) {
|
||||
@ -72,7 +70,9 @@ class _BillOfMaterialsState extends RefreshableState<BillOfMaterialsWidget> {
|
||||
ListTile(
|
||||
leading: InvenTreeAPI().getThumbnail(widget.part.thumbnail),
|
||||
title: Text(widget.part.fullname),
|
||||
subtitle: Text(widget.isParentComponent ? L10().billOfMaterials : L10().usedInDetails),
|
||||
subtitle: Text(widget.isParentComponent
|
||||
? L10().billOfMaterials
|
||||
: L10().usedInDetails),
|
||||
trailing: Text(L10().quantity),
|
||||
),
|
||||
Divider(thickness: 1.25),
|
||||
@ -87,13 +87,13 @@ class _BillOfMaterialsState extends RefreshableState<BillOfMaterialsWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create a paginated widget displaying a list of BomItem objects
|
||||
*/
|
||||
class PaginatedBomList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedBomList(Map<String, String> filters, {this.isParentPart = true}) : super(filters: filters);
|
||||
const PaginatedBomList(Map<String, String> filters,
|
||||
{this.isParentPart = true})
|
||||
: super(filters: filters);
|
||||
|
||||
final bool isParentPart;
|
||||
|
||||
@ -104,9 +104,7 @@ class PaginatedBomList extends PaginatedSearchWidget {
|
||||
_PaginatedBomListState createState() => _PaginatedBomListState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedBomListState extends PaginatedSearchState<PaginatedBomList> {
|
||||
|
||||
_PaginatedBomListState() : super();
|
||||
|
||||
@override
|
||||
@ -114,32 +112,33 @@ class _PaginatedBomListState extends PaginatedSearchState<PaginatedBomList> {
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"quantity": L10().quantity,
|
||||
"sub_part": L10().part,
|
||||
};
|
||||
"quantity": L10().quantity,
|
||||
"sub_part": L10().part,
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
"sub_part_assembly": {
|
||||
"label": L10().filterAssembly,
|
||||
"help_text": L10().filterAssemblyDetail,
|
||||
}
|
||||
};
|
||||
"sub_part_assembly": {
|
||||
"label": L10().filterAssembly,
|
||||
"help_text": L10().filterAssemblyDetail,
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
final page = await InvenTreeBomItem().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page =
|
||||
await InvenTreeBomItem().listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreeBomItem bomItem = model as InvenTreeBomItem;
|
||||
|
||||
InvenTreePart? subPart = widget.isParentPart ? bomItem.subPart : bomItem.part;
|
||||
InvenTreePart? subPart =
|
||||
widget.isParentPart ? bomItem.subPart : bomItem.part;
|
||||
|
||||
String title = subPart?.fullname ?? "error - no name";
|
||||
|
||||
@ -151,16 +150,17 @@ class _PaginatedBomListState extends PaginatedSearchState<PaginatedBomList> {
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
leading: InvenTreeAPI().getThumbnail(subPart?.thumbnail ?? ""),
|
||||
onTap: subPart == null ? null : () async {
|
||||
onTap: subPart == null
|
||||
? null
|
||||
: () async {
|
||||
showLoadingOverlay();
|
||||
var part = await InvenTreePart().get(subPart.pk);
|
||||
hideLoadingOverlay();
|
||||
|
||||
showLoadingOverlay();
|
||||
var part = await InvenTreePart().get(subPart.pk);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,7 @@ import "package:inventree/widget/progress.dart";
|
||||
import "package:inventree/widget/snacks.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
class CategoryDisplayWidget extends StatefulWidget {
|
||||
|
||||
const CategoryDisplayWidget(this.category, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreePartCategory? category;
|
||||
@ -24,9 +22,7 @@ class CategoryDisplayWidget extends StatefulWidget {
|
||||
_CategoryDisplayState createState() => _CategoryDisplayState();
|
||||
}
|
||||
|
||||
|
||||
class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
|
||||
_CategoryDisplayState();
|
||||
|
||||
@override
|
||||
@ -38,15 +34,13 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
|
||||
if (widget.category != null) {
|
||||
if (InvenTreePartCategory().canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editCategory,
|
||||
onPressed: () {
|
||||
_editCategoryDialog(context);
|
||||
},
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editCategory,
|
||||
onPressed: () {
|
||||
_editCategoryDialog(context);
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,25 +52,20 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (InvenTreePart().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.box),
|
||||
label: L10().partCreateDetail,
|
||||
onTap: _newPart,
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.box),
|
||||
label: L10().partCreateDetail,
|
||||
onTap: _newPart,
|
||||
));
|
||||
}
|
||||
|
||||
if (InvenTreePartCategory().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.sitemap),
|
||||
label: L10().categoryCreateDetail,
|
||||
onTap: () {
|
||||
_newCategory(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -90,14 +79,10 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
return;
|
||||
}
|
||||
|
||||
_cat.editForm(
|
||||
context,
|
||||
L10().editCategory,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().categoryUpdated, success: true);
|
||||
}
|
||||
);
|
||||
_cat.editForm(context, L10().editCategory, onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().categoryUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -107,7 +92,6 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
|
||||
@override
|
||||
Future<void> request(BuildContext context) async {
|
||||
|
||||
// Update the category
|
||||
if (widget.category != null) {
|
||||
final bool result = await widget.category?.reload() ?? false;
|
||||
@ -121,67 +105,60 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
Widget getCategoryDescriptionCard({bool extra = true}) {
|
||||
if (widget.category == null) {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
leading: Icon(TablerIcons.packages),
|
||||
title: Text(
|
||||
L10().partCategoryTopLevel,
|
||||
style: TextStyle(fontStyle: FontStyle.italic),
|
||||
)
|
||||
)
|
||||
);
|
||||
child: ListTile(
|
||||
leading: Icon(TablerIcons.packages),
|
||||
title: Text(
|
||||
L10().partCategoryTopLevel,
|
||||
style: TextStyle(fontStyle: FontStyle.italic),
|
||||
)));
|
||||
} else {
|
||||
|
||||
List<Widget> children = [
|
||||
ListTile(
|
||||
title: Text("${widget.category?.name}",
|
||||
style: TextStyle(fontWeight: FontWeight.bold)
|
||||
),
|
||||
subtitle: Text("${widget.category?.description}"),
|
||||
leading: widget.category!.customIcon != null ? Icon(widget.category!.customIcon) : Icon(TablerIcons.sitemap)
|
||||
),
|
||||
title: Text("${widget.category?.name}",
|
||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
subtitle: Text("${widget.category?.description}"),
|
||||
leading: widget.category!.customIcon != null
|
||||
? Icon(widget.category!.customIcon)
|
||||
: Icon(TablerIcons.sitemap)),
|
||||
];
|
||||
|
||||
if (extra) {
|
||||
children.add(
|
||||
ListTile(
|
||||
title: Text(L10().parentCategory),
|
||||
subtitle: Text("${widget.category?.parentPathString}"),
|
||||
leading: Icon(
|
||||
TablerIcons.arrow_move_up,
|
||||
color: COLOR_ACTION,
|
||||
),
|
||||
onTap: () async {
|
||||
children.add(ListTile(
|
||||
title: Text(L10().parentCategory),
|
||||
subtitle: Text("${widget.category?.parentPathString}"),
|
||||
leading: Icon(
|
||||
TablerIcons.arrow_move_up,
|
||||
color: COLOR_ACTION,
|
||||
),
|
||||
onTap: () async {
|
||||
int parentId = widget.category?.parentId ?? -1;
|
||||
|
||||
int parentId = widget.category?.parentId ?? -1;
|
||||
if (parentId < 0) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CategoryDisplayWidget(null)));
|
||||
} else {
|
||||
showLoadingOverlay();
|
||||
var cat = await InvenTreePartCategory().get(parentId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (parentId < 0) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
|
||||
} else {
|
||||
|
||||
showLoadingOverlay();
|
||||
var cat = await InvenTreePartCategory().get(parentId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (cat is InvenTreePartCategory) {
|
||||
cat.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
if (cat is InvenTreePartCategory) {
|
||||
cat.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
return Card(
|
||||
child: Column(
|
||||
children: children
|
||||
),
|
||||
child: Column(children: children),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
List<Widget> getTabIcons(BuildContext context) {
|
||||
|
||||
return [
|
||||
Tab(text: L10().details),
|
||||
Tab(text: L10().parts),
|
||||
@ -198,7 +175,6 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
|
||||
// Construct the "details" panel
|
||||
List<Widget> detailTiles() {
|
||||
|
||||
Map<String, String> filters = {};
|
||||
|
||||
int? parent = widget.category?.pk;
|
||||
@ -225,7 +201,6 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
|
||||
// Construct the "parts" panel
|
||||
List<Widget> partsTiles() {
|
||||
|
||||
Map<String, String> filters = {
|
||||
"category": widget.category?.pk.toString() ?? "null",
|
||||
};
|
||||
@ -239,50 +214,35 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
}
|
||||
|
||||
Future<void> _newCategory(BuildContext context) async {
|
||||
|
||||
int pk = widget.category?.pk ?? -1;
|
||||
|
||||
InvenTreePartCategory().createForm(
|
||||
context,
|
||||
L10().categoryCreate,
|
||||
data: {
|
||||
"parent": (pk > 0) ? pk : null,
|
||||
},
|
||||
onSuccess: (result) async {
|
||||
InvenTreePartCategory().createForm(context, L10().categoryCreate, data: {
|
||||
"parent": (pk > 0) ? pk : null,
|
||||
}, 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 cat = InvenTreePartCategory.fromJson(data);
|
||||
cat.goToDetailPage(context).then((_) {
|
||||
refresh(context);
|
||||
});
|
||||
} else {
|
||||
if (data.containsKey("pk")) {
|
||||
var cat = InvenTreePartCategory.fromJson(data);
|
||||
cat.goToDetailPage(context).then((_) {
|
||||
refresh(context);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _newPart() async {
|
||||
|
||||
int pk = widget.category?.pk ?? -1;
|
||||
|
||||
InvenTreePart().createForm(
|
||||
context,
|
||||
L10().partCreate,
|
||||
data: {
|
||||
"category": (pk > 0) ? pk : null
|
||||
},
|
||||
onSuccess: (result) async {
|
||||
InvenTreePart().createForm(context, L10().partCreate,
|
||||
data: {"category": (pk > 0) ? pk : null}, 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 part = InvenTreePart.fromJson(data);
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
if (data.containsKey("pk")) {
|
||||
var part = InvenTreePart.fromJson(data);
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -9,19 +9,15 @@ import "package:inventree/api.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
|
||||
class PartCategoryList extends StatefulWidget {
|
||||
|
||||
const PartCategoryList(this.filters);
|
||||
|
||||
final Map<String, String> filters;
|
||||
|
||||
@override
|
||||
_PartCategoryListState createState() => _PartCategoryListState();
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _PartCategoryListState extends RefreshableState<PartCategoryList> {
|
||||
|
||||
_PartCategoryListState();
|
||||
|
||||
@override
|
||||
@ -34,19 +30,20 @@ class _PartCategoryListState extends RefreshableState<PartCategoryList> {
|
||||
}
|
||||
|
||||
class PaginatedPartCategoryList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedPartCategoryList(Map<String, String> filters, {String title = ""}) : super(filters: filters, title: title);
|
||||
const PaginatedPartCategoryList(Map<String, String> filters,
|
||||
{String title = ""})
|
||||
: super(filters: filters, title: title);
|
||||
|
||||
@override
|
||||
String get searchTitle => title.isNotEmpty ? title : L10().partCategories;
|
||||
|
||||
@override
|
||||
_PaginatedPartCategoryListState createState() => _PaginatedPartCategoryListState();
|
||||
_PaginatedPartCategoryListState createState() =>
|
||||
_PaginatedPartCategoryListState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedPartCategoryListState extends PaginatedSearchState<PaginatedPartCategoryList> {
|
||||
|
||||
class _PaginatedPartCategoryListState
|
||||
extends PaginatedSearchState<PaginatedPartCategoryList> {
|
||||
// _PaginatedPartCategoryListState(Map<String, String> filters, bool searchEnabled) : super(filters, searchEnabled);
|
||||
|
||||
@override
|
||||
@ -54,17 +51,16 @@ class _PaginatedPartCategoryListState extends PaginatedSearchState<PaginatedPart
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
"cascade": {
|
||||
"default": false,
|
||||
"label": L10().includeSubcategories,
|
||||
"help_text": L10().includeSubcategoriesDetail,
|
||||
"tristate": false,
|
||||
}
|
||||
};
|
||||
"cascade": {
|
||||
"default": false,
|
||||
"label": L10().includeSubcategories,
|
||||
"help_text": L10().includeSubcategoriesDetail,
|
||||
"tristate": false,
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions {
|
||||
|
||||
Map<String, String> options = {
|
||||
"name": L10().name,
|
||||
"level": L10().level,
|
||||
@ -81,16 +77,16 @@ class _PaginatedPartCategoryListState extends PaginatedSearchState<PaginatedPart
|
||||
}
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
final page = await InvenTreePartCategory().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreePartCategory()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreePartCategory category = model as InvenTreePartCategory;
|
||||
|
||||
return ListTile(
|
||||
@ -103,4 +99,4 @@ class _PaginatedPartCategoryListState extends PaginatedSearchState<PaginatedPart
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,19 +11,15 @@ import "package:inventree/widget/snacks.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
|
||||
class PartImageWidget extends StatefulWidget {
|
||||
|
||||
const PartImageWidget(this.part, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreePart part;
|
||||
|
||||
@override
|
||||
_PartImageState createState() => _PartImageState(part);
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _PartImageState extends RefreshableState<PartImageWidget> {
|
||||
|
||||
_PartImageState(this.part);
|
||||
|
||||
final InvenTreePart part;
|
||||
@ -38,32 +34,24 @@ class _PartImageState extends RefreshableState<PartImageWidget> {
|
||||
|
||||
@override
|
||||
List<Widget> appBarActions(BuildContext context) {
|
||||
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (part.canEdit) {
|
||||
|
||||
// File upload
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.file_upload),
|
||||
onPressed: () async {
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.file_upload),
|
||||
onPressed: () async {
|
||||
FilePickerDialog.pickFile(onPicked: (File file) async {
|
||||
final result = await part.uploadImage(file);
|
||||
|
||||
FilePickerDialog.pickFile(
|
||||
onPicked: (File file) async {
|
||||
final result = await part.uploadImage(file);
|
||||
if (!result) {
|
||||
showSnackIcon(L10().uploadFailed, success: false);
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
showSnackIcon(L10().uploadFailed, success: false);
|
||||
}
|
||||
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
)
|
||||
);
|
||||
refresh(context);
|
||||
});
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -73,5 +61,4 @@ class _PartImageState extends RefreshableState<PartImageWidget> {
|
||||
Widget getBody(BuildContext context) {
|
||||
return InvenTreeAPI().getImage(part.image);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,7 @@ import "package:inventree/inventree/part.dart";
|
||||
import "package:inventree/widget/paginator.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
class PartList extends StatefulWidget {
|
||||
|
||||
const PartList(this.filters, {this.title = ""});
|
||||
|
||||
final String title;
|
||||
@ -22,9 +20,7 @@ class PartList extends StatefulWidget {
|
||||
_PartListState createState() => _PartListState(filters, title);
|
||||
}
|
||||
|
||||
|
||||
class _PartListState extends RefreshableState<PartList> {
|
||||
|
||||
_PartListState(this.filters, this.title);
|
||||
|
||||
final String title;
|
||||
@ -40,13 +36,11 @@ class _PartListState extends RefreshableState<PartList> {
|
||||
Widget getBody(BuildContext context) {
|
||||
return PaginatedPartList(filters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class PaginatedPartList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedPartList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedPartList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().parts;
|
||||
@ -55,9 +49,7 @@ class PaginatedPartList extends PaginatedSearchWidget {
|
||||
_PaginatedPartListState createState() => _PaginatedPartListState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedPartListState extends PaginatedSearchState<PaginatedPartList> {
|
||||
|
||||
_PaginatedPartListState() : super();
|
||||
|
||||
@override
|
||||
@ -65,74 +57,70 @@ class _PaginatedPartListState extends PaginatedSearchState<PaginatedPartList> {
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"name": L10().name,
|
||||
"in_stock": L10().stock,
|
||||
"IPN": L10().internalPartNumber,
|
||||
};
|
||||
"name": L10().name,
|
||||
"in_stock": L10().stock,
|
||||
"IPN": L10().internalPartNumber,
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
"cascade": {
|
||||
"default": true,
|
||||
"label": L10().includeSubcategories,
|
||||
"help_text": L10().includeSubcategoriesDetail,
|
||||
},
|
||||
"active": {
|
||||
"label": L10().filterActive,
|
||||
"help_text": L10().filterActiveDetail,
|
||||
"tristate": true,
|
||||
},
|
||||
"assembly": {
|
||||
"label": L10().filterAssembly,
|
||||
"help_text": L10().filterAssemblyDetail
|
||||
},
|
||||
"component": {
|
||||
"label": L10().filterComponent,
|
||||
"help_text": L10().filterComponentDetail,
|
||||
},
|
||||
"is_template": {
|
||||
"label": L10().filterTemplate,
|
||||
"help_text": L10().filterTemplateDetail
|
||||
},
|
||||
"trackable": {
|
||||
"label": L10().filterTrackable,
|
||||
"help_text": L10().filterTrackableDetail,
|
||||
},
|
||||
"virtual": {
|
||||
"label": L10().filterVirtual,
|
||||
"help_text": L10().filterVirtualDetail,
|
||||
},
|
||||
"has_stock": {
|
||||
"label": L10().filterInStock,
|
||||
"help_text": L10().filterInStockDetail,
|
||||
}
|
||||
};
|
||||
"cascade": {
|
||||
"default": true,
|
||||
"label": L10().includeSubcategories,
|
||||
"help_text": L10().includeSubcategoriesDetail,
|
||||
},
|
||||
"active": {
|
||||
"label": L10().filterActive,
|
||||
"help_text": L10().filterActiveDetail,
|
||||
"tristate": true,
|
||||
},
|
||||
"assembly": {
|
||||
"label": L10().filterAssembly,
|
||||
"help_text": L10().filterAssemblyDetail
|
||||
},
|
||||
"component": {
|
||||
"label": L10().filterComponent,
|
||||
"help_text": L10().filterComponentDetail,
|
||||
},
|
||||
"is_template": {
|
||||
"label": L10().filterTemplate,
|
||||
"help_text": L10().filterTemplateDetail
|
||||
},
|
||||
"trackable": {
|
||||
"label": L10().filterTrackable,
|
||||
"help_text": L10().filterTrackableDetail,
|
||||
},
|
||||
"virtual": {
|
||||
"label": L10().filterVirtual,
|
||||
"help_text": L10().filterVirtualDetail,
|
||||
},
|
||||
"has_stock": {
|
||||
"label": L10().filterInStock,
|
||||
"help_text": L10().filterInStockDetail,
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreePart().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page =
|
||||
await InvenTreePart().listPaginated(limit, offset, filters: params);
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreePart part = model as InvenTreePart;
|
||||
|
||||
return ListTile(
|
||||
title: Text(part.fullname),
|
||||
subtitle: Text(part.description),
|
||||
trailing: Text(
|
||||
part.stockString(),
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold
|
||||
)
|
||||
),
|
||||
trailing: Text(part.stockString(),
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
||||
leading: InvenTreeAPI().getThumbnail(part.thumbnail),
|
||||
onTap: () {
|
||||
part.goToDetailPage(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import "package:inventree/widget/refreshable_state.dart";
|
||||
* Widget for displaying a list of parameters associated with a given Part instance
|
||||
*/
|
||||
class PartParameterWidget extends StatefulWidget {
|
||||
|
||||
const PartParameterWidget(this.part);
|
||||
|
||||
final InvenTreePart part;
|
||||
@ -20,7 +19,6 @@ class PartParameterWidget extends StatefulWidget {
|
||||
_ParameterWidgetState createState() => _ParameterWidgetState();
|
||||
}
|
||||
|
||||
|
||||
class _ParameterWidgetState extends RefreshableState<PartParameterWidget> {
|
||||
_ParameterWidgetState();
|
||||
|
||||
@ -36,28 +34,20 @@ class _ParameterWidgetState extends RefreshableState<PartParameterWidget> {
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
|
||||
Map<String, String> filters = {
|
||||
"part": widget.part.pk.toString()
|
||||
};
|
||||
Map<String, String> filters = {"part": widget.part.pk.toString()};
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: PaginatedParameterList(filters)
|
||||
)
|
||||
],
|
||||
children: [Expanded(child: PaginatedParameterList(filters))],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Widget for displaying a paginated list of Part parameters
|
||||
*/
|
||||
class PaginatedParameterList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedParameterList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedParameterList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().parameters;
|
||||
@ -66,51 +56,43 @@ class PaginatedParameterList extends PaginatedSearchWidget {
|
||||
_PaginatedParameterState createState() => _PaginatedParameterState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedParameterState extends PaginatedSearchState<PaginatedParameterList> {
|
||||
|
||||
class _PaginatedParameterState
|
||||
extends PaginatedSearchState<PaginatedParameterList> {
|
||||
_PaginatedParameterState() : super();
|
||||
|
||||
@override
|
||||
String get prefix => "parameters_";
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
|
||||
};
|
||||
Map<String, String> get orderingOptions => {};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
// TODO
|
||||
};
|
||||
// TODO
|
||||
};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
final page = await InvenTreePartParameter().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreePartParameter()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
Future<void> editParameter(InvenTreePartParameter parameter) async {
|
||||
|
||||
// Checkbox values are handled separately
|
||||
if (parameter.is_checkbox) {
|
||||
return;
|
||||
} else {
|
||||
parameter.editForm(
|
||||
context,
|
||||
L10().editParameter,
|
||||
onSuccess: (data) async {
|
||||
updateSearchTerm();
|
||||
}
|
||||
);
|
||||
parameter.editForm(context, L10().editParameter, onSuccess: (data) async {
|
||||
updateSearchTerm();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreePartParameter parameter = model as InvenTreePartParameter;
|
||||
|
||||
String title = parameter.name;
|
||||
@ -123,27 +105,27 @@ class _PaginatedParameterState extends PaginatedSearchState<PaginatedParameterLi
|
||||
title: Text(title),
|
||||
subtitle: Text(parameter.description),
|
||||
trailing: parameter.is_checkbox
|
||||
? Switch(
|
||||
value: parameter.as_bool,
|
||||
onChanged: (bool value) {
|
||||
if (parameter.canEdit) {
|
||||
showLoadingOverlay();
|
||||
parameter.update(
|
||||
values: {
|
||||
"data": value.toString()
|
||||
? Switch(
|
||||
value: parameter.as_bool,
|
||||
onChanged: (bool value) {
|
||||
if (parameter.canEdit) {
|
||||
showLoadingOverlay();
|
||||
parameter.update(values: {"data": value.toString()}).then(
|
||||
(value) async {
|
||||
hideLoadingOverlay();
|
||||
updateSearchTerm();
|
||||
});
|
||||
}
|
||||
).then((value) async{
|
||||
hideLoadingOverlay();
|
||||
updateSearchTerm();
|
||||
});
|
||||
}
|
||||
},
|
||||
) : Text(parameter.value),
|
||||
onTap: parameter.is_checkbox ? null : () async {
|
||||
if (parameter.canEdit) {
|
||||
editParameter(parameter);
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
: Text(parameter.value),
|
||||
onTap: parameter.is_checkbox
|
||||
? null
|
||||
: () async {
|
||||
if (parameter.canEdit) {
|
||||
editParameter(parameter);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,9 @@ import "package:inventree/widget/refreshable_state.dart";
|
||||
import "package:inventree/helpers.dart";
|
||||
|
||||
class PartPricingWidget extends StatefulWidget {
|
||||
|
||||
const PartPricingWidget({Key? key, required this.part, required this.partPricing}) : super(key: key);
|
||||
const PartPricingWidget(
|
||||
{Key? key, required this.part, required this.partPricing})
|
||||
: super(key: key);
|
||||
final InvenTreePart part;
|
||||
final InvenTreePartPricing? partPricing;
|
||||
|
||||
@ -17,7 +18,6 @@ class PartPricingWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PartPricingWidgetState extends RefreshableState<PartPricingWidget> {
|
||||
|
||||
@override
|
||||
String getAppBarTitle() {
|
||||
return L10().partPricing;
|
||||
@ -25,174 +25,108 @@ class _PartPricingWidgetState extends RefreshableState<PartPricingWidget> {
|
||||
|
||||
@override
|
||||
List<Widget> getTiles(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [
|
||||
Card(
|
||||
child: ListTile(
|
||||
title: Text(widget.part.fullname),
|
||||
subtitle: Text(widget.part.description),
|
||||
leading: api.getThumbnail(widget.part.thumbnail)
|
||||
)
|
||||
),
|
||||
child: ListTile(
|
||||
title: Text(widget.part.fullname),
|
||||
subtitle: Text(widget.part.description),
|
||||
leading: api.getThumbnail(widget.part.thumbnail))),
|
||||
];
|
||||
|
||||
if (widget.partPricing == null) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().noPricingAvailable),
|
||||
subtitle: Text(L10().noPricingDataFound),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().noPricingAvailable),
|
||||
subtitle: Text(L10().noPricingDataFound),
|
||||
));
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
final pricing = widget.partPricing!;
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().currency),
|
||||
trailing: Text(pricing.currency),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().currency),
|
||||
trailing: Text(pricing.currency),
|
||||
));
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().priceRange),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.overallMin,
|
||||
pricing.overallMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().priceRange),
|
||||
trailing: Text(formatPriceRange(pricing.overallMin, pricing.overallMax,
|
||||
currency: pricing.currency)),
|
||||
));
|
||||
|
||||
if (pricing.overallMin != null) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().priceOverrideMin),
|
||||
trailing: Text(
|
||||
renderCurrency(pricing.overallMin, pricing.overrideMinCurrency)
|
||||
)
|
||||
)
|
||||
);
|
||||
trailing: Text(renderCurrency(
|
||||
pricing.overallMin, pricing.overrideMinCurrency))));
|
||||
}
|
||||
|
||||
if (pricing.overrideMax != null) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().priceOverrideMax),
|
||||
trailing: Text(
|
||||
renderCurrency(pricing.overallMax, pricing.overrideMaxCurrency)
|
||||
)
|
||||
)
|
||||
);
|
||||
trailing: Text(renderCurrency(
|
||||
pricing.overallMax, pricing.overrideMaxCurrency))));
|
||||
}
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().internalCost),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.internalCostMin,
|
||||
pricing.internalCostMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().internalCost),
|
||||
trailing: Text(formatPriceRange(
|
||||
pricing.internalCostMin, pricing.internalCostMax,
|
||||
currency: pricing.currency)),
|
||||
));
|
||||
|
||||
if (widget.part.isTemplate) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().variantCost),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.variantCostMin,
|
||||
pricing.variantCostMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().variantCost),
|
||||
trailing: Text(formatPriceRange(
|
||||
pricing.variantCostMin, pricing.variantCostMax,
|
||||
currency: pricing.currency)),
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.part.isAssembly) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().bomCost),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.bomCostMin,
|
||||
pricing.bomCostMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
trailing: Text(formatPriceRange(
|
||||
pricing.bomCostMin, pricing.bomCostMax,
|
||||
currency: pricing.currency))));
|
||||
}
|
||||
|
||||
if (widget.part.isPurchaseable) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().purchasePrice),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.purchaseCostMin,
|
||||
pricing.purchaseCostMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().purchasePrice),
|
||||
trailing: Text(formatPriceRange(
|
||||
pricing.purchaseCostMin, pricing.purchaseCostMax,
|
||||
currency: pricing.currency)),
|
||||
));
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().supplierPricing),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.supplierPriceMin,
|
||||
pricing.supplierPriceMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().supplierPricing),
|
||||
trailing: Text(formatPriceRange(
|
||||
pricing.supplierPriceMin, pricing.supplierPriceMax,
|
||||
currency: pricing.currency)),
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.part.isSalable) {
|
||||
tiles.add(Divider());
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().salePrice),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.salePriceMin,
|
||||
pricing.salePriceMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().salePrice),
|
||||
trailing: Text(formatPriceRange(
|
||||
pricing.salePriceMin, pricing.salePriceMax,
|
||||
currency: pricing.currency)),
|
||||
));
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().saleHistory),
|
||||
trailing: Text(
|
||||
formatPriceRange(
|
||||
pricing.saleHistoryMin,
|
||||
pricing.saleHistoryMax,
|
||||
currency: pricing.currency
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().saleHistory),
|
||||
trailing: Text(formatPriceRange(
|
||||
pricing.saleHistoryMin, pricing.saleHistoryMax,
|
||||
currency: pricing.currency)),
|
||||
));
|
||||
}
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,19 +10,15 @@ import "package:inventree/inventree/company.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
class PartSupplierWidget extends StatefulWidget {
|
||||
|
||||
const PartSupplierWidget(this.part, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreePart part;
|
||||
|
||||
@override
|
||||
_PartSupplierState createState() => _PartSupplierState(part);
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _PartSupplierState extends RefreshableState<PartSupplierWidget> {
|
||||
|
||||
_PartSupplierState(this.part);
|
||||
|
||||
final InvenTreePart part;
|
||||
@ -46,7 +42,6 @@ class _PartSupplierState extends RefreshableState<PartSupplierWidget> {
|
||||
}
|
||||
|
||||
Widget _supplierPartTile(BuildContext context, int index) {
|
||||
|
||||
InvenTreeSupplierPart _part = _supplierParts[index];
|
||||
|
||||
return ListTile(
|
||||
@ -73,5 +68,4 @@ class _PartSupplierState extends RefreshableState<PartSupplierWidget> {
|
||||
itemBuilder: _supplierPartTile,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
import "dart:io";
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
@ -7,17 +5,11 @@ import "package:flutter_overlay_loader/flutter_overlay_loader.dart";
|
||||
import "package:inventree/app_colors.dart";
|
||||
import "package:one_context/one_context.dart";
|
||||
|
||||
|
||||
/*
|
||||
* A simplified linear progress bar widget,
|
||||
* with standardized color depiction
|
||||
*/
|
||||
Widget ProgressBar(
|
||||
double value,
|
||||
{
|
||||
double maximum = 1.0
|
||||
}) {
|
||||
|
||||
Widget ProgressBar(double value, {double maximum = 1.0}) {
|
||||
double v = 0;
|
||||
|
||||
if (value <= 0 || maximum <= 0) {
|
||||
@ -33,20 +25,14 @@ Widget ProgressBar(
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Construct a circular progress indicator
|
||||
*/
|
||||
Widget progressIndicator() {
|
||||
|
||||
return Center(
|
||||
child: CircularProgressIndicator()
|
||||
);
|
||||
return Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
|
||||
void showLoadingOverlay() {
|
||||
|
||||
// Do not show overlay if running unit tests
|
||||
if (Platform.environment.containsKey("FLUTTER_TEST")) {
|
||||
return;
|
||||
@ -58,13 +44,11 @@ void showLoadingOverlay() {
|
||||
return;
|
||||
}
|
||||
|
||||
Loader.show(
|
||||
context,
|
||||
themeData: Theme.of(context).copyWith(colorScheme: ColorScheme.fromSwatch())
|
||||
);
|
||||
Loader.show(context,
|
||||
themeData:
|
||||
Theme.of(context).copyWith(colorScheme: ColorScheme.fromSwatch()));
|
||||
}
|
||||
|
||||
|
||||
void hideLoadingOverlay() {
|
||||
if (Loader.isShown) {
|
||||
Loader.hide();
|
||||
|
@ -10,12 +10,10 @@ import "package:inventree/widget/back.dart";
|
||||
import "package:inventree/widget/drawer.dart";
|
||||
import "package:inventree/widget/search.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Simple mixin class which defines simple methods for defining widget properties
|
||||
*/
|
||||
mixin BaseWidgetProperties {
|
||||
|
||||
/*
|
||||
* Return a list of appBar actions
|
||||
* By default, no appBar actions are available
|
||||
@ -23,7 +21,9 @@ mixin BaseWidgetProperties {
|
||||
List<Widget> appBarActions(BuildContext context) => [];
|
||||
|
||||
// Return a title for the appBar (placeholder)
|
||||
String getAppBarTitle() { return "--- app bar ---"; }
|
||||
String getAppBarTitle() {
|
||||
return "--- app bar ---";
|
||||
}
|
||||
|
||||
// Function to construct a drawer (override if needed)
|
||||
Widget getDrawer(BuildContext context) {
|
||||
@ -38,7 +38,6 @@ mixin BaseWidgetProperties {
|
||||
|
||||
// Function to construct a body
|
||||
Widget getBody(BuildContext context) {
|
||||
|
||||
// Default implementation is to return a ListView
|
||||
// Override getTiles to replace the internal context
|
||||
return ListView(
|
||||
@ -51,7 +50,6 @@ mixin BaseWidgetProperties {
|
||||
* Construct the top AppBar for this view
|
||||
*/
|
||||
AppBar? buildAppBar(BuildContext context, GlobalKey<ScaffoldState> key) {
|
||||
|
||||
List<Widget> tabs = getTabIcons(context);
|
||||
|
||||
return AppBar(
|
||||
@ -70,8 +68,8 @@ mixin BaseWidgetProperties {
|
||||
* - Button to access global search
|
||||
* - Button to access barcode scan
|
||||
*/
|
||||
BottomAppBar? buildBottomAppBar(BuildContext context, GlobalKey<ScaffoldState> key) {
|
||||
|
||||
BottomAppBar? buildBottomAppBar(
|
||||
BuildContext context, GlobalKey<ScaffoldState> key) {
|
||||
const double iconSize = 40;
|
||||
|
||||
List<Widget> icons = [
|
||||
@ -89,12 +87,8 @@ mixin BaseWidgetProperties {
|
||||
iconSize: iconSize,
|
||||
onPressed: () {
|
||||
if (InvenTreeAPI().checkConnection()) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SearchWidget(true)
|
||||
)
|
||||
);
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => SearchWidget(true)));
|
||||
}
|
||||
},
|
||||
),
|
||||
@ -125,9 +119,7 @@ mixin BaseWidgetProperties {
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: icons,
|
||||
)
|
||||
)
|
||||
);
|
||||
)));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -146,7 +138,6 @@ mixin BaseWidgetProperties {
|
||||
* Build out action buttons for a given widget
|
||||
*/
|
||||
Widget? buildSpeedDial(BuildContext context) {
|
||||
|
||||
final actions = actionButtons(context);
|
||||
final barcodeActions = barcodeButtons(context);
|
||||
|
||||
@ -157,29 +148,25 @@ mixin BaseWidgetProperties {
|
||||
List<Widget> children = [];
|
||||
|
||||
if (barcodeActions.isNotEmpty) {
|
||||
children.add(
|
||||
SpeedDial(
|
||||
icon: Icons.qr_code_scanner,
|
||||
activeIcon: Icons.close,
|
||||
children: barcodeActions,
|
||||
spacing: 14,
|
||||
childPadding: const EdgeInsets.all(5),
|
||||
spaceBetweenChildren: 15,
|
||||
)
|
||||
);
|
||||
children.add(SpeedDial(
|
||||
icon: Icons.qr_code_scanner,
|
||||
activeIcon: Icons.close,
|
||||
children: barcodeActions,
|
||||
spacing: 14,
|
||||
childPadding: const EdgeInsets.all(5),
|
||||
spaceBetweenChildren: 15,
|
||||
));
|
||||
}
|
||||
|
||||
if (actions.isNotEmpty) {
|
||||
children.add(
|
||||
SpeedDial(
|
||||
icon: Icons.more_horiz,
|
||||
activeIcon: Icons.close,
|
||||
children: actions,
|
||||
spacing: 14,
|
||||
childPadding: const EdgeInsets.all(5),
|
||||
spaceBetweenChildren: 15,
|
||||
)
|
||||
);
|
||||
children.add(SpeedDial(
|
||||
icon: Icons.more_horiz,
|
||||
activeIcon: Icons.close,
|
||||
children: actions,
|
||||
spacing: 14,
|
||||
childPadding: const EdgeInsets.all(5),
|
||||
spaceBetweenChildren: 15,
|
||||
));
|
||||
}
|
||||
|
||||
return Wrap(
|
||||
@ -191,18 +178,16 @@ mixin BaseWidgetProperties {
|
||||
|
||||
// Return list of "tabs" for this widget
|
||||
List<Widget> getTabIcons(BuildContext context) => [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Abstract base class which provides generic "refresh" functionality.
|
||||
*
|
||||
* - Drag down and release to 'refresh' the widget
|
||||
* - Define some method which runs to 'refresh' the widget state
|
||||
*/
|
||||
abstract class RefreshableState<T extends StatefulWidget> extends State<T> with BaseWidgetProperties {
|
||||
|
||||
abstract class RefreshableState<T extends StatefulWidget> extends State<T>
|
||||
with BaseWidgetProperties {
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final refreshKey = GlobalKey<RefreshIndicatorState>();
|
||||
|
||||
@ -235,7 +220,6 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> with
|
||||
|
||||
// Refresh the widget - handler for custom request() method
|
||||
Future<void> refresh(BuildContext context) async {
|
||||
|
||||
// Escape if the widget is no longer loaded
|
||||
if (!mounted) {
|
||||
return;
|
||||
@ -259,13 +243,14 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> with
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
// Save the context for future use
|
||||
_context = context;
|
||||
|
||||
List<Widget> tabs = getTabIcons(context);
|
||||
|
||||
Widget body = tabs.isEmpty ? getBody(context) : TabBarView(children: getTabs(context));
|
||||
Widget body = tabs.isEmpty
|
||||
? getBody(context)
|
||||
: TabBarView(children: getTabs(context));
|
||||
|
||||
Scaffold view = Scaffold(
|
||||
key: scaffoldKey,
|
||||
@ -274,27 +259,25 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> with
|
||||
floatingActionButton: buildSpeedDial(context),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.miniEndDocked,
|
||||
body: RefreshIndicator(
|
||||
key: refreshKey,
|
||||
notificationPredicate: (ScrollNotification notification) {
|
||||
return true;
|
||||
},
|
||||
|
||||
onRefresh: () async {
|
||||
refresh(context);
|
||||
},
|
||||
child: body
|
||||
),
|
||||
key: refreshKey,
|
||||
notificationPredicate: (ScrollNotification notification) {
|
||||
return true;
|
||||
},
|
||||
onRefresh: () async {
|
||||
refresh(context);
|
||||
},
|
||||
child: body),
|
||||
bottomNavigationBar: buildBottomAppBar(context, scaffoldKey),
|
||||
);
|
||||
|
||||
// Default implementation is *not* tabbed
|
||||
if (tabs.isNotEmpty) {
|
||||
return DefaultTabController(
|
||||
length: tabs.length,
|
||||
child: view,
|
||||
length: tabs.length,
|
||||
child: view,
|
||||
);
|
||||
} else {
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,21 +23,17 @@ import "package:inventree/widget/order/sales_order_list.dart";
|
||||
import "package:inventree/widget/company/company_list.dart";
|
||||
import "package:inventree/widget/company/supplier_part_list.dart";
|
||||
|
||||
|
||||
// Widget for performing database-wide search
|
||||
class SearchWidget extends StatefulWidget {
|
||||
|
||||
const SearchWidget(this.hasAppbar);
|
||||
|
||||
final bool hasAppbar;
|
||||
|
||||
@override
|
||||
_SearchDisplayState createState() => _SearchDisplayState(hasAppbar);
|
||||
|
||||
}
|
||||
|
||||
class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
|
||||
_SearchDisplayState(this.hasAppBar) : super();
|
||||
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
@ -80,7 +76,6 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
* Determine if the search is still running
|
||||
*/
|
||||
bool isSearching() {
|
||||
|
||||
if (searchController.text.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
@ -128,7 +123,6 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
// Callback when the text is being edited
|
||||
// Incorporates a debounce timer to restrict search frequency
|
||||
void onSearchTextChanged(String text, {bool immediate = false}) {
|
||||
|
||||
if (debounceTimer?.isActive ?? false) {
|
||||
debounceTimer!.cancel();
|
||||
}
|
||||
@ -151,8 +145,7 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
int getSearchResultCount(Map <String, dynamic> results, String key) {
|
||||
|
||||
int getSearchResultCount(Map<String, dynamic> results, String key) {
|
||||
dynamic result = results[key];
|
||||
|
||||
if (result == null || result is! Map) {
|
||||
@ -170,43 +163,50 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
|
||||
// Actually perform the search query
|
||||
Future<void> _perform_search(Map<String, dynamic> body) async {
|
||||
InvenTreeAPI().post(
|
||||
"search/",
|
||||
body: body,
|
||||
expectedStatusCode: 200).then((APIResponse response) {
|
||||
InvenTreeAPI()
|
||||
.post("search/", body: body, expectedStatusCode: 200)
|
||||
.then((APIResponse response) {
|
||||
String searchTerm = (body["search"] ?? "").toString();
|
||||
|
||||
String searchTerm = (body["search"] ?? "").toString();
|
||||
// Only update if the results correspond to the current search term
|
||||
if (searchTerm == searchController.text && mounted) {
|
||||
decrementPendingSearches();
|
||||
|
||||
// Only update if the results correspond to the current search term
|
||||
if (searchTerm == searchController.text && mounted) {
|
||||
Map<String, dynamic> results = {};
|
||||
|
||||
decrementPendingSearches();
|
||||
if (response.isValid() && response.data is Map<String, dynamic>) {
|
||||
results = response.data as Map<String, dynamic>;
|
||||
|
||||
Map<String, dynamic> results = {};
|
||||
setState(() {
|
||||
nPartResults =
|
||||
getSearchResultCount(results, InvenTreePart.MODEL_TYPE);
|
||||
nCategoryResults =
|
||||
getSearchResultCount(results, InvenTreePartCategory.MODEL_TYPE);
|
||||
nStockResults =
|
||||
getSearchResultCount(results, InvenTreeStockItem.MODEL_TYPE);
|
||||
nLocationResults = getSearchResultCount(
|
||||
results, InvenTreeStockLocation.MODEL_TYPE);
|
||||
nPurchaseOrderResults = getSearchResultCount(
|
||||
results, InvenTreePurchaseOrder.MODEL_TYPE);
|
||||
nSalesOrderResults =
|
||||
getSearchResultCount(results, InvenTreeSalesOrder.MODEL_TYPE);
|
||||
nSupplierPartResults =
|
||||
getSearchResultCount(results, InvenTreeSupplierPart.MODEL_TYPE);
|
||||
nManufacturerPartResults = getSearchResultCount(
|
||||
results, InvenTreeManufacturerPart.MODEL_TYPE);
|
||||
nCompanyResults =
|
||||
getSearchResultCount(results, InvenTreeCompany.MODEL_TYPE);
|
||||
|
||||
if (response.isValid() && response.data is Map<String, dynamic>) {
|
||||
results = response.data as Map<String, dynamic>;
|
||||
|
||||
setState(() {
|
||||
nPartResults = getSearchResultCount(results, InvenTreePart.MODEL_TYPE);
|
||||
nCategoryResults = getSearchResultCount(results, InvenTreePartCategory.MODEL_TYPE);
|
||||
nStockResults = getSearchResultCount(results, InvenTreeStockItem.MODEL_TYPE);
|
||||
nLocationResults = getSearchResultCount(results, InvenTreeStockLocation.MODEL_TYPE);
|
||||
nPurchaseOrderResults = getSearchResultCount(results, InvenTreePurchaseOrder.MODEL_TYPE);
|
||||
nSalesOrderResults = getSearchResultCount(results, InvenTreeSalesOrder.MODEL_TYPE);
|
||||
nSupplierPartResults = getSearchResultCount(results, InvenTreeSupplierPart.MODEL_TYPE);
|
||||
nManufacturerPartResults = getSearchResultCount(results, InvenTreeManufacturerPart.MODEL_TYPE);
|
||||
nCompanyResults = getSearchResultCount(results, InvenTreeCompany.MODEL_TYPE);
|
||||
|
||||
// Special case for company search results
|
||||
nCustomerResults = getSearchResultCount(results, "customer");
|
||||
nManufacturerResults = getSearchResultCount(results, "manufacturer");
|
||||
nSupplierResults = getSearchResultCount(results, "supplier");
|
||||
});
|
||||
} else {
|
||||
resetSearchResults();
|
||||
}
|
||||
// Special case for company search results
|
||||
nCustomerResults = getSearchResultCount(results, "customer");
|
||||
nManufacturerResults =
|
||||
getSearchResultCount(results, "manufacturer");
|
||||
nSupplierResults = getSearchResultCount(results, "supplier");
|
||||
});
|
||||
} else {
|
||||
resetSearchResults();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -237,11 +237,9 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
|
||||
// Consolidated search allows us to perform *all* searches in a single query
|
||||
if (api.supportsConsolidatedSearch) {
|
||||
|
||||
Map<String, dynamic> body = {
|
||||
"limit": 1,
|
||||
"search": term,
|
||||
|
||||
InvenTreePart.MODEL_TYPE: {},
|
||||
InvenTreePartCategory.MODEL_TYPE: {},
|
||||
InvenTreeStockItem.MODEL_TYPE: {},
|
||||
@ -262,7 +260,6 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
}
|
||||
|
||||
if (body.isNotEmpty) {
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
nPendingSearches = 1;
|
||||
@ -272,7 +269,6 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
_perform_search(body),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
legacySearch(term);
|
||||
@ -283,7 +279,6 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
* Perform "legacy" search (without consolidated search API endpoint
|
||||
*/
|
||||
Future<void> legacySearch(String term) async {
|
||||
|
||||
// Search parts
|
||||
if (InvenTreePart().canView) {
|
||||
nPendingSearches++;
|
||||
@ -302,7 +297,11 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
// Search part categories
|
||||
if (InvenTreePartCategory().canView) {
|
||||
nPendingSearches++;
|
||||
InvenTreePartCategory().count(searchQuery: term,).then((int n) {
|
||||
InvenTreePartCategory()
|
||||
.count(
|
||||
searchQuery: term,
|
||||
)
|
||||
.then((int n) {
|
||||
if (term == searchController.text) {
|
||||
if (mounted) {
|
||||
decrementPendingSearches();
|
||||
@ -346,13 +345,9 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
|
||||
// Search purchase orders
|
||||
if (InvenTreePurchaseOrder().canView) {
|
||||
nPendingSearches++;
|
||||
nPendingSearches++;
|
||||
InvenTreePurchaseOrder().count(
|
||||
searchQuery: term,
|
||||
filters: {
|
||||
"outstanding": "true"
|
||||
}
|
||||
).then((int n) {
|
||||
searchQuery: term, filters: {"outstanding": "true"}).then((int n) {
|
||||
if (term == searchController.text) {
|
||||
if (mounted) {
|
||||
decrementPendingSearches();
|
||||
@ -367,40 +362,37 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
|
||||
@override
|
||||
List<Widget> getTiles(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [];
|
||||
|
||||
// Search input
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: TextFormField(
|
||||
decoration: InputDecoration(
|
||||
hintText: L10().queryEmpty,
|
||||
),
|
||||
key: _formKey,
|
||||
readOnly: false,
|
||||
autofocus: true,
|
||||
autocorrect: false,
|
||||
controller: searchController,
|
||||
onChanged: (String text) {
|
||||
onSearchTextChanged(text);
|
||||
},
|
||||
onFieldSubmitted: (String text) {
|
||||
},
|
||||
tiles.add(ListTile(
|
||||
title: TextFormField(
|
||||
decoration: InputDecoration(
|
||||
hintText: L10().queryEmpty,
|
||||
),
|
||||
trailing: GestureDetector(
|
||||
child: Icon(
|
||||
searchController.text.isEmpty ? TablerIcons.search : TablerIcons.backspace,
|
||||
color: searchController.text.isEmpty ? COLOR_ACTION : COLOR_DANGER,
|
||||
),
|
||||
onTap: () {
|
||||
searchController.clear();
|
||||
onSearchTextChanged("", immediate: true);
|
||||
},
|
||||
key: _formKey,
|
||||
readOnly: false,
|
||||
autofocus: true,
|
||||
autocorrect: false,
|
||||
controller: searchController,
|
||||
onChanged: (String text) {
|
||||
onSearchTextChanged(text);
|
||||
},
|
||||
onFieldSubmitted: (String text) {},
|
||||
),
|
||||
trailing: GestureDetector(
|
||||
child: Icon(
|
||||
searchController.text.isEmpty
|
||||
? TablerIcons.search
|
||||
: TablerIcons.backspace,
|
||||
color: searchController.text.isEmpty ? COLOR_ACTION : COLOR_DANGER,
|
||||
),
|
||||
)
|
||||
|
||||
);
|
||||
onTap: () {
|
||||
searchController.clear();
|
||||
onSearchTextChanged("", immediate: true);
|
||||
},
|
||||
),
|
||||
));
|
||||
|
||||
String query = searchController.text;
|
||||
|
||||
@ -408,8 +400,7 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
|
||||
// Part Results
|
||||
if (nPartResults > 0) {
|
||||
results.add(
|
||||
ListTile(
|
||||
results.add(ListTile(
|
||||
title: Text(L10().parts),
|
||||
leading: Icon(TablerIcons.box),
|
||||
trailing: Text("${nPartResults}"),
|
||||
@ -417,275 +408,188 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PartList(
|
||||
{
|
||||
"original_search": query
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
builder: (context) =>
|
||||
PartList({"original_search": query})));
|
||||
}));
|
||||
}
|
||||
|
||||
// Part Category Results
|
||||
if (nCategoryResults > 0) {
|
||||
results.add(
|
||||
ListTile(
|
||||
title: Text(L10().partCategories),
|
||||
leading: Icon(TablerIcons.sitemap),
|
||||
trailing: Text("${nCategoryResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
results.add(ListTile(
|
||||
title: Text(L10().partCategories),
|
||||
leading: Icon(TablerIcons.sitemap),
|
||||
trailing: Text("${nCategoryResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PartCategoryList(
|
||||
{
|
||||
"original_search": query
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
builder: (context) =>
|
||||
PartCategoryList({"original_search": query})));
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Stock Item Results
|
||||
if (nStockResults > 0) {
|
||||
results.add(
|
||||
ListTile(
|
||||
title: Text(L10().stockItems),
|
||||
leading: Icon(TablerIcons.package),
|
||||
trailing: Text("${nStockResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
results.add(ListTile(
|
||||
title: Text(L10().stockItems),
|
||||
leading: Icon(TablerIcons.package),
|
||||
trailing: Text("${nStockResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => StockItemList(
|
||||
{
|
||||
"original_search": query,
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
builder: (context) => StockItemList({
|
||||
"original_search": query,
|
||||
})));
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Stock location results
|
||||
if (nLocationResults > 0) {
|
||||
results.add(
|
||||
ListTile(
|
||||
title: Text(L10().stockLocations),
|
||||
leading: Icon(TablerIcons.location),
|
||||
trailing: Text("${nLocationResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
results.add(ListTile(
|
||||
title: Text(L10().stockLocations),
|
||||
leading: Icon(TablerIcons.location),
|
||||
trailing: Text("${nLocationResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => StockLocationList(
|
||||
{
|
||||
"original_search": query
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
builder: (context) =>
|
||||
StockLocationList({"original_search": query})));
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Purchase orders
|
||||
if (nPurchaseOrderResults > 0) {
|
||||
results.add(
|
||||
ListTile(
|
||||
title: Text(L10().purchaseOrders),
|
||||
leading: Icon(TablerIcons.shopping_cart),
|
||||
trailing: Text("${nPurchaseOrderResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
results.add(ListTile(
|
||||
title: Text(L10().purchaseOrders),
|
||||
leading: Icon(TablerIcons.shopping_cart),
|
||||
trailing: Text("${nPurchaseOrderResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PurchaseOrderListWidget(
|
||||
filters: {
|
||||
"original_search": query
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
builder: (context) => PurchaseOrderListWidget(
|
||||
filters: {"original_search": query})));
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Sales orders
|
||||
if (nSalesOrderResults > 0) {
|
||||
results.add(
|
||||
ListTile(
|
||||
title: Text(L10().salesOrders),
|
||||
leading: Icon(TablerIcons.shopping_cart),
|
||||
trailing: Text("${nSalesOrderResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
results.add(ListTile(
|
||||
title: Text(L10().salesOrders),
|
||||
leading: Icon(TablerIcons.shopping_cart),
|
||||
trailing: Text("${nSalesOrderResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SalesOrderListWidget(
|
||||
filters: {
|
||||
"original_search": query
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
builder: (context) => SalesOrderListWidget(
|
||||
filters: {"original_search": query})));
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Company results
|
||||
if (nCompanyResults > 0) {
|
||||
results.add(
|
||||
ListTile(
|
||||
title: Text(L10().companies),
|
||||
leading: Icon(TablerIcons.building),
|
||||
trailing: Text("${nCompanyResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
results.add(ListTile(
|
||||
title: Text(L10().companies),
|
||||
leading: Icon(TablerIcons.building),
|
||||
trailing: Text("${nCompanyResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CompanyListWidget(
|
||||
L10().companies,
|
||||
{
|
||||
"original_search": query
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
builder: (context) => CompanyListWidget(
|
||||
L10().companies, {"original_search": query})));
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Customer results
|
||||
if (nCustomerResults > 0) {
|
||||
results.add(
|
||||
ListTile(
|
||||
title: Text(L10().customers),
|
||||
leading: Icon(TablerIcons.building_store),
|
||||
trailing: Text("${nCustomerResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
results.add(ListTile(
|
||||
title: Text(L10().customers),
|
||||
leading: Icon(TablerIcons.building_store),
|
||||
trailing: Text("${nCustomerResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CompanyListWidget(
|
||||
L10().customers,
|
||||
{
|
||||
"original_search": query,
|
||||
"is_customer": "true"
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
builder: (context) => CompanyListWidget(L10().customers,
|
||||
{"original_search": query, "is_customer": "true"})));
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Manufacturer results
|
||||
if (nManufacturerResults > 0) {
|
||||
results.add(
|
||||
ListTile(
|
||||
title: Text(L10().manufacturers),
|
||||
leading: Icon(TablerIcons.building_factory_2),
|
||||
trailing: Text("${nManufacturerResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
results.add(ListTile(
|
||||
title: Text(L10().manufacturers),
|
||||
leading: Icon(TablerIcons.building_factory_2),
|
||||
trailing: Text("${nManufacturerResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CompanyListWidget(
|
||||
L10().manufacturers,
|
||||
{
|
||||
"original_search": query,
|
||||
"is_manufacturer": "true"
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
builder: (context) => CompanyListWidget(L10().manufacturers,
|
||||
{"original_search": query, "is_manufacturer": "true"})));
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Supplier results
|
||||
if (nSupplierResults > 0) {
|
||||
results.add(
|
||||
ListTile(
|
||||
title: Text(L10().suppliers),
|
||||
leading: Icon(TablerIcons.building_store),
|
||||
trailing: Text("${nSupplierResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
results.add(ListTile(
|
||||
title: Text(L10().suppliers),
|
||||
leading: Icon(TablerIcons.building_store),
|
||||
trailing: Text("${nSupplierResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CompanyListWidget(
|
||||
L10().suppliers,
|
||||
{
|
||||
"original_search": query,
|
||||
"is_supplier": "true"
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
builder: (context) => CompanyListWidget(L10().suppliers,
|
||||
{"original_search": query, "is_supplier": "true"})));
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Supplier part results
|
||||
if (nSupplierPartResults > 0) {
|
||||
results.add(
|
||||
ListTile(
|
||||
title: Text(L10().supplierParts),
|
||||
leading: Icon(TablerIcons.box),
|
||||
trailing: Text("${nSupplierPartResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
results.add(ListTile(
|
||||
title: Text(L10().supplierParts),
|
||||
leading: Icon(TablerIcons.box),
|
||||
trailing: Text("${nSupplierPartResults}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SupplierPartList(
|
||||
{
|
||||
"original_search": query
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
builder: (context) =>
|
||||
SupplierPartList({"original_search": query})));
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
if (isSearching()) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().searching),
|
||||
leading: Icon(TablerIcons.search),
|
||||
trailing: CircularProgressIndicator(),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().searching),
|
||||
leading: Icon(TablerIcons.search),
|
||||
trailing: CircularProgressIndicator(),
|
||||
));
|
||||
}
|
||||
|
||||
if (!isSearching() && results.isEmpty && searchController.text.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10().queryNoResults,
|
||||
style: TextStyle(fontStyle: FontStyle.italic),
|
||||
),
|
||||
leading: Icon(TablerIcons.zoom_cancel),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(
|
||||
L10().queryNoResults,
|
||||
style: TextStyle(fontStyle: FontStyle.italic),
|
||||
),
|
||||
leading: Icon(TablerIcons.zoom_cancel),
|
||||
));
|
||||
} else {
|
||||
for (Widget result in results) {
|
||||
tiles.add(result);
|
||||
@ -694,5 +598,4 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ import "package:inventree/l10.dart";
|
||||
/*
|
||||
* Display a configurable 'snackbar' at the bottom of the screen
|
||||
*/
|
||||
void showSnackIcon(String text, {IconData? icon, Function()? onAction, bool? success, String? actionText}) {
|
||||
|
||||
void showSnackIcon(String text,
|
||||
{IconData? icon, Function()? onAction, bool? success, String? actionText}) {
|
||||
debug("showSnackIcon: '${text}'");
|
||||
|
||||
// Escape quickly if we do not have context
|
||||
@ -34,7 +34,6 @@ void showSnackIcon(String text, {IconData? icon, Function()? onAction, bool? suc
|
||||
if (icon == null && onAction == null) {
|
||||
icon = TablerIcons.circle_check;
|
||||
}
|
||||
|
||||
} else if (success != null && success == false) {
|
||||
backgroundColor = Colors.deepOrange;
|
||||
|
||||
@ -54,26 +53,24 @@ void showSnackIcon(String text, {IconData? icon, Function()? onAction, bool? suc
|
||||
childs.add(Icon(icon));
|
||||
}
|
||||
|
||||
OneContext().showSnackBar(builder: (context) => SnackBar(
|
||||
content: GestureDetector(
|
||||
child: Row(
|
||||
children: childs
|
||||
),
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context!).hideCurrentSnackBar();
|
||||
},
|
||||
),
|
||||
backgroundColor: backgroundColor,
|
||||
action: onAction == null ? null : SnackBarAction(
|
||||
label: _action,
|
||||
onPressed: () {
|
||||
// Immediately dismiss the notification
|
||||
ScaffoldMessenger.of(context!).hideCurrentSnackBar();
|
||||
onAction();
|
||||
}
|
||||
),
|
||||
duration: Duration(seconds: onAction == null ? 5 : 10),
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
OneContext().showSnackBar(
|
||||
builder: (context) => SnackBar(
|
||||
content: GestureDetector(
|
||||
child: Row(children: childs),
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context!).hideCurrentSnackBar();
|
||||
},
|
||||
),
|
||||
backgroundColor: backgroundColor,
|
||||
action: onAction == null
|
||||
? null
|
||||
: SnackBarAction(
|
||||
label: _action,
|
||||
onPressed: () {
|
||||
// Immediately dismiss the notification
|
||||
ScaffoldMessenger.of(context!).hideCurrentSnackBar();
|
||||
onAction();
|
||||
}),
|
||||
duration: Duration(seconds: onAction == null ? 5 : 10),
|
||||
));
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ import "package:flutter/material.dart";
|
||||
import "package:inventree/app_colors.dart";
|
||||
|
||||
class Spinner extends StatefulWidget {
|
||||
|
||||
const Spinner({
|
||||
this.color = COLOR_GRAY_LIGHT,
|
||||
Key? key,
|
||||
@ -27,12 +26,8 @@ class _SpinnerState extends State<Spinner> with SingleTickerProviderStateMixin {
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: Duration(milliseconds: 2000),
|
||||
)
|
||||
..repeat();
|
||||
_child = Icon(
|
||||
widget.icon,
|
||||
color: widget.color
|
||||
);
|
||||
)..repeat();
|
||||
_child = Icon(widget.icon, color: widget.color);
|
||||
|
||||
super.initState();
|
||||
}
|
||||
@ -50,4 +45,4 @@ class _SpinnerState extends State<Spinner> with SingleTickerProviderStateMixin {
|
||||
child: _child,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,10 @@ import "package:inventree/widget/snacks.dart";
|
||||
import "package:inventree/widget/stock/stock_list.dart";
|
||||
import "package:inventree/labels.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Widget for displaying detail view for a single StockLocation instance
|
||||
*/
|
||||
class LocationDisplayWidget extends StatefulWidget {
|
||||
|
||||
LocationDisplayWidget(this.location, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreeStockLocation? location;
|
||||
@ -35,7 +33,6 @@ class LocationDisplayWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
|
||||
_LocationDisplayState(this.location);
|
||||
|
||||
final InvenTreeStockLocation? location;
|
||||
@ -53,31 +50,24 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
|
||||
// Add "locate" button
|
||||
if (location != null && api.supportsMixin("locate")) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(Icons.travel_explore),
|
||||
tooltip: L10().locateLocation,
|
||||
onPressed: () async {
|
||||
api.locateItemOrLocation(context, location: location!.pk);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(Icons.travel_explore),
|
||||
tooltip: L10().locateLocation,
|
||||
onPressed: () async {
|
||||
api.locateItemOrLocation(context, location: location!.pk);
|
||||
}));
|
||||
}
|
||||
|
||||
// Add "edit" button
|
||||
if (location != null && InvenTreeStockLocation().canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editLocation,
|
||||
onPressed: () {
|
||||
_editLocationDialog(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editLocation,
|
||||
onPressed: () {
|
||||
_editLocationDialog(context);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
@ -88,63 +78,50 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
if (location != null) {
|
||||
// Scan items into this location
|
||||
if (InvenTreeStockItem().canEdit) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.qrcode),
|
||||
label: L10().barcodeScanItem,
|
||||
onTap: () {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: StockLocationScanInItemsHandler(location!),
|
||||
).then((value) {
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.qrcode),
|
||||
label: L10().barcodeScanItem,
|
||||
onTap: () {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: StockLocationScanInItemsHandler(location!),
|
||||
).then((value) {
|
||||
refresh(context);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
if (api.supportsBarcodePOReceiveEndpoint) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(Icons.barcode_reader),
|
||||
label: L10().scanReceivedParts,
|
||||
onTap:() async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: POReceiveBarcodeHandler(location: location),
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(Icons.barcode_reader),
|
||||
label: L10().scanReceivedParts,
|
||||
onTap: () async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: POReceiveBarcodeHandler(location: location),
|
||||
);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Scan this location into another one
|
||||
if (InvenTreeStockLocation().canEdit) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.qrcode),
|
||||
label: L10().transferStockLocation,
|
||||
onTap: () {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: ScanParentLocationHandler(location!),
|
||||
).then((value) {
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.qrcode),
|
||||
label: L10().transferStockLocation,
|
||||
onTap: () {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: ScanParentLocationHandler(location!),
|
||||
).then((value) {
|
||||
refresh(context);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
// Assign or un-assign barcodes
|
||||
actions.add(
|
||||
customBarcodeAction(
|
||||
context, this,
|
||||
location!.customBarcode, "stocklocation",
|
||||
location!.pk
|
||||
)
|
||||
);
|
||||
actions.add(customBarcodeAction(context, this, location!.customBarcode,
|
||||
"stocklocation", location!.pk));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -156,46 +133,32 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
|
||||
// Create new location
|
||||
if (InvenTreeStockLocation().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.sitemap),
|
||||
label: L10().locationCreate,
|
||||
onTap: () async {
|
||||
_newLocation(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.sitemap),
|
||||
label: L10().locationCreate,
|
||||
onTap: () async {
|
||||
_newLocation(context);
|
||||
}));
|
||||
}
|
||||
|
||||
// Create new item
|
||||
if (InvenTreeStockItem().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.packages),
|
||||
label: L10().stockItemCreate,
|
||||
onTap: () async {
|
||||
_newStockItem(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.packages),
|
||||
label: L10().stockItemCreate,
|
||||
onTap: () async {
|
||||
_newStockItem(context);
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.location != null && labels.isNotEmpty) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.printer),
|
||||
label: L10().printLabel,
|
||||
onTap: () async {
|
||||
selectAndPrintLabel(
|
||||
context,
|
||||
labels,
|
||||
widget.location!.pk,
|
||||
"location",
|
||||
"location=${widget.location!.pk}"
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.printer),
|
||||
label: L10().printLabel,
|
||||
onTap: () async {
|
||||
selectAndPrintLabel(context, labels, widget.location!.pk,
|
||||
"location", "location=${widget.location!.pk}");
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -211,14 +174,10 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
return;
|
||||
}
|
||||
|
||||
_loc.editForm(
|
||||
context,
|
||||
L10().editLocation,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().locationUpdated, success: true);
|
||||
}
|
||||
);
|
||||
_loc.editForm(context, L10().editLocation, onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().locationUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -238,22 +197,20 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> _labels = [];
|
||||
bool allowLabelPrinting = await InvenTreeSettingsManager().getBool(INV_ENABLE_LABEL_PRINTING, true);
|
||||
bool allowLabelPrinting = await InvenTreeSettingsManager()
|
||||
.getBool(INV_ENABLE_LABEL_PRINTING, true);
|
||||
allowLabelPrinting &= api.supportsMixin("labels");
|
||||
|
||||
if (allowLabelPrinting) {
|
||||
|
||||
if (widget.location != null) {
|
||||
|
||||
String model_type = api.supportsModernLabelPrinting ? InvenTreeStockLocation.MODEL_TYPE : "location";
|
||||
String item_key = api.supportsModernLabelPrinting ? "items" : "location";
|
||||
String model_type = api.supportsModernLabelPrinting
|
||||
? InvenTreeStockLocation.MODEL_TYPE
|
||||
: "location";
|
||||
String item_key =
|
||||
api.supportsModernLabelPrinting ? "items" : "location";
|
||||
|
||||
_labels = await getLabelTemplates(
|
||||
model_type,
|
||||
{
|
||||
item_key: widget.location!.pk.toString()
|
||||
}
|
||||
);
|
||||
model_type, {item_key: widget.location!.pk.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,28 +224,22 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
Future<void> _newLocation(BuildContext context) async {
|
||||
int pk = location?.pk ?? -1;
|
||||
|
||||
InvenTreeStockLocation().createForm(
|
||||
context,
|
||||
L10().locationCreate,
|
||||
data: {
|
||||
"parent": (pk > 0) ? pk : null,
|
||||
},
|
||||
onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
InvenTreeStockLocation().createForm(context, L10().locationCreate, data: {
|
||||
"parent": (pk > 0) ? pk : null,
|
||||
}, onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey("pk")) {
|
||||
var loc = InvenTreeStockLocation.fromJson(data);
|
||||
loc.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (data.containsKey("pk")) {
|
||||
var loc = InvenTreeStockLocation.fromJson(data);
|
||||
loc.goToDetailPage(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Launch a dialog form to create a new stock item
|
||||
*/
|
||||
Future<void> _newStockItem(BuildContext context) async {
|
||||
|
||||
var fields = InvenTreeStockItem().formFields();
|
||||
|
||||
// Serial number field is not required here
|
||||
@ -300,73 +251,65 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
data["location"] = location!.pk;
|
||||
}
|
||||
|
||||
InvenTreeStockItem().createForm(
|
||||
context,
|
||||
L10().stockItemCreate,
|
||||
data: data,
|
||||
fields: fields,
|
||||
onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
InvenTreeStockItem().createForm(context, L10().stockItemCreate,
|
||||
data: data, fields: fields, onSuccess: (result) async {
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget locationDescriptionCard({bool includeActions = true}) {
|
||||
if (location == null) {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
L10().stockTopLevel,
|
||||
style: TextStyle(fontStyle: FontStyle.italic)
|
||||
),
|
||||
leading: Icon(TablerIcons.packages),
|
||||
)
|
||||
);
|
||||
title: Text(L10().stockTopLevel,
|
||||
style: TextStyle(fontStyle: FontStyle.italic)),
|
||||
leading: Icon(TablerIcons.packages),
|
||||
));
|
||||
} else {
|
||||
List<Widget> children = [
|
||||
ListTile(
|
||||
title: Text("${location!.name}"),
|
||||
subtitle: Text("${location!.description}"),
|
||||
leading: location!.customIcon == null ? Icon(TablerIcons.packages) : Icon(location!.customIcon)
|
||||
),
|
||||
title: Text("${location!.name}"),
|
||||
subtitle: Text("${location!.description}"),
|
||||
leading: location!.customIcon == null
|
||||
? Icon(TablerIcons.packages)
|
||||
: Icon(location!.customIcon)),
|
||||
];
|
||||
|
||||
if (includeActions) {
|
||||
children.add(
|
||||
ListTile(
|
||||
title: Text(L10().parentLocation),
|
||||
subtitle: Text("${location!.parentPathString}"),
|
||||
leading: Icon(TablerIcons.arrow_move_up, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
int parentId = location?.parentId ?? -1;
|
||||
children.add(ListTile(
|
||||
title: Text(L10().parentLocation),
|
||||
subtitle: Text("${location!.parentPathString}"),
|
||||
leading: Icon(TablerIcons.arrow_move_up, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
int parentId = location?.parentId ?? -1;
|
||||
|
||||
if (parentId < 0) {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
if (parentId < 0) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => LocationDisplayWidget(null)));
|
||||
} else {
|
||||
showLoadingOverlay();
|
||||
var loc = await InvenTreeStockLocation().get(parentId);
|
||||
hideLoadingOverlay();
|
||||
} else {
|
||||
showLoadingOverlay();
|
||||
var loc = await InvenTreeStockLocation().get(parentId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (loc is InvenTreeStockLocation) {
|
||||
loc.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
if (loc is InvenTreeStockLocation) {
|
||||
loc.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
return Card(
|
||||
child: Column(
|
||||
children: children,
|
||||
)
|
||||
);
|
||||
children: children,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,7 +331,6 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
|
||||
// Construct the "details" panel
|
||||
List<Widget> detailTiles() {
|
||||
|
||||
Map<String, String> filters = {};
|
||||
|
||||
int? parent = location?.pk;
|
||||
|
@ -7,9 +7,7 @@ import "package:inventree/widget/paginator.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
|
||||
|
||||
class StockLocationList extends StatefulWidget {
|
||||
|
||||
const StockLocationList(this.filters);
|
||||
|
||||
final Map<String, String> filters;
|
||||
@ -18,9 +16,7 @@ class StockLocationList extends StatefulWidget {
|
||||
_StockLocationListState createState() => _StockLocationListState(filters);
|
||||
}
|
||||
|
||||
|
||||
class _StockLocationListState extends RefreshableState<StockLocationList> {
|
||||
|
||||
_StockLocationListState(this.filters);
|
||||
|
||||
final Map<String, String> filters;
|
||||
@ -34,50 +30,50 @@ class _StockLocationListState extends RefreshableState<StockLocationList> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PaginatedStockLocationList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedStockLocationList(Map<String, String> filters, {String title = ""}) : super(filters: filters, title: title);
|
||||
const PaginatedStockLocationList(Map<String, String> filters,
|
||||
{String title = ""})
|
||||
: super(filters: filters, title: title);
|
||||
|
||||
@override
|
||||
String get searchTitle => title.isNotEmpty ? title : L10().stockLocations;
|
||||
|
||||
@override
|
||||
_PaginatedStockLocationListState createState() => _PaginatedStockLocationListState();
|
||||
_PaginatedStockLocationListState createState() =>
|
||||
_PaginatedStockLocationListState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedStockLocationListState extends PaginatedSearchState<PaginatedStockLocationList> {
|
||||
|
||||
class _PaginatedStockLocationListState
|
||||
extends PaginatedSearchState<PaginatedStockLocationList> {
|
||||
_PaginatedStockLocationListState() : super();
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"name": L10().name,
|
||||
"items": L10().stockItems,
|
||||
"level": L10().level,
|
||||
};
|
||||
"name": L10().name,
|
||||
"items": L10().stockItems,
|
||||
"level": L10().level,
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
"cascade": {
|
||||
"label": L10().includeSublocations,
|
||||
"help_text": L10().includeSublocationsDetail,
|
||||
"tristate": false,
|
||||
}
|
||||
};
|
||||
"cascade": {
|
||||
"label": L10().includeSublocations,
|
||||
"help_text": L10().includeSublocationsDetail,
|
||||
"tristate": false,
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
final page = await InvenTreeStockLocation().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreeStockLocation()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreeStockLocation location = model as InvenTreeStockLocation;
|
||||
|
||||
return ListTile(
|
||||
@ -90,4 +86,4 @@ class _PaginatedStockLocationListState extends PaginatedSearchState<PaginatedSto
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,7 @@ import "package:inventree/widget/stock/stock_item_history.dart";
|
||||
import "package:inventree/widget/stock/stock_item_test_results.dart";
|
||||
import "package:inventree/widget/notes_widget.dart";
|
||||
|
||||
|
||||
class StockDetailWidget extends StatefulWidget {
|
||||
|
||||
const StockDetailWidget(this.item, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreeStockItem item;
|
||||
@ -39,9 +37,7 @@ class StockDetailWidget extends StatefulWidget {
|
||||
_StockItemDisplayState createState() => _StockItemDisplayState();
|
||||
}
|
||||
|
||||
|
||||
class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
|
||||
_StockItemDisplayState();
|
||||
|
||||
@override
|
||||
@ -61,27 +57,21 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (api.supportsMixin("locate")) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(Icons.travel_explore),
|
||||
tooltip: L10().locateItem,
|
||||
onPressed: () async {
|
||||
api.locateItemOrLocation(context, item: widget.item.pk);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(Icons.travel_explore),
|
||||
tooltip: L10().locateItem,
|
||||
onPressed: () async {
|
||||
api.locateItemOrLocation(context, item: widget.item.pk);
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.item.canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editItem,
|
||||
onPressed: () {
|
||||
_editStockItem(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editItem,
|
||||
onPressed: () {
|
||||
_editStockItem(context);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -89,79 +79,56 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
|
||||
@override
|
||||
List<SpeedDialChild> actionButtons(BuildContext context) {
|
||||
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (widget.item.canEdit) {
|
||||
|
||||
// Stock adjustment actions available if item is *not* serialized
|
||||
if (!widget.item.isSerialized()) {
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_check, color: Colors.blue),
|
||||
label: L10().countStock,
|
||||
onTap: _countStockDialog,
|
||||
));
|
||||
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_check, color: Colors.blue),
|
||||
label: L10().countStock,
|
||||
onTap: _countStockDialog,
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_minus, color: Colors.red),
|
||||
label: L10().removeStock,
|
||||
onTap: _removeStockDialog,
|
||||
));
|
||||
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_minus, color: Colors.red),
|
||||
label: L10().removeStock,
|
||||
onTap: _removeStockDialog,
|
||||
)
|
||||
);
|
||||
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().addStock,
|
||||
onTap: _addStockDialog,
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().addStock,
|
||||
onTap: _addStockDialog,
|
||||
));
|
||||
}
|
||||
|
||||
// Transfer item
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.transfer),
|
||||
label: L10().transferStock,
|
||||
onTap: () {
|
||||
_transferStockDialog(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
if (labels.isNotEmpty) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.printer),
|
||||
label: L10().printLabel,
|
||||
onTap: () async {
|
||||
selectAndPrintLabel(
|
||||
context,
|
||||
labels,
|
||||
widget.item.pk,
|
||||
"stock",
|
||||
"item=${widget.item.pk}"
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
selectAndPrintLabel(context, labels, widget.item.pk, "stock",
|
||||
"item=${widget.item.pk}");
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.item.canDelete) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.trash, color: Colors.red),
|
||||
label: L10().stockItemDelete,
|
||||
onTap: () {
|
||||
_deleteItem(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.trash, color: Colors.red),
|
||||
label: L10().stockItemDelete,
|
||||
onTap: () {
|
||||
_deleteItem(context);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -173,28 +140,19 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
|
||||
if (widget.item.canEdit) {
|
||||
// Scan item into location
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(Icons.qr_code_scanner),
|
||||
label: L10().scanIntoLocation,
|
||||
onTap: () {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: StockItemScanIntoLocationHandler(widget.item)
|
||||
).then((ctx) {
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(Icons.qr_code_scanner),
|
||||
label: L10().scanIntoLocation,
|
||||
onTap: () {
|
||||
scanBarcode(context,
|
||||
handler: StockItemScanIntoLocationHandler(widget.item))
|
||||
.then((ctx) {
|
||||
refresh(context);
|
||||
});
|
||||
}));
|
||||
|
||||
actions.add(
|
||||
customBarcodeAction(
|
||||
context, this,
|
||||
widget.item.customBarcode,
|
||||
"stockitem", widget.item.pk
|
||||
)
|
||||
);
|
||||
actions.add(customBarcodeAction(context, this, widget.item.customBarcode,
|
||||
"stockitem", widget.item.pk));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -217,8 +175,10 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
@override
|
||||
Future<void> request(BuildContext context) async {
|
||||
await api.StockStatus.load();
|
||||
stockShowHistory = await InvenTreeSettingsManager().getValue(INV_STOCK_SHOW_HISTORY, false) as bool;
|
||||
stockShowTests = await InvenTreeSettingsManager().getValue(INV_STOCK_SHOW_TESTS, true) as bool;
|
||||
stockShowHistory = await InvenTreeSettingsManager()
|
||||
.getValue(INV_STOCK_SHOW_HISTORY, false) as bool;
|
||||
stockShowTests = await InvenTreeSettingsManager()
|
||||
.getValue(INV_STOCK_SHOW_TESTS, true) as bool;
|
||||
|
||||
final bool result = widget.item.pk > 0 && await widget.item.reload();
|
||||
|
||||
@ -238,7 +198,6 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
// Request test results (async)
|
||||
if (stockShowTests) {
|
||||
widget.item.getTestResults().then((value) {
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
// Update
|
||||
@ -248,7 +207,9 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
}
|
||||
|
||||
// Request the number of attachments
|
||||
InvenTreeStockItemAttachment().countAttachments(widget.item.pk).then((int value) {
|
||||
InvenTreeStockItemAttachment()
|
||||
.countAttachments(widget.item.pk)
|
||||
.then((int value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
attachmentCount = value;
|
||||
@ -259,12 +220,13 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
// Request SalesOrder information
|
||||
if (widget.item.hasSalesOrder) {
|
||||
InvenTreeSalesOrder().get(widget.item.salesOrderId).then((instance) => {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
salesOrder = instance as InvenTreeSalesOrder?;
|
||||
})
|
||||
}
|
||||
});
|
||||
if (mounted)
|
||||
{
|
||||
setState(() {
|
||||
salesOrder = instance as InvenTreeSalesOrder?;
|
||||
})
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@ -276,12 +238,13 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
// Request Customer information
|
||||
if (widget.item.hasCustomer) {
|
||||
InvenTreeCompany().get(widget.item.customerId).then((instance) => {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
customer = instance as InvenTreeCompany?;
|
||||
})
|
||||
}
|
||||
});
|
||||
if (mounted)
|
||||
{
|
||||
setState(() {
|
||||
customer = instance as InvenTreeCompany?;
|
||||
})
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@ -291,22 +254,20 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> _labels = [];
|
||||
bool allowLabelPrinting = await InvenTreeSettingsManager().getBool(INV_ENABLE_LABEL_PRINTING, true);
|
||||
bool allowLabelPrinting = await InvenTreeSettingsManager()
|
||||
.getBool(INV_ENABLE_LABEL_PRINTING, true);
|
||||
allowLabelPrinting &= api.supportsMixin("labels");
|
||||
|
||||
// Request information on labels available for this stock item
|
||||
if (allowLabelPrinting) {
|
||||
|
||||
String model_type = api.supportsModernLabelPrinting ? InvenTreeStockItem.MODEL_TYPE : "stock";
|
||||
String model_type = api.supportsModernLabelPrinting
|
||||
? InvenTreeStockItem.MODEL_TYPE
|
||||
: "stock";
|
||||
String item_key = api.supportsModernLabelPrinting ? "items" : "item";
|
||||
|
||||
// Clear the existing labels list
|
||||
_labels = await getLabelTemplates(
|
||||
model_type,
|
||||
{
|
||||
item_key: widget.item.pk.toString()
|
||||
}
|
||||
);
|
||||
model_type, {item_key: widget.item.pk.toString()});
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
@ -318,7 +279,6 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
|
||||
/// Delete the stock item from the database
|
||||
Future<void> _deleteItem(BuildContext context) async {
|
||||
|
||||
confirmationDialog(
|
||||
L10().stockItemDelete,
|
||||
L10().stockItemDeleteConfirm,
|
||||
@ -327,7 +287,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
acceptText: L10().delete,
|
||||
onAccept: () async {
|
||||
final bool result = await widget.item.delete();
|
||||
|
||||
|
||||
if (result) {
|
||||
Navigator.of(context).pop();
|
||||
showSnackIcon(L10().stockItemDeleteSuccess, success: true);
|
||||
@ -336,11 +296,9 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
Future <void> _editStockItem(BuildContext context) async {
|
||||
|
||||
Future<void> _editStockItem(BuildContext context) async {
|
||||
var fields = InvenTreeStockItem().formFields();
|
||||
|
||||
// Some fields we don't want to edit!
|
||||
@ -353,23 +311,17 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
fields.remove("serial");
|
||||
}
|
||||
|
||||
widget.item.editForm(
|
||||
context,
|
||||
L10().editItem,
|
||||
fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().stockItemUpdated, success: true);
|
||||
}
|
||||
);
|
||||
|
||||
widget.item.editForm(context, L10().editItem, fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().stockItemUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Launch a dialog to 'add' quantity to this StockItem
|
||||
*/
|
||||
Future <void> _addStockDialog() async {
|
||||
|
||||
Future<void> _addStockDialog() async {
|
||||
Map<String, dynamic> fields = {
|
||||
"pk": {
|
||||
"parent": "items",
|
||||
@ -386,21 +338,14 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
};
|
||||
|
||||
launchApiForm(
|
||||
context,
|
||||
L10().addStock,
|
||||
InvenTreeStockItem.addStockUrl(),
|
||||
fields,
|
||||
method: "POST",
|
||||
icon: TablerIcons.circle_plus,
|
||||
onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
context, L10().addStock, InvenTreeStockItem.addStockUrl(), fields,
|
||||
method: "POST", icon: TablerIcons.circle_plus, onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
|
||||
void _stockUpdateMessage(bool result) {
|
||||
|
||||
if (result) {
|
||||
showSnackIcon(L10().stockItemUpdated, success: true);
|
||||
}
|
||||
@ -410,7 +355,6 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
* Launch a dialog to 'remove' quantity from this StockItem
|
||||
*/
|
||||
void _removeStockDialog() {
|
||||
|
||||
Map<String, dynamic> fields = {
|
||||
"pk": {
|
||||
"parent": "items",
|
||||
@ -427,21 +371,15 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
};
|
||||
|
||||
launchApiForm(
|
||||
context,
|
||||
L10().removeStock,
|
||||
InvenTreeStockItem.removeStockUrl(),
|
||||
fields,
|
||||
context, L10().removeStock, InvenTreeStockItem.removeStockUrl(), fields,
|
||||
method: "POST",
|
||||
icon: TablerIcons.circle_minus,
|
||||
onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
icon: TablerIcons.circle_minus, onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
|
||||
Future <void> _countStockDialog() async {
|
||||
|
||||
Future<void> _countStockDialog() async {
|
||||
Map<String, dynamic> fields = {
|
||||
"pk": {
|
||||
"parent": "items",
|
||||
@ -458,82 +396,60 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
};
|
||||
|
||||
launchApiForm(
|
||||
context,
|
||||
L10().countStock,
|
||||
InvenTreeStockItem.countStockUrl(),
|
||||
fields,
|
||||
context, L10().countStock, InvenTreeStockItem.countStockUrl(), fields,
|
||||
method: "POST",
|
||||
icon: TablerIcons.clipboard_check,
|
||||
onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
icon: TablerIcons.clipboard_check, onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Launches an API Form to transfer this stock item to a new location
|
||||
*/
|
||||
Future <void> _transferStockDialog(BuildContext context) async {
|
||||
|
||||
Future<void> _transferStockDialog(BuildContext context) async {
|
||||
Map<String, dynamic> fields = widget.item.transferFields();
|
||||
|
||||
launchApiForm(
|
||||
context,
|
||||
L10().transferStock,
|
||||
InvenTreeStockItem.transferStockUrl(),
|
||||
fields,
|
||||
method: "POST",
|
||||
icon: TablerIcons.transfer,
|
||||
onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
launchApiForm(context, L10().transferStock,
|
||||
InvenTreeStockItem.transferStockUrl(), fields,
|
||||
method: "POST", icon: TablerIcons.transfer, onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
|
||||
Widget headerTile() {
|
||||
|
||||
Widget? trailing;
|
||||
|
||||
if (!widget.item.isInStock) {
|
||||
trailing = Text(
|
||||
L10().unavailable,
|
||||
style: TextStyle(
|
||||
color: COLOR_DANGER
|
||||
)
|
||||
);
|
||||
trailing = Text(L10().unavailable, style: TextStyle(color: COLOR_DANGER));
|
||||
} else if (!widget.item.isSerialized()) {
|
||||
trailing = Text(
|
||||
widget.item.quantityString(),
|
||||
trailing = Text(widget.item.quantityString(),
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: api.StockStatus.color(widget.item.status),
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
return Card(
|
||||
child: ListTile(
|
||||
title: Text(widget.item.partName),
|
||||
subtitle: Text(widget.item.partDescription),
|
||||
leading: InvenTreeAPI().getThumbnail(widget.item.partImage),
|
||||
trailing: trailing,
|
||||
onTap: () async {
|
||||
if (widget.item.partId > 0) {
|
||||
child: ListTile(
|
||||
title: Text(widget.item.partName),
|
||||
subtitle: Text(widget.item.partDescription),
|
||||
leading: InvenTreeAPI().getThumbnail(widget.item.partImage),
|
||||
trailing: trailing,
|
||||
onTap: () async {
|
||||
if (widget.item.partId > 0) {
|
||||
showLoadingOverlay();
|
||||
var part = await InvenTreePart().get(widget.item.partId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
showLoadingOverlay();
|
||||
var part = await InvenTreePart().get(widget.item.partId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
//trailing: Text(item.serialOrQuantityDisplay()),
|
||||
)
|
||||
);
|
||||
}
|
||||
},
|
||||
//trailing: Text(item.serialOrQuantityDisplay()),
|
||||
));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -564,9 +480,9 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
),
|
||||
onTap: () async {
|
||||
if (widget.item.locationId > 0) {
|
||||
|
||||
showLoadingOverlay();
|
||||
var loc = await InvenTreeStockLocation().get(widget.item.locationId);
|
||||
var loc =
|
||||
await InvenTreeStockLocation().get(widget.item.locationId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (loc is InvenTreeStockLocation) {
|
||||
@ -577,37 +493,32 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().stockLocation),
|
||||
leading: Icon(TablerIcons.location),
|
||||
subtitle: Text(L10().locationNotSet),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().stockLocation),
|
||||
leading: Icon(TablerIcons.location),
|
||||
subtitle: Text(L10().locationNotSet),
|
||||
));
|
||||
}
|
||||
|
||||
// Quantity information
|
||||
if (widget.item.isSerialized()) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().serialNumber),
|
||||
leading: Icon(TablerIcons.hash),
|
||||
subtitle: Text("${widget.item.serialNumber}"),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().serialNumber),
|
||||
leading: Icon(TablerIcons.hash),
|
||||
subtitle: Text("${widget.item.serialNumber}"),
|
||||
));
|
||||
} else if (widget.item.isInStock) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: widget.item.allocated > 0 ? Text(L10().quantityAvailable) : Text(L10().quantity),
|
||||
leading: Icon(TablerIcons.packages),
|
||||
trailing: Text("${widget.item.quantityString()}"),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: widget.item.allocated > 0
|
||||
? Text(L10().quantityAvailable)
|
||||
: Text(L10().quantity),
|
||||
leading: Icon(TablerIcons.packages),
|
||||
trailing: Text("${widget.item.quantityString()}"),
|
||||
));
|
||||
}
|
||||
|
||||
if (!widget.item.isInStock) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
leading: Icon(TablerIcons.box_off),
|
||||
title: Text(
|
||||
L10().unavailable,
|
||||
@ -616,258 +527,207 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
L10().unavailableDetail,
|
||||
style: TextStyle(
|
||||
color: COLOR_DANGER
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
subtitle: Text(L10().unavailableDetail,
|
||||
style: TextStyle(color: COLOR_DANGER))));
|
||||
}
|
||||
|
||||
// Stock item status information
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().status),
|
||||
leading: Icon(TablerIcons.help_circle),
|
||||
trailing: Text(
|
||||
api.StockStatus.label(widget.item.status),
|
||||
style: TextStyle(
|
||||
color: api.StockStatus.color(widget.item.status),
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
trailing: Text(api.StockStatus.label(widget.item.status),
|
||||
style: TextStyle(
|
||||
color: api.StockStatus.color(widget.item.status),
|
||||
))));
|
||||
|
||||
// Supplier part information (if available)
|
||||
if (widget.item.supplierPartId > 0) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().supplierPart),
|
||||
subtitle: Text(widget.item.supplierSKU),
|
||||
leading: Icon(TablerIcons.building, color: COLOR_ACTION),
|
||||
trailing: InvenTreeAPI().getThumbnail(widget.item.supplierImage, hideIfNull: true),
|
||||
trailing: InvenTreeAPI()
|
||||
.getThumbnail(widget.item.supplierImage, hideIfNull: true),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
var sp = await InvenTreeSupplierPart().get(
|
||||
widget.item.supplierPartId);
|
||||
var sp =
|
||||
await InvenTreeSupplierPart().get(widget.item.supplierPartId);
|
||||
hideLoadingOverlay();
|
||||
if (sp is InvenTreeSupplierPart) {
|
||||
Navigator.push(
|
||||
context, MaterialPageRoute(
|
||||
builder: (context) => SupplierPartDetailWidget(sp))
|
||||
);
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SupplierPartDetailWidget(sp)));
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.item.isBuilding) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().inProduction),
|
||||
leading: Icon(TablerIcons.tools),
|
||||
subtitle: Text(L10().inProductionDetail),
|
||||
onTap: () {
|
||||
// TODO: Click through to the "build order"
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().inProduction),
|
||||
leading: Icon(TablerIcons.tools),
|
||||
subtitle: Text(L10().inProductionDetail),
|
||||
onTap: () {
|
||||
// TODO: Click through to the "build order"
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.item.hasSalesOrder && salesOrder != null) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().salesOrder),
|
||||
subtitle: Text(salesOrder?.description ?? ""),
|
||||
leading: Icon(TablerIcons.truck_delivery, color: COLOR_ACTION),
|
||||
trailing: Text(salesOrder?.reference ?? ""),
|
||||
onTap: () {
|
||||
salesOrder?.goToDetailPage(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.item.hasCustomer && customer != null) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().customer),
|
||||
subtitle: Text(customer?.description ?? ""),
|
||||
leading: Icon(TablerIcons.building_store, color: COLOR_ACTION),
|
||||
trailing: Text(customer?.name ?? ""),
|
||||
onTap: () {
|
||||
customer?.goToDetailPage(context);
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().customer),
|
||||
subtitle: Text(customer?.description ?? ""),
|
||||
leading: Icon(TablerIcons.building_store, color: COLOR_ACTION),
|
||||
trailing: Text(customer?.name ?? ""),
|
||||
onTap: () {
|
||||
customer?.goToDetailPage(context);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.item.batch.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().batchCode),
|
||||
subtitle: Text(widget.item.batch),
|
||||
leading: Icon(TablerIcons.clipboard_text),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().batchCode),
|
||||
subtitle: Text(widget.item.batch),
|
||||
leading: Icon(TablerIcons.clipboard_text),
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.item.packaging.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().packaging),
|
||||
subtitle: Text(widget.item.packaging),
|
||||
leading: Icon(TablerIcons.package),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().packaging),
|
||||
subtitle: Text(widget.item.packaging),
|
||||
leading: Icon(TablerIcons.package),
|
||||
));
|
||||
}
|
||||
|
||||
if (expiryEnabled && widget.item.expiryDate != null) {
|
||||
|
||||
Widget? _expiryIcon;
|
||||
|
||||
if (widget.item.expired) {
|
||||
_expiryIcon = Text(L10().expiryExpired, style: TextStyle(color: COLOR_DANGER));
|
||||
_expiryIcon =
|
||||
Text(L10().expiryExpired, style: TextStyle(color: COLOR_DANGER));
|
||||
} else if (widget.item.stale) {
|
||||
_expiryIcon = Text(L10().expiryStale, style: TextStyle(color: COLOR_WARNING));
|
||||
_expiryIcon =
|
||||
Text(L10().expiryStale, style: TextStyle(color: COLOR_WARNING));
|
||||
}
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().expiryDate),
|
||||
subtitle: Text(widget.item.expiryDateString),
|
||||
leading: Icon(TablerIcons.calendar_x),
|
||||
trailing: _expiryIcon,
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().expiryDate),
|
||||
subtitle: Text(widget.item.expiryDateString),
|
||||
leading: Icon(TablerIcons.calendar_x),
|
||||
trailing: _expiryIcon,
|
||||
));
|
||||
}
|
||||
|
||||
// Last update?
|
||||
if (widget.item.updatedDateString.isNotEmpty) {
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().lastUpdated),
|
||||
subtitle: Text(widget.item.updatedDateString),
|
||||
leading: Icon(TablerIcons.calendar)
|
||||
)
|
||||
);
|
||||
leading: Icon(TablerIcons.calendar)));
|
||||
}
|
||||
|
||||
// Stocktake?
|
||||
if (widget.item.stocktakeDateString.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().lastStocktake),
|
||||
subtitle: Text(widget.item.stocktakeDateString),
|
||||
leading: Icon(TablerIcons.calendar)
|
||||
)
|
||||
);
|
||||
leading: Icon(TablerIcons.calendar)));
|
||||
}
|
||||
|
||||
if (widget.item.link.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("${widget.item.link}"),
|
||||
leading: Icon(TablerIcons.link, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
widget.item.openLink();
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text("${widget.item.link}"),
|
||||
leading: Icon(TablerIcons.link, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
widget.item.openLink();
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
if (stockShowTests || (widget.item.testResultCount > 0)) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().testResults),
|
||||
leading: Icon(TablerIcons.list_check, color: COLOR_ACTION),
|
||||
trailing: Text("${widget.item.testResultCount}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => StockItemTestResultsWidget(widget.item))
|
||||
).then((ctx) {
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().testResults),
|
||||
leading: Icon(TablerIcons.list_check, color: COLOR_ACTION),
|
||||
trailing: Text("${widget.item.testResultCount}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
StockItemTestResultsWidget(widget.item))).then((ctx) {
|
||||
refresh(context);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.item.hasPurchasePrice) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().purchasePrice),
|
||||
leading: Icon(TablerIcons.currency_dollar),
|
||||
trailing: Text(
|
||||
renderCurrency(widget.item.purchasePrice, widget.item.purchasePriceCurrency)
|
||||
)
|
||||
)
|
||||
);
|
||||
trailing: Text(renderCurrency(
|
||||
widget.item.purchasePrice, widget.item.purchasePriceCurrency))));
|
||||
}
|
||||
|
||||
// TODO - Is this stock item linked to a PurchaseOrder?
|
||||
|
||||
if (stockShowHistory && widget.item.trackingItemCount > 0) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().history),
|
||||
leading: Icon(TablerIcons.history, color: COLOR_ACTION),
|
||||
trailing: Text("${widget.item.trackingItemCount}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().history),
|
||||
leading: Icon(TablerIcons.history, color: COLOR_ACTION),
|
||||
trailing: Text("${widget.item.trackingItemCount}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => StockItemHistoryWidget(widget.item))
|
||||
).then((ctx) {
|
||||
refresh(context);
|
||||
});
|
||||
},
|
||||
)
|
||||
);
|
||||
builder: (context) =>
|
||||
StockItemHistoryWidget(widget.item))).then((ctx) {
|
||||
refresh(context);
|
||||
});
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Notes field
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().notes),
|
||||
leading: Icon(TablerIcons.note, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => NotesWidget(widget.item))
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
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) => NotesWidget(widget.item)));
|
||||
}));
|
||||
|
||||
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(
|
||||
InvenTreeStockItemAttachment(),
|
||||
widget.item.pk,
|
||||
L10().stockItem,
|
||||
widget.item.canEdit,
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
InvenTreeStockItemAttachment(),
|
||||
widget.item.pk,
|
||||
L10().stockItem,
|
||||
widget.item.canEdit,
|
||||
)));
|
||||
},
|
||||
));
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,12 @@ class StockItemHistoryWidget extends StatefulWidget {
|
||||
final InvenTreeStockItem item;
|
||||
|
||||
@override
|
||||
_StockItemHistoryDisplayState createState() => _StockItemHistoryDisplayState(item);
|
||||
_StockItemHistoryDisplayState createState() =>
|
||||
_StockItemHistoryDisplayState(item);
|
||||
}
|
||||
|
||||
class _StockItemHistoryDisplayState extends RefreshableState<StockItemHistoryWidget> {
|
||||
class _StockItemHistoryDisplayState
|
||||
extends RefreshableState<StockItemHistoryWidget> {
|
||||
_StockItemHistoryDisplayState(this.item);
|
||||
|
||||
final InvenTreeStockItem item;
|
||||
@ -36,14 +38,14 @@ class _StockItemHistoryDisplayState extends RefreshableState<StockItemHistoryWid
|
||||
|
||||
return PaginatedStockHistoryList(filters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Widget which displays a paginated stock history list
|
||||
*/
|
||||
class PaginatedStockHistoryList extends PaginatedSearchWidget {
|
||||
const PaginatedStockHistoryList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedStockHistoryList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().stockItemHistory;
|
||||
@ -75,7 +77,8 @@ class _PaginatedStockHistoryState
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
await InvenTreeAPI().StockHistoryStatus.load();
|
||||
|
||||
final page = await InvenTreeStockItemHistory().listPaginated(limit, offset, filters: params);
|
||||
final page = await InvenTreeStockItemHistory()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
@ -13,20 +13,18 @@ import "package:inventree/inventree/model.dart";
|
||||
import "package:inventree/widget/progress.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
class StockItemTestResultsWidget extends StatefulWidget {
|
||||
|
||||
const StockItemTestResultsWidget(this.item, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreeStockItem item;
|
||||
|
||||
@override
|
||||
_StockItemTestResultDisplayState createState() => _StockItemTestResultDisplayState(item);
|
||||
_StockItemTestResultDisplayState createState() =>
|
||||
_StockItemTestResultDisplayState(item);
|
||||
}
|
||||
|
||||
|
||||
class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestResultsWidget> {
|
||||
|
||||
class _StockItemTestResultDisplayState
|
||||
extends RefreshableState<StockItemTestResultsWidget> {
|
||||
_StockItemTestResultDisplayState(this.item);
|
||||
|
||||
@override
|
||||
@ -40,15 +38,12 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (InvenTreeStockItemTestResult().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus),
|
||||
label: L10().testResultAdd,
|
||||
onTap: () {
|
||||
addTestResult(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -62,9 +57,16 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
|
||||
final InvenTreeStockItem item;
|
||||
|
||||
Future <void> addTestResult(BuildContext context, {int templateId = 0, String name = "", bool nameIsEditable = true, bool result = false, String value = "", bool valueRequired = false, bool attachmentRequired = false}) async {
|
||||
|
||||
Map<String, Map<String, dynamic>> fields = InvenTreeStockItemTestResult().formFields();
|
||||
Future<void> addTestResult(BuildContext context,
|
||||
{int templateId = 0,
|
||||
String name = "",
|
||||
bool nameIsEditable = true,
|
||||
bool result = false,
|
||||
String value = "",
|
||||
bool valueRequired = false,
|
||||
bool attachmentRequired = false}) async {
|
||||
Map<String, Map<String, dynamic>> fields =
|
||||
InvenTreeStockItemTestResult().formFields();
|
||||
|
||||
// Add additional filters
|
||||
fields["template"]?["filters"]?["part"] = "${item.partId}";
|
||||
@ -102,7 +104,6 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
bool match = false;
|
||||
|
||||
for (var ii = 0; ii < outputs.length; ii++) {
|
||||
|
||||
// Check against templates
|
||||
if (outputs[ii] is InvenTreePartTestTemplate) {
|
||||
var template = outputs[ii] as InvenTreePartTestTemplate;
|
||||
@ -137,23 +138,16 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
List<Widget> getTiles(BuildContext context) {
|
||||
List<Widget> tiles = [];
|
||||
|
||||
tiles.add(
|
||||
Card(
|
||||
tiles.add(Card(
|
||||
child: ListTile(
|
||||
title: Text(item.partName),
|
||||
subtitle: Text(item.partDescription),
|
||||
leading: InvenTreeAPI().getThumbnail(item.partImage),
|
||||
)
|
||||
)
|
||||
);
|
||||
title: Text(item.partName),
|
||||
subtitle: Text(item.partDescription),
|
||||
leading: InvenTreeAPI().getThumbnail(item.partImage),
|
||||
)));
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().testResults,
|
||||
style: TextStyle(fontWeight: FontWeight.bold)
|
||||
)
|
||||
)
|
||||
);
|
||||
style: TextStyle(fontWeight: FontWeight.bold))));
|
||||
|
||||
if (loading) {
|
||||
tiles.add(progressIndicator());
|
||||
@ -172,7 +166,6 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
}
|
||||
|
||||
for (var item in results) {
|
||||
|
||||
bool _hasResult = false;
|
||||
bool _required = false;
|
||||
String _test = "";
|
||||
@ -214,26 +207,23 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
}
|
||||
|
||||
tiles.add(ListTile(
|
||||
title: Text(_test, style: TextStyle(
|
||||
fontWeight: _required ? FontWeight.bold : FontWeight.normal,
|
||||
fontStyle: _hasResult ? FontStyle.normal : FontStyle.italic
|
||||
)),
|
||||
subtitle: Text(_value),
|
||||
trailing: Text(_date),
|
||||
leading: _icon,
|
||||
onTap: () {
|
||||
if (InvenTreeStockItemTestResult().canCreate) {
|
||||
addTestResult(
|
||||
context,
|
||||
name: _test,
|
||||
templateId: _templateId,
|
||||
nameIsEditable: !_required,
|
||||
valueRequired: _valueRequired,
|
||||
attachmentRequired: _attachmentRequired
|
||||
);
|
||||
}
|
||||
}
|
||||
));
|
||||
title: Text(_test,
|
||||
style: TextStyle(
|
||||
fontWeight: _required ? FontWeight.bold : FontWeight.normal,
|
||||
fontStyle: _hasResult ? FontStyle.normal : FontStyle.italic)),
|
||||
subtitle: Text(_value),
|
||||
trailing: Text(_date),
|
||||
leading: _icon,
|
||||
onTap: () {
|
||||
if (InvenTreeStockItemTestResult().canCreate) {
|
||||
addTestResult(context,
|
||||
name: _test,
|
||||
templateId: _templateId,
|
||||
nameIsEditable: !_required,
|
||||
valueRequired: _valueRequired,
|
||||
attachmentRequired: _attachmentRequired);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
if (tiles.isEmpty) {
|
||||
@ -244,4 +234,4 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
|
||||
return tiles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,7 @@ import "package:inventree/widget/refreshable_state.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
import "package:inventree/api.dart";
|
||||
|
||||
|
||||
class StockItemList extends StatefulWidget {
|
||||
|
||||
const StockItemList(this.filters);
|
||||
|
||||
final Map<String, String> filters;
|
||||
@ -18,9 +16,7 @@ class StockItemList extends StatefulWidget {
|
||||
_StockListState createState() => _StockListState(filters);
|
||||
}
|
||||
|
||||
|
||||
class _StockListState extends RefreshableState<StockItemList> {
|
||||
|
||||
_StockListState(this.filters);
|
||||
|
||||
final Map<String, String> filters;
|
||||
@ -35,20 +31,18 @@ class _StockListState extends RefreshableState<StockItemList> {
|
||||
}
|
||||
|
||||
class PaginatedStockItemList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedStockItemList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedStockItemList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().stockItems;
|
||||
|
||||
@override
|
||||
_PaginatedStockItemListState createState() => _PaginatedStockItemListState();
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedStockItemListState extends PaginatedSearchState<PaginatedStockItemList> {
|
||||
|
||||
class _PaginatedStockItemListState
|
||||
extends PaginatedSearchState<PaginatedStockItemList> {
|
||||
_PaginatedStockItemListState() : super();
|
||||
|
||||
@override
|
||||
@ -56,14 +50,14 @@ class _PaginatedStockItemListState extends PaginatedSearchState<PaginatedStockIt
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"part__name": L10().name,
|
||||
"part__IPN": L10().internalPartNumber,
|
||||
"stock": L10().quantity,
|
||||
"status": L10().status,
|
||||
"batch": L10().batchCode,
|
||||
"updated": L10().lastUpdated,
|
||||
"stocktake_date": L10().lastStocktake,
|
||||
};
|
||||
"part__name": L10().name,
|
||||
"part__IPN": L10().internalPartNumber,
|
||||
"stock": L10().quantity,
|
||||
"status": L10().status,
|
||||
"batch": L10().batchCode,
|
||||
"updated": L10().lastUpdated,
|
||||
"stocktake_date": L10().lastStocktake,
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions {
|
||||
@ -111,23 +105,19 @@ class _PaginatedStockItemListState extends PaginatedSearchState<PaginatedStockIt
|
||||
}
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
// Ensure StockStatus codes are loaded
|
||||
await InvenTreeAPI().StockStatus.load();
|
||||
|
||||
final page = await InvenTreeStockItem().listPaginated(
|
||||
limit,
|
||||
offset,
|
||||
filters: params
|
||||
);
|
||||
final page = await InvenTreeStockItem()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreeStockItem item = model as InvenTreeStockItem;
|
||||
|
||||
return ListTile(
|
||||
@ -135,18 +125,18 @@ class _PaginatedStockItemListState extends PaginatedSearchState<PaginatedStockIt
|
||||
subtitle: Text(item.locationPathString),
|
||||
leading: InvenTreeAPI().getThumbnail(item.partThumbnail),
|
||||
trailing: SizedBox(
|
||||
width: 48,
|
||||
child: Text("${item.displayQuantity}",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: InvenTreeAPI().StockStatus.color(item.status),
|
||||
),
|
||||
)
|
||||
),
|
||||
width: 48,
|
||||
child: Text(
|
||||
"${item.displayQuantity}",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: InvenTreeAPI().StockStatus.color(item.status),
|
||||
),
|
||||
)),
|
||||
onTap: () {
|
||||
item.goToDetailPage(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user