mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Also use the productamountpicker on the shopping list item page (refernces #1015)
This commit is contained in:
parent
8400175f1d
commit
33a6a28208
@ -25,7 +25,7 @@
|
|||||||
- (Thanks @fipwmaqzufheoxq92ebc for the initial work on this)
|
- (Thanks @fipwmaqzufheoxq92ebc for the initial work on this)
|
||||||
|
|
||||||
### Stock improvements/fixes
|
### Stock improvements/fixes
|
||||||
- On the purchase/consume/transfer/inventory page any product related quantity unit can now be used
|
- On the purchase/consume/transfer/inventory/shopping list item page (so everywhere) any product related quantity unit can now be used
|
||||||
- When creating a quantity unit conversion it's now possible to automatically create the inverse conversion (thanks @kriddles)
|
- When creating a quantity unit conversion it's now possible to automatically create the inverse conversion (thanks @kriddles)
|
||||||
- Optimized/clarified what the total/unit price is on the purchase page (thanks @kriddles)
|
- 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 best before date for better `TAB` handling (thanks @kriddles)
|
- On the purchase page the amount field is now displayed above/before the best before date for better `TAB` handling (thanks @kriddles)
|
||||||
|
@ -30,9 +30,7 @@ class StockController extends BaseController
|
|||||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||||
'barcodes' => $productBarcodes,
|
'barcodes' => $productBarcodes,
|
||||||
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name'),
|
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name'),
|
||||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||||
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
|
||||||
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +345,9 @@ class StockController extends BaseController
|
|||||||
return $this->renderPage($response, 'shoppinglistitemform', [
|
return $this->renderPage($response, 'shoppinglistitemform', [
|
||||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||||
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
|
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
|
||||||
'mode' => 'create'
|
'mode' => 'create',
|
||||||
|
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
|
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -356,7 +356,9 @@ class StockController extends BaseController
|
|||||||
'listItem' => $this->getDatabase()->shopping_list($args['itemId']),
|
'listItem' => $this->getDatabase()->shopping_list($args['itemId']),
|
||||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||||
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
|
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
|
||||||
'mode' => 'edit'
|
'mode' => 'edit',
|
||||||
|
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
|
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1374,7 +1374,7 @@ msgstr ""
|
|||||||
msgid "Override for product"
|
msgid "Override for product"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "This equals %1$s %2$s in stock"
|
msgid "This equals %1$s %2$s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Edit QU conversion"
|
msgid "Edit QU conversion"
|
||||||
|
@ -87,7 +87,7 @@ $(".input-group-productamountpicker").on("change", function()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$("#qu-conversion-info").removeClass("d-none");
|
$("#qu-conversion-info").removeClass("d-none");
|
||||||
$("#qu-conversion-info").text(__t("This equals %1$s %2$s in stock", destinationAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }), destinationQuName));
|
$("#qu-conversion-info").text(__t("This equals %1$s %2$s", destinationAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }), destinationQuName));
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#amount").val(destinationAmount.toFixed(4).replace(/0*$/g, ''));
|
$("#amount").val(destinationAmount.toFixed(4).replace(/0*$/g, ''));
|
||||||
|
@ -272,7 +272,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
function(productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
|
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
|
||||||
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.quantity_unit_purchase.id);
|
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.quantity_unit_stock.id);
|
||||||
|
|
||||||
$("#location_id").find("option").remove().end().append("<option></option>");
|
$("#location_id").find("option").remove().end().append("<option></option>");
|
||||||
Grocy.Api.Get("stock/products/" + productId + '/locations',
|
Grocy.Api.Get("stock/products/" + productId + '/locations',
|
||||||
|
@ -133,7 +133,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
function(productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
|
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
|
||||||
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.quantity_unit_purchase.id);
|
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.quantity_unit_stock.id);
|
||||||
|
|
||||||
$('#display_amount').attr('data-not-equal', productDetails.stock_amount);
|
$('#display_amount').attr('data-not-equal', productDetails.stock_amount);
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var jsonData = $('#shoppinglist-form').serializeJSON();
|
var jsonData = $('#shoppinglist-form').serializeJSON();
|
||||||
|
delete jsonData.display_amount;
|
||||||
|
delete jsonData.qu_id;
|
||||||
Grocy.FrontendHelpers.BeginUiBusy("shoppinglist-form");
|
Grocy.FrontendHelpers.BeginUiBusy("shoppinglist-form");
|
||||||
|
|
||||||
if (GetUriParam("updateexistingproduct") !== undefined)
|
if (GetUriParam("updateexistingproduct") !== undefined)
|
||||||
@ -118,9 +120,10 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
Grocy.Api.Get('stock/products/' + productId,
|
Grocy.Api.Get('stock/products/' + productId,
|
||||||
function(productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
|
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_purchase.id);
|
||||||
|
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.quantity_unit_purchase.id);
|
||||||
|
|
||||||
$('#amount').focus();
|
$('#display_amount').focus();
|
||||||
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
|
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
@ -140,7 +143,7 @@ if (Grocy.EditMode === "edit")
|
|||||||
Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#amount').on('focus', function(e)
|
$('#display_amount').on('focus', function(e)
|
||||||
{
|
{
|
||||||
$(this).select();
|
$(this).select();
|
||||||
});
|
});
|
||||||
@ -174,8 +177,8 @@ if (GetUriParam("list") !== undefined)
|
|||||||
|
|
||||||
if (GetUriParam("amount") !== undefined)
|
if (GetUriParam("amount") !== undefined)
|
||||||
{
|
{
|
||||||
$("#amount").val(parseFloat(GetUriParam("amount")).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }));
|
$("#display_amount").val(parseFloat(GetUriParam("amount")).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }));
|
||||||
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
|
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', "0." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1"));
|
$("#display_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', "0." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1"));
|
||||||
|
@ -139,7 +139,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
function(productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
|
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
|
||||||
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.quantity_unit_purchase.id);
|
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.quantity_unit_stock.id);
|
||||||
|
|
||||||
if (productDetails.product.enable_tare_weight_handling == 1)
|
if (productDetails.product.enable_tare_weight_handling == 1)
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
@php if(empty($additionalHtmlContextHelp)) { $additionalHtmlContextHelp = ''; } @endphp
|
@php if(empty($additionalHtmlContextHelp)) { $additionalHtmlContextHelp = ''; } @endphp
|
||||||
@php if(empty($additionalHtmlElements)) { $additionalHtmlElements = ''; } @endphp
|
@php if(empty($additionalHtmlElements)) { $additionalHtmlElements = ''; } @endphp
|
||||||
@php if(empty($label)) { $label = 'Amount'; } @endphp
|
@php if(empty($label)) { $label = 'Amount'; } @endphp
|
||||||
|
@php if(empty($initialQuId)) { $initialQuId = '-1'; } @endphp
|
||||||
|
|
||||||
<div class="form-group row {{ $additionalGroupCssClasses }}">
|
<div class="form-group row {{ $additionalGroupCssClasses }}">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
@ -9,6 +9,11 @@
|
|||||||
@section('viewJsName', 'shoppinglistitemform')
|
@section('viewJsName', 'shoppinglistitemform')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
<script>
|
||||||
|
Grocy.QuantityUnits = {!! json_encode($quantityUnits) !!};
|
||||||
|
Grocy.QuantityUnitConversionsResolved = {!! json_encode($quantityUnitConversionsResolved) !!};
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h2 class="title">@yield('title')</h2>
|
<h2 class="title">@yield('title')</h2>
|
||||||
@ -62,13 +67,9 @@
|
|||||||
))
|
))
|
||||||
</div>
|
</div>
|
||||||
@php if($mode == 'edit') { $value = $listItem->amount; } else { $value = 1; } @endphp
|
@php if($mode == 'edit') { $value = $listItem->amount; } else { $value = 1; } @endphp
|
||||||
@include('components.numberpicker', array(
|
@include('components.productamountpicker', array(
|
||||||
'id' => 'amount',
|
|
||||||
'label' => 'Amount',
|
|
||||||
'hintId' => 'amount_qu_unit',
|
|
||||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
|
||||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
|
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1')
|
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1')
|
||||||
))
|
))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user