2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-08-07 04:52:08 +00:00

Add ability to edit Part object

This commit is contained in:
Oliver Walters
2020-04-18 23:18:53 +10:00
parent 8374691d8c
commit 16cdae42ed
4 changed files with 125 additions and 5 deletions

View File

@@ -126,6 +126,45 @@ class InvenTreeModel {
return true;
}
// POST data to update the model
Future<bool> update(BuildContext context, {Map<String, String> values}) async {
var addr = path.join(URL, pk.toString());
if (!addr.endsWith("/")) {
addr += "/";
}
showProgressDialog(context, "Updating ${NAME}", "Sending data to server");
var response = await api.patch(addr, body: values)
.timeout(Duration(seconds: 10))
.catchError((e) {
hideProgressDialog(context);
if (e is TimeoutException) {
showErrorDialog(context, "Timeout", "No response from server");
} else {
showErrorDialog(context, "Error", e.toString());
}
return null;
});
if (response == null) return false;
hideProgressDialog(context);
if (response.statusCode != 200) {
print("Error updating ${NAME}: Status code ${response.statusCode}");
return false;
}
return true;
}
// Return the detail view for the associated pk
Future<InvenTreeModel> get(BuildContext context, int pk, {Map<String, String> filters}) async {