mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
Add a checkbox to set the "never expires date" (closes #40)
This commit is contained in:
parent
282ee0885b
commit
339d81318f
@ -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',
|
||||
|
@ -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
|
||||
|
@ -14,6 +14,12 @@
|
||||
<div class="input-group-append" data-target="#{{ $id }}" data-toggle="datetimepicker">
|
||||
<div class="input-group-text"><i class="fas fa-calendar"></i></div>
|
||||
</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 }}">
|
||||
<label class="form-check-label" for="datetimepicker-shortcut">{{ $L($shortcutLabel) }}</label>
|
||||
</div>
|
||||
@endif
|
||||
<div class="invalid-feedback">{{ $invalidFeedback }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -33,7 +33,9 @@
|
||||
'limitStartToNow' => true,
|
||||
'invalidFeedback' => $L('A best before date is required and must be later than today'),
|
||||
'nextInputSelector' => '#best_before_date',
|
||||
'additionalCssClasses' => 'date-only-datetimepicker'
|
||||
'additionalCssClasses' => 'date-only-datetimepicker',
|
||||
'shortcutValue' => '2999-12-31',
|
||||
'shortcutLabel' => 'Never expires'
|
||||
))
|
||||
|
||||
<button id="save-inventory-button" type="submit" class="btn btn-success">{{ $L('OK') }}</button>
|
||||
|
@ -55,9 +55,9 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="default_best_before_days">{{ $L('Default best before days') }}<br><span class="small text-muted">{{ $L('For purchases this amount of days will be added to today for the best before date suggestion') }}</span></label>
|
||||
<input required min="0" type="number" class="form-control" id="default_best_before_days" name="default_best_before_days" value="@if($mode == 'edit'){{ $product->default_best_before_days }}@else{{0}}@endif">
|
||||
<div class="invalid-feedback">{{ $L('This cannot be negative') }}</div>
|
||||
<label for="default_best_before_days">{{ $L('Default best before days') }}<br><span class="small text-muted">{{ $L('For purchases this amount of days will be added to today for the best before date suggestion') }} ({{ $L('-1 means that this product never expires') }})</span></label>
|
||||
<input required min="-1" type="number" class="form-control" id="default_best_before_days" name="default_best_before_days" value="@if($mode == 'edit'){{ $product->default_best_before_days }}@else{{0}}@endif">
|
||||
<div class="invalid-feedback">{{ $L('This cannot be lower than #1', '-1') }}</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
@ -25,7 +25,9 @@
|
||||
'limitStartToNow' => true,
|
||||
'invalidFeedback' => $L('A best before date is required and must be later than today'),
|
||||
'nextInputSelector' => '#amount',
|
||||
'additionalCssClasses' => 'date-only-datetimepicker'
|
||||
'additionalCssClasses' => 'date-only-datetimepicker',
|
||||
'shortcutValue' => '2999-12-31',
|
||||
'shortcutLabel' => 'Never expires'
|
||||
))
|
||||
|
||||
<div class="form-group">
|
||||
|
Loading…
x
Reference in New Issue
Block a user