mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-29 14:06:47 +00:00
commit
6a42bc0ec0
@ -1,6 +1,14 @@
|
|||||||
## InvenTree App Release Notes
|
## InvenTree App Release Notes
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### 0.8.0 - July 2022
|
||||||
|
---
|
||||||
|
|
||||||
|
- Display part variants in the part detail view
|
||||||
|
- Display Bill of Materials in the part detail view
|
||||||
|
- Indicate available quantity in stock detail view
|
||||||
|
- Adds configurable filtering to various list views
|
||||||
|
|
||||||
### 0.7.3 - June 2022
|
### 0.7.3 - June 2022
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -34,6 +34,9 @@ class InvenTreeBomItem extends InvenTreeModel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extract the 'reference' value associated with this BomItem
|
||||||
|
String get reference => (jsondata["reference"] ?? "") as String;
|
||||||
|
|
||||||
// Extract the 'quantity' value associated with this BomItem
|
// Extract the 'quantity' value associated with this BomItem
|
||||||
double get quantity => double.tryParse(jsondata["quantity"].toString()) ?? 0;
|
double get quantity => double.tryParse(jsondata["quantity"].toString()) ?? 0;
|
||||||
|
|
||||||
|
@ -294,6 +294,9 @@
|
|||||||
"feedbackSuccess": "Feedback submitted",
|
"feedbackSuccess": "Feedback submitted",
|
||||||
"@feedbackSuccess": {},
|
"@feedbackSuccess": {},
|
||||||
|
|
||||||
|
"filteringOptions": "Filtering Options",
|
||||||
|
"@filteringOptions": {},
|
||||||
|
|
||||||
"formatException": "Format Exception",
|
"formatException": "Format Exception",
|
||||||
"@formatException": {},
|
"@formatException": {},
|
||||||
|
|
||||||
@ -425,6 +428,9 @@
|
|||||||
"lastUpdated": "Last Updated",
|
"lastUpdated": "Last Updated",
|
||||||
"@lastUpdated": {},
|
"@lastUpdated": {},
|
||||||
|
|
||||||
|
"level": "Level",
|
||||||
|
"@level": {},
|
||||||
|
|
||||||
"lineItem": "Line Item",
|
"lineItem": "Line Item",
|
||||||
"@lineItem": {},
|
"@lineItem": {},
|
||||||
|
|
||||||
@ -685,6 +691,9 @@
|
|||||||
"receivedItem": "Received Stock Item",
|
"receivedItem": "Received Stock Item",
|
||||||
"@receivedItem": {},
|
"@receivedItem": {},
|
||||||
|
|
||||||
|
"reference": "Reference",
|
||||||
|
"@reference": {},
|
||||||
|
|
||||||
"refresh": "Refresh",
|
"refresh": "Refresh",
|
||||||
"@refresh": {},
|
"@refresh": {},
|
||||||
|
|
||||||
|
@ -1,9 +1,3 @@
|
|||||||
/*
|
|
||||||
* A generic widget for displaying a list of attachments.
|
|
||||||
*
|
|
||||||
* To allow use with different "types" of attachments,
|
|
||||||
* we pass a subclassed instance of the InvenTreeAttachment model.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import "dart:io";
|
import "dart:io";
|
||||||
|
|
||||||
@ -17,6 +11,12 @@ import "package:inventree/widget/refreshable_state.dart";
|
|||||||
import "package:inventree/l10.dart";
|
import "package:inventree/l10.dart";
|
||||||
import "package:url_launcher/url_launcher.dart";
|
import "package:url_launcher/url_launcher.dart";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A generic widget for displaying a list of attachments.
|
||||||
|
*
|
||||||
|
* To allow use with different "types" of attachments,
|
||||||
|
* we pass a subclassed instance of the InvenTreeAttachment model.
|
||||||
|
*/
|
||||||
class AttachmentWidget extends StatefulWidget {
|
class AttachmentWidget extends StatefulWidget {
|
||||||
|
|
||||||
const AttachmentWidget(this.attachment, this.referenceId, this.hasUploadPermission) : super();
|
const AttachmentWidget(this.attachment, this.referenceId, this.hasUploadPermission) : super();
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
|
import "package:flutter/material.dart";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A custom implementation of a "Back" button for display in the app drawer
|
* Construct a custom back button with special feature!
|
||||||
*
|
*
|
||||||
* Long-pressing on this will return the user to the home screen
|
* Long-pressing on this will return the user to the home screen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import "package:flutter/material.dart";
|
|
||||||
|
|
||||||
Widget backButton(BuildContext context, GlobalKey<ScaffoldState> key) {
|
Widget backButton(BuildContext context, GlobalKey<ScaffoldState> key) {
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
|
|
||||||
import "package:inventree/api.dart";
|
import "package:inventree/api.dart";
|
||||||
@ -16,25 +15,22 @@ import "package:inventree/widget/refreshable_state.dart";
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Widget for displaying a list of BomItems for the specified 'parent' Part instance
|
* Widget for displaying a Bill of Materials for a specified Part instance
|
||||||
*/
|
*/
|
||||||
class BomList extends StatefulWidget {
|
class BillOfMaterialsWidget extends StatefulWidget {
|
||||||
|
|
||||||
const BomList(this.parent);
|
const BillOfMaterialsWidget(this.part, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
final InvenTreePart parent;
|
final InvenTreePart part;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_BomListState createState() => _BomListState(parent);
|
_BillOfMaterialsState createState() => _BillOfMaterialsState(part);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _BillOfMaterialsState extends RefreshableState<BillOfMaterialsWidget> {
|
||||||
|
_BillOfMaterialsState(this.part);
|
||||||
|
|
||||||
class _BomListState extends RefreshableState<BomList> {
|
final InvenTreePart part;
|
||||||
|
|
||||||
_BomListState(this.parent);
|
|
||||||
|
|
||||||
final InvenTreePart parent;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String getAppBarTitle(BuildContext context) => L10().billOfMaterials;
|
String getAppBarTitle(BuildContext context) => L10().billOfMaterials;
|
||||||
@ -42,7 +38,7 @@ class _BomListState extends RefreshableState<BomList> {
|
|||||||
@override
|
@override
|
||||||
Widget getBody(BuildContext context) {
|
Widget getBody(BuildContext context) {
|
||||||
return PaginatedBomList({
|
return PaginatedBomList({
|
||||||
"part": parent.pk.toString(),
|
"part": part.pk.toString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,6 +58,7 @@ class PaginatedBomList extends StatefulWidget {
|
|||||||
@override
|
@override
|
||||||
_PaginatedBomListState createState() => _PaginatedBomListState(filters, onTotalChanged);
|
_PaginatedBomListState createState() => _PaginatedBomListState(filters, onTotalChanged);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,6 +68,15 @@ class _PaginatedBomListState extends PaginatedSearchState<PaginatedBomList> {
|
|||||||
|
|
||||||
Function(int)? onTotalChanged;
|
Function(int)? onTotalChanged;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get prefix => "bom_";
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, String> get orderingOptions => {
|
||||||
|
"quantity": L10().quantity,
|
||||||
|
"sub_part": L10().part,
|
||||||
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||||
|
|
||||||
@ -87,11 +93,10 @@ class _PaginatedBomListState extends PaginatedSearchState<PaginatedBomList> {
|
|||||||
InvenTreePart? subPart = bomItem.subPart;
|
InvenTreePart? subPart = bomItem.subPart;
|
||||||
|
|
||||||
String title = subPart?.fullname ?? "error - no name";
|
String title = subPart?.fullname ?? "error - no name";
|
||||||
String description = subPart?.description ?? "error - no description";
|
|
||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
subtitle: Text(description),
|
subtitle: Text(bomItem.reference),
|
||||||
trailing: Text(
|
trailing: Text(
|
||||||
simpleNumberString(bomItem.quantity),
|
simpleNumberString(bomItem.quantity),
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
@ -50,6 +50,15 @@ class _PaginatedPartCategoryListState extends PaginatedSearchState<PaginatedPart
|
|||||||
|
|
||||||
_PaginatedPartCategoryListState(Map<String, String> filters) : super(filters);
|
_PaginatedPartCategoryListState(Map<String, String> filters) : super(filters);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get prefix => "category_";
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, String> get orderingOptions => {
|
||||||
|
"name": L10().name,
|
||||||
|
"level": L10().level,
|
||||||
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Widget _listTile(BuildContext context, String label, IconData icon, {Function()? callback, String role = "", String permission = ""}) {
|
Widget _listTile(BuildContext context, String label, IconData icon, {Function()? callback, String role = "", String permission = "", Widget? trailing}) {
|
||||||
|
|
||||||
bool connected = InvenTreeAPI().isConnected();
|
bool connected = InvenTreeAPI().isConnected();
|
||||||
|
|
||||||
@ -211,6 +211,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
|||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: FaIcon(icon, color: connected && allowed ? COLOR_CLICK : Colors.grey),
|
leading: FaIcon(icon, color: connected && allowed ? COLOR_CLICK : Colors.grey),
|
||||||
title: Text(label),
|
title: Text(label),
|
||||||
|
trailing: trailing,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@ -257,7 +258,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
|||||||
FontAwesomeIcons.shapes,
|
FontAwesomeIcons.shapes,
|
||||||
callback: () {
|
callback: () {
|
||||||
_showParts(context);
|
_showParts(context);
|
||||||
}
|
},
|
||||||
));
|
));
|
||||||
|
|
||||||
// Starred parts
|
// Starred parts
|
||||||
|
@ -24,7 +24,7 @@ class _NotificationState extends RefreshableState<NotificationWidget> {
|
|||||||
List<InvenTreeNotification> notifications = [];
|
List<InvenTreeNotification> notifications = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
AppBar? buildAppBar(BuildContext context) {
|
AppBar? buildAppBar(BuildContext context, GlobalKey<ScaffoldState> key) {
|
||||||
// No app bar for the notification widget
|
// No app bar for the notification widget
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,24 @@ import "package:flutter/material.dart";
|
|||||||
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
||||||
import "package:infinite_scroll_pagination/infinite_scroll_pagination.dart";
|
import "package:infinite_scroll_pagination/infinite_scroll_pagination.dart";
|
||||||
|
|
||||||
import "package:inventree/inventree/model.dart";
|
import "package:inventree/api_form.dart";
|
||||||
import "package:inventree/inventree/sentry.dart";
|
import "package:inventree/app_colors.dart";
|
||||||
import "package:inventree/l10.dart";
|
import "package:inventree/l10.dart";
|
||||||
|
|
||||||
|
import "package:inventree/inventree/model.dart";
|
||||||
|
import "package:inventree/inventree/sentry.dart";
|
||||||
|
import "package:inventree/preferences.dart";
|
||||||
|
|
||||||
class PaginatedSearchState<T extends StatefulWidget> extends State<T> {
|
import "package:inventree/widget/refreshable_state.dart";
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generic stateful widget for displaying paginated data retrieved via the API
|
||||||
|
*
|
||||||
|
* - Can be displayed as "full screen" (with app-bar and drawer)
|
||||||
|
* - Can be displayed as a standalone widget
|
||||||
|
*/
|
||||||
|
class PaginatedSearchState<T extends StatefulWidget> extends State<T> with BaseWidgetProperties {
|
||||||
|
|
||||||
PaginatedSearchState(this.filters);
|
PaginatedSearchState(this.filters);
|
||||||
|
|
||||||
@ -16,11 +28,130 @@ class PaginatedSearchState<T extends StatefulWidget> extends State<T> {
|
|||||||
|
|
||||||
static const _pageSize = 25;
|
static const _pageSize = 25;
|
||||||
|
|
||||||
|
// Prefix for storing and loading pagination options
|
||||||
|
// Override in implementing class
|
||||||
|
String get prefix => "prefix_";
|
||||||
|
|
||||||
|
// Return a map of sorting options available for this list
|
||||||
|
// Should be overridden by an implementing subclass
|
||||||
|
Map<String, String> get orderingOptions => {};
|
||||||
|
|
||||||
|
// Return the selected ordering "field" for this list widget
|
||||||
|
Future<String> orderingField() async {
|
||||||
|
dynamic field = await InvenTreeSettingsManager().getValue("${prefix}ordering_field", null);
|
||||||
|
|
||||||
|
if (field != null && orderingOptions.containsKey(field.toString())) {
|
||||||
|
// A valid ordering field has been found
|
||||||
|
return field.toString();
|
||||||
|
} else if (orderingOptions.isNotEmpty) {
|
||||||
|
// By default, return the first specified key
|
||||||
|
return orderingOptions.keys.first;
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the selected ordering "order" ("+" or "-") for this list widget
|
||||||
|
Future<String> orderingOrder() async {
|
||||||
|
dynamic order = await InvenTreeSettingsManager().getValue("${prefix}ordering_order", "+");
|
||||||
|
|
||||||
|
return order == "+" ? "+" : "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return string for determining 'ordering' of paginated list
|
||||||
|
Future<String> get orderingString async {
|
||||||
|
dynamic field = await orderingField();
|
||||||
|
dynamic order = await orderingOrder();
|
||||||
|
|
||||||
|
// Return an empty string if no field is provided
|
||||||
|
if (field.toString().isEmpty) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "${order}${field}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the (configurable) filters for this paginated list
|
||||||
|
Future<void> _saveOrderingOptions(BuildContext context) async {
|
||||||
|
// Retrieve stored setting
|
||||||
|
dynamic _field = await orderingField();
|
||||||
|
dynamic _order = await orderingOrder();
|
||||||
|
|
||||||
|
// Construct the 'ordering' options
|
||||||
|
List<Map<String, dynamic>> _opts = [];
|
||||||
|
|
||||||
|
orderingOptions.forEach((k, v) => _opts.add({
|
||||||
|
"value": k.toString(),
|
||||||
|
"display_name": v.toString()
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (_field == null && _opts.isNotEmpty) {
|
||||||
|
_field = _opts.first["value"];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> fields = {
|
||||||
|
"ordering_field": {
|
||||||
|
"type": "choice",
|
||||||
|
"label": "Ordering Field",
|
||||||
|
"required": true,
|
||||||
|
"choices": _opts,
|
||||||
|
"value": _field,
|
||||||
|
},
|
||||||
|
"ordering_order": {
|
||||||
|
"type": "choice",
|
||||||
|
"label": "Ordering Direction",
|
||||||
|
"required": true,
|
||||||
|
"value": _order,
|
||||||
|
"choices": [
|
||||||
|
{
|
||||||
|
"value": "+",
|
||||||
|
"display_name": "Ascending",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "-",
|
||||||
|
"display_name": "Descending",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Launch an interactive form for the user to select options
|
||||||
|
launchApiForm(
|
||||||
|
context,
|
||||||
|
L10().filteringOptions,
|
||||||
|
"",
|
||||||
|
fields,
|
||||||
|
icon: FontAwesomeIcons.checkCircle,
|
||||||
|
onSuccess: (Map<String, dynamic> data) async {
|
||||||
|
|
||||||
|
// Extract data from the processed form
|
||||||
|
String f = (data["ordering_field"] ?? _field) as String;
|
||||||
|
String o = (data["ordering_order"] ?? _order) as String;
|
||||||
|
|
||||||
|
// Save values to settings
|
||||||
|
await InvenTreeSettingsManager().setValue("${prefix}ordering_field", f);
|
||||||
|
await InvenTreeSettingsManager().setValue("${prefix}ordering_order", o);
|
||||||
|
|
||||||
|
// Refresh data from the server
|
||||||
|
_pagingController.refresh();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Search query term
|
// Search query term
|
||||||
String searchTerm = "";
|
String searchTerm = "";
|
||||||
|
|
||||||
int resultCount = 0;
|
int resultCount = 0;
|
||||||
|
|
||||||
|
String resultsString() {
|
||||||
|
|
||||||
|
if (resultCount <= 0) {
|
||||||
|
return noResultsText;
|
||||||
|
} else {
|
||||||
|
return "${resultCount} ${L10().results}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Text controller
|
// Text controller
|
||||||
final TextEditingController searchController = TextEditingController();
|
final TextEditingController searchController = TextEditingController();
|
||||||
|
|
||||||
@ -42,18 +173,33 @@ class PaginatedSearchState<T extends StatefulWidget> extends State<T> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Custom function to request a single page of results from the server.
|
||||||
|
* Each implementing class must override this function,
|
||||||
|
* and return an InvenTreePageResponse object with the correct data format
|
||||||
|
*/
|
||||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||||
|
|
||||||
// Default implementation returns null - must be overridden
|
// Default implementation returns null - must be overridden
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Request a single page of results from the server
|
||||||
|
*/
|
||||||
Future<void> _fetchPage(int pageKey) async {
|
Future<void> _fetchPage(int pageKey) async {
|
||||||
try {
|
try {
|
||||||
Map<String, String> params = filters;
|
Map<String, String> params = filters;
|
||||||
|
|
||||||
|
// Include user search term
|
||||||
params["search"] = "${searchTerm}";
|
params["search"] = "${searchTerm}";
|
||||||
|
|
||||||
|
// Use custom query ordering if available
|
||||||
|
String o = await orderingString;
|
||||||
|
if (o.isNotEmpty) {
|
||||||
|
params["ordering"] = o;
|
||||||
|
}
|
||||||
|
|
||||||
final page = await requestPage(
|
final page = await requestPage(
|
||||||
_pageSize,
|
_pageSize,
|
||||||
pageKey,
|
pageKey,
|
||||||
@ -93,11 +239,14 @@ class PaginatedSearchState<T extends StatefulWidget> extends State<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Callback function when the search term is updated
|
||||||
void updateSearchTerm() {
|
void updateSearchTerm() {
|
||||||
searchTerm = searchController.text;
|
searchTerm = searchController.text;
|
||||||
_pagingController.refresh();
|
_pagingController.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to construct a single paginated item
|
||||||
|
// Must be overridden in an implementing subclass
|
||||||
Widget buildItem(BuildContext context, InvenTreeModel item) {
|
Widget buildItem(BuildContext context, InvenTreeModel item) {
|
||||||
|
|
||||||
// This method must be overridden by the child class
|
// This method must be overridden by the child class
|
||||||
@ -107,21 +256,23 @@ class PaginatedSearchState<T extends StatefulWidget> extends State<T> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return a string which is displayed when there are no results
|
||||||
|
// Can be overridden by an implementing subclass
|
||||||
String get noResultsText => L10().noResults;
|
String get noResultsText => L10().noResults;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build (BuildContext context) {
|
Widget build (BuildContext context) {
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
PaginatedSearchWidget(searchController, updateSearchTerm, resultCount),
|
buildSearchInput(context),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: ClampingScrollPhysics(),
|
physics: ClampingScrollPhysics(),
|
||||||
scrollDirection: Axis.vertical,
|
scrollDirection: Axis.vertical,
|
||||||
slivers: <Widget>[
|
slivers: <Widget>[
|
||||||
// TODO - Search input
|
|
||||||
PagedSliverList.separated(
|
PagedSliverList.separated(
|
||||||
pagingController: _pagingController,
|
pagingController: _pagingController,
|
||||||
builderDelegate: PagedChildBuilderDelegate<InvenTreeModel>(
|
builderDelegate: PagedChildBuilderDelegate<InvenTreeModel>(
|
||||||
@ -141,46 +292,42 @@ class PaginatedSearchState<T extends StatefulWidget> extends State<T> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
/*
|
||||||
|
* Construct a search input text field for the user to enter a search term
|
||||||
|
*/
|
||||||
class PaginatedSearchWidget extends StatelessWidget {
|
Widget buildSearchInput(BuildContext context) {
|
||||||
|
|
||||||
const PaginatedSearchWidget(this.controller, this.onChanged, this.results);
|
|
||||||
|
|
||||||
final Function onChanged;
|
|
||||||
|
|
||||||
final int results;
|
|
||||||
|
|
||||||
final TextEditingController controller;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: GestureDetector(
|
leading: orderingOptions.isEmpty ? null : GestureDetector(
|
||||||
child: FaIcon(controller.text.isEmpty ? FontAwesomeIcons.search : FontAwesomeIcons.backspace),
|
child: FaIcon(FontAwesomeIcons.sort, color: COLOR_CLICK),
|
||||||
|
onTap: () async {
|
||||||
|
_saveOrderingOptions(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
trailing: GestureDetector(
|
||||||
|
child: FaIcon(
|
||||||
|
searchController.text.isEmpty ? FontAwesomeIcons.search : FontAwesomeIcons.backspace,
|
||||||
|
color: searchController.text.isNotEmpty ? COLOR_DANGER : COLOR_CLICK,
|
||||||
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
controller.clear();
|
searchController.clear();
|
||||||
onChanged();
|
updateSearchTerm();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
title: TextFormField(
|
title: TextFormField(
|
||||||
controller: controller,
|
controller: searchController,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
onChanged();
|
updateSearchTerm();
|
||||||
},
|
},
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: L10().search,
|
hintText: L10().search,
|
||||||
|
helperText: resultsString(),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
trailing: Text(
|
|
||||||
"${results}",
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class NoResultsWidget extends StatelessWidget {
|
class NoResultsWidget extends StatelessWidget {
|
||||||
|
|
||||||
const NoResultsWidget(this.description);
|
const NoResultsWidget(this.description);
|
||||||
|
@ -354,7 +354,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => BomList(part)
|
builder: (context) => BillOfMaterialsWidget(part)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,16 @@ class _PaginatedPartListState extends PaginatedSearchState<PaginatedPartList> {
|
|||||||
|
|
||||||
Function(int)? onTotalChanged;
|
Function(int)? onTotalChanged;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get prefix => "part_";
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, String> get orderingOptions => {
|
||||||
|
"name": L10().name,
|
||||||
|
"in_stock": L10().stock,
|
||||||
|
"IPN": L10().internalPartNumber,
|
||||||
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||||
|
|
||||||
|
@ -58,6 +58,17 @@ class _PaginatedPurchaseOrderListState extends PaginatedSearchState<PaginatedPur
|
|||||||
// Purchase order prefix
|
// Purchase order prefix
|
||||||
String _poPrefix = "";
|
String _poPrefix = "";
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get prefix => "po_";
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, String> get orderingOptions => {
|
||||||
|
"reference": L10().reference,
|
||||||
|
"supplier__name": L10().supplier,
|
||||||
|
"status": L10().status,
|
||||||
|
"target_date": L10().targetDate,
|
||||||
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||||
|
|
||||||
|
@ -3,7 +3,53 @@ import "package:inventree/widget/drawer.dart";
|
|||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
|
|
||||||
|
|
||||||
abstract class RefreshableState<T extends StatefulWidget> extends State<T> {
|
/*
|
||||||
|
* Simple mixin class which defines simple methods for defining widget properties
|
||||||
|
*/
|
||||||
|
mixin BaseWidgetProperties {
|
||||||
|
|
||||||
|
// Return a list of appBar actions (default = None)
|
||||||
|
List<Widget> getAppBarActions(BuildContext context) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return a title for the appBar
|
||||||
|
String getAppBarTitle(BuildContext context) { return "--- app bar ---"; }
|
||||||
|
|
||||||
|
// Function to construct a drawer (override if needed)
|
||||||
|
Widget getDrawer(BuildContext context) {
|
||||||
|
return InvenTreeDrawer(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to construct a body (MUST BE PROVIDED)
|
||||||
|
Widget getBody(BuildContext context) {
|
||||||
|
|
||||||
|
// Default return is an empty ListView
|
||||||
|
return ListView();
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget? getBottomNavBar(BuildContext context) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppBar? buildAppBar(BuildContext context, GlobalKey<ScaffoldState> key) {
|
||||||
|
return AppBar(
|
||||||
|
title: Text(getAppBarTitle(context)),
|
||||||
|
actions: getAppBarActions(context),
|
||||||
|
leading: backButton(context, key),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Abstract base class which provides generic "refresh" functionality.
|
||||||
|
*
|
||||||
|
* - Drag down and release to 'refresh' the widget
|
||||||
|
* - Define some method which runs to 'refresh' the widget state
|
||||||
|
*/
|
||||||
|
abstract class RefreshableState<T extends StatefulWidget> extends State<T> with BaseWidgetProperties {
|
||||||
|
|
||||||
final refreshableKey = GlobalKey<ScaffoldState>();
|
final refreshableKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
@ -25,12 +71,6 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getAppBarActions(BuildContext context) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
String getAppBarTitle(BuildContext context) { return "App Bar Title"; }
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -60,34 +100,6 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to construct a drawer (override if needed)
|
|
||||||
Widget getDrawer(BuildContext context) {
|
|
||||||
return InvenTreeDrawer(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to construct a body (MUST BE PROVIDED)
|
|
||||||
Widget getBody(BuildContext context) {
|
|
||||||
|
|
||||||
// Default return is an empty ListView
|
|
||||||
return ListView();
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget? getBottomNavBar(BuildContext context) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget? getFab(BuildContext context) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
AppBar? buildAppBar(BuildContext context) {
|
|
||||||
return AppBar(
|
|
||||||
title: Text(getAppBarTitle(context)),
|
|
||||||
actions: getAppBarActions(context),
|
|
||||||
leading: backButton(context, refreshableKey),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
@ -96,9 +108,8 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> {
|
|||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
key: refreshableKey,
|
key: refreshableKey,
|
||||||
appBar: buildAppBar(context),
|
appBar: buildAppBar(context, refreshableKey),
|
||||||
drawer: getDrawer(context),
|
drawer: getDrawer(context),
|
||||||
floatingActionButton: getFab(context),
|
|
||||||
body: Builder(
|
body: Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
|
@ -53,9 +53,9 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
|||||||
String getAppBarTitle(BuildContext context) => L10().search;
|
String getAppBarTitle(BuildContext context) => L10().search;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
AppBar? buildAppBar(BuildContext context) {
|
AppBar? buildAppBar(BuildContext context, GlobalKey<ScaffoldState> key) {
|
||||||
if (hasAppBar) {
|
if (hasAppBar) {
|
||||||
return super.buildAppBar(context);
|
return super.buildAppBar(context, key);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,20 @@ class _PaginatedStockItemListState extends PaginatedSearchState<PaginatedStockIt
|
|||||||
|
|
||||||
_PaginatedStockItemListState(Map<String, String> filters) : super(filters);
|
_PaginatedStockItemListState(Map<String, String> filters) : super(filters);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get prefix => "stock_";
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, String> get orderingOptions => {
|
||||||
|
"part__name": L10().name,
|
||||||
|
"part__IPN": L10().internalPartNumber,
|
||||||
|
"quantity": L10().quantity,
|
||||||
|
"status": L10().status,
|
||||||
|
"batch": L10().batchCode,
|
||||||
|
"updated": L10().lastUpdated,
|
||||||
|
"stocktake_date": L10().lastStocktake,
|
||||||
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user