Use the products "Quick consume amount" optionally also on the consume page (closes #1148)

This commit is contained in:
Bernd Bestel 2020-12-04 18:16:58 +01:00
parent 8ec7e9923c
commit 2bdb6ab2d4
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
6 changed files with 62 additions and 4 deletions

View File

@ -44,6 +44,7 @@
- The product option "Allow partial units in stock" was removed, partial amounts are now possible by default for all products
- On purchase there is now a warning shown, when the due date of the purchased product is earlier than the next due date in stock (enabled by default, can be disabled by a new stock setting (top right corner settings menu))
- The amount to be used for the "quick consume/open buttons" on the stock overview page can now be configured per product (new product option "Quick consume amount", defaults to 1)
- This "Quick consume amount" can optionally also be used as the default on the consume page (new stock setting / top right corner settings menu)
- Products can now be duplicated (new button on the products list page, all fields will be preset from the copied product, except the name)
- Optimized/clarified what the total/unit price is on the purchase page (thanks @kriddles)
- On the purchase page the amount field is now displayed above/before the due date for better `TAB` handling (thanks @kriddles)

View File

@ -116,6 +116,7 @@ DefaultUserSetting('stock_decimal_places_prices', 2); // Default decimal places
DefaultUserSetting('stock_due_soon_days', 5);
DefaultUserSetting('stock_default_purchase_amount', 0);
DefaultUserSetting('stock_default_consume_amount', 1);
DefaultUserSetting('stock_default_consume_amount_use_quick_consume_amount', false);
DefaultUserSetting('scan_mode_consume_enabled', false);
DefaultUserSetting('scan_mode_purchase_enabled', false);
DefaultUserSetting('show_icon_on_stock_overview_page_when_product_is_on_shopping_list', true);

View File

@ -1993,3 +1993,6 @@ msgstr ""
msgid "Download file"
msgstr ""
msgid "Use the products \"Quick consume amount\""
msgstr ""

View File

@ -94,7 +94,14 @@
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));
if (BoolVal(Grocy.UserSettings.stock_default_consume_amount_use_quick_consume_amount))
{
$('#display_amount').val(productDetails.product.quick_consume_amount);
}
else
{
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount));
}
RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
$("#tare-weight-handling-info").addClass("d-none");
@ -160,7 +167,14 @@ $('#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) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + result.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>');
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount));
if (BoolVal(Grocy.UserSettings.stock_default_consume_amount_use_quick_consume_amount))
{
$('#display_amount').val(productDetails.product.quick_consume_amount);
}
else
{
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount));
}
RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
Grocy.Components.ProductPicker.Clear();
@ -276,7 +290,14 @@ 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));
if (BoolVal(Grocy.UserSettings.stock_default_consume_amount_use_quick_consume_amount))
{
$('#display_amount').val(productDetails.product.quick_consume_amount);
}
else
{
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount));
}
RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");

View File

@ -21,4 +21,22 @@ if (BoolVal(Grocy.UserSettings.show_warning_on_purchase_when_due_date_is_earlier
$("#show_warning_on_purchase_when_due_date_is_earlier_than_next").prop("checked", true);
}
if (BoolVal(Grocy.UserSettings.stock_default_consume_amount_use_quick_consume_amount))
{
$("#stock_default_consume_amount_use_quick_consume_amount").prop("checked", true);
$("#stock_default_consume_amount").attr("disabled", "");
}
RefreshLocaleNumberInput();
$("#stock_default_consume_amount_use_quick_consume_amount").on("click", function()
{
if (this.checked)
{
$("#stock_default_consume_amount").attr("disabled", "");
}
else
{
$("#stock_default_consume_amount").removeAttr("disabled");
}
});

View File

@ -122,9 +122,23 @@
'label' => 'Default amount for consume',
'min' => 0,
'decimals' => $userSettings['stock_decimal_places_amounts'],
'additionalCssClasses' => 'user-setting-control locale-number-input locale-number-quantity-amount'
'additionalCssClasses' => 'user-setting-control locale-number-input locale-number-quantity-amount',
'additionalGroupCssClasses' => 'mb-0'
))
<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox"
class="form-check-input custom-control-input user-setting-control"
id="stock_default_consume_amount_use_quick_consume_amount"
data-setting-key="stock_default_consume_amount_use_quick_consume_amount">
<label class="form-check-label custom-control-label"
for="stock_default_consume_amount_use_quick_consume_amount">
{{ $__t('Use the products "Quick consume amount"') }}
</label>
</div>
</div>
<h4 class="mt-2">{{ $__t('Common') }}</h4>
@include('components.numberpicker', array(