diff --git a/lib/inventree/stock.dart b/lib/inventree/stock.dart index 0e2e69dc..6072b72b 100644 --- a/lib/inventree/stock.dart +++ b/lib/inventree/stock.dart @@ -548,6 +548,15 @@ class InvenTreeStockLocation extends InvenTreeModel { String get pathstring => jsondata['pathstring'] ?? ''; + @override + Map formFields() { + return { + "name": {}, + "description": {}, + "parent": {}, + }; + } + String get parentpathstring { // TODO - Drive the refactor tractor through this List psplit = pathstring.split('/'); diff --git a/lib/l10n b/lib/l10n index 0e304cc1..c81c1c79 160000 --- a/lib/l10n +++ b/lib/l10n @@ -1 +1 @@ -Subproject commit 0e304cc16fad68baa84204fea0b2eaf64f07c817 +Subproject commit c81c1c79d18a7304761a30adb15090017a613157 diff --git a/lib/widget/location_display.dart b/lib/widget/location_display.dart index 7d7b15c9..ab456c0c 100644 --- a/lib/widget/location_display.dart +++ b/lib/widget/location_display.dart @@ -84,16 +84,9 @@ class _LocationDisplayState extends RefreshableState { return; } - launchApiForm( + _loc.editForm( context, L10().editLocation, - _loc.url, - { - "name": {}, - "description": {}, - "parent": {}, - }, - modelData: _loc.jsondata, onSuccess: (data) async { refresh(); } @@ -144,6 +137,31 @@ class _LocationDisplayState extends RefreshableState { setState(() {}); } + Future _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}) { if (location == null) { return Card( @@ -285,6 +303,21 @@ List detailTiles() { 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) { // Stock adjustment actions if (InvenTreeAPI().checkPermission('stock', 'change')) {