mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 03:26:24 +00:00
Stock history fix (#320)
* Improves quantity parsing from * Add paginated history widget * Refactor stock history widget as a paginated widget * Allow paginated result list to handle results returned as list - Some API endpoints (older ones most likely) don't paginate results correctly * Fix code layout * Render user information in "history" widget (not quantity) * Hide filter button * Update release notes * remove unused import
This commit is contained in:
parent
01a45568a0
commit
d926686a89
5 changed files with 116 additions and 63 deletions
|
|
@ -575,10 +575,12 @@ class InvenTreeModel {
|
|||
// Construct the response
|
||||
InvenTreePageResponse page = InvenTreePageResponse();
|
||||
|
||||
var data = response.asMap();
|
||||
var dataMap = response.asMap();
|
||||
|
||||
if (data.containsKey("count") && data.containsKey("results")) {
|
||||
page.count = (data["count"] ?? 0) as int;
|
||||
// First attempt is to look for paginated data, returned as a map
|
||||
|
||||
if (dataMap.isNotEmpty && dataMap.containsKey("count") && dataMap.containsKey("results")) {
|
||||
page.count = (dataMap["count"] ?? 0) as int;
|
||||
|
||||
page.results = [];
|
||||
|
||||
|
|
@ -587,15 +589,28 @@ class InvenTreeModel {
|
|||
}
|
||||
|
||||
return page;
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Second attempt is to look for a list of data (not paginated)
|
||||
var dataList = response.asList();
|
||||
|
||||
if (dataList.isNotEmpty) {
|
||||
page.count = dataList.length;
|
||||
page.results = [];
|
||||
|
||||
for (var result in dataList) {
|
||||
page.addResult(createFromJson(result as Map<String, dynamic>));
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
// Finally, no results available
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return list of objects from the database, with optional filters
|
||||
Future<List<InvenTreeModel>> list({Map<String, String> filters = const {}}) async {
|
||||
|
||||
var params = defaultListFilters();
|
||||
|
||||
for (String key in filters.keys) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue