From 8233fb39d61765044ddffc36c9fb32c99bab5f6a Mon Sep 17 00:00:00 2001 From: Oliver Walters <oliver.henry.walters@gmail.com> Date: Mon, 28 Mar 2022 21:41:21 +1100 Subject: [PATCH] Adds user setting to show or hide stock history --- lib/app_settings.dart | 1 + lib/l10n | 2 +- lib/settings/app_settings.dart | 16 ++++++++++++++++ lib/widget/stock_detail.dart | 11 ++++++++--- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/app_settings.dart b/lib/app_settings.dart index 88145bd2..7d97b9c4 100644 --- a/lib/app_settings.dart +++ b/lib/app_settings.dart @@ -18,6 +18,7 @@ const String INV_SOUNDS_SERVER = "serverSounds"; const String INV_PART_SUBCATEGORY = "partSubcategory"; const String INV_STOCK_SUBLOCATION = "stockSublocation"; +const String INV_STOCK_SHOW_HISTORY = "stockShowHistory"; const String INV_REPORT_ERRORS = "reportErrors"; diff --git a/lib/l10n b/lib/l10n index a66dab99..10ae8c64 160000 --- a/lib/l10n +++ b/lib/l10n @@ -1 +1 @@ -Subproject commit a66dab998bc92b3cceed70aaffc92ffa8b5da836 +Subproject commit 10ae8c64e0754206e21b06531186375e247c796d diff --git a/lib/settings/app_settings.dart b/lib/settings/app_settings.dart index 2431b630..46306bbe 100644 --- a/lib/settings/app_settings.dart +++ b/lib/settings/app_settings.dart @@ -28,6 +28,7 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> { // Stock settings bool stockSublocation = false; + bool stockShowHistory = false; bool reportErrors = true; @@ -48,6 +49,7 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> { partSubcategory = await InvenTreeSettingsManager().getValue(INV_PART_SUBCATEGORY, true) as bool; stockSublocation = await InvenTreeSettingsManager().getValue(INV_STOCK_SUBLOCATION, true) as bool; + stockShowHistory = await InvenTreeSettingsManager().getValue(INV_STOCK_SHOW_HISTORY, false) as bool; reportErrors = await InvenTreeSettingsManager().getValue(INV_REPORT_ERRORS, true) as bool; @@ -109,6 +111,20 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> { }, ), ), + ListTile( + title: Text(L10().stockItemHistory), + subtitle: Text(L10().stockItemHistoryDetail), + leading: FaIcon(FontAwesomeIcons.history), + trailing: Switch( + value: stockShowHistory, + onChanged: (bool value) { + InvenTreeSettingsManager().setValue(INV_STOCK_SHOW_HISTORY, value); + setState(() { + stockShowHistory = value; + }); + }, + ), + ), /* Sound Settings */ Divider(height: 3), ListTile( diff --git a/lib/widget/stock_detail.dart b/lib/widget/stock_detail.dart index 330d55e1..389abfe5 100644 --- a/lib/widget/stock_detail.dart +++ b/lib/widget/stock_detail.dart @@ -16,13 +16,14 @@ import "package:inventree/widget/part_detail.dart"; import "package:inventree/widget/progress.dart"; import "package:inventree/widget/refreshable_state.dart"; import "package:inventree/widget/snacks.dart"; -import 'package:inventree/widget/stock_item_history.dart'; +import "package:inventree/widget/stock_item_history.dart"; import "package:inventree/widget/stock_item_test_results.dart"; import "package:inventree/widget/stock_notes.dart"; import "package:inventree/l10.dart"; import "package:inventree/helpers.dart"; import "package:inventree/api.dart"; import "package:inventree/api_form.dart"; +import "package:inventree/app_settings.dart"; class StockDetailWidget extends StatefulWidget { @@ -51,6 +52,8 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> { final _countStockKey = GlobalKey<FormState>(); final _moveStockKey = GlobalKey<FormState>(); + bool stockShowHistory = false; + @override List<Widget> getAppBarActions(BuildContext context) { @@ -106,6 +109,8 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> { final bool result = await item.reload(); + stockShowHistory = await InvenTreeSettingsManager().getValue(INV_STOCK_SHOW_HISTORY, false) as bool; + // Could not load this stock item for some reason // Perhaps it has been depleted? if (!result || item.pk == -1) { @@ -862,11 +867,11 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> { // TODO - Is this stock item linked to a PurchaseOrder? - if (item.trackingItemCount > 0) { + if (stockShowHistory && item.trackingItemCount > 0) { tiles.add( ListTile( title: Text(L10().history), - leading: FaIcon(FontAwesomeIcons.history), + leading: FaIcon(FontAwesomeIcons.history, color: COLOR_CLICK), trailing: Text("${item.trackingItemCount}"), onTap: () { Navigator.push(