mirror of
https://github.com/grocy/grocy.git
synced 2025-04-28 17:23:56 +00:00
Improved the meal plan add-dialogs (closes #540)
This commit is contained in:
parent
b4a759c0fc
commit
58cff18b03
@ -12,6 +12,9 @@
|
||||
- Fixed that when editing a recipe ingredient which had "Only check if a single unit is in stock" set, not any quantity unit could be picked and the amount stayed empty
|
||||
- Fixed that when reloading the "new recipe"-page (or when it gets auto-reloaded due to "Auto reload on external changes" is enabled), for each reload a new recipe was created
|
||||
|
||||
### Meal plan improvements
|
||||
- Improved that all add-dialogs can be submitted by using `ENTER` and that the next input is automatically selected after selecting a recipe/product
|
||||
|
||||
### General & other improvements/fixes
|
||||
- Optimized the top navbar height to waste less space
|
||||
- Fixed that the "contextual time ago" of date/time pickers was not displayed
|
||||
|
@ -277,6 +277,7 @@ $(document).on("click", ".add-recipe-button", function(e)
|
||||
|
||||
$("#add-recipe-modal-title").text(__t("Add recipe to %s", day.toString()));
|
||||
$("#day").val(day.toString());
|
||||
$("#recipe_servings").val(1);
|
||||
Grocy.Components.RecipePicker.Clear();
|
||||
$("#add-recipe-modal").modal("show");
|
||||
Grocy.FrontendHelpers.ValidateForm("add-recipe-form");
|
||||
@ -407,7 +408,7 @@ $('#save-add-product-button').on('click', function(e)
|
||||
);
|
||||
});
|
||||
|
||||
Grocy.Components.RecipePicker.GetInputElement().keydown(function(event)
|
||||
$('#add-recipe-form input').keydown(function (event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
@ -424,6 +425,23 @@ Grocy.Components.RecipePicker.GetInputElement().keydown(function(event)
|
||||
}
|
||||
});
|
||||
|
||||
$('#add-product-form input').keydown(function (event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
event.preventDefault();
|
||||
|
||||
if (document.getElementById("add-product-form").checkValidity() === false) //There is at least one validation error
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#save-add-product-button").click();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("keydown", "#servings", function(e)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
@ -629,10 +647,11 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
Grocy.Api.Get('stock/products/' + productId,
|
||||
function(productDetails)
|
||||
{
|
||||
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id, true);
|
||||
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
|
||||
|
||||
$('#display_amount').val(1);
|
||||
$('#display_amount').focus();
|
||||
$('#display_amount').select();
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
Grocy.FrontendHelpers.ValidateForm('add-product-form');
|
||||
},
|
||||
@ -657,3 +676,18 @@ function UndoStockTransaction(transactionId)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
Grocy.Components.RecipePicker.GetPicker().on('change', function(e)
|
||||
{
|
||||
var recipeId = $(e.target).val();
|
||||
|
||||
if (recipeId)
|
||||
{
|
||||
// Does not work (clears the RecipePicker) when done immediately, don't know why...
|
||||
setTimeout(function()
|
||||
{
|
||||
$("#recipe_servings").focus();
|
||||
$("#recipe_servings").select();
|
||||
}, 200);
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user