Show optionally an icon on the stock overview page if the product is already on the shopping list (closes #708)

This commit is contained in:
Bernd Bestel 2020-04-13 18:47:41 +02:00
parent 840b35b30d
commit 1390c65864
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
7 changed files with 28 additions and 1 deletions

View File

@ -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"

View File

@ -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

View File

@ -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(),
]);
}

View File

@ -1786,3 +1786,6 @@ msgstr ""
msgid "Delete this item"
msgstr ""
msgid "Show an icon if the product is already on the shopping list"
msgstr ""

View File

@ -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);
}

View File

@ -195,6 +195,14 @@
@if($currentStockEntry->amount_opened_aggregated > 0)<span id="product-{{ $currentStockEntry->product_id }}-opened-amount-aggregated" class="small font-italic">{{ $__t('%s opened', $currentStockEntry->amount_opened_aggregated) }}</span>@endif
</span>
@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)
<span class="btn btn-link btn-sm text-muted">
<i class="fas fa-shopping-cart"></i>
</span>
@endif
@endif
</td>
@if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
<td>

View File

@ -75,6 +75,14 @@
'additionalCssClasses' => 'user-setting-control'
))
<div class="form-group">
<div class="checkbox">
<label for="show_icon_on_stock_overview_page_when_product_is_on_shopping_list">
<input type="checkbox" class="user-setting-control" id="show_icon_on_stock_overview_page_when_product_is_on_shopping_list" data-setting-key="show_icon_on_stock_overview_page_when_product_is_on_shopping_list"> {{ $__t('Show an icon if the product is already on the shopping list') }}
</label>
</div>
</div>
<a href="{{ $U('/stockoverview') }}" class="btn btn-success">{{ $__t('OK') }}</a>
</div>
</div>