mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 11:36:24 +00:00
API_Form: Allow customizable icon
- Also fixes for API search
This commit is contained in:
parent
86584b366f
commit
2f8d02b0be
5 changed files with 53 additions and 28 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ class InvenTreePurchaseOrder extends InvenTreeModel {
|
|||
@override
|
||||
String get URL => "order/po/";
|
||||
|
||||
String get receive_url => "${url}receive/";
|
||||
|
||||
@override
|
||||
Map<String, dynamic> formFields() {
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue