mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Add callback functions
This commit is contained in:
parent
faf20030e3
commit
27caf3983a
@ -137,7 +137,7 @@ Map<String, dynamic> extractFields(APIResponse response) {
|
|||||||
* @param method is the HTTP method to use to send the form data to the server (e.g. POST / PATCH)
|
* @param method is the HTTP method to use to send the form data to the server (e.g. POST / PATCH)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Future<void> launchApiForm(String title, String url, Map<String, dynamic> fields, {Map<String, dynamic> modelData = const {}, String method = "PATCH"}) async {
|
Future<void> launchApiForm(String title, String url, Map<String, dynamic> fields, {Map<String, dynamic> modelData = const {}, String method = "PATCH", Function? onSuccess, Function? onCancel}) async {
|
||||||
|
|
||||||
var options = await InvenTreeAPI().options(url);
|
var options = await InvenTreeAPI().options(url);
|
||||||
|
|
||||||
@ -225,6 +225,11 @@ Future<void> launchApiForm(String title, String url, Map<String, dynamic> fields
|
|||||||
case 201:
|
case 201:
|
||||||
// Form was validated by the server
|
// Form was validated by the server
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|
||||||
|
if (onSuccess != null) {
|
||||||
|
onSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 400:
|
case 400:
|
||||||
|
|
||||||
@ -255,6 +260,10 @@ Future<void> launchApiForm(String title, String url, Map<String, dynamic> fields
|
|||||||
child: Text(L10().cancel),
|
child: Text(L10().cancel),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|
||||||
|
if (onCancel != null) {
|
||||||
|
onCancel();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
// Save button
|
// Save button
|
||||||
|
@ -192,7 +192,8 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
},
|
},
|
||||||
"active": {},
|
"active": {},
|
||||||
},
|
},
|
||||||
modelData: part.jsondata
|
modelData: part.jsondata,
|
||||||
|
onSuccess: refresh,
|
||||||
);
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user