mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-11-04 07:15:46 +00:00 
			
		
		
		
	Move the "edit" button to the app bar
This commit is contained in:
		@@ -32,6 +32,18 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
 | 
				
			|||||||
  @override
 | 
					  @override
 | 
				
			||||||
  String getAppBarTitle(BuildContext context) { return "Part"; }
 | 
					  String getAppBarTitle(BuildContext context) { return "Part"; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  List<Widget> getAppBarActions(BuildContext context) {
 | 
				
			||||||
 | 
					    return <Widget>[
 | 
				
			||||||
 | 
					      // TODO: Hide the 'edit' button if the user does not have permission!!
 | 
				
			||||||
 | 
					      IconButton(
 | 
				
			||||||
 | 
					        icon: FaIcon(FontAwesomeIcons.edit),
 | 
				
			||||||
 | 
					        tooltip: 'Edit',
 | 
				
			||||||
 | 
					        onPressed: _editPartDialog,
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  _PartDisplayState(this.part) {
 | 
					  _PartDisplayState(this.part) {
 | 
				
			||||||
    // TODO
 | 
					    // TODO
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -114,6 +126,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
 | 
				
			|||||||
        StringField(
 | 
					        StringField(
 | 
				
			||||||
          label: "Internal Part Number",
 | 
					          label: "Internal Part Number",
 | 
				
			||||||
          initial: part.IPN,
 | 
					          initial: part.IPN,
 | 
				
			||||||
 | 
					          allowEmpty: true,
 | 
				
			||||||
          onSaved: (value) => _ipn = value,
 | 
					          onSaved: (value) => _ipn = value,
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -136,10 +149,6 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
 | 
				
			|||||||
          title: Text("${part.fullname}"),
 | 
					          title: Text("${part.fullname}"),
 | 
				
			||||||
          subtitle: Text("${part.description}"),
 | 
					          subtitle: Text("${part.description}"),
 | 
				
			||||||
          leading: InvenTreeAPI().getImage(part.thumbnail),
 | 
					          leading: InvenTreeAPI().getImage(part.thumbnail),
 | 
				
			||||||
          trailing: IconButton(
 | 
					 | 
				
			||||||
            icon: FaIcon(FontAwesomeIcons.edit),
 | 
					 | 
				
			||||||
            onPressed: _editPartDialog,
 | 
					 | 
				
			||||||
          ),
 | 
					 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
      )
 | 
					      )
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,6 +11,10 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> {
 | 
				
			|||||||
  // Storage for context once "Build" is called
 | 
					  // Storage for context once "Build" is called
 | 
				
			||||||
  BuildContext context;
 | 
					  BuildContext context;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  List<Widget> getAppBarActions(BuildContext context) {
 | 
				
			||||||
 | 
					    return [];
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  String getAppBarTitle(BuildContext context) { return "App Bar Title"; }
 | 
					  String getAppBarTitle(BuildContext context) { return "App Bar Title"; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void initState() {
 | 
					  void initState() {
 | 
				
			||||||
@@ -37,6 +41,7 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> {
 | 
				
			|||||||
  AppBar getAppBar(BuildContext context) {
 | 
					  AppBar getAppBar(BuildContext context) {
 | 
				
			||||||
    return AppBar(
 | 
					    return AppBar(
 | 
				
			||||||
      title: Text(getAppBarTitle(context)),
 | 
					      title: Text(getAppBarTitle(context)),
 | 
				
			||||||
 | 
					      actions: getAppBarActions(context),
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,6 +37,18 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
 | 
				
			|||||||
  @override
 | 
					  @override
 | 
				
			||||||
  String getAppBarTitle(BuildContext context) { return "Stock Item"; }
 | 
					  String getAppBarTitle(BuildContext context) { return "Stock Item"; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  List<Widget> getAppBarActions(BuildContext context) {
 | 
				
			||||||
 | 
					    return <Widget>[
 | 
				
			||||||
 | 
					      // 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 _quantityController = TextEditingController();
 | 
				
			||||||
  final TextEditingController _notesController = TextEditingController();
 | 
					  final TextEditingController _notesController = TextEditingController();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -333,10 +345,6 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
 | 
				
			|||||||
          title: Text("${item.partName}"),
 | 
					          title: Text("${item.partName}"),
 | 
				
			||||||
          subtitle: Text("${item.partDescription}"),
 | 
					          subtitle: Text("${item.partDescription}"),
 | 
				
			||||||
          leading: InvenTreeAPI().getImage(item.partImage),
 | 
					          leading: InvenTreeAPI().getImage(item.partImage),
 | 
				
			||||||
          trailing: IconButton(
 | 
					 | 
				
			||||||
            icon: FaIcon(FontAwesomeIcons.edit),
 | 
					 | 
				
			||||||
            onPressed: _editStockItemDialog,
 | 
					 | 
				
			||||||
          )
 | 
					 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
      )
 | 
					      )
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user