diff --git a/lib/widget/part_detail.dart b/lib/widget/part_detail.dart index 063ec743..6e72184d 100644 --- a/lib/widget/part_detail.dart +++ b/lib/widget/part_detail.dart @@ -32,6 +32,18 @@ class _PartDisplayState extends RefreshableState { @override String getAppBarTitle(BuildContext context) { return "Part"; } + @override + List getAppBarActions(BuildContext context) { + return [ + // TODO: Hide the 'edit' button if the user does not have permission!! + IconButton( + icon: FaIcon(FontAwesomeIcons.edit), + tooltip: 'Edit', + onPressed: _editPartDialog, + ) + ]; + } + _PartDisplayState(this.part) { // TODO } @@ -114,6 +126,7 @@ class _PartDisplayState extends RefreshableState { StringField( label: "Internal Part Number", initial: part.IPN, + allowEmpty: true, onSaved: (value) => _ipn = value, ) @@ -136,10 +149,6 @@ class _PartDisplayState extends RefreshableState { title: Text("${part.fullname}"), subtitle: Text("${part.description}"), leading: InvenTreeAPI().getImage(part.thumbnail), - trailing: IconButton( - icon: FaIcon(FontAwesomeIcons.edit), - onPressed: _editPartDialog, - ), ) ) ); diff --git a/lib/widget/refreshable_state.dart b/lib/widget/refreshable_state.dart index f4a35f3b..44e48553 100644 --- a/lib/widget/refreshable_state.dart +++ b/lib/widget/refreshable_state.dart @@ -11,6 +11,10 @@ abstract class RefreshableState extends State { // Storage for context once "Build" is called BuildContext context; + List getAppBarActions(BuildContext context) { + return []; + } + String getAppBarTitle(BuildContext context) { return "App Bar Title"; } void initState() { @@ -37,6 +41,7 @@ abstract class RefreshableState extends State { AppBar getAppBar(BuildContext context) { return AppBar( title: Text(getAppBarTitle(context)), + actions: getAppBarActions(context), ); } diff --git a/lib/widget/stock_detail.dart b/lib/widget/stock_detail.dart index 52170ae8..9e70a3c0 100644 --- a/lib/widget/stock_detail.dart +++ b/lib/widget/stock_detail.dart @@ -37,6 +37,18 @@ class _StockItemDisplayState extends RefreshableState { @override String getAppBarTitle(BuildContext context) { return "Stock Item"; } + @override + List getAppBarActions(BuildContext context) { + return [ + // TODO: Hide the 'edit' button if the user does not have permission!! + IconButton( + icon: FaIcon(FontAwesomeIcons.edit), + tooltip: "Edit", + onPressed: _editStockItemDialog, + ) + ]; + } + final TextEditingController _quantityController = TextEditingController(); final TextEditingController _notesController = TextEditingController(); @@ -333,10 +345,6 @@ class _StockItemDisplayState extends RefreshableState { title: Text("${item.partName}"), subtitle: Text("${item.partDescription}"), leading: InvenTreeAPI().getImage(item.partImage), - trailing: IconButton( - icon: FaIcon(FontAwesomeIcons.edit), - onPressed: _editStockItemDialog, - ) ) ) );