mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-31 21:35:42 +00:00 
			
		
		
		
	Bom optional (#227)
* Split part settings onto different screen * show_bom setting controls whether BOM information is displayed * linting
This commit is contained in:
		| @@ -142,6 +142,9 @@ | ||||
|   "bom": "BOM", | ||||
|   "@bom": {}, | ||||
|  | ||||
|   "bomEnable": "Display Bill of Materials", | ||||
|   "@bomEnable": {}, | ||||
|  | ||||
|   "build": "Build", | ||||
|   "@build": {}, | ||||
|  | ||||
| @@ -619,6 +622,9 @@ | ||||
|   "partNoResults": "No parts matching query", | ||||
|   "@partNoResults": {}, | ||||
|  | ||||
|   "partSettings": "Part Settings", | ||||
|   "@partSettings": {}, | ||||
|  | ||||
|   "partsStarred": "Subscribed Parts", | ||||
|   "@partsStarred": {}, | ||||
|  | ||||
|   | ||||
| @@ -20,15 +20,14 @@ const String INV_SOUNDS_SERVER = "serverSounds"; | ||||
|  | ||||
| // Part settings | ||||
| const String INV_PART_SHOW_PARAMETERS = "partShowParameters"; | ||||
| const String INV_PART_SHOW_BOM = "partShowBom"; | ||||
|  | ||||
| // Stock settings | ||||
| const String INV_STOCK_SHOW_HISTORY = "stockShowHistory"; | ||||
|  | ||||
| const String INV_REPORT_ERRORS = "reportErrors"; | ||||
|  | ||||
| const String INV_STRICT_HTTPS = "strictHttps"; | ||||
|  | ||||
|  | ||||
| /* | ||||
|  * Class for storing InvenTree preferences in a NoSql DB | ||||
|  */ | ||||
|   | ||||
| @@ -25,12 +25,6 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> { | ||||
|   bool barcodeSounds = true; | ||||
|   bool serverSounds = true; | ||||
|  | ||||
|   // Part settings | ||||
|   bool partShowParameters = true; | ||||
|  | ||||
|   // Stock settings | ||||
|   bool stockShowHistory = false; | ||||
|  | ||||
|   bool reportErrors = true; | ||||
|   bool strictHttps = false; | ||||
|  | ||||
| @@ -44,16 +38,8 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> { | ||||
|   } | ||||
|  | ||||
|   Future <void> loadSettings() async { | ||||
|  | ||||
|     // Load initial settings | ||||
|  | ||||
|     barcodeSounds = await InvenTreeSettingsManager().getValue(INV_SOUNDS_BARCODE, true) as bool; | ||||
|     serverSounds = await InvenTreeSettingsManager().getValue(INV_SOUNDS_SERVER, true) as bool; | ||||
|  | ||||
|     partShowParameters = await InvenTreeSettingsManager().getValue(INV_PART_SHOW_PARAMETERS, true) as bool; | ||||
|  | ||||
|     stockShowHistory = await InvenTreeSettingsManager().getValue(INV_STOCK_SHOW_HISTORY, false) as bool; | ||||
|  | ||||
|     reportErrors = await InvenTreeSettingsManager().getValue(INV_REPORT_ERRORS, true) as bool; | ||||
|     strictHttps = await InvenTreeSettingsManager().getValue(INV_STRICT_HTTPS, false) as bool; | ||||
|  | ||||
| @@ -137,47 +123,6 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> { | ||||
|       body: Container( | ||||
|         child: ListView( | ||||
|           children: [ | ||||
|             /* Part Settings */ | ||||
|             ListTile( | ||||
|               title: Text(L10().part, style: TextStyle(fontWeight: FontWeight.bold)), | ||||
|               leading: FaIcon(FontAwesomeIcons.shapes), | ||||
|             ), | ||||
|             ListTile( | ||||
|               title: Text(L10().parameters), | ||||
|               subtitle: Text(L10().parametersSettingDetail), | ||||
|               leading: FaIcon(FontAwesomeIcons.thList), | ||||
|               trailing: Switch( | ||||
|                 value: partShowParameters, | ||||
|                 onChanged: (bool value) { | ||||
|                   InvenTreeSettingsManager().setValue(INV_PART_SHOW_PARAMETERS, value); | ||||
|                   setState(() { | ||||
|                     partShowParameters = value; | ||||
|                   }); | ||||
|                 }, | ||||
|               ), | ||||
|             ), | ||||
|             Divider(), | ||||
|             /* Stock Settings */ | ||||
|             ListTile( | ||||
|               title: Text(L10().stock, | ||||
|                 style: TextStyle(fontWeight: FontWeight.bold), | ||||
|               ), | ||||
|               leading: FaIcon(FontAwesomeIcons.boxes), | ||||
|             ), | ||||
|             ListTile( | ||||
|               title: Text(L10().stockItemHistory), | ||||
|               subtitle: Text(L10().stockItemHistoryDetail), | ||||
|               leading: FaIcon(FontAwesomeIcons.history), | ||||
|               trailing: Switch( | ||||
|                 value: stockShowHistory, | ||||
|                 onChanged: (bool value) { | ||||
|                   InvenTreeSettingsManager().setValue(INV_STOCK_SHOW_HISTORY, value); | ||||
|                   setState(() { | ||||
|                     stockShowHistory = value; | ||||
|                   }); | ||||
|                 }, | ||||
|               ), | ||||
|             ), | ||||
|             /* Sound Settings */ | ||||
|             Divider(height: 3), | ||||
|             ListTile( | ||||
|   | ||||
							
								
								
									
										94
									
								
								lib/settings/part_settings.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								lib/settings/part_settings.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,94 @@ | ||||
|  | ||||
| import "package:flutter/material.dart"; | ||||
| import "package:font_awesome_flutter/font_awesome_flutter.dart"; | ||||
| import "package:inventree/l10.dart"; | ||||
| import "package:inventree/preferences.dart"; | ||||
|  | ||||
|  | ||||
| class InvenTreePartSettingsWidget extends StatefulWidget { | ||||
|   @override | ||||
|   _InvenTreePartSettingsState createState() => _InvenTreePartSettingsState(); | ||||
| } | ||||
|  | ||||
|  | ||||
| class _InvenTreePartSettingsState extends State<InvenTreePartSettingsWidget> { | ||||
|  | ||||
|   _InvenTreePartSettingsState(); | ||||
|  | ||||
|   bool partShowParameters = true; | ||||
|   bool partShowBom = true; | ||||
|   bool stockShowHistory = false; | ||||
|  | ||||
|   @override | ||||
|   void initState() { | ||||
|     super.initState(); | ||||
|  | ||||
|     loadSettings(); | ||||
|   } | ||||
|  | ||||
|   Future<void> loadSettings() async { | ||||
|     partShowParameters = await InvenTreeSettingsManager().getValue(INV_PART_SHOW_PARAMETERS, true) as bool; | ||||
|     partShowBom = await InvenTreeSettingsManager().getValue(INV_PART_SHOW_BOM, true) as bool; | ||||
|     stockShowHistory = await InvenTreeSettingsManager().getValue(INV_STOCK_SHOW_HISTORY, false) as bool; | ||||
|  | ||||
|     if (mounted) { | ||||
|       setState(() { | ||||
|       }); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Scaffold( | ||||
|       appBar: AppBar(title: Text(L10().part)), | ||||
|       body: Container( | ||||
|         child: ListView( | ||||
|           children: [ | ||||
|             ListTile( | ||||
|               title: Text(L10().parameters), | ||||
|               subtitle: Text(L10().parametersSettingDetail), | ||||
|               leading: FaIcon(FontAwesomeIcons.thList), | ||||
|               trailing: Switch( | ||||
|                 value: partShowParameters, | ||||
|                 onChanged: (bool value) { | ||||
|                   InvenTreeSettingsManager().setValue(INV_PART_SHOW_PARAMETERS, value); | ||||
|                   setState(() { | ||||
|                     partShowParameters = value; | ||||
|                   }); | ||||
|                 }, | ||||
|               ), | ||||
|             ), | ||||
|             ListTile( | ||||
|               title: Text(L10().bom), | ||||
|               subtitle: Text(L10().bomEnable), | ||||
|               leading: FaIcon(FontAwesomeIcons.list), | ||||
|               trailing: Switch( | ||||
|                 value: partShowBom, | ||||
|                 onChanged: (bool value) { | ||||
|                   InvenTreeSettingsManager().setValue(INV_PART_SHOW_BOM, value); | ||||
|                   setState(() { | ||||
|                     partShowBom = value; | ||||
|                   }); | ||||
|                 }, | ||||
|               ), | ||||
|             ), | ||||
|             ListTile( | ||||
|               title: Text(L10().stockItemHistory), | ||||
|               subtitle: Text(L10().stockItemHistoryDetail), | ||||
|               leading: FaIcon(FontAwesomeIcons.history), | ||||
|               trailing: Switch( | ||||
|                 value: stockShowHistory, | ||||
|                 onChanged: (bool value) { | ||||
|                   InvenTreeSettingsManager().setValue(INV_STOCK_SHOW_HISTORY, value); | ||||
|                   setState(() { | ||||
|                     stockShowHistory = value; | ||||
|                   }); | ||||
|                 }, | ||||
|               ), | ||||
|             ), | ||||
|           ] | ||||
|         ) | ||||
|       ) | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @@ -1,11 +1,12 @@ | ||||
| import "package:flutter/material.dart"; | ||||
| import "package:font_awesome_flutter/font_awesome_flutter.dart"; | ||||
|  | ||||
| import "package:inventree/app_colors.dart"; | ||||
| import "package:inventree/l10.dart"; | ||||
| import "package:inventree/settings/app_settings.dart"; | ||||
| import "package:inventree/settings/home_settings.dart"; | ||||
| import "package:inventree/settings/login.dart"; | ||||
|  | ||||
| import "package:flutter/material.dart"; | ||||
| import "package:font_awesome_flutter/font_awesome_flutter.dart"; | ||||
| import "package:inventree/l10.dart"; | ||||
| import "package:inventree/settings/part_settings.dart"; | ||||
|  | ||||
|  | ||||
| class InvenTreeSettingsWidget extends StatefulWidget { | ||||
| @@ -37,38 +38,38 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> { | ||||
|                   title: Text(L10().server), | ||||
|                   subtitle: Text(L10().configureServer), | ||||
|                   leading: FaIcon(FontAwesomeIcons.server, color: COLOR_CLICK), | ||||
|                   onTap: _editServerSettings, | ||||
|                   onTap: () { | ||||
|                     Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeLoginSettingsWidget())); | ||||
|                   }, | ||||
|               ), | ||||
|               ListTile( | ||||
|                 title: Text(L10().homeScreen), | ||||
|                 subtitle: Text(L10().homeScreenSettings), | ||||
|                 leading: FaIcon(FontAwesomeIcons.home, color: COLOR_CLICK), | ||||
|                 onTap: _editHomeScreenSettings, | ||||
|                 onTap: () { | ||||
|                   Navigator.push(context, MaterialPageRoute(builder: (context) => HomeScreenSettingsWidget())); | ||||
|                 } | ||||
|               ), | ||||
|               ListTile( | ||||
|                 title: Text(L10().appSettings), | ||||
|                 subtitle: Text(L10().appSettingsDetails), | ||||
|                 leading: FaIcon(FontAwesomeIcons.cogs, color: COLOR_CLICK), | ||||
|                 onTap: _editAppSettings, | ||||
|                 onTap: () { | ||||
|                   Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeAppSettingsWidget())); | ||||
|                 } | ||||
|               ), | ||||
|               ListTile( | ||||
|                 title: Text(L10().part), | ||||
|                 subtitle: Text(L10().partSettings), | ||||
|                 leading: FaIcon(FontAwesomeIcons.shapes, color: COLOR_CLICK), | ||||
|                 onTap: () { | ||||
|                   Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreePartSettingsWidget())); | ||||
|                 } | ||||
|               ) | ||||
|             ] | ||||
|           ).toList() | ||||
|         ) | ||||
|       ) | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   Future <void> _editServerSettings() async { | ||||
|  | ||||
|     Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeLoginSettingsWidget())); | ||||
|   } | ||||
|  | ||||
|   Future<void> _editHomeScreenSettings() async { | ||||
|     Navigator.push(context, MaterialPageRoute(builder: (context) => HomeScreenSettingsWidget())); | ||||
|   } | ||||
|  | ||||
|   Future <void> _editAppSettings() async { | ||||
|     Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeAppSettingsWidget())); | ||||
|   } | ||||
|  | ||||
| } | ||||
| @@ -53,6 +53,8 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> { | ||||
|  | ||||
|   bool showParameters = false; | ||||
|  | ||||
|   bool showBom = false; | ||||
|  | ||||
|   int attachmentCount = 0; | ||||
|  | ||||
|   int bomCount = 0; | ||||
| @@ -169,6 +171,8 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> { | ||||
|       } | ||||
|     }); | ||||
|  | ||||
|     showBom = await InvenTreeSettingsManager().getValue(INV_PART_SHOW_BOM, true) as bool; | ||||
|  | ||||
|     // Request the number of BOM items | ||||
|     InvenTreePart().count( | ||||
|       filters: { | ||||
| @@ -424,7 +428,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> { | ||||
|     // Tiles for an "assembly" part | ||||
|     if (part.isAssembly) { | ||||
|  | ||||
|       if (bomCount > 0) { | ||||
|       if (showBom && bomCount > 0) { | ||||
|         tiles.add( | ||||
|             ListTile( | ||||
|                 title: Text(L10().billOfMaterials), | ||||
| @@ -457,7 +461,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> { | ||||
|     } | ||||
|  | ||||
|     if (part.isComponent) { | ||||
|       if (usedInCount > 0) { | ||||
|       if (showBom && usedInCount > 0) { | ||||
|         tiles.add( | ||||
|           ListTile( | ||||
|             title: Text(L10().usedIn), | ||||
| @@ -534,21 +538,6 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> { | ||||
|       ); | ||||
|     } | ||||
|  | ||||
|     // Notes field | ||||
|     tiles.add( | ||||
|       ListTile( | ||||
|         title: Text(L10().notes), | ||||
|         leading: FaIcon(FontAwesomeIcons.stickyNote, color: COLOR_CLICK), | ||||
|         trailing: Text(""), | ||||
|         onTap: () { | ||||
|           Navigator.push( | ||||
|             context, | ||||
|             MaterialPageRoute(builder: (context) => PartNotesWidget(part)) | ||||
|           ); | ||||
|         }, | ||||
|       ) | ||||
|     ); | ||||
|  | ||||
|     if (showParameters) { | ||||
|       tiles.add( | ||||
|           ListTile( | ||||
| @@ -567,6 +556,21 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> { | ||||
|       ); | ||||
|     } | ||||
|  | ||||
|     // Notes field | ||||
|     tiles.add( | ||||
|         ListTile( | ||||
|           title: Text(L10().notes), | ||||
|           leading: FaIcon(FontAwesomeIcons.stickyNote, color: COLOR_CLICK), | ||||
|           trailing: Text(""), | ||||
|           onTap: () { | ||||
|             Navigator.push( | ||||
|                 context, | ||||
|                 MaterialPageRoute(builder: (context) => PartNotesWidget(part)) | ||||
|             ); | ||||
|           }, | ||||
|         ) | ||||
|     ); | ||||
|  | ||||
|     tiles.add( | ||||
|       ListTile( | ||||
|         title: Text(L10().attachments), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user