mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-30 21:05:42 +00:00 
			
		
		
		
	Yet more linting
This commit is contained in:
		| @@ -55,5 +55,7 @@ linter: | ||||
|  | ||||
|     sort_child_properties_last: false | ||||
|  | ||||
|     directives_ordering: false | ||||
|  | ||||
|     # Blindly follow the Flutter code style, which prefers types everywhere | ||||
|     always_specify_types: false | ||||
|   | ||||
							
								
								
									
										27
									
								
								lib/api.dart
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								lib/api.dart
									
									
									
									
									
								
							| @@ -50,7 +50,7 @@ class APIResponse { | ||||
|  | ||||
|   bool clientError() => (statusCode >= 400) && (statusCode < 500); | ||||
|  | ||||
|   bool serverError() => (statusCode >= 500); | ||||
|   bool serverError() => statusCode >= 500; | ||||
|  | ||||
|   bool isMap() { | ||||
|     return data != null && data is Map<String, dynamic>; | ||||
| @@ -86,8 +86,6 @@ class APIResponse { | ||||
|  */ | ||||
| class InvenTreeFileService extends FileService { | ||||
|  | ||||
|   HttpClient? _client; | ||||
|  | ||||
|   InvenTreeFileService({HttpClient? client, bool strictHttps = false}) { | ||||
|     _client = client ?? HttpClient(); | ||||
|  | ||||
| @@ -99,6 +97,8 @@ class InvenTreeFileService extends FileService { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   HttpClient? _client; | ||||
|  | ||||
|   @override | ||||
|   Future<FileServiceResponse> get(String url, | ||||
|       {Map<String, String>? headers}) async { | ||||
| @@ -133,6 +133,12 @@ class InvenTreeFileService extends FileService { | ||||
|  | ||||
| class InvenTreeAPI { | ||||
|  | ||||
|   factory InvenTreeAPI() { | ||||
|     return _api; | ||||
|   } | ||||
|  | ||||
|   InvenTreeAPI._internal(); | ||||
|  | ||||
|   // Minimum required API version for server | ||||
|   static const _minApiVersion = 7; | ||||
|  | ||||
| @@ -236,14 +242,7 @@ class InvenTreeAPI { | ||||
|   } | ||||
|  | ||||
|   // Ensure we only ever create a single instance of the API class | ||||
|   static final InvenTreeAPI _api = new InvenTreeAPI._internal(); | ||||
|  | ||||
|   factory InvenTreeAPI() { | ||||
|     return _api; | ||||
|   } | ||||
|  | ||||
|   InvenTreeAPI._internal(); | ||||
|  | ||||
|   static final InvenTreeAPI _api = InvenTreeAPI._internal(); | ||||
|  | ||||
|   /* | ||||
|    * Connect to the remote InvenTree server: | ||||
| @@ -481,7 +480,7 @@ class InvenTreeAPI { | ||||
|  | ||||
|   // Perform a PATCH request | ||||
|   Future<APIResponse> patch(String url, {Map<String, String> body = const {}, int? expectedStatusCode}) async { | ||||
|     var _body = Map<String, String>(); | ||||
|     Map<String, String> _body = {}; | ||||
|  | ||||
|     // Copy across provided data | ||||
|     body.forEach((K, V) => _body[K] = V); | ||||
| @@ -939,7 +938,7 @@ class InvenTreeAPI { | ||||
|  | ||||
|   // Return a list of request headers | ||||
|   Map<String, String> defaultHeaders() { | ||||
|     var headers = Map<String, String>(); | ||||
|     Map<String, String> headers = {}; | ||||
|  | ||||
|     headers[HttpHeaders.authorizationHeader] = _authorizationHeader(); | ||||
|     headers[HttpHeaders.acceptHeader] = "application/json"; | ||||
| @@ -983,7 +982,7 @@ class InvenTreeAPI { | ||||
|       ) | ||||
|     ); | ||||
|  | ||||
|     return new CachedNetworkImage( | ||||
|     return CachedNetworkImage( | ||||
|       imageUrl: url, | ||||
|       placeholder: (context, url) => CircularProgressIndicator(), | ||||
|       errorWidget: (context, url, error) => FaIcon(FontAwesomeIcons.timesCircle, color: COLOR_DANGER), | ||||
|   | ||||
| @@ -209,7 +209,7 @@ class APIFormField { | ||||
|   // Field for selecting and uploading files | ||||
|   Widget _constructFileField() { | ||||
|  | ||||
|     TextEditingController controller = new TextEditingController(); | ||||
|     TextEditingController controller = TextEditingController(); | ||||
|  | ||||
|     controller.text = (attachedfile?.path ?? L10().attachmentSelect).split("/").last; | ||||
|  | ||||
| @@ -506,7 +506,7 @@ class APIFormField { | ||||
|   } | ||||
|  | ||||
|   TextStyle _labelStyle() { | ||||
|     return new TextStyle( | ||||
|     return TextStyle( | ||||
|       fontWeight: FontWeight.bold, | ||||
|       fontSize: 18, | ||||
|       fontFamily: "arial", | ||||
| @@ -516,7 +516,7 @@ class APIFormField { | ||||
|   } | ||||
|  | ||||
|   TextStyle _helperStyle() { | ||||
|     return new TextStyle( | ||||
|     return TextStyle( | ||||
|       fontStyle: FontStyle.italic, | ||||
|       color: hasErrors() ? COLOR_DANGER : COLOR_GRAY, | ||||
|     ); | ||||
| @@ -660,6 +660,18 @@ Future<void> launchApiForm(BuildContext context, String title, String url, Map<S | ||||
|  | ||||
| class APIFormWidget extends StatefulWidget { | ||||
|  | ||||
|   APIFormWidget( | ||||
|       this.title, | ||||
|       this.url, | ||||
|       this.fields, | ||||
|       this.method, | ||||
|       { | ||||
|         Key? key, | ||||
|         this.onSuccess, | ||||
|         this.fileField = "", | ||||
|       } | ||||
|       ) : super(key: key); | ||||
|  | ||||
|   //! Form title to display | ||||
|   final String title; | ||||
|  | ||||
| @@ -675,18 +687,6 @@ class APIFormWidget extends StatefulWidget { | ||||
|  | ||||
|   Function(Map<String, dynamic>)? onSuccess; | ||||
|  | ||||
|   APIFormWidget( | ||||
|       this.title, | ||||
|       this.url, | ||||
|       this.fields, | ||||
|       this.method, | ||||
|       { | ||||
|         Key? key, | ||||
|         this.onSuccess, | ||||
|         this.fileField = "", | ||||
|       } | ||||
|   ) : super(key: key); | ||||
|  | ||||
|   @override | ||||
|   _APIFormWidgetState createState() => _APIFormWidgetState(title, url, fields, method, onSuccess, fileField); | ||||
|  | ||||
| @@ -695,7 +695,9 @@ class APIFormWidget extends StatefulWidget { | ||||
|  | ||||
| class _APIFormWidgetState extends State<APIFormWidget> { | ||||
|  | ||||
|   final _formKey = new GlobalKey<FormState>(); | ||||
|   _APIFormWidgetState(this.title, this.url, this.fields, this.method, this.onSuccess, this.fileField) : super(); | ||||
|  | ||||
|   final _formKey = GlobalKey<FormState>(); | ||||
|  | ||||
|   String title; | ||||
|  | ||||
| @@ -709,8 +711,6 @@ class _APIFormWidgetState extends State<APIFormWidget> { | ||||
|  | ||||
|   Function(Map<String, dynamic>)? onSuccess; | ||||
|  | ||||
|   _APIFormWidgetState(this.title, this.url, this.fields, this.method, this.onSuccess, this.fileField) : super(); | ||||
|  | ||||
|   bool spacerRequired = false; | ||||
|  | ||||
|   List<Widget> _buildForm() { | ||||
| @@ -788,29 +788,36 @@ class _APIFormWidgetState extends State<APIFormWidget> { | ||||
|           if (file != null) { | ||||
|  | ||||
|             // A valid file has been supplied | ||||
|             return await InvenTreeAPI().uploadFile( | ||||
|             final response = await InvenTreeAPI().uploadFile( | ||||
|               url, | ||||
|               file, | ||||
|               name: fileField, | ||||
|               fields: data, | ||||
|             ); | ||||
|  | ||||
|             return response; | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     if (method == "POST") { | ||||
|       return await InvenTreeAPI().post( | ||||
|       final response =  await InvenTreeAPI().post( | ||||
|         url, | ||||
|         body: data, | ||||
|         expectedStatusCode: null | ||||
|       ); | ||||
|  | ||||
|       return response; | ||||
|  | ||||
|     } else { | ||||
|       return await InvenTreeAPI().patch( | ||||
|       final response = await InvenTreeAPI().patch( | ||||
|         url, | ||||
|         body: data, | ||||
|         expectedStatusCode: null | ||||
|       ); | ||||
|  | ||||
|       return response; | ||||
|     } | ||||
|  | ||||
|   } | ||||
|   | ||||
| @@ -7,9 +7,15 @@ import "package:inventree/preferences.dart"; | ||||
|  | ||||
| class InvenTreeSettingsManager { | ||||
|  | ||||
|   factory InvenTreeSettingsManager() { | ||||
|     return _manager; | ||||
|   } | ||||
|  | ||||
|   InvenTreeSettingsManager._internal(); | ||||
|  | ||||
|   final store = StoreRef("settings"); | ||||
|  | ||||
|   Future<Database> get _db async => await InvenTreePreferencesDB.instance.database; | ||||
|   Future<Database> get _db async => InvenTreePreferencesDB.instance.database; | ||||
|  | ||||
|   Future<dynamic> getValue(String key, dynamic backup) async { | ||||
|  | ||||
| @@ -39,11 +45,5 @@ class InvenTreeSettingsManager { | ||||
|   } | ||||
|  | ||||
|   // Ensure we only ever create a single instance of this class | ||||
|   static final InvenTreeSettingsManager _manager = new InvenTreeSettingsManager._internal(); | ||||
|  | ||||
|   factory InvenTreeSettingsManager() { | ||||
|     return _manager; | ||||
|   } | ||||
|  | ||||
|   InvenTreeSettingsManager._internal(); | ||||
| } | ||||
|   static final InvenTreeSettingsManager _manager = InvenTreeSettingsManager._internal(); | ||||
| } | ||||
|   | ||||
| @@ -32,21 +32,21 @@ class BarcodeHandler { | ||||
|    * based on the response returned from the InvenTree server | ||||
|    */ | ||||
|  | ||||
|     String getOverlayText(BuildContext context) => "Barcode Overlay"; | ||||
|   BarcodeHandler(); | ||||
|  | ||||
|     BarcodeHandler(); | ||||
|   String getOverlayText(BuildContext context) => "Barcode Overlay"; | ||||
|  | ||||
|     QRViewController? _controller; | ||||
|   QRViewController? _controller; | ||||
|  | ||||
|     Future<void> successTone() async { | ||||
|   Future<void> successTone() async { | ||||
|  | ||||
|       final bool en = await InvenTreeSettingsManager().getValue("barcodeSounds", true) as bool; | ||||
|     final bool en = await InvenTreeSettingsManager().getValue("barcodeSounds", true) as bool; | ||||
|  | ||||
|       if (en) { | ||||
|         final player = AudioCache(); | ||||
|         player.play("sounds/barcode_scan.mp3"); | ||||
|       } | ||||
|     if (en) { | ||||
|       final player = AudioCache(); | ||||
|       player.play("sounds/barcode_scan.mp3"); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|     Future <void> failureTone() async { | ||||
|  | ||||
| @@ -266,10 +266,10 @@ class StockItemBarcodeAssignmentHandler extends BarcodeHandler { | ||||
|    * Barcode handler for assigning a new barcode to a stock item | ||||
|    */ | ||||
|  | ||||
|   final InvenTreeStockItem item; | ||||
|  | ||||
|   StockItemBarcodeAssignmentHandler(this.item); | ||||
|  | ||||
|   final InvenTreeStockItem item; | ||||
|  | ||||
|   @override | ||||
|   String getOverlayText(BuildContext context) => L10().barcodeScanAssign; | ||||
|  | ||||
| @@ -334,10 +334,10 @@ class StockItemScanIntoLocationHandler extends BarcodeHandler { | ||||
|    * Barcode handler for scanning a provided StockItem into a scanned StockLocation | ||||
|    */ | ||||
|  | ||||
|   final InvenTreeStockItem item; | ||||
|  | ||||
|   StockItemScanIntoLocationHandler(this.item); | ||||
|  | ||||
|   final InvenTreeStockItem item; | ||||
|  | ||||
|   @override | ||||
|   String getOverlayText(BuildContext context) => L10().barcodeScanLocation; | ||||
|  | ||||
| @@ -396,11 +396,11 @@ class StockLocationScanInItemsHandler extends BarcodeHandler { | ||||
|   /* | ||||
|    * Barcode handler for scanning stock item(s) into the specified StockLocation | ||||
|    */ | ||||
|    | ||||
|   final InvenTreeStockLocation location; | ||||
|    | ||||
|  | ||||
|   StockLocationScanInItemsHandler(this.location); | ||||
|    | ||||
|  | ||||
|   final InvenTreeStockLocation location; | ||||
|  | ||||
|   @override | ||||
|   String getOverlayText(BuildContext context) => L10().barcodeScanItem; | ||||
|  | ||||
| @@ -466,10 +466,10 @@ class StockLocationScanInItemsHandler extends BarcodeHandler { | ||||
|  | ||||
| class InvenTreeQRView extends StatefulWidget { | ||||
|  | ||||
|   final BarcodeHandler _handler; | ||||
|  | ||||
|   const InvenTreeQRView(this._handler, {Key? key}) : super(key: key); | ||||
|  | ||||
|   final BarcodeHandler _handler; | ||||
|  | ||||
|   @override | ||||
|   State<StatefulWidget> createState() => _QRViewState(_handler); | ||||
| } | ||||
| @@ -477,6 +477,8 @@ class InvenTreeQRView extends StatefulWidget { | ||||
|  | ||||
| class _QRViewState extends State<InvenTreeQRView> { | ||||
|  | ||||
|   _QRViewState(this._handler) : super(); | ||||
|  | ||||
|   final GlobalKey qrKey = GlobalKey(debugLabel: "QR"); | ||||
|  | ||||
|   QRViewController? _controller; | ||||
| @@ -496,8 +498,6 @@ class _QRViewState extends State<InvenTreeQRView> { | ||||
|     _controller!.resumeCamera(); | ||||
|   } | ||||
|  | ||||
|   _QRViewState(this._handler) : super(); | ||||
|  | ||||
|   void _onViewCreated(BuildContext context, QRViewController controller) { | ||||
|     _controller = controller; | ||||
|     controller.scannedDataStream.listen((barcode) { | ||||
|   | ||||
| @@ -10,6 +10,8 @@ class InvenTreeCompany extends InvenTreeModel { | ||||
|  | ||||
|   InvenTreeCompany() : super(); | ||||
|  | ||||
|   InvenTreeCompany.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   String get URL => "company/"; | ||||
|  | ||||
| @@ -42,8 +44,6 @@ class InvenTreeCompany extends InvenTreeModel { | ||||
|  | ||||
|   bool get isCustomer => (jsondata["is_customer"] ?? false) as bool; | ||||
|  | ||||
|   InvenTreeCompany.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   InvenTreeModel createFromJson(Map<String, dynamic> json) { | ||||
|     var company = InvenTreeCompany.fromJson(json); | ||||
| @@ -57,6 +57,11 @@ class InvenTreeCompany extends InvenTreeModel { | ||||
|  * The InvenTreeSupplierPart class represents the SupplierPart model in the InvenTree database | ||||
|  */ | ||||
| class InvenTreeSupplierPart extends InvenTreeModel { | ||||
|  | ||||
|   InvenTreeSupplierPart() : super(); | ||||
|  | ||||
|   InvenTreeSupplierPart.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   String get URL => "company/part/"; | ||||
|  | ||||
| @@ -78,10 +83,6 @@ class InvenTreeSupplierPart extends InvenTreeModel { | ||||
|     return _filters(); | ||||
|   } | ||||
|  | ||||
|   InvenTreeSupplierPart() : super(); | ||||
|  | ||||
|   InvenTreeSupplierPart.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   int get manufacturerId => (jsondata["manufacturer"] ?? -1) as int; | ||||
|  | ||||
|   String get manufacturerName => (jsondata["manufacturer_detail"]["name"] ?? "") as String; | ||||
| @@ -117,6 +118,10 @@ class InvenTreeSupplierPart extends InvenTreeModel { | ||||
|  | ||||
| class InvenTreeManufacturerPart extends InvenTreeModel { | ||||
|  | ||||
|   InvenTreeManufacturerPart() : super(); | ||||
|  | ||||
|   InvenTreeManufacturerPart.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   String url = "company/part/manufacturer/"; | ||||
|  | ||||
| @@ -127,10 +132,6 @@ class InvenTreeManufacturerPart extends InvenTreeModel { | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   InvenTreeManufacturerPart() : super(); | ||||
|  | ||||
|   InvenTreeManufacturerPart.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   int get partId => (jsondata["part"] ?? -1) as int; | ||||
|  | ||||
|   int get manufacturerId => (jsondata["manufacturer"] ?? -1) as int; | ||||
|   | ||||
| @@ -39,6 +39,11 @@ class InvenTreePageResponse { | ||||
|  */ | ||||
| class InvenTreeModel { | ||||
|  | ||||
|   InvenTreeModel(); | ||||
|  | ||||
|   // Construct an InvenTreeModel from a JSON data object | ||||
|   InvenTreeModel.fromJson(this.jsondata); | ||||
|  | ||||
|   // Override the endpoint URL for each subclass | ||||
|   String get URL => ""; | ||||
|  | ||||
| @@ -115,19 +120,6 @@ class InvenTreeModel { | ||||
|   // Accessor for the API | ||||
|   var api = InvenTreeAPI(); | ||||
|  | ||||
|   // Default empty object constructor | ||||
|   InvenTreeModel() { | ||||
|     jsondata.clear(); | ||||
|   } | ||||
|  | ||||
|   // Construct an InvenTreeModel from a JSON data object | ||||
|   InvenTreeModel.fromJson(Map<String, dynamic> json) { | ||||
|  | ||||
|     // Store the json object | ||||
|     jsondata = json; | ||||
|  | ||||
|   } | ||||
|  | ||||
|   int get pk => (jsondata["pk"] ?? -1) as int; | ||||
|  | ||||
|   // Some common accessors | ||||
| @@ -185,10 +177,14 @@ class InvenTreeModel { | ||||
|  | ||||
|   } | ||||
|  | ||||
|   Map<String, String> defaultListFilters() { return Map<String, String>(); } | ||||
|   Map<String, String> defaultListFilters() { | ||||
|     return {}; | ||||
|   } | ||||
|  | ||||
|   // A map of "default" headers to use when performing a GET request | ||||
|   Map<String, String> defaultGetFilters() { return Map<String, String>(); } | ||||
|   Map<String, String> defaultGetFilters() { | ||||
|     return {}; | ||||
|   } | ||||
|  | ||||
|   /* | ||||
|    * Reload this object, by requesting data from the server | ||||
| @@ -357,7 +353,7 @@ class InvenTreeModel { | ||||
|     } | ||||
|  | ||||
|     // Construct the response | ||||
|     InvenTreePageResponse page = new InvenTreePageResponse(); | ||||
|     InvenTreePageResponse page = InvenTreePageResponse(); | ||||
|  | ||||
|     var data = response.asMap(); | ||||
|  | ||||
| @@ -458,9 +454,10 @@ class InvenTreeModel { | ||||
|  | ||||
| class InvenTreeAttachment extends InvenTreeModel { | ||||
|   // Class representing an "attachment" file | ||||
|  | ||||
|   InvenTreeAttachment() : super(); | ||||
|  | ||||
|   InvenTreeAttachment.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   String get attachment => (jsondata["attachment"] ?? "") as String; | ||||
|  | ||||
|   // Return the filename of the attachment | ||||
| @@ -509,8 +506,6 @@ class InvenTreeAttachment extends InvenTreeModel { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   InvenTreeAttachment.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   Future<bool> uploadAttachment(File attachment, {String comment = "", Map<String, String> fields = const {}}) async { | ||||
|  | ||||
|     final APIResponse response = await InvenTreeAPI().uploadFile( | ||||
|   | ||||
| @@ -10,6 +10,10 @@ import "model.dart"; | ||||
|  | ||||
| class InvenTreePartCategory extends InvenTreeModel { | ||||
|  | ||||
|   InvenTreePartCategory() : super(); | ||||
|  | ||||
|   InvenTreePartCategory.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   String get URL => "part/category/"; | ||||
|  | ||||
| @@ -25,12 +29,11 @@ class InvenTreePartCategory extends InvenTreeModel { | ||||
|  | ||||
|   @override | ||||
|   Map<String, String> defaultListFilters() { | ||||
|     var filters = new Map<String, String>(); | ||||
|  | ||||
|     filters["active"] = "true"; | ||||
|     filters["cascade"] = "false"; | ||||
|  | ||||
|     return filters; | ||||
|     return { | ||||
|       "active": "true", | ||||
|       "cascade": "false" | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   String get pathstring => (jsondata["pathstring"] ?? "") as String; | ||||
| @@ -54,10 +57,6 @@ class InvenTreePartCategory extends InvenTreeModel { | ||||
|  | ||||
|   int get partcount => (jsondata["parts"] ?? 0) as int; | ||||
|  | ||||
|   InvenTreePartCategory() : super(); | ||||
|  | ||||
|   InvenTreePartCategory.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   InvenTreeModel createFromJson(Map<String, dynamic> json) { | ||||
|     var cat = InvenTreePartCategory.fromJson(json); | ||||
| @@ -71,6 +70,10 @@ class InvenTreePartCategory extends InvenTreeModel { | ||||
|  | ||||
| class InvenTreePartTestTemplate extends InvenTreeModel { | ||||
|  | ||||
|   InvenTreePartTestTemplate() : super(); | ||||
|  | ||||
|   InvenTreePartTestTemplate.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   String get URL => "part/test-template/"; | ||||
|  | ||||
| @@ -84,10 +87,6 @@ class InvenTreePartTestTemplate extends InvenTreeModel { | ||||
|  | ||||
|   bool get requiresAttachment => (jsondata["requires_attachment"] ?? false) as bool; | ||||
|  | ||||
|   InvenTreePartTestTemplate() : super(); | ||||
|  | ||||
|   InvenTreePartTestTemplate.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   InvenTreeModel createFromJson(Map<String, dynamic> json) { | ||||
|     var template = InvenTreePartTestTemplate.fromJson(json); | ||||
| @@ -123,6 +122,10 @@ class InvenTreePartTestTemplate extends InvenTreeModel { | ||||
|  | ||||
| class InvenTreePart extends InvenTreeModel { | ||||
|  | ||||
|   InvenTreePart() : super(); | ||||
|  | ||||
|   InvenTreePart.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   String get URL => "part/"; | ||||
|  | ||||
| @@ -377,12 +380,6 @@ class InvenTreePart extends InvenTreeModel { | ||||
|     // Return the "starred" status of this part | ||||
|     bool get starred => (jsondata["starred"] ?? false) as bool; | ||||
|  | ||||
|     InvenTreePart() : super(); | ||||
|  | ||||
|   InvenTreePart.fromJson(Map<String, dynamic> json) : super.fromJson(json) { | ||||
|     // TODO | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   InvenTreeModel createFromJson(Map<String, dynamic> json) { | ||||
|  | ||||
| @@ -397,11 +394,11 @@ class InvenTreePartAttachment extends InvenTreeAttachment { | ||||
|  | ||||
|   InvenTreePartAttachment() : super(); | ||||
|  | ||||
|   InvenTreePartAttachment.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   String get URL => "part/attachment/"; | ||||
|  | ||||
|   InvenTreePartAttachment.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   InvenTreeModel createFromJson(Map<String, dynamic> json) { | ||||
|     return InvenTreePartAttachment.fromJson(json); | ||||
|   | ||||
| @@ -13,6 +13,10 @@ const int PO_STATUS_RETURNED = 60; | ||||
|  | ||||
| class InvenTreePurchaseOrder extends InvenTreeModel { | ||||
|  | ||||
|   InvenTreePurchaseOrder() : super(); | ||||
|  | ||||
|   InvenTreePurchaseOrder.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   String get URL => "order/po/"; | ||||
|  | ||||
| @@ -28,8 +32,6 @@ class InvenTreePurchaseOrder extends InvenTreeModel { | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   InvenTreePurchaseOrder() : super(); | ||||
|  | ||||
|   @override | ||||
|   Map<String, String> defaultGetFilters() { | ||||
|     return { | ||||
| @@ -102,8 +104,6 @@ class InvenTreePurchaseOrder extends InvenTreeModel { | ||||
|     return items; | ||||
|   } | ||||
|  | ||||
|   InvenTreePurchaseOrder.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   InvenTreeModel createFromJson(Map<String, dynamic> json) { | ||||
|     return InvenTreePurchaseOrder.fromJson(json); | ||||
| @@ -111,6 +111,11 @@ class InvenTreePurchaseOrder extends InvenTreeModel { | ||||
| } | ||||
|  | ||||
| class InvenTreePOLineItem extends InvenTreeModel { | ||||
|  | ||||
|   InvenTreePOLineItem() : super(); | ||||
|  | ||||
|   InvenTreePOLineItem.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   String get URL => "order/po-line/"; | ||||
|  | ||||
| @@ -189,11 +194,6 @@ class InvenTreePOLineItem extends InvenTreeModel { | ||||
|  | ||||
|   Map<String, dynamic> get destinationDetail => (jsondata["destination_detail"] ?? {}) as Map<String, dynamic>; | ||||
|  | ||||
|   InvenTreePOLineItem() : super(); | ||||
|  | ||||
|   InvenTreePOLineItem.fromJson(Map<String, dynamic> json) | ||||
|       : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   InvenTreeModel createFromJson(Map<String, dynamic> json) { | ||||
|     return InvenTreePOLineItem.fromJson(json); | ||||
|   | ||||
| @@ -12,6 +12,10 @@ import "package:inventree/api.dart"; | ||||
|  | ||||
| class InvenTreeStockItemTestResult extends InvenTreeModel { | ||||
|  | ||||
|   InvenTreeStockItemTestResult() : super(); | ||||
|  | ||||
|   InvenTreeStockItemTestResult.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   String get URL => "stock/test/"; | ||||
|  | ||||
| @@ -41,10 +45,6 @@ class InvenTreeStockItemTestResult extends InvenTreeModel { | ||||
|  | ||||
|   String get date => (jsondata["date"] ?? "") as String; | ||||
|  | ||||
|   InvenTreeStockItemTestResult() : super(); | ||||
|  | ||||
|   InvenTreeStockItemTestResult.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   InvenTreeStockItemTestResult createFromJson(Map<String, dynamic> json) { | ||||
|     var result = InvenTreeStockItemTestResult.fromJson(json); | ||||
| @@ -56,6 +56,10 @@ class InvenTreeStockItemTestResult extends InvenTreeModel { | ||||
|  | ||||
| class InvenTreeStockItem extends InvenTreeModel { | ||||
|  | ||||
|   InvenTreeStockItem() : super(); | ||||
|  | ||||
|   InvenTreeStockItem.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   // Stock status codes | ||||
|   static const int OK = 10; | ||||
|   static const int ATTENTION = 50; | ||||
| @@ -128,33 +132,23 @@ class InvenTreeStockItem extends InvenTreeModel { | ||||
|   @override | ||||
|   Map<String, String> defaultGetFilters() { | ||||
|  | ||||
|     var headers = new Map<String, String>(); | ||||
|  | ||||
|     headers["part_detail"] = "true"; | ||||
|     headers["location_detail"] = "true"; | ||||
|     headers["supplier_detail"] = "true"; | ||||
|     headers["cascade"] = "false"; | ||||
|  | ||||
|     return headers; | ||||
|     return { | ||||
|       "part_detail": "true", | ||||
|       "location_detail": "true", | ||||
|       "supplier_detail": "true", | ||||
|       "cascade": "false" | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   Map<String, String> defaultListFilters() { | ||||
|  | ||||
|     var headers = new Map<String, String>(); | ||||
|  | ||||
|     headers["part_detail"] = "true"; | ||||
|     headers["location_detail"] = "true"; | ||||
|     headers["supplier_detail"] = "true"; | ||||
|     headers["cascade"] = "false"; | ||||
|  | ||||
|     return headers; | ||||
|   } | ||||
|  | ||||
|   InvenTreeStockItem() : super(); | ||||
|  | ||||
|   InvenTreeStockItem.fromJson(Map<String, dynamic> json) : super.fromJson(json) { | ||||
|     // TODO | ||||
|     return { | ||||
|       "part_detail": "true", | ||||
|       "location_detail": "true", | ||||
|       "supplier_detail": "true", | ||||
|       "cascade": "false" | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   List<InvenTreePartTestTemplate> testTemplates = []; | ||||
| @@ -533,6 +527,10 @@ class InvenTreeStockItem extends InvenTreeModel { | ||||
|  | ||||
| class InvenTreeStockLocation extends InvenTreeModel { | ||||
|  | ||||
|   InvenTreeStockLocation() : super(); | ||||
|  | ||||
|   InvenTreeStockLocation.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   String get URL => "stock/location/"; | ||||
|  | ||||
| @@ -566,10 +564,6 @@ class InvenTreeStockLocation extends InvenTreeModel { | ||||
|  | ||||
|   int get itemcount => (jsondata["items"] ?? 0) as int; | ||||
|  | ||||
|   InvenTreeStockLocation() : super(); | ||||
|  | ||||
|   InvenTreeStockLocation.fromJson(Map<String, dynamic> json) : super.fromJson(json); | ||||
|  | ||||
|   @override | ||||
|   InvenTreeModel createFromJson(Map<String, dynamic> json) { | ||||
|  | ||||
|   | ||||
| @@ -11,12 +11,12 @@ import "package:path/path.dart"; | ||||
|  */ | ||||
| class InvenTreePreferencesDB { | ||||
|  | ||||
|   InvenTreePreferencesDB._(); | ||||
|  | ||||
|   static final InvenTreePreferencesDB _singleton = InvenTreePreferencesDB._(); | ||||
|  | ||||
|   static InvenTreePreferencesDB get instance => _singleton; | ||||
|  | ||||
|   InvenTreePreferencesDB._(); | ||||
|  | ||||
|   Completer<Database> _dbOpenCompleter = Completer(); | ||||
|  | ||||
|   bool isOpen = false; | ||||
| @@ -56,6 +56,12 @@ class InvenTreePreferencesDB { | ||||
|  | ||||
| class InvenTreePreferences { | ||||
|  | ||||
|   factory InvenTreePreferences() { | ||||
|     return _api; | ||||
|   } | ||||
|  | ||||
|   InvenTreePreferences._internal(); | ||||
|  | ||||
|   /* The following settings are not stored to persistent storage, | ||||
|    * instead they are only used as "session preferences". | ||||
|    * They are kept here as a convenience only. | ||||
| @@ -74,11 +80,6 @@ class InvenTreePreferences { | ||||
|   bool expandStockList = true; | ||||
|  | ||||
|   // Ensure we only ever create a single instance of the preferences class | ||||
|   static final InvenTreePreferences _api = new InvenTreePreferences._internal(); | ||||
|   static final InvenTreePreferences _api = InvenTreePreferences._internal(); | ||||
|  | ||||
|   factory InvenTreePreferences() { | ||||
|     return _api; | ||||
|   } | ||||
|  | ||||
|   InvenTreePreferences._internal(); | ||||
| } | ||||
| @@ -12,10 +12,10 @@ import "package:inventree/l10.dart"; | ||||
|  | ||||
| class InvenTreeAboutWidget extends StatelessWidget { | ||||
|  | ||||
|   final PackageInfo info; | ||||
|  | ||||
|   const InvenTreeAboutWidget(this.info) : super(); | ||||
|  | ||||
|   final PackageInfo info; | ||||
|  | ||||
|   Future <void> _releaseNotes(BuildContext context) async { | ||||
|  | ||||
|     // Load release notes from external file | ||||
|   | ||||
| @@ -15,10 +15,10 @@ class InvenTreeAppSettingsWidget extends StatefulWidget { | ||||
|  | ||||
| class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> { | ||||
|  | ||||
|   final GlobalKey<_InvenTreeAppSettingsState> _settingsKey = GlobalKey<_InvenTreeAppSettingsState>(); | ||||
|  | ||||
|   _InvenTreeAppSettingsState(); | ||||
|  | ||||
|   final GlobalKey<_InvenTreeAppSettingsState> _settingsKey = GlobalKey<_InvenTreeAppSettingsState>(); | ||||
|  | ||||
|   bool barcodeSounds = true; | ||||
|   bool serverSounds = true; | ||||
|   bool partSubcategory = false; | ||||
|   | ||||
| @@ -17,14 +17,14 @@ class InvenTreeLoginSettingsWidget extends StatefulWidget { | ||||
|  | ||||
| class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> { | ||||
|  | ||||
|   final GlobalKey<_InvenTreeLoginSettingsState> _loginKey = GlobalKey<_InvenTreeLoginSettingsState>(); | ||||
|  | ||||
|   List<UserProfile> profiles = []; | ||||
|  | ||||
|   _InvenTreeLoginSettingsState() { | ||||
|     _reload(); | ||||
|   } | ||||
|  | ||||
|   final GlobalKey<_InvenTreeLoginSettingsState> _loginKey = GlobalKey<_InvenTreeLoginSettingsState>(); | ||||
|  | ||||
|   List<UserProfile> profiles = []; | ||||
|  | ||||
|   Future <void> _reload() async { | ||||
|  | ||||
|     profiles = await UserProfileDBManager().getAllProfiles(); | ||||
| @@ -237,21 +237,21 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> { | ||||
|  | ||||
| class ProfileEditWidget extends StatefulWidget { | ||||
|  | ||||
|   UserProfile? profile; | ||||
|  | ||||
|   ProfileEditWidget(this.profile) : super(); | ||||
|  | ||||
|   UserProfile? profile; | ||||
|  | ||||
|   @override | ||||
|   _ProfileEditState createState() => _ProfileEditState(profile); | ||||
| } | ||||
|  | ||||
| class _ProfileEditState extends State<ProfileEditWidget> { | ||||
|  | ||||
|   UserProfile? profile; | ||||
|  | ||||
|   _ProfileEditState(this.profile) : super(); | ||||
|  | ||||
|   final formKey = new GlobalKey<FormState>(); | ||||
|   UserProfile? profile; | ||||
|  | ||||
|   final formKey = GlobalKey<FormState>(); | ||||
|  | ||||
|   String name = ""; | ||||
|   String server = ""; | ||||
| @@ -359,7 +359,7 @@ class _ProfileEditState extends State<ProfileEditWidget> { | ||||
|  | ||||
|                     if (uri.hasScheme) { | ||||
|                       print("Scheme: ${uri.scheme}"); | ||||
|                       if (!(["http", "https"].contains(uri.scheme.toLowerCase()))) { | ||||
|                       if (!["http", "https"].contains(uri.scheme.toLowerCase())) { | ||||
|                         return L10().serverStart; | ||||
|                       } | ||||
|                     } else { | ||||
|   | ||||
| @@ -6,10 +6,10 @@ import "package:inventree/l10.dart"; | ||||
|  | ||||
| class ReleaseNotesWidget extends StatelessWidget { | ||||
|  | ||||
|   final String releaseNotes; | ||||
|  | ||||
|   const ReleaseNotesWidget(this.releaseNotes); | ||||
|  | ||||
|   final String releaseNotes; | ||||
|  | ||||
|   @override | ||||
|   Widget build (BuildContext context) { | ||||
|     return Scaffold( | ||||
| @@ -27,10 +27,10 @@ class ReleaseNotesWidget extends StatelessWidget { | ||||
|  | ||||
| class CreditsWidget extends StatelessWidget { | ||||
|  | ||||
|   final String credits; | ||||
|  | ||||
|   const CreditsWidget(this.credits); | ||||
|  | ||||
|   final String credits; | ||||
|  | ||||
|   @override | ||||
|   Widget build (BuildContext context) { | ||||
|     return Scaffold( | ||||
|   | ||||
| @@ -16,6 +16,15 @@ class UserProfile { | ||||
|     this.selected = false, | ||||
|   }); | ||||
|  | ||||
|   factory UserProfile.fromJson(int key, Map<String, dynamic> json, bool isSelected) => UserProfile( | ||||
|     key: key, | ||||
|     name: json["name"] as String, | ||||
|     server: json["server"] as String, | ||||
|     username: json["username"] as String, | ||||
|     password: json["password"] as String, | ||||
|     selected: isSelected, | ||||
|   ); | ||||
|  | ||||
|   // ID of the profile | ||||
|   int? key; | ||||
|  | ||||
| @@ -36,15 +45,6 @@ class UserProfile { | ||||
|   // User ID (will be provided by the server on log-in) | ||||
|   int user_id = -1; | ||||
|  | ||||
|   factory UserProfile.fromJson(int key, Map<String, dynamic> json, bool isSelected) => UserProfile( | ||||
|     key: key, | ||||
|     name: json["name"] as String, | ||||
|     server: json["server"] as String, | ||||
|     username: json["username"] as String, | ||||
|     password: json["password"] as String, | ||||
|     selected: isSelected, | ||||
|   ); | ||||
|  | ||||
|   Map<String, dynamic> toJson() => { | ||||
|     "name": name, | ||||
|     "server": server, | ||||
| @@ -62,7 +62,7 @@ class UserProfileDBManager { | ||||
|  | ||||
|   final store = StoreRef("profiles"); | ||||
|  | ||||
|   Future<Database> get _db async => await InvenTreePreferencesDB.instance.database; | ||||
|   Future<Database> get _db async => InvenTreePreferencesDB.instance.database; | ||||
|  | ||||
|   Future<bool> profileNameExists(String name) async { | ||||
|  | ||||
|   | ||||
| @@ -32,6 +32,7 @@ class CategoryDisplayWidget extends StatefulWidget { | ||||
|  | ||||
| class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> { | ||||
|  | ||||
|   _CategoryDisplayState(this.category); | ||||
|  | ||||
|   @override | ||||
|   String getAppBarTitle(BuildContext context) => L10().partCategory; | ||||
| @@ -74,8 +75,6 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> { | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   _CategoryDisplayState(this.category); | ||||
|  | ||||
|   // The local InvenTreePartCategory object | ||||
|   final InvenTreePartCategory? category; | ||||
|  | ||||
| @@ -350,10 +349,11 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> { | ||||
|  * Builder for displaying a list of PartCategory objects | ||||
|  */ | ||||
| class SubcategoryList extends StatelessWidget { | ||||
|   final List<InvenTreePartCategory> _categories; | ||||
|  | ||||
|   const SubcategoryList(this._categories); | ||||
|  | ||||
|   final List<InvenTreePartCategory> _categories; | ||||
|  | ||||
|   void _openCategory(BuildContext context, int pk) { | ||||
|  | ||||
|     // Attempt to load the sub-category. | ||||
| @@ -397,12 +397,12 @@ class SubcategoryList extends StatelessWidget { | ||||
|  | ||||
| class PaginatedPartList extends StatefulWidget { | ||||
|  | ||||
|   PaginatedPartList(this.filters, {this.onTotalChanged}); | ||||
|  | ||||
|   final Map<String, String> filters; | ||||
|  | ||||
|   Function(int)? onTotalChanged; | ||||
|  | ||||
|   PaginatedPartList(this.filters, {this.onTotalChanged}); | ||||
|  | ||||
|   @override | ||||
|   _PaginatedPartListState createState() => _PaginatedPartListState(filters, onTotalChanged); | ||||
| } | ||||
| @@ -410,6 +410,8 @@ class PaginatedPartList extends StatefulWidget { | ||||
|  | ||||
| class _PaginatedPartListState extends State<PaginatedPartList> { | ||||
|  | ||||
|   _PaginatedPartListState(this.filters, this.onTotalChanged); | ||||
|  | ||||
|   static const _pageSize = 25; | ||||
|  | ||||
|   String _searchTerm = ""; | ||||
| @@ -418,8 +420,6 @@ class _PaginatedPartListState extends State<PaginatedPartList> { | ||||
|  | ||||
|   final Map<String, String> filters; | ||||
|  | ||||
|   _PaginatedPartListState(this.filters, this.onTotalChanged); | ||||
|  | ||||
|   final PagingController<int, InvenTreePart> _pagingController = PagingController(firstPageKey: 0); | ||||
|  | ||||
|   @override | ||||
|   | ||||
| @@ -10,10 +10,10 @@ import "package:inventree/l10.dart"; | ||||
|  | ||||
| class CompanyDetailWidget extends StatefulWidget { | ||||
|  | ||||
|   final InvenTreeCompany company; | ||||
|  | ||||
|   const CompanyDetailWidget(this.company, {Key? key}) : super(key: key); | ||||
|  | ||||
|   final InvenTreeCompany company; | ||||
|  | ||||
|   @override | ||||
|   _CompanyDetailState createState() => _CompanyDetailState(company); | ||||
|  | ||||
|   | ||||
| @@ -13,10 +13,10 @@ import "package:font_awesome_flutter/font_awesome_flutter.dart"; | ||||
|  | ||||
| class InvenTreeDrawer extends StatelessWidget { | ||||
|  | ||||
|   final BuildContext context; | ||||
|  | ||||
|   const InvenTreeDrawer(this.context); | ||||
|  | ||||
|   final BuildContext context; | ||||
|  | ||||
|   void _closeDrawer() { | ||||
|     // Close the drawer | ||||
|     Navigator.of(context).pop(); | ||||
|   | ||||
| @@ -31,14 +31,14 @@ class InvenTreeHomePage extends StatefulWidget { | ||||
|  | ||||
| class _InvenTreeHomePageState extends State<InvenTreeHomePage> { | ||||
|  | ||||
|   final GlobalKey<_InvenTreeHomePageState> _homeKey = GlobalKey<_InvenTreeHomePageState>(); | ||||
|  | ||||
|   _InvenTreeHomePageState() : super() { | ||||
|  | ||||
|     // Initially load the profile and attempt server connection | ||||
|     _loadProfile(); | ||||
|   } | ||||
|  | ||||
|   final GlobalKey<_InvenTreeHomePageState> _homeKey = GlobalKey<_InvenTreeHomePageState>(); | ||||
|  | ||||
|   // Selected user profile | ||||
|   UserProfile? _profile; | ||||
|  | ||||
| @@ -266,7 +266,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> { | ||||
|       appBar: AppBar( | ||||
|         title: Text(L10().appTitle), | ||||
|       ), | ||||
|       drawer: new InvenTreeDrawer(context), | ||||
|       drawer: InvenTreeDrawer(context), | ||||
|       body: ListView( | ||||
|         physics: ClampingScrollPhysics(), | ||||
|         shrinkWrap: true, | ||||
|   | ||||
| @@ -31,6 +31,8 @@ class LocationDisplayWidget extends StatefulWidget { | ||||
|  | ||||
| class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> { | ||||
|  | ||||
|   _LocationDisplayState(this.location); | ||||
|  | ||||
|   final InvenTreeStockLocation? location; | ||||
|  | ||||
|   @override | ||||
| @@ -92,8 +94,6 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> { | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   _LocationDisplayState(this.location); | ||||
|  | ||||
|   List<InvenTreeStockLocation> _sublocations = []; | ||||
|  | ||||
|   String _locationFilter = ""; | ||||
| @@ -428,10 +428,11 @@ List<Widget> detailTiles() { | ||||
|  | ||||
|  | ||||
| class SublocationList extends StatelessWidget { | ||||
|   final List<InvenTreeStockLocation> _locations; | ||||
|  | ||||
|   const SublocationList(this._locations); | ||||
|  | ||||
|   final List<InvenTreeStockLocation> _locations; | ||||
|  | ||||
|   void _openLocation(BuildContext context, int pk) { | ||||
|  | ||||
|     InvenTreeStockLocation().get(pk).then((var loc) { | ||||
| @@ -475,10 +476,10 @@ class SublocationList extends StatelessWidget { | ||||
|  | ||||
| class PaginatedStockList extends StatefulWidget { | ||||
|  | ||||
|   final Map<String, String> filters; | ||||
|  | ||||
|   const PaginatedStockList(this.filters); | ||||
|  | ||||
|   final Map<String, String> filters; | ||||
|  | ||||
|   @override | ||||
|   _PaginatedStockListState createState() => _PaginatedStockListState(filters); | ||||
| } | ||||
| @@ -486,14 +487,14 @@ class PaginatedStockList extends StatefulWidget { | ||||
|  | ||||
| class _PaginatedStockListState extends State<PaginatedStockList> { | ||||
|  | ||||
|   _PaginatedStockListState(this.filters); | ||||
|  | ||||
|   static const _pageSize = 25; | ||||
|  | ||||
|   String _searchTerm = ""; | ||||
|  | ||||
|   final Map<String, String> filters; | ||||
|  | ||||
|   _PaginatedStockListState(this.filters); | ||||
|  | ||||
|   final PagingController<int, InvenTreeStockItem> _pagingController = PagingController(firstPageKey: 0); | ||||
|  | ||||
|   @override | ||||
|   | ||||
| @@ -5,14 +5,14 @@ import "package:inventree/l10.dart"; | ||||
|  | ||||
| class PaginatedSearchWidget extends StatelessWidget { | ||||
|  | ||||
|   PaginatedSearchWidget(this.controller, this.onChanged, this.results); | ||||
|  | ||||
|   Function onChanged; | ||||
|  | ||||
|   int results = 0; | ||||
|  | ||||
|   TextEditingController controller; | ||||
|  | ||||
|   PaginatedSearchWidget(this.controller, this.onChanged, this.results); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return ListTile( | ||||
|   | ||||
| @@ -34,10 +34,10 @@ class PartDetailWidget extends StatefulWidget { | ||||
|  | ||||
| class _PartDisplayState extends RefreshableState<PartDetailWidget> { | ||||
|  | ||||
|   InvenTreePart part; | ||||
|  | ||||
|   _PartDisplayState(this.part); | ||||
|  | ||||
|   InvenTreePart part; | ||||
|  | ||||
|   @override | ||||
|   String getAppBarTitle(BuildContext context) => L10().partDetails; | ||||
|  | ||||
|   | ||||
| @@ -10,10 +10,10 @@ import "package:inventree/l10.dart"; | ||||
|  | ||||
| class PartNotesWidget extends StatefulWidget { | ||||
|  | ||||
|   final InvenTreePart part; | ||||
|  | ||||
|   const PartNotesWidget(this.part, {Key? key}) : super(key: key); | ||||
|  | ||||
|   final InvenTreePart part; | ||||
|  | ||||
|   @override | ||||
|   _PartNotesState createState() => _PartNotesState(part); | ||||
| } | ||||
| @@ -21,10 +21,10 @@ class PartNotesWidget extends StatefulWidget { | ||||
|  | ||||
| class _PartNotesState extends RefreshableState<PartNotesWidget> { | ||||
|  | ||||
|   final InvenTreePart part; | ||||
|  | ||||
|   _PartNotesState(this.part); | ||||
|  | ||||
|   final InvenTreePart part; | ||||
|  | ||||
|   @override | ||||
|   Future<void> request() async { | ||||
|     await part.reload(); | ||||
|   | ||||
| @@ -17,18 +17,6 @@ import "package:inventree/api.dart"; | ||||
|  | ||||
| class PartSearchDelegate extends SearchDelegate<InvenTreePart?> { | ||||
|  | ||||
|   final partSearchKey = GlobalKey<ScaffoldState>(); | ||||
|  | ||||
|   BuildContext context; | ||||
|  | ||||
|   // What did we search for last time? | ||||
|   String _cachedQuery = ""; | ||||
|  | ||||
|   bool _searching = false; | ||||
|  | ||||
|   // Custom filters for the part search | ||||
|   Map<String, String> _filters = {}; | ||||
|  | ||||
|   PartSearchDelegate(this.context, {Map<String, String> filters = const {}}) { | ||||
|  | ||||
|     // Copy filter values | ||||
| @@ -42,6 +30,18 @@ class PartSearchDelegate extends SearchDelegate<InvenTreePart?> { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   final partSearchKey = GlobalKey<ScaffoldState>(); | ||||
|  | ||||
|   BuildContext context; | ||||
|  | ||||
|   // What did we search for last time? | ||||
|   String _cachedQuery = ""; | ||||
|  | ||||
|   bool _searching = false; | ||||
|  | ||||
|   // Custom filters for the part search | ||||
|   Map<String, String> _filters = {}; | ||||
|  | ||||
|   @override | ||||
|   String get searchFieldLabel => L10().searchParts; | ||||
|  | ||||
| @@ -207,17 +207,6 @@ class PartSearchDelegate extends SearchDelegate<InvenTreePart?> { | ||||
|  | ||||
| class StockSearchDelegate extends SearchDelegate<InvenTreeStockItem?> { | ||||
|  | ||||
|   final stockSearchKey = GlobalKey<ScaffoldState>(); | ||||
|  | ||||
|   final BuildContext context; | ||||
|  | ||||
|   String _cachedQuery = ""; | ||||
|  | ||||
|   bool _searching = false; | ||||
|  | ||||
|   // Custom filters for the stock item search | ||||
|   Map<String, String> _filters = {}; | ||||
|  | ||||
|   StockSearchDelegate(this.context, {Map<String, String> filters = const {}}) { | ||||
|  | ||||
|     // Copy filter values | ||||
| @@ -231,6 +220,17 @@ class StockSearchDelegate extends SearchDelegate<InvenTreeStockItem?> { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   final stockSearchKey = GlobalKey<ScaffoldState>(); | ||||
|  | ||||
|   final BuildContext context; | ||||
|  | ||||
|   String _cachedQuery = ""; | ||||
|  | ||||
|   bool _searching = false; | ||||
|  | ||||
|   // Custom filters for the stock item search | ||||
|   Map<String, String> _filters = {}; | ||||
|  | ||||
|   @override | ||||
|   String get searchFieldLabel => L10().searchStock; | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ import "package:font_awesome_flutter/font_awesome_flutter.dart"; | ||||
| import "package:inventree/app_colors.dart"; | ||||
|  | ||||
| class Spinner extends StatefulWidget { | ||||
|   final IconData? icon; | ||||
|   final Duration duration; | ||||
|   final Color color; | ||||
|  | ||||
|   const Spinner({ | ||||
|     this.color = COLOR_GRAY_LIGHT, | ||||
| @@ -16,6 +13,10 @@ class Spinner extends StatefulWidget { | ||||
|     this.duration = const Duration(milliseconds: 1800), | ||||
|   }) : super(key: key); | ||||
|  | ||||
|   final IconData? icon; | ||||
|   final Duration duration; | ||||
|   final Color color; | ||||
|  | ||||
|   @override | ||||
|   _SpinnerState createState() => _SpinnerState(); | ||||
| } | ||||
|   | ||||
| @@ -35,6 +35,8 @@ class StockDetailWidget extends StatefulWidget { | ||||
|  | ||||
| class _StockItemDisplayState extends RefreshableState<StockDetailWidget> { | ||||
|  | ||||
|   _StockItemDisplayState(this.item); | ||||
|  | ||||
|   @override | ||||
|   String getAppBarTitle(BuildContext context) => L10().stockItem; | ||||
|  | ||||
| @@ -46,8 +48,6 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> { | ||||
|   final _countStockKey = GlobalKey<FormState>(); | ||||
|   final _moveStockKey = GlobalKey<FormState>(); | ||||
|  | ||||
|   _StockItemDisplayState(this.item); | ||||
|  | ||||
|   @override | ||||
|   List<Widget> getAppBarActions(BuildContext context) { | ||||
|  | ||||
|   | ||||
| @@ -26,6 +26,8 @@ class StockItemTestResultsWidget extends StatefulWidget { | ||||
|  | ||||
| class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestResultsWidget> { | ||||
|  | ||||
|   _StockItemTestResultDisplayState(this.item); | ||||
|  | ||||
|   @override | ||||
|   String getAppBarTitle(BuildContext context) => L10().testResults; | ||||
|  | ||||
| @@ -49,8 +51,6 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes | ||||
|  | ||||
|   final InvenTreeStockItem item; | ||||
|  | ||||
|   _StockItemTestResultDisplayState(this.item); | ||||
|  | ||||
|   Future <void> addTestResult(BuildContext context, {String name = "", bool nameIsEditable = true, bool result = false, String value = "", bool valueRequired = false, bool attachmentRequired = false}) async  { | ||||
|  | ||||
|     InvenTreeStockItemTestResult().createForm( | ||||
|   | ||||
| @@ -12,10 +12,10 @@ import "package:inventree/api.dart"; | ||||
|  | ||||
| class StockNotesWidget extends StatefulWidget { | ||||
|  | ||||
|   final InvenTreeStockItem item; | ||||
|  | ||||
|   const StockNotesWidget(this.item, {Key? key}) : super(key: key); | ||||
|  | ||||
|   final InvenTreeStockItem item; | ||||
|  | ||||
|   @override | ||||
|   _StockNotesState createState() => _StockNotesState(item); | ||||
| } | ||||
| @@ -23,10 +23,10 @@ class StockNotesWidget extends StatefulWidget { | ||||
|  | ||||
| class _StockNotesState extends RefreshableState<StockNotesWidget> { | ||||
|  | ||||
|   final InvenTreeStockItem item; | ||||
|  | ||||
|   _StockNotesState(this.item); | ||||
|  | ||||
|   final InvenTreeStockItem item; | ||||
|  | ||||
|   @override | ||||
|   String getAppBarTitle(BuildContext context) => L10().stockItemNotes; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user