mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-17 20:55:26 +00:00
Format code
This commit is contained in:
@ -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)));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user