2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 13:36:50 +00:00

Display error message when form submission returns error

This commit is contained in:
Oliver 2021-08-15 13:44:27 +10:00
parent cae6dd412c
commit 81602512a5
4 changed files with 13 additions and 5 deletions

View File

@ -4,9 +4,12 @@
### 0.4.4 - August 2021
---
- Add ability to create new Part Categories
- Add ability to create new Parts
- Add ability to create new Stock Locations
- App bar now always displays "back" button
- Display "batch code" information for stock item
- Display "packagin" information for stock item
- Display "packaging" information for stock item
### 0.4.3 - August 2021
---

View File

@ -540,7 +540,7 @@ class InvenTreeAPI {
* Perform a HTTP POST request
* Returns a json object (or null if unsuccessful)
*/
Future<APIResponse> post(String url, {Map<String, dynamic> body = const {}, int expectedStatusCode=201}) async {
Future<APIResponse> post(String url, {Map<String, dynamic> body = const {}, int? expectedStatusCode=201}) async {
HttpClientRequest? request = await apiRequest(url, "POST");
@ -763,7 +763,7 @@ class InvenTreeAPI {
* Perform a HTTP GET request
* Returns a json object (or null if did not complete)
*/
Future<APIResponse> get(String url, {Map<String, String> params = const {}, int expectedStatusCode=200}) async {
Future<APIResponse> get(String url, {Map<String, String> params = const {}, int? expectedStatusCode=200}) async {
HttpClientRequest? request = await apiRequest(
url,

View File

@ -597,12 +597,14 @@ class _APIFormWidgetState extends State<APIFormWidget> {
if (method == "POST") {
return await InvenTreeAPI().post(
url,
body: data
body: data,
expectedStatusCode: null
);
} else {
return await InvenTreeAPI().patch(
url,
body: data,
expectedStatusCode: null
);
}
@ -660,6 +662,10 @@ class _APIFormWidgetState extends State<APIFormWidget> {
return;
case 400:
// Form submission / validation error
showSnackIcon(
L10().error,
success: false
);
// Update field errors
for (var field in fields) {

View File

@ -1,6 +1,5 @@
import 'package:email_validator/email_validator.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';