mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 20:26:42 +00:00
Finish "shopping list to stock workflow" (closes #98)
This commit is contained in:
@@ -302,5 +302,8 @@ return array(
|
|||||||
'Booking successfully undone' => 'Booking successfully undone',
|
'Booking successfully undone' => 'Booking successfully undone',
|
||||||
'Charge cycle successfully undone' => 'Charge cycle successfully undone',
|
'Charge cycle successfully undone' => 'Charge cycle successfully undone',
|
||||||
'This cannot be negative and must be an integral number' => 'This cannot be negative and must be an integral number',
|
'This cannot be negative and must be an integral number' => 'This cannot be negative and must be an integral number',
|
||||||
'Disable stock fulfillment checking for this ingredient' => 'Disable stock fulfillment checking for this ingredient'
|
'Disable stock fulfillment checking for this ingredient' => 'Disable stock fulfillment checking for this ingredient',
|
||||||
|
'Add all list items to stock' => 'Add all list items to stock',
|
||||||
|
'Add #3 #1 of #2 to stock' => 'Add #3 #1 of #2 to stock',
|
||||||
|
'Adding shopping list item #1 of #2' => 'Adding shopping list item #1 of #2'
|
||||||
);
|
);
|
||||||
|
@@ -82,6 +82,10 @@ body.embedded.fixed-nav {
|
|||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iframe {
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Hide the default up/down arrow buttons for number inputs because we use our own buttons in numberpicker */
|
/* Hide the default up/down arrow buttons for number inputs because we use our own buttons in numberpicker */
|
||||||
input[type='number'] {
|
input[type='number'] {
|
||||||
-moz-appearance: textfield;
|
-moz-appearance: textfield;
|
||||||
|
@@ -345,3 +345,15 @@ $(window).on('resize', function()
|
|||||||
{
|
{
|
||||||
ResizeResponsiveEmbeds($("body").hasClass("fullscreen-card"));
|
ResizeResponsiveEmbeds($("body").hasClass("fullscreen-card"));
|
||||||
});
|
});
|
||||||
|
$("iframe").on("load", function()
|
||||||
|
{
|
||||||
|
ResizeResponsiveEmbeds($("body").hasClass("fullscreen-card"));
|
||||||
|
});
|
||||||
|
|
||||||
|
function WindowMessageBag(message, payload = null)
|
||||||
|
{
|
||||||
|
var obj = { };
|
||||||
|
obj.Message = message;
|
||||||
|
obj.Payload = payload;
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
@@ -40,18 +40,21 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
toastr.success(L('Added #1 #2 of #3 to stock', amount, Pluralize(amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBooking(' + result.booking_id + ')"><i class="fas fa-undo"></i> ' + L("Undo") + '</a>');
|
var successMessage = L('Added #1 #2 of #3 to stock', amount, Pluralize(amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBooking(' + result.booking_id + ')"><i class="fas fa-undo"></i> ' + L("Undo") + '</a>';
|
||||||
|
|
||||||
if (addBarcode !== undefined)
|
if (addBarcode !== undefined)
|
||||||
{
|
{
|
||||||
window.location.href = U('/purchase');
|
window.location.href = U('/purchase');
|
||||||
}
|
}
|
||||||
else if (GetUriParam("flow") === "shoppinglistitemtostock")
|
else if (GetUriParam("flow") === "shoppinglistitemtostock" && typeof GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.location.href = U('/shoppinglist?flow=shoppinglistitemtostock&listitemid=' + GetUriParam("listitemid"));
|
window.parent.postMessage(WindowMessageBag("AfterItemAdded", GetUriParam("listitemid")), Grocy.BaseUrl);
|
||||||
|
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
|
||||||
|
window.parent.postMessage(WindowMessageBag("Ready"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
toastr.success(successMessage);
|
||||||
$('#amount').val(0);
|
$('#amount').val(0);
|
||||||
$('#price').val('');
|
$('#price').val('');
|
||||||
Grocy.Components.DateTimePicker.Clear();
|
Grocy.Components.DateTimePicker.Clear();
|
||||||
@@ -179,7 +182,6 @@ $('#amount').on('change', function (e)
|
|||||||
if (GetUriParam("flow") === "shoppinglistitemtostock")
|
if (GetUriParam("flow") === "shoppinglistitemtostock")
|
||||||
{
|
{
|
||||||
$('#amount').val(GetUriParam("amount"));
|
$('#amount').val(GetUriParam("amount"));
|
||||||
$('#save-purchase-button').html(L("OK") + " & " + L("Back to shopping list"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function UndoStockBooking(bookingId)
|
function UndoStockBooking(bookingId)
|
||||||
|
@@ -68,6 +68,7 @@ $(document).on('click', '.shoppinglist-delete-button', function (e)
|
|||||||
$('#shoppinglistitem-' + shoppingListItemId + '-row').fadeOut(500, function()
|
$('#shoppinglistitem-' + shoppingListItemId + '-row').fadeOut(500, function()
|
||||||
{
|
{
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
|
OnListItemRemoved();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
@@ -115,6 +116,7 @@ $(document).on('click', '#clear-shopping-list', function(e)
|
|||||||
$('#shoppinglist-table tbody tr').fadeOut(500, function()
|
$('#shoppinglist-table tbody tr').fadeOut(500, function()
|
||||||
{
|
{
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
|
OnListItemRemoved();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
@@ -127,8 +129,71 @@ $(document).on('click', '#clear-shopping-list', function(e)
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (GetUriParam("flow") === "shoppinglistitemtostock")
|
$(document).on('click', '.shopping-list-stock-add-workflow-list-item-button', function(e)
|
||||||
{
|
{
|
||||||
var listItem = GetUriParam("listitemid");
|
e.preventDefault();
|
||||||
$(".shoppinglist-delete-button[data-shoppinglist-id='" + listItem + "']").click();
|
|
||||||
|
var href = $(e.currentTarget).attr('href');
|
||||||
|
|
||||||
|
$("#shopping-list-stock-add-workflow-purchase-form-frame").attr("src", href);
|
||||||
|
$("#shopping-list-stock-add-workflow-modal").modal("show");
|
||||||
|
|
||||||
|
if (Grocy.ShoppingListToStockWorkflowAll)
|
||||||
|
{
|
||||||
|
$("#shopping-list-stock-add-workflow-modal .modal-footer").removeClass("d-none");
|
||||||
|
$("#shopping-list-stock-add-workflow-purchase-item-count").text(L("Adding shopping list item #1 of #2", Grocy.ShoppingListToStockWorkflowCurrent, Grocy.ShoppingListToStockWorkflowCount));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Grocy.ShoppingListToStockWorkflowAll = false;
|
||||||
|
Grocy.ShoppingListToStockWorkflowCount = 0;
|
||||||
|
Grocy.ShoppingListToStockWorkflowCurrent = 0;
|
||||||
|
$(document).on('click', '#add-all-items-to-stock-button', function(e)
|
||||||
|
{
|
||||||
|
Grocy.ShoppingListToStockWorkflowAll = true;
|
||||||
|
Grocy.ShoppingListToStockWorkflowCount = $(".shopping-list-stock-add-workflow-list-item-button").length;
|
||||||
|
Grocy.ShoppingListToStockWorkflowCurrent++;
|
||||||
|
$(".shopping-list-stock-add-workflow-list-item-button").first().click();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(window).on("message", function(e)
|
||||||
|
{
|
||||||
|
var data = e.originalEvent.data;
|
||||||
|
|
||||||
|
if (data.Message === "AfterItemAdded")
|
||||||
|
{
|
||||||
|
$(".shoppinglist-delete-button[data-shoppinglist-id='" + data.Payload + "']").click();
|
||||||
|
}
|
||||||
|
else if (data.Message === "Ready")
|
||||||
|
{
|
||||||
|
if (!Grocy.ShoppingListToStockWorkflowAll)
|
||||||
|
{
|
||||||
|
$("#shopping-list-stock-add-workflow-modal").modal("hide");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Grocy.ShoppingListToStockWorkflowCurrent++;
|
||||||
|
if (Grocy.ShoppingListToStockWorkflowCurrent <= Grocy.ShoppingListToStockWorkflowCount)
|
||||||
|
{
|
||||||
|
$(".shopping-list-stock-add-workflow-list-item-button")[1].click();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#shopping-list-stock-add-workflow-modal").modal("hide");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (data.Message === "ShowSuccessMessage")
|
||||||
|
{
|
||||||
|
toastr.success(data.Payload);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function OnListItemRemoved()
|
||||||
|
{
|
||||||
|
if ($(".shopping-list-stock-add-workflow-list-item-button").length === 0)
|
||||||
|
{
|
||||||
|
$("#add-all-items-to-stock-button").addClass("disabled");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
OnListItemRemoved();
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
<script src="{{ $U('/node_modules/jquery-ui-dist/jquery-ui.min.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/jquery-ui-dist/jquery-ui.min.js?v=', true) }}{{ $version }}"></script>
|
||||||
<script src="{{ $U('/node_modules/datatables.net-rowgroup/js/dataTables.rowGroup.min.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/datatables.net-rowgroup/js/dataTables.rowGroup.min.js?v=', true) }}{{ $version }}"></script>
|
||||||
<script src="{{ $U('/node_modules/datatables.net-rowgroup-bs4/js/rowGroup.bootstrap4.min.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/datatables.net-rowgroup-bs4/js/rowGroup.bootstrap4.min.js?v=', true) }}{{ $version }}"></script>
|
||||||
|
<script src="{{ $U('/viewjs/purchase.js?v=', true) }}{{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
@push('pageStyles')
|
@push('pageStyles')
|
||||||
@@ -28,6 +29,9 @@
|
|||||||
<a id="add-products-below-min-stock-amount" class="btn btn-outline-primary responsive-button" href="#">
|
<a id="add-products-below-min-stock-amount" class="btn btn-outline-primary responsive-button" href="#">
|
||||||
<i class="fas fa-cart-plus"></i> {{ $L('Add products that are below defined min. stock amount') }}
|
<i class="fas fa-cart-plus"></i> {{ $L('Add products that are below defined min. stock amount') }}
|
||||||
</a>
|
</a>
|
||||||
|
<a id="add-all-items-to-stock-button" class="btn btn-outline-primary responsive-button" href="#">
|
||||||
|
<i class="fas fa-box"></i> {{ $L('Add all list items to stock') }}
|
||||||
|
</a>
|
||||||
</h1>
|
</h1>
|
||||||
<p data-status-filter="belowminstockamount" class="btn btn-lg btn-info status-filter-button responsive-button">{{ Pluralize(count($missingProducts), $L('#1 product is below defined min. stock amount', count($missingProducts)), $L('#1 products are below defined min. stock amount', count($missingProducts))) }}</p>
|
<p data-status-filter="belowminstockamount" class="btn btn-lg btn-info status-filter-button responsive-button">{{ Pluralize(count($missingProducts), $L('#1 product is below defined min. stock amount', count($missingProducts)), $L('#1 products are below defined min. stock amount', count($missingProducts))) }}</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -69,7 +73,7 @@
|
|||||||
<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) }}">
|
<a class="btn btn-sm btn-primary @if(empty($listItem->product_id)) disabled @else shopping-list-stock-add-workflow-list-item-button @endif" href="{{ $U('/purchase?embedded&flow=shoppinglistitemtostock&product=') }}{{ $listItem->product_id }}&amount={{ $listItem->amount + $listItem->amount_autoadded }}&listitemid={{ $listItem->id }}" @if(!empty($listItem->product_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) }}" @endif>
|
||||||
<i class="fas fa-box"></i>
|
<i class="fas fa-box"></i>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
@@ -95,4 +99,17 @@
|
|||||||
@include('components.calendarcard')
|
@include('components.calendarcard')
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="modal fade" id="shopping-list-stock-add-workflow-modal" tabindex="-1">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content text-center">
|
||||||
|
<div class="modal-body">
|
||||||
|
<iframe id="shopping-list-stock-add-workflow-purchase-form-frame" class="embed-responsive" src=""></iframe>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer d-none">
|
||||||
|
<span id="shopping-list-stock-add-workflow-purchase-item-count"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@stop
|
@stop
|
||||||
|
Reference in New Issue
Block a user