2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-16 20:25:26 +00:00

API_Form: Allow customizable icon

- Also fixes for API search
This commit is contained in:
Oliver
2021-10-02 22:31:28 +10:00
parent 86584b366f
commit 2f8d02b0be
5 changed files with 53 additions and 28 deletions

View File

@ -118,7 +118,7 @@ class InvenTreeModel {
Map<String, dynamic> jsondata = {};
// Accessor for the API
InvenTreeAPI api = InvenTreeAPI();
InvenTreeAPI get api => InvenTreeAPI();
int get pk => (jsondata["pk"] ?? -1) as int;
@ -167,11 +167,19 @@ class InvenTreeModel {
String get url => "${URL}/${pk}/".replaceAll("//", "/");
// Search this Model type in the database
Future<List<InvenTreeModel>> search(BuildContext context, String searchTerm, {Map<String, String> filters = const {}}) async {
Future<List<InvenTreeModel>> search(String searchTerm, {Map<String, String> filters = const {}, int offset = 0, int limit = 25}) async {
filters["search"] = searchTerm;
Map<String, String> searchFilters = {};
final results = list(filters: filters);
for (String key in filters.keys) {
searchFilters[key] = filters[key] ?? "";
}
searchFilters["search"] = searchTerm;
searchFilters["offset"] = "${offset}";
searchFilters["limit"] = "${limit}";
final results = list(filters: searchFilters);
return results;