diff --git a/changelog/58_UNRELEASED_2020-xx-xx.md b/changelog/58_UNRELEASED_2020-xx-xx.md index 133fddea..917421e0 100644 --- a/changelog/58_UNRELEASED_2020-xx-xx.md +++ b/changelog/58_UNRELEASED_2020-xx-xx.md @@ -9,6 +9,7 @@ - When creating a new product, the "QU id stock" is now preset by the "QU id purchase" (because most of the time that's most probably the same) (thanks @Mik-) - Clarified the row-button colors and toolips on the stock entries page - Added a camera-barcode-scanning-button to the barcode(s) field on the product edit page to be able to also scan barcodes by the device camera there +- Added a new option (stock settings / top right corner settings menu) to show an icon on the stock overview if the product is already on the shopping list (next to the amount) (defaults to enabled) - Fixed that the aggregated parent product amount (displayed on the stock overview page and on the product card) did not respect quantity unit conversions when the parent/sub products had different stock quantity units (the unit conversion needs to be globally defined, or as an override on the sub product) - Fixed the conversion factor hint to display also decimal places on the purchase page (only displayed when the product has a different purchase/stock quantity unit) - Fixed that the stock entries page was broken when there were product userfields defined with enabled "Show as column in tables" diff --git a/config-dist.php b/config-dist.php index 70643821..2c746528 100644 --- a/config-dist.php +++ b/config-dist.php @@ -100,6 +100,7 @@ DefaultUserSetting('stock_default_purchase_amount', 0); DefaultUserSetting('stock_default_consume_amount', 1); DefaultUserSetting('scan_mode_consume_enabled', false); DefaultUserSetting('scan_mode_purchase_enabled', false); +DefaultUserSetting('show_icon_on_stock_overview_page_when_product_is_on_shopping_list', true); # Shopping list settings DefaultUserSetting('shopping_list_to_stock_workflow_auto_submit_when_prefilled', false); // Automatically do the booking using the last price and the amount of the shopping list item, if the product has "Default best before days" set diff --git a/controllers/StockController.php b/controllers/StockController.php index f42546e6..693bd016 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -25,7 +25,8 @@ class StockController extends BaseController 'nextXDays' => $nextXDays, 'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'), 'userfields' => $this->getUserfieldsService()->GetFields('products'), - 'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products') + 'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products'), + 'shoppingListItems' => $this->getDatabase()->shopping_list(), ]); } diff --git a/localization/strings.pot b/localization/strings.pot index bb9a7ece..d06db14f 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -1786,3 +1786,6 @@ msgstr "" msgid "Delete this item" msgstr "" + +msgid "Show an icon if the product is already on the shopping list" +msgstr "" diff --git a/public/viewjs/stocksettings.js b/public/viewjs/stocksettings.js index cdd60ca8..81e7ac34 100644 --- a/public/viewjs/stocksettings.js +++ b/public/viewjs/stocksettings.js @@ -4,3 +4,8 @@ $("#product_presets_qu_id").val(Grocy.UserSettings.product_presets_qu_id); $("#stock_expring_soon_days").val(Grocy.UserSettings.stock_expring_soon_days); $("#stock_default_purchase_amount").val(Grocy.UserSettings.stock_default_purchase_amount); $("#stock_default_consume_amount").val(Grocy.UserSettings.stock_default_consume_amount); + +if (BoolVal(Grocy.UserSettings.show_icon_on_stock_overview_page_when_product_is_on_shopping_list)) +{ + $("#show_icon_on_stock_overview_page_when_product_is_on_shopping_list").prop("checked", true); +} diff --git a/views/stockoverview.blade.php b/views/stockoverview.blade.php index 98fe643c..8ff7dd7b 100644 --- a/views/stockoverview.blade.php +++ b/views/stockoverview.blade.php @@ -195,6 +195,14 @@ @if($currentStockEntry->amount_opened_aggregated > 0){{ $__t('%s opened', $currentStockEntry->amount_opened_aggregated) }}@endif @endif + @if(boolval($userSettings['show_icon_on_stock_overview_page_when_product_is_on_shopping_list'])) + @php $currentStockEntryShoppingListItems = FindAllObjectsInArrayByPropertyValue($shoppingListItems, 'product_id', $currentStockEntry->product_id) @endphp + @if(count($currentStockEntryShoppingListItems) > 0) + + + + @endif + @endif @if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING) diff --git a/views/stocksettings.blade.php b/views/stocksettings.blade.php index 02677772..b5444045 100644 --- a/views/stocksettings.blade.php +++ b/views/stocksettings.blade.php @@ -75,6 +75,14 @@ 'additionalCssClasses' => 'user-setting-control' )) +
+
+ +
+
+ {{ $__t('OK') }}