mirror of
https://github.com/inventree/inventree-app.git
synced 2025-07-02 03:40:47 +00:00
Format Code and Add Format Checks to CI (#643)
* Remove unused lib/generated/i18n.dart * Use `fvm dart format .` * Add contributing guidelines * Enforce dart format * Add `dart format off` directive to generated files
This commit is contained in:
@ -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;
|
||||
@ -61,15 +56,15 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
if (InvenTreeCompany().canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().companyEdit,
|
||||
onPressed: () {
|
||||
editCompany(context);
|
||||
}
|
||||
)
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().companyEdit,
|
||||
onPressed: () {
|
||||
editCompany(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
@ -78,23 +73,27 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (widget.company.isCustomer && InvenTreeSalesOrder().canCreate) {
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.truck),
|
||||
label: L10().salesOrderCreate,
|
||||
onTap: () async {
|
||||
_createSalesOrder(context);
|
||||
}
|
||||
));
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
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);
|
||||
}
|
||||
));
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.shopping_cart),
|
||||
label: L10().purchaseOrderCreate,
|
||||
onTap: () async {
|
||||
_createPurchaseOrder(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -109,17 +108,17 @@ 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>;
|
||||
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);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -132,17 +131,17 @@ 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>;
|
||||
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);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -156,32 +155,37 @@ 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;
|
||||
|
||||
InvenTreeSupplierPart().count(
|
||||
filters: {
|
||||
"supplier": widget.company.pk.toString()
|
||||
}
|
||||
).then((value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
supplierPartCount = value;
|
||||
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) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
supplierPartCount = value;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
InvenTreeCompanyAttachment().countAttachments(widget.company.pk)
|
||||
.then((value) {
|
||||
InvenTreeCompanyAttachment().countAttachments(widget.company.pk).then((
|
||||
value,
|
||||
) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
attachmentCount = value;
|
||||
@ -190,15 +194,14 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
});
|
||||
}
|
||||
|
||||
Future <void> editCompany(BuildContext context) async {
|
||||
|
||||
Future<void> editCompany(BuildContext context) async {
|
||||
widget.company.editForm(
|
||||
context,
|
||||
L10().companyEdit,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().companyUpdated, success: true);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -207,87 +210,86 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
*/
|
||||
@override
|
||||
List<Widget> getTiles(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [];
|
||||
|
||||
bool sep = false;
|
||||
|
||||
tiles.add(Card(
|
||||
child: ListTile(
|
||||
title: Text("${widget.company.name}"),
|
||||
subtitle: Text("${widget.company.description}"),
|
||||
leading: InvenTreeAPI().getThumbnail(widget.company.image),
|
||||
tiles.add(
|
||||
Card(
|
||||
child: ListTile(
|
||||
title: Text("${widget.company.name}"),
|
||||
subtitle: Text("${widget.company.description}"),
|
||||
leading: InvenTreeAPI().getThumbnail(widget.company.image),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
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
|
||||
),
|
||||
)
|
||||
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) {
|
||||
tiles.add(ListTile(
|
||||
title: Text("${widget.company.link}"),
|
||||
leading: Icon(TablerIcons.link, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
widget.company.openLink();
|
||||
},
|
||||
));
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("${widget.company.link}"),
|
||||
leading: Icon(TablerIcons.link, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
widget.company.openLink();
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
sep = true;
|
||||
}
|
||||
@ -297,7 +299,6 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
}
|
||||
|
||||
if (widget.company.isSupplier) {
|
||||
|
||||
if (supplierPartCount > 0) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
@ -309,12 +310,12 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SupplierPartList({
|
||||
"supplier": widget.company.pk.toString()
|
||||
})
|
||||
)
|
||||
"supplier": widget.company.pk.toString(),
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -328,14 +329,12 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PurchaseOrderListWidget(
|
||||
filters: {
|
||||
"supplier": "${widget.company.pk}"
|
||||
}
|
||||
)
|
||||
)
|
||||
filters: {"supplier": "${widget.company.pk}"},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
// TODO: Display "supplied parts" count (click through to list of supplier parts)
|
||||
@ -365,46 +364,46 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SalesOrderListWidget(
|
||||
filters: {
|
||||
"customer": widget.company.pk.toString()
|
||||
}
|
||||
)
|
||||
)
|
||||
filters: {"customer": widget.company.pk.toString()},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (widget.company.notes.isNotEmpty) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().notes),
|
||||
leading: Icon(TablerIcons.note),
|
||||
onTap: null,
|
||||
));
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().notes),
|
||||
leading: Icon(TablerIcons.note),
|
||||
onTap: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
));
|
||||
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,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
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,16 +26,13 @@ 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,
|
||||
@ -49,7 +44,7 @@ class _CompanyListWidgetState extends RefreshableState<CompanyListWidget> {
|
||||
var company = InvenTreeCompany.fromJson(data);
|
||||
company.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -59,13 +54,13 @@ class _CompanyListWidgetState extends RefreshableState<CompanyListWidget> {
|
||||
|
||||
if (InvenTreeAPI().checkPermission("company", "add")) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().companyAdd,
|
||||
onTap: () {
|
||||
_addCompany(context);
|
||||
}
|
||||
)
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().companyAdd,
|
||||
onTap: () {
|
||||
_addCompany(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -76,12 +71,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 +87,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 +105,22 @@ 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);
|
||||
: 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
|
||||
@ -39,7 +37,8 @@ class _ManufacturerPartDisplayState extends RefreshableState<ManufacturerPartDet
|
||||
|
||||
@override
|
||||
Future<void> request(BuildContext context) async {
|
||||
final bool result = widget.manufacturerPart.pk > 0 &&
|
||||
final bool result =
|
||||
widget.manufacturerPart.pk > 0 &&
|
||||
await widget.manufacturerPart.reload();
|
||||
|
||||
if (!result) {
|
||||
@ -49,12 +48,12 @@ class _ManufacturerPartDisplayState extends RefreshableState<ManufacturerPartDet
|
||||
|
||||
Future<void> editManufacturerPart(BuildContext context) async {
|
||||
widget.manufacturerPart.editForm(
|
||||
context,
|
||||
L10().manufacturerPartEdit,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().itemUpdated, success: true);
|
||||
}
|
||||
context,
|
||||
L10().manufacturerPartEdit,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().itemUpdated, success: true);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -73,13 +72,13 @@ class _ManufacturerPartDisplayState extends RefreshableState<ManufacturerPartDet
|
||||
|
||||
if (widget.manufacturerPart.canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().edit,
|
||||
onPressed: () {
|
||||
editManufacturerPart(context);
|
||||
}
|
||||
)
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().edit,
|
||||
onPressed: () {
|
||||
editManufacturerPart(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -100,78 +99,85 @@ 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();
|
||||
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();
|
||||
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),
|
||||
)
|
||||
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),
|
||||
)
|
||||
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);
|
||||
}
|
||||
},
|
||||
)
|
||||
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
|
||||
@ -44,12 +42,12 @@ class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidge
|
||||
*/
|
||||
Future<void> editSupplierPart(BuildContext context) async {
|
||||
widget.supplierPart.editForm(
|
||||
context,
|
||||
L10().supplierPartEdit,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().supplierPartUpdated, success: true);
|
||||
}
|
||||
context,
|
||||
L10().supplierPartEdit,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().supplierPartUpdated, success: true);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -60,11 +58,12 @@ class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidge
|
||||
if (widget.supplierPart.canEdit) {
|
||||
actions.add(
|
||||
customBarcodeAction(
|
||||
context, this,
|
||||
context,
|
||||
this,
|
||||
widget.supplierPart.customBarcode,
|
||||
"supplierpart",
|
||||
widget.supplierPart.pk
|
||||
)
|
||||
widget.supplierPart.pk,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -77,13 +76,13 @@ class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidge
|
||||
|
||||
if (widget.supplierPart.canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().edit,
|
||||
onPressed: () {
|
||||
editSupplierPart(context);
|
||||
}
|
||||
)
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().edit,
|
||||
onPressed: () {
|
||||
editSupplierPart(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -92,7 +91,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();
|
||||
@ -113,43 +113,33 @@ 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();
|
||||
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
|
||||
),
|
||||
)
|
||||
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),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -159,26 +149,30 @@ class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidge
|
||||
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),
|
||||
)
|
||||
ListTile(
|
||||
title: Text(L10().supplierPartNumber),
|
||||
subtitle: Text(widget.supplierPart.SKU),
|
||||
leading: Icon(TablerIcons.hash),
|
||||
),
|
||||
);
|
||||
|
||||
// Manufacturer information
|
||||
@ -188,17 +182,21 @@ class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidge
|
||||
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(
|
||||
@ -208,28 +206,39 @@ class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidge
|
||||
leading: Icon(TablerIcons.hash, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
var manufacturerPart = await InvenTreeManufacturerPart().get(widget.supplierPart.manufacturerPartId);
|
||||
var manufacturerPart = await InvenTreeManufacturerPart().get(
|
||||
widget.supplierPart.manufacturerPartId,
|
||||
);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (manufacturerPart is InvenTreeManufacturerPart) {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) => ManufacturerPartDetailWidget(manufacturerPart)
|
||||
));
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
ManufacturerPartDetailWidget(manufacturerPart),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Packaging
|
||||
if (widget.supplierPart.packaging.isNotEmpty || widget.supplierPart.pack_quantity.isNotEmpty) {
|
||||
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,
|
||||
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,
|
||||
)
|
||||
trailing: widget.supplierPart.pack_quantity.isNotEmpty
|
||||
? Text(widget.supplierPart.pack_quantity)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -244,7 +253,7 @@ class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidge
|
||||
await launchUrl(uri);
|
||||
}
|
||||
},
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -253,11 +262,10 @@ class _SupplierPartDisplayState extends RefreshableState<SupplierPartDetailWidge
|
||||
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,16 @@ 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;
|
||||
}
|
||||
|
||||
@ -96,10 +96,10 @@ class _PaginatedSupplierPartListState extends PaginatedSearchState<PaginatedSupp
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SupplierPartDetailWidget(supplierPart)
|
||||
)
|
||||
builder: (context) => SupplierPartDetailWidget(supplierPart),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user