2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 05:26:47 +00:00

Merge pull request #93 from inventree/pagination-fixes

Fix "related field" in API forms
This commit is contained in:
Oliver 2022-04-02 11:47:59 +11:00 committed by GitHub
commit 9c091fee21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View File

@ -558,6 +558,9 @@ class APIFormField {
popupItemBuilder: (context, item, isSelected) {
return _renderRelatedField(item, isSelected, true);
},
emptyBuilder: (context, item) {
return _renderEmptyResult();
},
onSaved: (item) {
if (item != null) {
data["value"] = item["pk"];
@ -650,9 +653,21 @@ class APIFormField {
subtitle: Text("Model '${model}' rendering not supported"),
);
}
}
// Construct a widget to instruct the user that no results were found
Widget _renderEmptyResult() {
return ListTile(
leading: FaIcon(FontAwesomeIcons.search),
title: Text(L10().noResults),
subtitle: Text(
L10().queryNoResults,
style: TextStyle(fontStyle: FontStyle.italic),
),
);
}
// Construct a string input element
Widget _constructString() {

View File

@ -170,7 +170,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
int pk = location?.pk ?? -1;
if (pk <= 0) {
if (location != null && pk <= 0) {
return;
}
@ -178,7 +178,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
context,
L10().stockItemCreate,
data: {
"location": pk,
"location": location != null ? pk : null,
},
onSuccess: (result) async {