mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Allow best before date on purchase/inventory to be today or in the past, but display a hint when so (closes #172)
This commit is contained in:
parent
3d485d4850
commit
bfcd05473a
@ -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?'
|
||||
);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{ $id }}">{{ $L($label) }}
|
||||
@ -20,12 +22,14 @@
|
||||
data-init-value="{{ $initialValue }}"
|
||||
data-limit-end-to-now="{{ BoolToString($limitEndToNow) }}"
|
||||
data-limit-start-to-now="{{ BoolToString($limitStartToNow) }}"
|
||||
data-next-input-selector="{{ $nextInputSelector }}" />
|
||||
data-next-input-selector="{{ $nextInputSelector }}"
|
||||
data-earlier-than-limit="{{ $earlierThanInfoLimit }}" />
|
||||
<div class="input-group-append" data-target="#{{ $id }}" data-toggle="datetimepicker">
|
||||
<div class="input-group-text"><i class="fas fa-calendar"></i></div>
|
||||
</div>
|
||||
<div class="invalid-feedback">{{ $invalidFeedback }}</div>
|
||||
</div>
|
||||
<div id="datetimepicker-earlier-than-info" class="form-text text-info font-italic d-none">{{ $earlierThanInfoText }}</div>
|
||||
@if(isset($shortcutValue) && isset($shortcutLabel))
|
||||
<div class="form-check w-100">
|
||||
<input class="form-check-input" type="checkbox" id="datetimepicker-shortcut" data-datetimepicker-shortcut-value="{{ $shortcutValue }}">
|
||||
|
@ -35,12 +35,14 @@
|
||||
'format' => 'YYYY-MM-DD',
|
||||
'initWithNow' => false,
|
||||
'limitEndToNow' => false,
|
||||
'limitStartToNow' => true,
|
||||
'invalidFeedback' => $L('A best before date is required and must be later than today'),
|
||||
'limitStartToNow' => false,
|
||||
'invalidFeedback' => $L('A best before date is required'),
|
||||
'nextInputSelector' => '#best_before_date',
|
||||
'additionalCssClasses' => 'date-only-datetimepicker',
|
||||
'shortcutValue' => '2999-12-31',
|
||||
'shortcutLabel' => 'Never expires'
|
||||
'shortcutLabel' => 'Never expires',
|
||||
'earlierThanInfoLimit' => date('Y-m-d'),
|
||||
'earlierThanInfoText' => $L('The given date is earlier than today, are you sure?')
|
||||
))
|
||||
|
||||
<button id="save-inventory-button" class="btn btn-success">{{ $L('OK') }}</button>
|
||||
|
@ -22,12 +22,14 @@
|
||||
'format' => 'YYYY-MM-DD',
|
||||
'initWithNow' => false,
|
||||
'limitEndToNow' => false,
|
||||
'limitStartToNow' => true,
|
||||
'invalidFeedback' => $L('A best before date is required and must be later than today'),
|
||||
'limitStartToNow' => false,
|
||||
'invalidFeedback' => $L('A best before date is required'),
|
||||
'nextInputSelector' => '#amount',
|
||||
'additionalCssClasses' => 'date-only-datetimepicker',
|
||||
'shortcutValue' => '2999-12-31',
|
||||
'shortcutLabel' => 'Never expires'
|
||||
'shortcutLabel' => 'Never expires',
|
||||
'earlierThanInfoLimit' => date('Y-m-d'),
|
||||
'earlierThanInfoText' => $L('The given date is earlier than today, are you sure?')
|
||||
))
|
||||
|
||||
@include('components.numberpicker', array(
|
||||
@ -52,8 +54,7 @@
|
||||
|
||||
@include('components.locationpicker', array(
|
||||
'locations' => $locations,
|
||||
'isRequired' => false,
|
||||
'hint' => $L('This is for statistical purposes only')
|
||||
'isRequired' => false
|
||||
))
|
||||
|
||||
<button id="save-purchase-button" class="btn btn-success">{{ $L('OK') }}</button>
|
||||
|
Loading…
x
Reference in New Issue
Block a user