diff --git a/localization/de.php b/localization/de.php index 60c53951..96c700ab 100644 --- a/localization/de.php +++ b/localization/de.php @@ -205,6 +205,9 @@ return array( '#1 unit was automatically added and will apply in addition to the amount entered here' => '#1 Einheit wurde automatisch hinzugefügt und gilt zusätzlich der hier eingegebenen Menge', 'in singular form' => 'in der Einzahl', 'in plural form' => 'in der Mehrzahl', + 'Never expires' => 'Läuft nie ab', + 'This cannot be lower than #1' => 'Dies darf nicht kleiner als #1 sein', + '-1 means that this product never expires' => '-1 bedeuet, dass dieses Produkt niemals abläuft', //Constants 'manually' => 'Manuell', diff --git a/public/viewjs/components/datetimepicker.js b/public/viewjs/components/datetimepicker.js index 0b156cc4..cccb007f 100644 --- a/public/viewjs/components/datetimepicker.js +++ b/public/viewjs/components/datetimepicker.js @@ -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(); + } +}); diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js index e48efa14..a62cb7f1 100644 --- a/public/viewjs/purchase.js +++ b/public/viewjs/purchase.js @@ -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 diff --git a/views/components/datetimepicker.blade.php b/views/components/datetimepicker.blade.php index 42db0019..d857081f 100644 --- a/views/components/datetimepicker.blade.php +++ b/views/components/datetimepicker.blade.php @@ -14,6 +14,12 @@