mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Edit StockLocation
This commit is contained in:
parent
bc713dfdcd
commit
e8cb002e3c
@ -6,6 +6,7 @@ import 'package:dropdown_search/dropdown_search.dart';
|
||||
import 'package:inventree/api.dart';
|
||||
import 'package:inventree/app_colors.dart';
|
||||
import 'package:inventree/inventree/part.dart';
|
||||
import 'package:inventree/inventree/stock.dart';
|
||||
import 'package:inventree/widget/fields.dart';
|
||||
import 'package:inventree/l10.dart';
|
||||
|
||||
@ -261,6 +262,20 @@ class APIFormField {
|
||||
style: TextStyle(fontWeight: selected ? FontWeight.bold : FontWeight.normal),
|
||||
) : null,
|
||||
);
|
||||
case "stocklocation":
|
||||
|
||||
var loc = InvenTreeStockLocation.fromJson(item);
|
||||
|
||||
return ListTile(
|
||||
title: Text(
|
||||
loc.pathstring,
|
||||
style: TextStyle(fontWeight: selected && extended ? FontWeight.bold : FontWeight.normal)
|
||||
),
|
||||
subtitle: extended ? Text(
|
||||
loc.description,
|
||||
style: TextStyle(fontWeight: selected ? FontWeight.bold : FontWeight.normal),
|
||||
) : null,
|
||||
);
|
||||
default:
|
||||
return ListTile(
|
||||
title: Text(
|
||||
|
@ -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);
|
||||
if (_loc == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
showSnackIcon(
|
||||
result ? "Location edited" : "Location editing failed",
|
||||
success: result
|
||||
launchApiForm(
|
||||
context,
|
||||
L10().editLocation,
|
||||
_loc.url,
|
||||
{
|
||||
"name": {},
|
||||
"description": {},
|
||||
"parent": {},
|
||||
},
|
||||
modelData: _loc.jsondata,
|
||||
onSuccess: refresh
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user