Fixed the "Shopping list to stock workflow" with disabled FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING (fixes #537)

This commit is contained in:
Bernd Bestel
2020-02-02 13:01:31 +01:00
parent 5effa0c103
commit 890663bf63
13 changed files with 23 additions and 18 deletions

View File

@@ -163,7 +163,7 @@ function animateCSS(selector, animationName, callback, speed = "faster")
{
nodes.removeClass('animated').removeClass(speed).removeClass(animationName);
nodes.unbind('animationend', handleAnimationEnd);
if (typeof callback === 'function')
{
callback();

View File

@@ -178,6 +178,11 @@ if (Grocy.Components.ProductPicker !== undefined)
$("#tare-weight-handling-info").addClass("d-none");
}
if (!Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
{
Grocy.Components.DateTimePicker.SetValue(moment().format('YYYY-MM-DD'));
}
if (productDetails.product.default_best_before_days.toString() !== '0')
{
if (productDetails.product.default_best_before_days == -1)
@@ -192,12 +197,6 @@ if (Grocy.Components.ProductPicker !== undefined)
Grocy.Components.DateTimePicker.SetValue(moment().add(productDetails.product.default_best_before_days, 'days').format('YYYY-MM-DD'));
}
$('#amount').focus();
Grocy.FrontendHelpers.ValidateForm('purchase-form');
if (GetUriParam("flow") === "shoppinglistitemtostock" && BoolVal(Grocy.UserSettings.shopping_list_to_stock_workflow_auto_submit_when_prefilled) && document.getElementById("purchase-form").checkValidity() === true)
{
$("#save-purchase-button").click();
}
}
else
{
@@ -207,11 +206,16 @@ if (Grocy.Components.ProductPicker !== undefined)
}
else
{
Grocy.Components.DateTimePicker.SetValue(moment().format('YYYY-MM-DD'));
$('#amount').focus();
}
}
Grocy.FrontendHelpers.ValidateForm('purchase-form');
if (GetUriParam("flow") === "shoppinglistitemtostock" && BoolVal(Grocy.UserSettings.shopping_list_to_stock_workflow_auto_submit_when_prefilled) && document.getElementById("purchase-form").checkValidity() === true)
{
$("#save-purchase-button").click();
}
if (BoolVal(Grocy.UserSettings.scan_mode_purchase_enabled))
{
$("#amount").val(1);

View File

@@ -95,7 +95,7 @@ $(document).on('click', '.shoppinglist-delete-button', function(e)
var shoppingListItemId = $(e.currentTarget).attr('data-shoppinglist-id');
Grocy.FrontendHelpers.BeginUiBusy();
Grocy.Api.Delete('objects/shopping_list/' + shoppingListItemId, {},
Grocy.Api.Delete('objects/shopping_list/' + shoppingListItemId, { },
function(result)
{
animateCSS("#shoppinglistitem-" + shoppingListItemId + "-row", "fadeOut", function()