Made "Disable stock fulfillment checking for this ingredient" a default option per product (closes #182)

This commit is contained in:
Bernd Bestel 2019-04-06 15:42:40 +02:00
parent 25c257bb2c
commit fa6f09679f
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
3 changed files with 16 additions and 2 deletions

View File

@ -46,7 +46,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
Grocy.Components.ProductCard.Refresh(productId); Grocy.Components.ProductCard.Refresh(productId);
Grocy.Api.Get('stock/products/' + productId, Grocy.Api.Get('stock/products/' + productId,
function (productDetails) function(productDetails)
{ {
if (!$("#only_check_single_unit_in_stock").is(":checked")) if (!$("#only_check_single_unit_in_stock").is(":checked"))
{ {
@ -66,6 +66,8 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
$("#amount").parent().find(".invalid-feedback").text(L('The amount cannot be lower than #1', '1')); $("#amount").parent().find(".invalid-feedback").text(L('The amount cannot be lower than #1', '1'));
} }
$("#not_check_stock_fulfillment").prop("checked", productDetails.product.not_check_stock_fulfillment_for_recipes == 1);
$('#amount').focus(); $('#amount').focus();
Grocy.FrontendHelpers.ValidateForm('recipe-pos-form'); Grocy.FrontendHelpers.ValidateForm('recipe-pos-form');
}, },

View File

@ -165,6 +165,18 @@
'hintId' => 'tare_weight_qu_info' 'hintId' => 'tare_weight_qu_info'
)) ))
@if(GROCY_FEATURE_FLAG_RECIPES)
<div class="form-group">
<div class="form-check">
<input type="hidden" name="not_check_stock_fulfillment_for_recipes" value="0">
<input @if($mode == 'edit' && $product->not_check_stock_fulfillment_for_recipes == 1) checked @endif class="form-check-input" type="checkbox" id="not_check_stock_fulfillment_for_recipes" name="not_check_stock_fulfillment_for_recipes" value="1">
<label class="form-check-label" for="not_check_stock_fulfillment_for_recipes">{{ $L('Disable stock fulfillment checking for this ingredient') }}
<span class="text-muted small">{{ $L('This will be used as the default setting when adding this product as a recipe ingredient') }}</span>
</label>
</div>
</div>
@endif
<div class="form-group"> <div class="form-group">
<label for="product-picture">{{ $L('Product picture') }} <label for="product-picture">{{ $L('Product picture') }}
<span class="text-muted small">{{ $L('If you don\'t select a file, the current picture will not be altered') }}</span> <span class="text-muted small">{{ $L('If you don\'t select a file, the current picture will not be altered') }}</span>

View File

@ -71,7 +71,7 @@
<div class="form-check mb-3"> <div class="form-check mb-3">
<input type="hidden" name="not_check_stock_fulfillment" value="0"> <input type="hidden" name="not_check_stock_fulfillment" value="0">
<input @if($mode == 'edit' && $recipePos->not_check_stock_fulfillment == 1) checked @endif class="form-check-input" type="checkbox" id="not_check_stock_fulfillment" name="not_check_stock_fulfillment" value="1"> <input @if($mode == 'edit' && ($recipePos->not_check_stock_fulfillment == 1 || FindObjectInArrayByPropertyValue($products, 'id', $recipePos->product_id)->not_check_stock_fulfillment_for_recipes == 1)) checked @endif class="form-check-input" type="checkbox" id="not_check_stock_fulfillment" name="not_check_stock_fulfillment" value="1">
<label class="form-check-label" for="not_check_stock_fulfillment">{{ $L('Disable stock fulfillment checking for this ingredient') }}</label> <label class="form-check-label" for="not_check_stock_fulfillment">{{ $L('Disable stock fulfillment checking for this ingredient') }}</label>
</div> </div>