diff --git a/lib/api_form.dart b/lib/api_form.dart index 88ffa885..4b496fe9 100644 --- a/lib/api_form.dart +++ b/lib/api_form.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:dropdown_search/dropdown_search.dart'; +import 'package:date_field/date_field.dart'; import 'package:inventree/api.dart'; import 'package:inventree/app_colors.dart'; @@ -167,6 +168,8 @@ class APIFormField { case "file upload": case "image upload": return _constructFileField(); + case "date": + return _constructDateField(); default: return ListTile( title: Text( @@ -179,6 +182,30 @@ class APIFormField { } } + // Field for displaying and selecting dates + Widget _constructDateField() { + + return DateTimeFormField( + mode: DateTimeFieldPickerMode.date, + decoration: InputDecoration( + helperText: helpText, + helperStyle: _helperStyle(), + labelText: label, + labelStyle: _labelStyle(), + ), + initialValue: DateTime.tryParse(value ?? ""), + autovalidateMode: AutovalidateMode.always, + validator: (e) { + // TODO + }, + onDateSelected: (DateTime dt) { + data['value'] = dt.toString().split(" ").first; + }, + ); + + } + + // Field for selecting and uploading files Widget _constructFileField() { @@ -418,6 +445,13 @@ class APIFormField { style: TextStyle(fontWeight: selected ? FontWeight.bold : FontWeight.normal), ) : null, ); + case "owner": + String name = item["name"] ?? ""; + bool isGroup = (item["label"] ?? "") == "group"; + return ListTile( + title: Text(name), + leading: FaIcon(isGroup ? FontAwesomeIcons.users : FontAwesomeIcons.user), + ); default: return ListTile( title: Text( diff --git a/lib/inventree/stock.dart b/lib/inventree/stock.dart index 795dbda7..ad743f8f 100644 --- a/lib/inventree/stock.dart +++ b/lib/inventree/stock.dart @@ -223,6 +223,8 @@ class InvenTreeStockItem extends InvenTreeModel { return pp.isNotEmpty && pp.trim() != "-"; } + int get purchaseOrderId => jsondata['purchase_order'] ?? -1; + int get trackingItemCount => (jsondata['tracking_items'] ?? 0) as int; // Date of last update diff --git a/pubspec.lock b/pubspec.lock index bf07cf78..6a5f06d6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -127,6 +127,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.3" + date_field: + dependency: "direct main" + description: + name: date_field + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" device_info_plus: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 35538e4c..f562a966 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -31,6 +31,7 @@ dependencies: sentry_flutter: 5.0.0 # Error reporting image_picker: ^0.8.3 # Select or take photos file_picker: ^4.0.0 # Select files from the device + date_field: ^2.1.2 # Date / time picker url_launcher: 6.0.9 # Open link in system browser open_file: 3.2.1 # Open local files flutter_markdown: ^0.6.2 # Rendering markdown