2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 21:46:46 +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

@ -6,6 +6,7 @@ import 'package:dropdown_search/dropdown_search.dart';
import 'package:inventree/api.dart'; import 'package:inventree/api.dart';
import 'package:inventree/app_colors.dart'; import 'package:inventree/app_colors.dart';
import 'package:inventree/inventree/part.dart'; import 'package:inventree/inventree/part.dart';
import 'package:inventree/inventree/stock.dart';
import 'package:inventree/widget/fields.dart'; import 'package:inventree/widget/fields.dart';
import 'package:inventree/l10.dart'; import 'package:inventree/l10.dart';
@ -261,6 +262,20 @@ class APIFormField {
style: TextStyle(fontWeight: selected ? FontWeight.bold : FontWeight.normal), style: TextStyle(fontWeight: selected ? FontWeight.bold : FontWeight.normal),
) : null, ) : 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: default:
return ListTile( return ListTile(
title: Text( title: Text(

View File

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