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

Create a new stock location

This commit is contained in:
Oliver 2021-08-10 17:21:12 +10:00
parent 0d11af002b
commit 76c0ab3d7f
3 changed files with 51 additions and 9 deletions

View File

@ -548,6 +548,15 @@ class InvenTreeStockLocation extends InvenTreeModel {
String get pathstring => jsondata['pathstring'] ?? ''; String get pathstring => jsondata['pathstring'] ?? '';
@override
Map<String, dynamic> formFields() {
return {
"name": {},
"description": {},
"parent": {},
};
}
String get parentpathstring { String get parentpathstring {
// TODO - Drive the refactor tractor through this // TODO - Drive the refactor tractor through this
List<String> psplit = pathstring.split('/'); List<String> psplit = pathstring.split('/');

@ -1 +1 @@
Subproject commit 0e304cc16fad68baa84204fea0b2eaf64f07c817 Subproject commit c81c1c79d18a7304761a30adb15090017a613157

View File

@ -84,16 +84,9 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
return; return;
} }
launchApiForm( _loc.editForm(
context, context,
L10().editLocation, L10().editLocation,
_loc.url,
{
"name": {},
"description": {},
"parent": {},
},
modelData: _loc.jsondata,
onSuccess: (data) async { onSuccess: (data) async {
refresh(); refresh();
} }
@ -144,6 +137,31 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
setState(() {}); setState(() {});
} }
Future<void> _newLocation(BuildContext context) async {
int pk = location?.pk ?? -1;
InvenTreeStockLocation().createForm(
context,
L10().locationCreate,
data: {
"parent": (pk > 0) ? pk : null,
},
onSuccess: (data) async {
if (data.containsKey("pk")) {
var loc = InvenTreeStockLocation.fromJson(data);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LocationDisplayWidget(loc)
)
);
}
}
);
}
Widget locationDescriptionCard({bool includeActions = true}) { Widget locationDescriptionCard({bool includeActions = true}) {
if (location == null) { if (location == null) {
return Card( return Card(
@ -285,6 +303,21 @@ List<Widget> detailTiles() {
tiles.add(locationDescriptionCard(includeActions: false)); tiles.add(locationDescriptionCard(includeActions: false));
if (InvenTreeAPI().checkPermission('stock', 'add')) {
tiles.add(
ListTile(
title: Text(L10().locationCreate),
subtitle: Text(L10().locationCreateDetail),
leading: FaIcon(FontAwesomeIcons.sitemap, color: COLOR_CLICK),
onTap: () async {
_newLocation(context);
},
)
);
}
if (location != null) { if (location != null) {
// Stock adjustment actions // Stock adjustment actions
if (InvenTreeAPI().checkPermission('stock', 'change')) { if (InvenTreeAPI().checkPermission('stock', 'change')) {