2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 13:36:50 +00:00

Adds user setting to show or hide stock history

This commit is contained in:
Oliver Walters 2022-03-28 21:41:21 +11:00
parent 43faec8b21
commit 8233fb39d6
4 changed files with 26 additions and 4 deletions

View File

@ -18,6 +18,7 @@ const String INV_SOUNDS_SERVER = "serverSounds";
const String INV_PART_SUBCATEGORY = "partSubcategory"; const String INV_PART_SUBCATEGORY = "partSubcategory";
const String INV_STOCK_SUBLOCATION = "stockSublocation"; const String INV_STOCK_SUBLOCATION = "stockSublocation";
const String INV_STOCK_SHOW_HISTORY = "stockShowHistory";
const String INV_REPORT_ERRORS = "reportErrors"; const String INV_REPORT_ERRORS = "reportErrors";

@ -1 +1 @@
Subproject commit a66dab998bc92b3cceed70aaffc92ffa8b5da836 Subproject commit 10ae8c64e0754206e21b06531186375e247c796d

View File

@ -28,6 +28,7 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
// Stock settings // Stock settings
bool stockSublocation = false; bool stockSublocation = false;
bool stockShowHistory = false;
bool reportErrors = true; bool reportErrors = true;
@ -48,6 +49,7 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
partSubcategory = await InvenTreeSettingsManager().getValue(INV_PART_SUBCATEGORY, true) as bool; partSubcategory = await InvenTreeSettingsManager().getValue(INV_PART_SUBCATEGORY, true) as bool;
stockSublocation = await InvenTreeSettingsManager().getValue(INV_STOCK_SUBLOCATION, 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; 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 */ /* Sound Settings */
Divider(height: 3), Divider(height: 3),
ListTile( ListTile(

View File

@ -16,13 +16,14 @@ import "package:inventree/widget/part_detail.dart";
import "package:inventree/widget/progress.dart"; import "package:inventree/widget/progress.dart";
import "package:inventree/widget/refreshable_state.dart"; import "package:inventree/widget/refreshable_state.dart";
import "package:inventree/widget/snacks.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_item_test_results.dart";
import "package:inventree/widget/stock_notes.dart"; import "package:inventree/widget/stock_notes.dart";
import "package:inventree/l10.dart"; import "package:inventree/l10.dart";
import "package:inventree/helpers.dart"; import "package:inventree/helpers.dart";
import "package:inventree/api.dart"; import "package:inventree/api.dart";
import "package:inventree/api_form.dart"; import "package:inventree/api_form.dart";
import "package:inventree/app_settings.dart";
class StockDetailWidget extends StatefulWidget { class StockDetailWidget extends StatefulWidget {
@ -51,6 +52,8 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
final _countStockKey = GlobalKey<FormState>(); final _countStockKey = GlobalKey<FormState>();
final _moveStockKey = GlobalKey<FormState>(); final _moveStockKey = GlobalKey<FormState>();
bool stockShowHistory = false;
@override @override
List<Widget> getAppBarActions(BuildContext context) { List<Widget> getAppBarActions(BuildContext context) {
@ -106,6 +109,8 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
final bool result = await item.reload(); 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 // Could not load this stock item for some reason
// Perhaps it has been depleted? // Perhaps it has been depleted?
if (!result || item.pk == -1) { if (!result || item.pk == -1) {
@ -862,11 +867,11 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
// TODO - Is this stock item linked to a PurchaseOrder? // TODO - Is this stock item linked to a PurchaseOrder?
if (item.trackingItemCount > 0) { if (stockShowHistory && item.trackingItemCount > 0) {
tiles.add( tiles.add(
ListTile( ListTile(
title: Text(L10().history), title: Text(L10().history),
leading: FaIcon(FontAwesomeIcons.history), leading: FaIcon(FontAwesomeIcons.history, color: COLOR_CLICK),
trailing: Text("${item.trackingItemCount}"), trailing: Text("${item.trackingItemCount}"),
onTap: () { onTap: () {
Navigator.push( Navigator.push(