mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
Also use the productamountpicker for inventory (refernces #1015)
This commit is contained in:
parent
ad3b91ef98
commit
b6f4cfa851
@ -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 page any product related quantity unit can now be used
|
- On the purchase/consume/transfer/inventory page 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,7 +30,9 @@ 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()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var jsonData = {};
|
var jsonData = {};
|
||||||
jsonData.new_amount = jsonForm.new_amount;
|
jsonData.new_amount = jsonForm.amount;
|
||||||
jsonData.best_before_date = Grocy.Components.DateTimePicker.GetValue();
|
jsonData.best_before_date = Grocy.Components.DateTimePicker.GetValue();
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||||
{
|
{
|
||||||
@ -80,13 +80,13 @@
|
|||||||
Grocy.FrontendHelpers.EndUiBusy("inventory-form");
|
Grocy.FrontendHelpers.EndUiBusy("inventory-form");
|
||||||
toastr.success(successMessage);
|
toastr.success(successMessage);
|
||||||
|
|
||||||
|
Grocy.Components.ProductAmountPicker.Reset();
|
||||||
$('#inventory-change-info').addClass('d-none');
|
$('#inventory-change-info').addClass('d-none');
|
||||||
$("#tare-weight-handling-info").addClass("d-none");
|
$("#tare-weight-handling-info").addClass("d-none");
|
||||||
$("#new_amount").attr("min", "0");
|
$("#display_amount").attr("min", "0");
|
||||||
$("#new_amount").attr("step", "1");
|
$("#display_amount").attr("step", "1");
|
||||||
$("#new_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', '0'));
|
$("#display_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', '0'));
|
||||||
$('#new_amount').val('');
|
$('#display_amount').val('');
|
||||||
$('#new_amount_qu_unit').text("");
|
|
||||||
$('#price').val('');
|
$('#price').val('');
|
||||||
Grocy.Components.DateTimePicker.Clear();
|
Grocy.Components.DateTimePicker.Clear();
|
||||||
Grocy.Components.ProductPicker.SetValue('');
|
Grocy.Components.ProductPicker.SetValue('');
|
||||||
@ -132,26 +132,28 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
Grocy.Api.Get('stock/products/' + productId,
|
Grocy.Api.Get('stock/products/' + productId,
|
||||||
function(productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
$('#new_amount').attr('data-not-equal', productDetails.stock_amount);
|
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
|
||||||
$('#new_amount_qu_unit').text(productDetails.quantity_unit_stock.name);
|
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.quantity_unit_purchase.id);
|
||||||
|
|
||||||
|
$('#display_amount').attr('data-not-equal', productDetails.stock_amount);
|
||||||
|
|
||||||
if (productDetails.product.allow_partial_units_in_stock == 1)
|
if (productDetails.product.allow_partial_units_in_stock == 1)
|
||||||
{
|
{
|
||||||
$("#new_amount").attr("min", "0." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1");
|
$("#display_amount").attr("min", "0." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1");
|
||||||
$("#amount").attr("step", "." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1");
|
$("#display_amount").attr("step", "." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1");
|
||||||
$("#new_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s or equal %2$s', "0." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1", productDetails.stock_amount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts })));
|
$("#display_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s or equal %2$s', "0." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1", productDetails.stock_amount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts })));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$("#new_amount").attr("min", "0");
|
$("#display_amount").attr("min", "0");
|
||||||
$("#new_amount").attr("step", "1");
|
$("#display_amount").attr("step", "1");
|
||||||
$("#new_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s or equal %2$s', '0', productDetails.stock_amount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts })));
|
$("#display_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s or equal %2$s', '0', productDetails.stock_amount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts })));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (productDetails.product.enable_tare_weight_handling == 1)
|
if (productDetails.product.enable_tare_weight_handling == 1)
|
||||||
{
|
{
|
||||||
$("#new_amount").attr("min", productDetails.product.tare_weight);
|
$("#display_amount").attr("min", productDetails.product.tare_weight);
|
||||||
$("#new_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s or equal %2$s', parseFloat(productDetails.product.tare_weight).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }), (parseFloat(productDetails.stock_amount) + parseFloat(productDetails.product.tare_weight)).toLocaleString()));
|
$("#display_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %1$s or equal %2$s', parseFloat(productDetails.product.tare_weight).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }), (parseFloat(productDetails.stock_amount) + parseFloat(productDetails.product.tare_weight)).toLocaleString()));
|
||||||
$("#tare-weight-handling-info").removeClass("d-none");
|
$("#tare-weight-handling-info").removeClass("d-none");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -169,9 +171,9 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
Grocy.Components.LocationPicker.SetId(productDetails.location.id);
|
Grocy.Components.LocationPicker.SetId(productDetails.location.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#new_amount').val(productDetails.stock_amount);
|
$('#display_amount').val(productDetails.stock_amount);
|
||||||
$('#new_amount').focus();
|
$('#display_amount').focus();
|
||||||
$('#new_amount').trigger('keyup');
|
$('#display_amount').trigger('keyup');
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
@ -181,7 +183,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#new_amount').val('');
|
$('#display_amount').val('');
|
||||||
Grocy.FrontendHelpers.ValidateForm('inventory-form');
|
Grocy.FrontendHelpers.ValidateForm('inventory-form');
|
||||||
|
|
||||||
if (Grocy.Components.ProductPicker.InProductAddWorkflow() === false)
|
if (Grocy.Components.ProductPicker.InProductAddWorkflow() === false)
|
||||||
@ -193,7 +195,7 @@ else
|
|||||||
Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#new_amount').on('focus', function(e)
|
$('#display_amount').on('focus', function(e)
|
||||||
{
|
{
|
||||||
if (Grocy.Components.ProductPicker.GetValue().length === 0)
|
if (Grocy.Components.ProductPicker.GetValue().length === 0)
|
||||||
{
|
{
|
||||||
@ -227,9 +229,9 @@ $('#inventory-form input').keydown(function(event)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#new_amount').on('keypress', function(e)
|
$('#display_amount').on('keypress', function(e)
|
||||||
{
|
{
|
||||||
$('#new_amount').trigger('change');
|
$('#display_amount').trigger('change');
|
||||||
});
|
});
|
||||||
|
|
||||||
Grocy.Components.DateTimePicker.GetInputElement().on('change', function(e)
|
Grocy.Components.DateTimePicker.GetInputElement().on('change', function(e)
|
||||||
@ -242,10 +244,10 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keypress', function(e)
|
|||||||
Grocy.FrontendHelpers.ValidateForm('inventory-form');
|
Grocy.FrontendHelpers.ValidateForm('inventory-form');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#new_amount').on('keyup', function(e)
|
$('#display_amount').on('keyup', function(e)
|
||||||
{
|
{
|
||||||
var productId = Grocy.Components.ProductPicker.GetValue();
|
var productId = Grocy.Components.ProductPicker.GetValue();
|
||||||
var newAmount = parseInt($('#new_amount').val());
|
var newAmount = parseInt($('#display_amount').val());
|
||||||
|
|
||||||
if (productId)
|
if (productId)
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
@php if(empty($additionalGroupCssClasses)) { $additionalGroupCssClasses = ''; } @endphp
|
@php if(empty($additionalGroupCssClasses)) { $additionalGroupCssClasses = ''; } @endphp
|
||||||
@php if(empty($additionalHtmlContextHelp)) { $additionalHtmlContextHelp = ''; } @endphp
|
@php if(empty($additionalHtmlContextHelp)) { $additionalHtmlContextHelp = ''; } @endphp
|
||||||
|
@php if(empty($additionalHtmlElements)) { $additionalHtmlElements = ''; } @endphp
|
||||||
|
@php if(empty($label)) { $label = 'Amount'; } @endphp
|
||||||
|
|
||||||
<div class="form-group row {{ $additionalGroupCssClasses }}">
|
<div class="form-group row {{ $additionalGroupCssClasses }}">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
@ -13,14 +15,15 @@
|
|||||||
|
|
||||||
@include('components.numberpicker', array(
|
@include('components.numberpicker', array(
|
||||||
'id' => 'display_amount',
|
'id' => 'display_amount',
|
||||||
'label' => 'Amount',
|
'label' => $label,
|
||||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
'invalidFeedback' => $__t('This cannot be negative and must be an integral number'),
|
'invalidFeedback' => $__t('This cannot be negative and must be an integral number'),
|
||||||
'additionalGroupCssClasses' => 'col-sm-5 col-xs-12 my-0',
|
'additionalGroupCssClasses' => 'col-sm-5 col-xs-12 my-0',
|
||||||
'additionalCssClasses' => 'input-group-productamountpicker',
|
'additionalCssClasses' => 'input-group-productamountpicker',
|
||||||
'additionalHtmlContextHelp' => ''
|
'additionalHtmlContextHelp' => '',
|
||||||
|
'additionalHtmlElements' => ''
|
||||||
))
|
))
|
||||||
|
|
||||||
<div class="col-sm-7 col-xs-12">
|
<div class="col-sm-7 col-xs-12">
|
||||||
@ -36,7 +39,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="qu-conversion-info"
|
<div id="qu-conversion-info"
|
||||||
class="col form-text text-info d-none"></div>
|
class="ml-3 my-0 form-text text-info d-none w-100"></div>
|
||||||
|
|
||||||
|
{!! $additionalHtmlElements !!}
|
||||||
|
|
||||||
<input type="hidden"
|
<input type="hidden"
|
||||||
id="amount"
|
id="amount"
|
||||||
name="amount"
|
name="amount"
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
@section('viewJsName', 'inventory')
|
@section('viewJsName', 'inventory')
|
||||||
|
|
||||||
@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-xs-12 col-md-6 col-xl-4 pb-3">
|
<div class="col-xs-12 col-md-6 col-xl-4 pb-3">
|
||||||
<h2 class="title">@yield('title')</h2>
|
<h2 class="title">@yield('title')</h2>
|
||||||
@ -20,19 +25,14 @@
|
|||||||
'nextInputSelector' => '#new_amount'
|
'nextInputSelector' => '#new_amount'
|
||||||
))
|
))
|
||||||
|
|
||||||
@include('components.numberpicker', array(
|
@include('components.productamountpicker', array(
|
||||||
'id' => 'new_amount',
|
|
||||||
'label' => 'New stock amount',
|
|
||||||
'hintId' => 'new_amount_qu_unit',
|
|
||||||
'min' => 0,
|
|
||||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
|
||||||
'value' => 1,
|
'value' => 1,
|
||||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'),
|
'label' => 'New stock amount',
|
||||||
'additionalAttributes' => 'data-not-equal="-1"',
|
'additionalAttributes' => 'data-not-equal="-1"',
|
||||||
'additionalHtmlElements' => '<div id="inventory-change-info"
|
'additionalHtmlElements' => '<div id="inventory-change-info"
|
||||||
class="form-text text-muted small d-none"></div>',
|
class="form-text text-muted d-none ml-3 my-0 w-100"></div>',
|
||||||
'additionalHtmlContextHelp' => '<div id="tare-weight-handling-info"
|
'additionalHtmlContextHelp' => '<div id="tare-weight-handling-info"
|
||||||
class="text-small text-info font-italic d-none">' . $__t('Tare weight handling enabled - please weigh the whole container, the amount to be posted will be automatically calculcated') . '</div>'
|
class="text-info font-italic d-none">' . $__t('Tare weight handling enabled - please weigh the whole container, the amount to be posted will be automatically calculcated') . '</div>'
|
||||||
))
|
))
|
||||||
|
|
||||||
@if(boolval($userSettings['show_purchased_date_on_purchase']))
|
@if(boolval($userSettings['show_purchased_date_on_purchase']))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user