Added a filter option to only show currently out-of-stock products on /products (closes #2192)

This commit is contained in:
Bernd Bestel
2023-04-13 20:28:28 +02:00
parent 2bce428339
commit 16011b91c6
6 changed files with 43 additions and 17 deletions

View File

@@ -40,14 +40,20 @@ $("#clear-filter-button").on("click", function()
$("#product-group-filter").val("all");
productsTable.column(productsTable.colReorder.transpose(6)).search("").draw();
productsTable.search("").draw();
if ($("#show-disabled").is(":checked") || $("#show-only-in-stock").is(":checked"))
if ($("#show-disabled").is(":checked"))
{
$("#show-disabled").prop("checked", false);
$("#show-only-in-stock").prop("checked", false);
RemoveUriParam("include_disabled");
RemoveUriParam("only_in_stock");
window.location.reload();
}
if ($("#status-filter").val() != "all")
{
$("#status-filter").val("all");
$("#status-filter").trigger("change");
}
});
if (typeof GetUriParam("product-group") !== "undefined")
@@ -109,15 +115,25 @@ $("#show-disabled").change(function()
window.location.reload();
});
$("#show-only-in-stock").change(function()
$("#status-filter").change(function()
{
if (this.checked)
var value = $(this).val();
if (value == "all")
{
UpdateUriParam("only_in_stock", "true");
RemoveUriParam("only_in_stock");
RemoveUriParam("only_out_of_stock");
}
else
else if (value == "out-of-stock")
{
RemoveUriParam("only_in_stock");
UpdateUriParam("only_out_of_stock", "true");
}
else if (value == "in-stock")
{
RemoveUriParam("only_out_of_stock");
UpdateUriParam("only_in_stock", "true");
}
window.location.reload();