Added a product context menu on /stockjournal (the same as on /stockoverview) (closes #2239)

This commit is contained in:
Bernd Bestel 2023-05-21 18:40:59 +02:00
parent 979c67b44c
commit 04f362b723
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
5 changed files with 128 additions and 3 deletions

View File

@ -34,8 +34,9 @@
- The product option "Quick consume amount" (the amount used for the "quick consume/open buttons" on the stock overview page) has been split into another option "Quick open amount", to be able to set different amounts for consume and open (defaults to the "Quick consume amount" per product, so no changed behavior when not configured)
- Changed that for the product's average and last price (and for the price history chart) stock transactions with an empty or `0` price are ignored
- Added a filter option to only show currently out-of-stock products on the products list (master data) page
- When clicking the product name on the products list (master data) page, the product card will now be displayed (like on the stock overview page)
- When clicking a product name on the products list (master data) or on the stock journal page, the product card will now be displayed (like on the stock overview page)
- When using/scanning a product barcode and the purchase or inventory page, the barcode's note will now also be prefilled (if any)
- Each row on the stock journal now also has a context-/more menu for quick access to product related actions (the same as on the stock overview page)
- Fixed that hiding the "Purchased date" column (table options) on the stock entries page didn't work
- Fixed that sorting by the "Value" and "Min. stock amount" columns on the stock overview page didn't work
- Fixed that the consumed amount was wrong, when consuming multiple substituted subproducts at once and when multiple/different conversion factors were involved

View File

@ -129,3 +129,24 @@ $(document).on('click', '.undo-stock-booking-button', function(e)
}
);
});
$(document).on('click', '.product-grocycode-label-print', function(e)
{
e.preventDefault();
document.activeElement.blur();
var productId = $(e.currentTarget).attr('data-product-id');
Grocy.Api.Get('stock/products/' + productId + '/printlabel', function(labelData)
{
if (Grocy.Webhooks.labelprinter !== undefined)
{
Grocy.FrontendHelpers.RunWebhook(Grocy.Webhooks.labelprinter, labelData);
}
});
});
$(document).on("click", ".product-name-cell", function(e)
{
Grocy.Components.ProductCard.Refresh($(e.currentTarget).attr("data-product-id"));
$("#stockjournal-productcard-modal").modal("show");
});

View File

@ -178,7 +178,6 @@
href="{{ $U('/inventory?embedded&product=' . $stockEntry->product_id ) }}">
<i class="fa-solid fa-list"></i> {{ $__t('Inventory') }}
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item stock-consume-button stock-consume-button-spoiled"
type="button"
href="#"
@ -192,6 +191,7 @@
{{ $__t('Consume this stock entry as spoiled', '1 ' . FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->qu_id_stock)->name, FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->name) }}
</a>
@if(GROCY_FEATURE_FLAG_RECIPES)
<div class="dropdown-divider"></div>
<a class="dropdown-item"
type="button"
href="{{ $U('/recipes?search=') }}{{ FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->name }}">

View File

@ -171,8 +171,93 @@
title="{{ $__t('Undo transaction') }}">
<i class="fa-solid fa-undo"></i>
</a>
<div class="dropdown d-inline-block">
<button class="btn btn-xs btn-light text-secondary"
type="button"
data-toggle="dropdown">
<i class="fa-solid fa-ellipsis-v"></i>
</button>
<div class="table-inline-menu dropdown-menu dropdown-menu-right">
@if(GROCY_FEATURE_FLAG_SHOPPINGLIST)
<a class="dropdown-item show-as-dialog-link permission-SHOPPINGLIST_ITEMS_ADD"
type="button"
href="{{ $U('/shoppinglistitem/new?embedded&updateexistingproduct&product=' . $stockLogEntry->product_id ) }}">
<span class="dropdown-item-icon"><i class="fa-solid fa-shopping-cart"></i></span> <span class="dropdown-item-text">{{ $__t('Add to shopping list') }}</span>
</a>
<div class="dropdown-divider"></div>
@endif
<a class="dropdown-item show-as-dialog-link permission-STOCK_PURCHASE"
type="button"
href="{{ $U('/purchase?embedded&product=' . $stockLogEntry->product_id ) }}">
<span class="dropdown-item-icon"><i class="fa-solid fa-cart-plus"></i></span> <span class="dropdown-item-text">{{ $__t('Purchase') }}</span>
</a>
<a class="dropdown-item show-as-dialog-link permission-STOCK_CONSUME"
type="button"
href="{{ $U('/consume?embedded&product=' . $stockLogEntry->product_id ) }}">
<span class="dropdown-item-icon"><i class="fa-solid fa-utensils"></i></span> <span class="dropdown-item-text">{{ $__t('Consume') }}</span>
</a>
@if(GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
<a class="dropdown-item show-as-dialog-link permission-STOCK_TRANSFER"
type="button"
href="{{ $U('/transfer?embedded&product=' . $stockLogEntry->product_id) }}">
<span class="dropdown-item-icon"><i class="fa-solid fa-exchange-alt"></i></span> <span class="dropdown-item-text">{{ $__t('Transfer') }}</span>
</a>
@endif
<a class="dropdown-item show-as-dialog-link permission-STOCK_INVENTORY"
type="button"
href="{{ $U('/inventory?embedded&product=' . $stockLogEntry->product_id ) }}">
<span class="dropdown-item-icon"><i class="fa-solid fa-list"></i></span> <span class="dropdown-item-text">{{ $__t('Inventory') }}</span>
</a>
@if(GROCY_FEATURE_FLAG_RECIPES)
<div class="dropdown-divider"></div>
<a class="dropdown-item"
type="button"
href="{{ $U('/recipes?search=') }}{{ $stockLogEntry->product_name }}">
<span class="dropdown-item-text">{{ $__t('Search for recipes containing this product') }}</span>
</a>
@endif
<div class="dropdown-divider"></div>
<a class="dropdown-item product-name-cell"
data-product-id="{{ $stockLogEntry->product_id }}"
type="button"
href="#">
<span class="dropdown-item-text">{{ $__t('Product overview') }}</span>
</a>
<a class="dropdown-item show-as-dialog-link"
type="button"
href="{{ $U('/stockentries?embedded&product=') }}{{ $stockLogEntry->product_id }}"
data-product-id="{{ $stockLogEntry->product_id }}">
<span class="dropdown-item-text">{{ $__t('Stock entries') }}</span>
</a>
<a class="dropdown-item show-as-dialog-link"
type="button"
href="{{ $U('/stockjournal/summary?embedded&product_id=') }}{{ $stockLogEntry->product_id }}">
<span class="dropdown-item-text">{{ $__t('Stock journal summary') }}</span>
</a>
<a class="dropdown-item permission-MASTER_DATA_EDIT link-return"
type="button"
data-href="{{ $U('/product/') }}{{ $stockLogEntry->product_id }}">
<span class="dropdown-item-text">{{ $__t('Edit product') }}</span>
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item"
type="button"
href="{{ $U('/product/' . $stockLogEntry->product_id . '/grocycode?download=true') }}">
{!! str_replace('Grocycode', '<span class="ls-n1">Grocycode</span>', $__t('Download %s Grocycode', $__t('Product'))) !!}
</a>
@if(GROCY_FEATURE_FLAG_LABEL_PRINTER)
<a class="dropdown-item product-grocycode-label-print"
data-product-id="{{ $stockLogEntry->product_id }}"
type="button"
href="#">
{!! str_replace('Grocycode', '<span class="ls-n1">Grocycode</span>', $__t('Print %s Grocycode on label printer', $__t('Product'))) !!}
</a>
@endif
</div>
</div>
</td>
<td>
<td class="product-name-cell cursor-link"
data-product-id="{{ $stockLogEntry->product_id }}">
<span class="name-anchor @if($stockLogEntry->undone == 1) text-strike-through @endif">{{ $stockLogEntry->product_name }}</span>
@if($stockLogEntry->undone == 1)
<br>
@ -215,4 +300,21 @@
</table>
</div>
</div>
<div class="modal fade"
id="stockjournal-productcard-modal"
tabindex="-1">
<div class="modal-dialog">
<div class="modal-content text-center">
<div class="modal-body">
@include('components.productcard')
</div>
<div class="modal-footer">
<button type="button"
class="btn btn-secondary"
data-dismiss="modal">{{ $__t('Close') }}</button>
</div>
</div>
</div>
</div>
@stop

View File

@ -271,6 +271,7 @@
<span class="dropdown-item-icon"><i class="fa-solid fa-list"></i></span> <span class="dropdown-item-text">{{ $__t('Inventory') }}</span>
</a>
@if(GROCY_FEATURE_FLAG_RECIPES)
<div class="dropdown-divider"></div>
<a class="dropdown-item"
type="button"
href="{{ $U('/recipes?search=') }}{{ $currentStockEntry->product_name }}">