views consume.blade: add LocationPicker

This commit is contained in:
Kurt Riddlesperger 2019-10-11 14:22:38 -05:00
parent 9258f4eecd
commit 5aacf319a0
3 changed files with 28 additions and 1 deletions

View File

@ -50,7 +50,8 @@ class StockController extends BaseController
{
return $this->AppContainer->view->render($response, 'consume', [
'products' => $this->Database->products()->orderBy('name'),
'recipes' => $this->Database->recipes()->orderBy('name')
'recipes' => $this->Database->recipes()->orderBy('name'),
'locations' => $this->Database->locations()->orderBy('name')
]);
}

View File

@ -21,6 +21,15 @@
jsonData.stock_entry_id = jsonForm.specific_stock_entry;
}
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
{
jsonData.location_id = Grocy.Components.LocationPicker.GetValue();
}
else
{
jsonData.location_id = 1;
}
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_RECIPES && Grocy.Components.RecipePicker.GetValue().toString().length > 0)
{
jsonData.recipe_id = Grocy.Components.RecipePicker.GetValue();
@ -102,6 +111,10 @@
{
Grocy.Components.RecipePicker.Clear();
}
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
{
Grocy.Components.LocationPicker.Clear();
}
Grocy.Components.ProductPicker.GetInputElement().focus();
Grocy.FrontendHelpers.ValidateForm('consume-form');
}
@ -197,6 +210,10 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
{
$('#amount').attr('max', productDetails.stock_amount);
$('#amount_qu_unit').text(productDetails.quantity_unit_stock.name);
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
{
Grocy.Components.LocationPicker.SetId(productDetails.location.id);
}
if (productDetails.product.allow_partial_units_in_stock == 1)
{

View File

@ -27,6 +27,15 @@
'additionalHtmlContextHelp' => '<div id="tare-weight-handling-info" 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(GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
@include('components.locationpicker', array(
'locations' => $locations,
'isRequired' => false
))
@else
<input type="hidden" name="location_id" id="location_id" value="1">
@endif
<div class="form-group">
<label for="use_specific_stock_entry">
<input type="checkbox" id="use_specific_stock_entry" name="use_specific_stock_entry"> {{ $__t('Use a specific stock item') }}