mirror of
https://github.com/grocy/grocy.git
synced 2025-10-14 17:24:07 +00:00
Add a checkbox to set the "never expires date" (closes #40)
This commit is contained in:
@@ -2,7 +2,7 @@ Grocy.Components.DateTimePicker = { };
|
||||
|
||||
Grocy.Components.DateTimePicker.GetInputElement = function()
|
||||
{
|
||||
return $('.datetimepicker').find('input');
|
||||
return $('.datetimepicker').find('input').not(".form-check-input");
|
||||
}
|
||||
|
||||
Grocy.Components.DateTimePicker.GetValue = function()
|
||||
@@ -171,3 +171,20 @@ $('.datetimepicker').on('update.datetimepicker', function(e)
|
||||
{
|
||||
Grocy.Components.DateTimePicker.GetInputElement().trigger('input');
|
||||
});
|
||||
|
||||
$("#datetimepicker-shortcut").on("click", function()
|
||||
{
|
||||
if (this.checked)
|
||||
{
|
||||
var value = $("#datetimepicker-shortcut").data("datetimepicker-shortcut-value");
|
||||
Grocy.Components.DateTimePicker.SetValue(value);
|
||||
Grocy.Components.DateTimePicker.GetInputElement().attr("readonly", "");
|
||||
$(Grocy.Components.DateTimePicker.GetInputElement().data('next-input-selector')).focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.Components.DateTimePicker.SetValue("");
|
||||
Grocy.Components.DateTimePicker.GetInputElement().removeAttr("readonly");
|
||||
Grocy.Components.DateTimePicker.GetInputElement().focus();
|
||||
}
|
||||
});
|
||||
|
@@ -85,7 +85,17 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
|
||||
if (productDetails.product.default_best_before_days.toString() !== '0')
|
||||
{
|
||||
Grocy.Components.DateTimePicker.SetValue(moment().add(productDetails.product.default_best_before_days, 'days').format('YYYY-MM-DD'));
|
||||
if (productDetails.product.default_best_before_days == -1)
|
||||
{
|
||||
if (!$("#datetimepicker-shortcut").is(":checked"))
|
||||
{
|
||||
$("#datetimepicker-shortcut").click();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.Components.DateTimePicker.SetValue(moment().add(productDetails.product.default_best_before_days, 'days').format('YYYY-MM-DD'));
|
||||
}
|
||||
$('#amount').focus();
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user