mirror of
https://github.com/grocy/grocy.git
synced 2025-08-17 19:16:37 +00:00
Also refresh the parent product on sub product actions on the stock overview page (closes #394)
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
- Fixed that barcode lookups now compare the whole barcode, not parts of it (e. g. when you have two products with the barcodes `$1` and `$10` and scan `$1` maybe the product of `$10` was found till now)
|
- Fixed that barcode lookups now compare the whole barcode, not parts of it (e. g. when you have two products with the barcodes `$1` and `$10` and scan `$1` maybe the product of `$10` was found till now)
|
||||||
- Fixed that the "X products are already expired" count on the stock overview page was wrong
|
- Fixed that the "X products are already expired" count on the stock overview page was wrong
|
||||||
- Fixed that after product actions (consume/purchase/etc.) on the stock overview page the highlighting of the row was maybe wrong
|
- Fixed that after product actions (consume/purchase/etc.) on the stock overview page the highlighting of the row was maybe wrong
|
||||||
|
- After product actions (consume/purchase/etc.) on the stock overview page on a sub product, now also the parent product (row) is refreshed
|
||||||
- It's now possible to accumulate min. stock amounts on parent product level (new option per product, means the sub product will never be "missing" then, only the parent product)
|
- It's now possible to accumulate min. stock amounts on parent product level (new option per product, means the sub product will never be "missing" then, only the parent product)
|
||||||
- When adding a product to the shopping list from the new context/more menu from the stock overview page and if the product is already on the shopping list, the amount of that entry will be updated acccordingly instead of adding a new (double) shopping list item
|
- When adding a product to the shopping list from the new context/more menu from the stock overview page and if the product is already on the shopping list, the amount of that entry will be updated acccordingly instead of adding a new (double) shopping list item
|
||||||
|
|
||||||
|
@@ -312,6 +312,12 @@ function RefreshProductRow(productId)
|
|||||||
Grocy.Api.Get('stock/products/' + productId,
|
Grocy.Api.Get('stock/products/' + productId,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
|
// Also refresh the parent product, if any
|
||||||
|
if (result.product.parent_product_id !== null && !result.product.parent_product_id.toString().isEmpty())
|
||||||
|
{
|
||||||
|
RefreshProductRow(result.product.parent_product_id);
|
||||||
|
}
|
||||||
|
|
||||||
var productRow = $('#product-' + productId + '-row');
|
var productRow = $('#product-' + productId + '-row');
|
||||||
var expiringThreshold = moment().add($("#info-expiring-products").data("next-x-days"), "days");
|
var expiringThreshold = moment().add($("#info-expiring-products").data("next-x-days"), "days");
|
||||||
var now = moment();
|
var now = moment();
|
||||||
@@ -396,10 +402,32 @@ function RefreshProductRow(productId)
|
|||||||
$('#product-' + productId + '-opened-amount').text("");
|
$('#product-' + productId + '-opened-amount').text("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parseInt(result.is_aggregated_amount) === 1)
|
||||||
|
{
|
||||||
|
$('#product-' + productId + '-amount-aggregated').fadeOut(500, function()
|
||||||
|
{
|
||||||
|
$(this).text(result.stock_amount_aggregated).fadeIn(500);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.stock_amount_opened_aggregated > 0)
|
||||||
|
{
|
||||||
|
$('#product-' + productId + '-opened-amount-aggregated').parent().effect('highlight', {}, 500);
|
||||||
|
$('#product-' + productId + '-opened-amount-aggregated').fadeOut(500, function ()
|
||||||
|
{
|
||||||
|
$(this).text(__t('%s opened', result.stock_amount_opened_aggregated)).fadeIn(500);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#product-' + productId + '-opened-amount-aggregated').text("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Needs to be delayed because of the animation above the date-text would be wrong if fired immediately...
|
// Needs to be delayed because of the animation above the date-text would be wrong if fired immediately...
|
||||||
setTimeout(function()
|
setTimeout(function()
|
||||||
{
|
{
|
||||||
RefreshContextualTimeago();
|
RefreshContextualTimeago();
|
||||||
|
RefreshLocaleNumberDisplay();
|
||||||
}, 600);
|
}, 600);
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
|
@@ -68,7 +68,7 @@ class DemoDataGeneratorService extends BaseService
|
|||||||
|
|
||||||
DELETE FROM sqlite_sequence WHERE name = 'products'; --Just to keep IDs in order as mentioned here...
|
DELETE FROM sqlite_sequence WHERE name = 'products'; --Just to keep IDs in order as mentioned here...
|
||||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, min_stock_amount, product_group_id, picture_file_name) VALUES ('{$this->__t_sql('Cookies')}', 4, 3, 3, 1, 8, 1, 'cookies.jpg'); --1
|
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, min_stock_amount, product_group_id, picture_file_name) VALUES ('{$this->__t_sql('Cookies')}', 4, 3, 3, 1, 8, 1, 'cookies.jpg'); --1
|
||||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, min_stock_amount, product_group_id) VALUES ('{$this->__t_sql('Chocolate')}', 4, 3, 3, 1, 8, 1); --2
|
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, min_stock_amount, product_group_id, cumulate_min_stock_amount_of_sub_products) VALUES ('{$this->__t_sql('Chocolate')}', 4, 3, 3, 1, 8, 1, 1); --2
|
||||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, min_stock_amount, product_group_id, picture_file_name) VALUES ('{$this->__t_sql('Gummy bears')}', 4, 3, 3, 1, 8, 1, 'gummybears.jpg'); --3
|
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, min_stock_amount, product_group_id, picture_file_name) VALUES ('{$this->__t_sql('Gummy bears')}', 4, 3, 3, 1, 8, 1, 'gummybears.jpg'); --3
|
||||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, min_stock_amount, product_group_id) VALUES ('{$this->__t_sql('Crisps')}', 4, 3, 3, 1, 10, 1); --4
|
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, min_stock_amount, product_group_id) VALUES ('{$this->__t_sql('Crisps')}', 4, 3, 3, 1, 10, 1); --4
|
||||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id) VALUES ('{$this->__t_sql('Eggs')}', 2, 3, 2, 10, 5); --5
|
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id) VALUES ('{$this->__t_sql('Eggs')}', 2, 3, 2, 10, 5); --5
|
||||||
@@ -92,7 +92,7 @@ class DemoDataGeneratorService extends BaseService
|
|||||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, calories) VALUES ('{$this->__t_sql('Milk')}', 2, 10, 10, 1, 6, 1); --23
|
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, calories) VALUES ('{$this->__t_sql('Milk')}', 2, 10, 10, 1, 6, 1); --23
|
||||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, parent_product_id) VALUES ('{$this->__t_sql('Milk Chocolate')}', 4, 3, 3, 1, 1, 2); --24
|
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, parent_product_id) VALUES ('{$this->__t_sql('Milk Chocolate')}', 4, 3, 3, 1, 1, 2); --24
|
||||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, parent_product_id) VALUES ('{$this->__t_sql('Dark Chocolate')}', 4, 3, 3, 1, 1, 2); --25
|
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, parent_product_id) VALUES ('{$this->__t_sql('Dark Chocolate')}', 4, 3, 3, 1, 1, 2); --25
|
||||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, parent_product_id, barcode) VALUES ('{$this->__t_sql('Waffle rolls')}', 4, 3, 3, 1, 1, 2, '22111289'); --26
|
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, barcode) VALUES ('{$this->__t_sql('Waffle rolls')}', 4, 3, 3, 1, 1, '22111289'); --26
|
||||||
UPDATE products SET calories = 123 WHERE IFNULL(calories, 0) = 0;
|
UPDATE products SET calories = 123 WHERE IFNULL(calories, 0) = 0;
|
||||||
|
|
||||||
/* Prevent invalid quantity unit assignments */
|
/* Prevent invalid quantity unit assignments */
|
||||||
|
@@ -178,8 +178,8 @@
|
|||||||
<span id="product-{{ $currentStockEntry->product_id }}-opened-amount" class="small font-italic">@if($currentStockEntry->amount_opened > 0){{ $__t('%s opened', $currentStockEntry->amount_opened) }}@endif</span>
|
<span id="product-{{ $currentStockEntry->product_id }}-opened-amount" class="small font-italic">@if($currentStockEntry->amount_opened > 0){{ $__t('%s opened', $currentStockEntry->amount_opened) }}@endif</span>
|
||||||
@if($currentStockEntry->is_aggregated_amount == 1)
|
@if($currentStockEntry->is_aggregated_amount == 1)
|
||||||
<span class="pl-1 text-secondary">
|
<span class="pl-1 text-secondary">
|
||||||
<i class="fas fa-custom-sigma-sign"></i> <span class="locale-number locale-number-quantity-amount">{{ $currentStockEntry->amount_aggregated }}</span> {{ $__n($currentStockEntry->amount_aggregated, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->qu_id_stock)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->qu_id_stock)->name_plural) }}
|
<i class="fas fa-custom-sigma-sign"></i> <span id="product-{{ $currentStockEntry->product_id }}-amount-aggregated" class="locale-number locale-number-quantity-amount">{{ $currentStockEntry->amount_aggregated }}</span> {{ $__n($currentStockEntry->amount_aggregated, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->qu_id_stock)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->qu_id_stock)->name_plural) }}
|
||||||
@if($currentStockEntry->amount_opened_aggregated > 0)<span class="small font-italic">{{ $__t('%s opened', $currentStockEntry->amount_opened_aggregated) }}</span>@endif
|
@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>
|
</span>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
|
Reference in New Issue
Block a user