Added a new stock settings to always show all products on /stockoverview (closes #2398)

This commit is contained in:
Bernd Bestel
2025-01-15 21:44:45 +01:00
parent 113a9ecf39
commit b0dded1346
10 changed files with 149 additions and 7 deletions

View File

@@ -318,6 +318,7 @@ RefreshContextualTimeago = function(rootSelector = "#page-content")
}
var isNever = timestamp && timestamp.substring(0, 10) == "2999-12-31";
var isUnknown = timestamp && timestamp.substring(0, 10) == "2888-12-31";
var isToday = timestamp && timestamp.substring(0, 10) == moment().format("YYYY-MM-DD");
var isDateWithoutTime = element.hasClass("timeago-date-only");
@@ -326,6 +327,11 @@ RefreshContextualTimeago = function(rootSelector = "#page-content")
element.prev().text(__t("Never"));
element.text("");
}
else if (isUnknown)
{
element.prev().text(__t("Unknown"));
element.text("");
}
else if (isToday)
{
element.text(__t("Today"));

View File

@@ -289,6 +289,11 @@ function RefreshProductRow(productId)
RefreshProductRow(result.product.parent_product_id);
}
if (!result.next_due_date)
{
result.next_due_date = "2888-12-31"; // Unknown
}
var productRow = $('#product-' + productId + '-row');
var dueSoonThreshold = moment().add($("#info-duesoon-products").data("next-x-days"), "days");
var now = moment();
@@ -320,7 +325,7 @@ function RefreshProductRow(productId)
productRow.addClass("table-info");
}
if (result.stock_amount == 0 && result.stock_amount_aggregated == 0 && result.product.min_stock_amount == 0)
if (!BoolVal(Grocy.UserSettings.stock_overview_show_all_out_of_stock_products) && result.stock_amount == 0 && result.stock_amount_aggregated == 0 && result.product.min_stock_amount == 0)
{
animateCSS("#product-" + productId + "-row", "fadeOut", function()
{
@@ -348,6 +353,12 @@ function RefreshProductRow(productId)
{
$('#product-' + productId + '-opened-amount').text("");
}
if (result.stock_amount_aggregated == 0)
{
$(".product-consume-button[data-product-id='" + productId + "']").addClass("disabled");
$(".product-open-button[data-product-id='" + productId + "']").addClass("disabled");
}
}
$('#product-' + productId + '-next-due-date').text(result.next_due_date);

View File

@@ -2,14 +2,17 @@
$("#product_presets_product_group_id").val(Grocy.UserSettings.product_presets_product_group_id);
$("#product_presets_qu_id").val(Grocy.UserSettings.product_presets_qu_id);
$("#product_presets_default_due_days").val(Grocy.UserSettings.product_presets_default_due_days);
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING && BoolVal(Grocy.UserSettings.product_presets_treat_opened_as_out_of_stock))
{
$("#product_presets_treat_opened_as_out_of_stock").prop("checked", true);
}
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_LABEL_PRINTER)
{
$("#product_presets_default_stock_label_type").val(Grocy.UserSettings.product_presets_default_stock_label_type);
}
$("#stock_due_soon_days").val(Grocy.UserSettings.stock_due_soon_days);
$("#stock_default_purchase_amount").val(Grocy.UserSettings.stock_default_purchase_amount);
$("#stock_default_consume_amount").val(Grocy.UserSettings.stock_default_consume_amount);
@@ -21,6 +24,12 @@ if (BoolVal(Grocy.UserSettings.show_icon_on_stock_overview_page_when_product_is_
{
$("#show_icon_on_stock_overview_page_when_product_is_on_shopping_list").prop("checked", true);
}
if (BoolVal(Grocy.UserSettings.stock_overview_show_all_out_of_stock_products))
{
$("#stock_overview_show_all_out_of_stock_products").prop("checked", true);
}
if (BoolVal(Grocy.UserSettings.show_purchased_date_on_purchase))
{
$("#show_purchased_date_on_purchase").prop("checked", true);