diff --git a/localization/en/strings.php b/localization/en/strings.php index 521cdf6f..6954e623 100644 --- a/localization/en/strings.php +++ b/localization/en/strings.php @@ -139,7 +139,7 @@ return array( 'This cannot be negative' => 'This cannot be negative', 'A quantity unit is required' => 'A quantity unit is required', 'A period type is required' => 'A period type is required', - 'A best before date is required and must be later than today' => 'A best before date is required and must be later than today', + 'A best before date is required' => 'A best before date is required', 'Settings' => 'Settings', 'This can only be before now' => 'This can only be before now', 'Calendar' => 'Calendar', @@ -354,5 +354,6 @@ return array( 'Journal for this battery' => 'Journal for this battery', 'System info' => 'System info', 'Changelog' => 'Changelog', - 'will be multiplied a factor of #1 to get #2' => 'will be multiplied a factor of #1 to get #2' + 'will be multiplied a factor of #1 to get #2' => 'will be multiplied a factor of #1 to get #2', + 'The given date is earlier than today, are you sure?' => 'The given date is earlier than today, are you sure?' ); diff --git a/public/viewjs/components/datetimepicker.js b/public/viewjs/components/datetimepicker.js index 48f52b6e..c92a28f2 100644 --- a/public/viewjs/components/datetimepicker.js +++ b/public/viewjs/components/datetimepicker.js @@ -193,6 +193,19 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keyup', function(e) { element.setCustomValidity(""); } + + var earlierThanLimit = Grocy.Components.DateTimePicker.GetInputElement().data("earlier-than-limit"); + if (!earlierThanLimit.isEmpty()) + { + if (moment(value).isBefore(moment(earlierThanLimit))) + { + $("#datetimepicker-earlier-than-info").removeClass("d-none"); + } + else + { + $("#datetimepicker-earlier-than-info").addClass("d-none"); + } + } } // "Click" the shortcut checkbox when the shortcut value was diff --git a/views/components/datetimepicker.blade.php b/views/components/datetimepicker.blade.php index 421049e3..cbb87f11 100644 --- a/views/components/datetimepicker.blade.php +++ b/views/components/datetimepicker.blade.php @@ -4,6 +4,8 @@ @php if(!isset($isRequired)) { $isRequired = true; } @endphp @php if(!isset($initialValue)) { $initialValue = ''; } @endphp +@php if(empty($earlierThanInfoLimit)) { $earlierThanInfoLimit = ''; } @endphp +@php if(empty($earlierThanInfoText)) { $earlierThanInfoText = ''; } @endphp