Allow no product for shopping list items & always in-/decrement by 1 when using the number input arrow buttons (fixes #964)

This commit is contained in:
Bernd Bestel
2020-10-18 14:27:23 +02:00
parent 7e08224c75
commit 80cf68aeaa
13 changed files with 11 additions and 30 deletions

View File

@@ -1,17 +1,17 @@
$(".numberpicker-down-button").unbind('click').on("click", function()
{
var inputElement = $(this).parent().parent().find('input[type="number"]')[0];
inputElement.stepDown();
$(inputElement).trigger('keyup');
$(inputElement).trigger('change');
var inputElement = $(this).parent().parent().find('input[type="number"]');
inputElement.val(parseFloat(inputElement.val()) - 1);
inputElement.trigger('keyup');
inputElement.trigger('change');
});
$(".numberpicker-up-button").unbind('click').on("click", function()
{
var inputElement = $(this).parent().parent().find('input[type="number"]')[0];
inputElement.stepUp();
$(inputElement).trigger('keyup');
$(inputElement).trigger('change');
var inputElement = $(this).parent().parent().find('input[type="number"]');
inputElement.val(parseFloat(inputElement.val()) + 1);
inputElement.trigger('keyup');
inputElement.trigger('change');
});
$(".numberpicker").on("keyup", function()

View File

@@ -138,15 +138,8 @@ if (Grocy.EditMode === "edit")
}
$('#amount').on('focus', function(e)
{
if (Grocy.Components.ProductPicker.GetValue().length === 0 && Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK)
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}
else
{
$(this).select();
}
});
$('#shoppinglist-form input').keyup(function(event)

View File

@@ -256,7 +256,6 @@
'label' => 'Amount',
'hintId' => 'amount_qu_unit',
'min' => 0.0001,
'step' => 0.0001,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
'isRequired' => false,
'value' => $value

View File

@@ -5,7 +5,6 @@
@php if(!isset($value)) { $value = 1; } @endphp
@php if(empty($min)) { $min = 0; } @endphp
@php if(empty($max)) { $max = 999999; } @endphp
@php if(empty($step)) { $step = 1; } @endphp
@php if(empty($hint)) { $hint = ''; } @endphp
@php if(empty($hintId)) { $hintId = ''; } @endphp
@php if(empty($additionalCssClasses)) { $additionalCssClasses = ''; } @endphp
@@ -36,7 +35,7 @@
value="{{ $value }}"
min="{{ $min }}"
max="{{ $max }}"
step="{{ $step }}"
step="{{ $min }}"
@if($isRequired)
required
@endif>

View File

@@ -42,7 +42,6 @@
'label' => $userfield->caption,
'noNameAttribute' => true,
'min' => 0,
'step' => 0.01,
'isRequired' => false,
'additionalCssClasses' => 'userfield-input',
'additionalAttributes' => 'data-userfield-name="' . $userfield->name . '"'

View File

@@ -64,7 +64,6 @@
'id' => 'price',
'label' => 'Price',
'min' => 0,
'step' => 0.01,
'value' => '',
'hint' => $__t('in %s per purchase quantity unit', GROCY_CURRENCY),
'additionalHtmlContextHelp' => '<br><span class="small text-muted">' . $__t('This will apply to added products') . '</span>',

View File

@@ -286,7 +286,6 @@
'id' => 'tare_weight',
'label' => 'Tare weight',
'min' => 0,
'step' => 0.01,
'value' => $value,
'invalidFeedback' => $__t('This cannot be lower than %s', '0'),
'additionalAttributes' => $additionalAttributes,
@@ -315,7 +314,6 @@
'id' => 'calories',
'label' => 'Energy (kcal)',
'min' => 0,
'step' => 0.01,
'value' => $value,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'),
'hint' => $__t('Per stock quantity unit'),

View File

@@ -94,7 +94,6 @@
'id' => 'price',
'label' => 'Price',
'min' => 0,
'step' => 0.01,
'value' => '',
'hintId' => 'price-hint',
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'),

View File

@@ -82,7 +82,6 @@
'id' => 'factor',
'label' => 'Factor',
'min' => 0,
'step' => 0.001,
'value' => $value,
'invalidFeedback' => $__t('This cannot be lower than %1$s and must be a valid number with max. %2$s decimal places', '0', '3'),
'additionalHtmlElements' => '<p id="qu-conversion-info"

View File

@@ -39,7 +39,6 @@
'id' => 'amount',
'label' => 'Amount',
'min' => 0,
'step' => 1,
'isRequired' => false,
'value' => 1
))

View File

@@ -107,7 +107,6 @@
'id' => 'price_factor',
'label' => 'Price factor',
'min' => 0,
'step' => 0.01,
'value' => '',
'hint' => $__t('The resulting price of this ingredient will be multiplied by this factor'),
'invalidFeedback' => $__t('This cannot be lower than %s', '0'),

View File

@@ -65,7 +65,6 @@
'label' => 'Amount',
'hintId' => 'amount_qu_unit',
'min' => 0.01,
'step' => 0.01,
'value' => $value,
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0.01')
))

View File

@@ -89,7 +89,6 @@
'value' => $price,
'label' => 'Price',
'min' => 0,
'step' => 0.01,
'hint' => $__t('in %s per purchase quantity unit', GROCY_CURRENCY),
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'),
'isRequired' => false