mirror of
https://github.com/inventree/inventree-app.git
synced 2025-05-03 07:48:53 +00:00
Cleanup
This commit is contained in:
parent
c3e6d3f902
commit
bb73fb7400
@ -4,7 +4,7 @@ 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/api_form.dart";
|
import "package:inventree/api_form.dart";
|
||||||
import 'package:inventree/app_colors.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/model.dart";
|
||||||
@ -117,6 +117,7 @@ class PaginatedSearchState<T extends StatefulWidget> extends State<T> with BaseW
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Launch an interactive form for the user to select options
|
||||||
launchApiForm(
|
launchApiForm(
|
||||||
context,
|
context,
|
||||||
L10().filteringOptions,
|
L10().filteringOptions,
|
||||||
@ -174,18 +175,32 @@ class PaginatedSearchState<T extends StatefulWidget> extends State<T> with BaseW
|
|||||||
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}";
|
||||||
params["ordering"] = await orderingString;
|
|
||||||
|
// 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,
|
||||||
@ -226,6 +241,7 @@ class PaginatedSearchState<T extends StatefulWidget> extends State<T> with BaseW
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Callback function when the search term is updated
|
||||||
void updateSearchTerm() {
|
void updateSearchTerm() {
|
||||||
searchTerm = searchController.text;
|
searchTerm = searchController.text;
|
||||||
_pagingController.refresh();
|
_pagingController.refresh();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user