From 349a70e418baff964657323e74d94faf33b3e5f3 Mon Sep 17 00:00:00 2001 From: sleeplessnight2 <8561601+sleeplessnight2@users.noreply.github.com> Date: Tue, 1 Dec 2020 23:32:35 +0100 Subject: [PATCH] prefill the Amount or/and Standard Amount per Produkt i'm sorry - this produce a console.error on pooper.js. but it's working. leave the rest from the global Amount untouched in the case, that later it's used again... --- public/viewjs/consume.js | 12 +++++++----- views/productform.blade.php | 4 ++-- views/stocksettings.blade.php | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js index e3462436..2453c284 100644 --- a/public/viewjs/consume.js +++ b/public/viewjs/consume.js @@ -94,7 +94,7 @@ Grocy.Components.ProductAmountPicker.Reset(); $("#display_amount").attr("min", "0." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1"); $("#display_amount").removeAttr("max"); - $('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount)); + $('#display_amount').val(parseFloat(productDetails.product.quick_consume_amount)); RefreshLocaleNumberInput(); $(".input-group-productamountpicker").trigger("change"); $("#tare-weight-handling-info").addClass("d-none"); @@ -160,7 +160,7 @@ $('#save-mark-as-open-button').on('click', function(e) Grocy.FrontendHelpers.EndUiBusy("consume-form"); toastr.success(__t('Marked %1$s of %2$s as opened', jsonForm.amount + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '
' + __t("Undo") + ''); - $('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount)); + $('#display_amount').val(parseFloat(productDetails.product.quick_consume_amount)); RefreshLocaleNumberInput(); $(".input-group-productamountpicker").trigger("change"); Grocy.Components.ProductPicker.Clear(); @@ -276,7 +276,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e) Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id); Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.quantity_unit_stock.id); - $('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount)); + $('#display_amount').val(parseFloat(productDetails.product.quick_consume_amount)); RefreshLocaleNumberInput(); $(".input-group-productamountpicker").trigger("change"); @@ -380,7 +380,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e) } }); -$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount)); +$('#display_amount').val(parseFloat(0)); //ergibt leider aerger mit popper.js beim oeffnen des dropdown... warum auch immer es funktioniert dennoch... $(".input-group-productamountpicker").trigger("change"); Grocy.FrontendHelpers.ValidateForm('consume-form'); @@ -400,9 +400,11 @@ $('#consume-form input').keyup(function(event) Grocy.FrontendHelpers.ValidateForm('consume-form'); }); +//das Timeout wurde eingepflegt damit bei valider vorausgewaehlter Menge die Buttons von selbst aktiviert werden $('#consume-form select').change(function(event) -{ + {setTimeout(function(){ Grocy.FrontendHelpers.ValidateForm('consume-form'); + }, 150) }); $('#consume-form input').keydown(function(event) diff --git a/views/productform.blade.php b/views/productform.blade.php index 0c399dcb..263b61be 100644 --- a/views/productform.blade.php +++ b/views/productform.blade.php @@ -399,11 +399,11 @@ @php if($mode == 'edit') { $value = $product->quick_consume_amount; } else { $value = 1; } @endphp @include('components.numberpicker', array( 'id' => 'quick_consume_amount', - 'label' => 'Quick consume amount', + 'label' => 'Standard Consume-Amount for this Product', 'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1', 'decimals' => $userSettings['stock_decimal_places_amounts'], 'value' => $value, - 'hint' => $__t('This amount is used for the "quick consume/open buttons" on the stock overview page (related to quantity unit stock)'), + 'hint' => $__t('This amount is used as the Standard Amount for Consuming'), 'contextInfoId' => 'quick_consume_qu_info', 'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount' )) diff --git a/views/stocksettings.blade.php b/views/stocksettings.blade.php index 71a9ddf9..5ce8b3f9 100644 --- a/views/stocksettings.blade.php +++ b/views/stocksettings.blade.php @@ -114,7 +114,7 @@ - + {{ $__t('Consume') }} @include('components.numberpicker', array( 'id' => 'stock_default_consume_amount', @@ -124,6 +124,7 @@ 'decimals' => $userSettings['stock_decimal_places_amounts'], 'additionalCssClasses' => 'user-setting-control locale-number-input locale-number-quantity-amount' )) + */ ?>

{{ $__t('Common') }}