From e5f09acf3f9f014926d4c7411963db20a55cc759 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 3 Aug 2021 01:00:55 +1000 Subject: [PATCH] Update CompanyDetail page --- lib/l10n | 2 +- lib/widget/company_detail.dart | 76 +++++++++++++++++++++++++--------- 2 files changed, 57 insertions(+), 21 deletions(-) diff --git a/lib/l10n b/lib/l10n index f53df596..15a67a8a 160000 --- a/lib/l10n +++ b/lib/l10n @@ -1 +1 @@ -Subproject commit f53df5968c451c511152d931ef32290644e21747 +Subproject commit 15a67a8aa7ec5af876b0467152de13baff8f7806 diff --git a/lib/widget/company_detail.dart b/lib/widget/company_detail.dart index 79b49c1c..bccfaa1a 100644 --- a/lib/widget/company_detail.dart +++ b/lib/widget/company_detail.dart @@ -1,5 +1,7 @@ import 'package:inventree/api.dart'; +import 'package:inventree/api_form.dart'; +import 'package:inventree/app_colors.dart'; import 'package:inventree/inventree/company.dart'; import 'package:inventree/widget/refreshable_state.dart'; import 'package:flutter/cupertino.dart'; @@ -21,30 +23,64 @@ class CompanyDetailWidget extends StatefulWidget { class _CompanyDetailState extends RefreshableState { - final InvenTreeCompany company; + _CompanyDetailState(this.company); - final _editCompanyKey = GlobalKey(); + final InvenTreeCompany company; @override String getAppBarTitle(BuildContext context) => L10().company; + @override + List getAppBarActions(BuildContext context) { + + List actions = []; + + actions.add( + IconButton( + icon: FaIcon(FontAwesomeIcons.globe), + onPressed: () async { + company.goToInvenTreePage(); + }, + ) + ); + + actions.add( + IconButton( + icon: FaIcon(FontAwesomeIcons.edit), + tooltip: L10().edit, + onPressed: () { + editCompany(context); + } + ) + ); + + return actions; + + } + @override Future request() async { await company.reload(); } - _CompanyDetailState(this.company) { - // TODO - } + void editCompany(BuildContext context) async { - void editCompanyDialog() { - - // Values which can be edited - var _name; - var _description; - var _website; - - // TODO - API form + launchApiForm( + context, + L10().companyEdit, + company.url, + { + "name": {}, + "description": {}, + "website": {}, + "is_supplier": {}, + "is_manufacturer": {}, + "is_customer": {}, + "currency": {}, + }, + modelData: company.jsondata, + onSuccess: refresh + ); } List _companyTiles() { @@ -57,11 +93,7 @@ class _CompanyDetailState extends RefreshableState { child: ListTile( title: Text("${company.name}"), subtitle: Text("${company.description}"), - leading: InvenTreeAPI().getImage(company.image), - trailing: IconButton( - icon: FaIcon(FontAwesomeIcons.edit), - onPressed: editCompanyDialog, - ), + leading: InvenTreeAPI().getImage(company.image, width: 40, height: 40), ), )); @@ -105,9 +137,9 @@ class _CompanyDetailState extends RefreshableState { if (company.link.isNotEmpty) { tiles.add(ListTile( title: Text("${company.link}"), - leading: FaIcon(FontAwesomeIcons.link), + leading: FaIcon(FontAwesomeIcons.link, color: COLOR_CLICK), onTap: () { - // TODO - Open external link + company.openLink(); }, )); @@ -125,6 +157,10 @@ class _CompanyDetailState extends RefreshableState { tiles.add(Divider()); } + if (company.isManufacturer) { + // TODO - Add list of manufacturer parts + } + if (company.isCustomer) { // TODO - Add list of sales orders