mirror of
https://github.com/grocy/grocy.git
synced 2025-08-17 19:16:37 +00:00
Add a "shopping list item to stock flow" (references #98)
This commit is contained in:
@@ -23,7 +23,7 @@ Grocy.Components.ProductPicker.SetValue = function(value)
|
|||||||
|
|
||||||
Grocy.Components.ProductPicker.InProductAddWorkflow = function()
|
Grocy.Components.ProductPicker.InProductAddWorkflow = function()
|
||||||
{
|
{
|
||||||
return typeof GetUriParam('createdproduct') !== "undefined";
|
return typeof GetUriParam('createdproduct') !== "undefined" || typeof GetUriParam('product') !== "undefined";
|
||||||
}
|
}
|
||||||
|
|
||||||
Grocy.Components.ProductPicker.InProductModifyWorkflow = function()
|
Grocy.Components.ProductPicker.InProductModifyWorkflow = function()
|
||||||
@@ -74,6 +74,17 @@ if (typeof prefillProduct !== "undefined")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var prefillProductId = GetUriParam("product");
|
||||||
|
if (typeof prefillProductId !== "undefined")
|
||||||
|
{
|
||||||
|
$('#product_id').val(prefillProductId);
|
||||||
|
$('#product_id').data('combobox').refresh();
|
||||||
|
$('#product_id').trigger('change');
|
||||||
|
|
||||||
|
var nextInputElement = $(Grocy.Components.ProductPicker.GetPicker().parent().data('next-input-selector').toString());
|
||||||
|
nextInputElement.focus();
|
||||||
|
}
|
||||||
|
|
||||||
var addBarcode = GetUriParam('addbarcodetoselection');
|
var addBarcode = GetUriParam('addbarcodetoselection');
|
||||||
if (addBarcode !== undefined)
|
if (addBarcode !== undefined)
|
||||||
{
|
{
|
||||||
|
@@ -46,6 +46,10 @@
|
|||||||
{
|
{
|
||||||
window.location.href = U('/purchase');
|
window.location.href = U('/purchase');
|
||||||
}
|
}
|
||||||
|
else if (GetUriParam("flow") === "shoppinglistitemtostock")
|
||||||
|
{
|
||||||
|
window.location.href = U('/shoppinglist?flow=shoppinglistitemtostock&listitemid=' + GetUriParam("listitemid"));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$('#amount').val(0);
|
$('#amount').val(0);
|
||||||
@@ -172,6 +176,12 @@ $('#amount').on('change', function (e)
|
|||||||
Grocy.FrontendHelpers.ValidateForm('purchase-form');
|
Grocy.FrontendHelpers.ValidateForm('purchase-form');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (GetUriParam("flow") === "shoppinglistitemtostock")
|
||||||
|
{
|
||||||
|
$('#amount').val(GetUriParam("amount"));
|
||||||
|
$('#save-purchase-button').html(L("OK") + " & " + L("Back to shopping list"));
|
||||||
|
}
|
||||||
|
|
||||||
function UndoStockBooking(bookingId)
|
function UndoStockBooking(bookingId)
|
||||||
{
|
{
|
||||||
Grocy.Api.Get('stock/undo-booking/' + bookingId.toString(),
|
Grocy.Api.Get('stock/undo-booking/' + bookingId.toString(),
|
||||||
|
@@ -126,3 +126,9 @@ $(document).on('click', '#clear-shopping-list', function(e)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (GetUriParam("flow") === "shoppinglistitemtostock")
|
||||||
|
{
|
||||||
|
var listItem = GetUriParam("listitemid");
|
||||||
|
$(".shoppinglist-delete-button[data-shoppinglist-id='" + listItem + "']").click();
|
||||||
|
}
|
||||||
|
@@ -69,6 +69,9 @@
|
|||||||
<a class="btn btn-sm btn-danger shoppinglist-delete-button" href="#" data-shoppinglist-id="{{ $listItem->id }}">
|
<a class="btn btn-sm btn-danger shoppinglist-delete-button" href="#" data-shoppinglist-id="{{ $listItem->id }}">
|
||||||
<i class="fas fa-trash"></i>
|
<i class="fas fa-trash"></i>
|
||||||
</a>
|
</a>
|
||||||
|
<a class="btn btn-sm btn-primary" href="{{ $U('/purchase?flow=shoppinglistitemtostock&product=') }}{{ $listItem->product_id }}&amount={{ $listItem->amount + $listItem->amount_autoadded }}&listitemid={{ $listItem->id }}" data-toggle="tooltip" title="{{ $L('Add #3 #1 of #2 to stock', Pluralize($listItem->amount + $listItem->amount_autoadded, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->qu_id_purchase)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->qu_id_purchase)->name_plural), FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->name, $listItem->amount + $listItem->amount_autoadded) }}">
|
||||||
|
<i class="fas fa-box"></i>
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if(!empty($listItem->product_id)) {{ FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->name }}<br>@endif<em>{!! nl2br($listItem->note) !!}</em>
|
@if(!empty($listItem->product_id)) {{ FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->name }}<br>@endif<em>{!! nl2br($listItem->note) !!}</em>
|
||||||
|
Reference in New Issue
Block a user