2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 10:15:32 +00:00

Edit StockLocation

This commit is contained in:
Oliver
2021-07-26 22:03:37 +10:00
parent bc713dfdcd
commit e8cb002e3c
2 changed files with 33 additions and 35 deletions

View File

@ -1,4 +1,5 @@
import 'package:inventree/api.dart';
import 'package:inventree/api_form.dart';
import 'package:inventree/app_settings.dart';
import 'package:inventree/barcode.dart';
import 'package:inventree/inventree/sentry.dart';
@ -71,7 +72,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
IconButton(
icon: FaIcon(FontAwesomeIcons.edit),
tooltip: L10().edit,
onPressed: _editLocationDialog,
onPressed: () { _editLocationDialog(context); },
)
);
}
@ -79,23 +80,27 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
return actions;
}
void _editLocation(Map<String, String> values) async {
void _editLocationDialog(BuildContext context) {
bool result = false;
final _loc = location;
if (location != null) {
result = await location!.update(values: values);
showSnackIcon(
result ? "Location edited" : "Location editing failed",
success: result
);
if (_loc == null) {
return;
}
refresh();
}
launchApiForm(
context,
L10().editLocation,
_loc.url,
{
"name": {},
"description": {},
"parent": {},
},
modelData: _loc.jsondata,
onSuccess: refresh
);
void _editLocationDialog() {
// Values which an be edited
var _name;
var _description;
@ -103,28 +108,6 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
if (location == null) {
return;
}
showFormDialog(L10().editLocation,
key: _editLocationKey,
callback: () {
_editLocation({
"name": _name,
"description": _description
});
},
fields: <Widget> [
StringField(
label: L10().name,
initial: location?.name ?? '',
onSaved: (value) => _name = value,
),
StringField(
label: L10().description,
initial: location?.description ?? '',
onSaved: (value) => _description = value,
)
]
);
}
_LocationDisplayState(this.location);