Rename /stockedit and /stockdetail to match the "naming conventions" (references #421)

This commit is contained in:
Bernd Bestel
2020-01-27 19:19:09 +01:00
parent 40730328b8
commit 4c1c971f6d
8 changed files with 208 additions and 211 deletions

View File

@@ -1,11 +1,11 @@
var stockDetailTable = $('#stock-detail-table').DataTable({
var stockEntriesTable = $('#stockentries-table').DataTable({
'order': [[2, 'asc']],
'columnDefs': [
{ 'orderable': false, 'targets': 0 },
{ 'searchable': false, "targets": 0 }
],
});
$('#stock-detail-table tbody').removeClass("d-none");
$('#stockentries-table tbody').removeClass("d-none");
$.fn.dataTable.ext.search.push(function(settings, data, dataIndex)
{
@@ -22,7 +22,7 @@ $.fn.dataTable.ext.search.push(function(settings, data, dataIndex)
Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
{
stockDetailTable.draw();
stockEntriesTable.draw();
});
$(document).on('click', '.stock-consume-button', function(e)
@@ -56,7 +56,7 @@ $(document).on('click', '.stock-consume-button', function(e)
}
Grocy.FrontendHelpers.EndUiBusy();
RefreshStockDetailRow(stockRowId);
RefreshStockEntryRow(stockRowId);
toastr.success(toastMessage);
},
function(xhr)
@@ -97,7 +97,7 @@ $(document).on('click', '.product-open-button', function(e)
button.addClass("disabled");
Grocy.FrontendHelpers.EndUiBusy();
toastr.success(__t('Marked %1$s of %2$s as opened', 1 + " " + productQuName, productName) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBookingEntry(' + bookingResponse.id + ',' + stockRowId + ')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>');
RefreshStockDetailRow(stockRowId);
RefreshStockEntryRow(stockRowId);
},
function(xhr)
{
@@ -110,10 +110,10 @@ $(document).on('click', '.product-open-button', function(e)
$(document).on("click", ".stock-name-cell", function(e)
{
Grocy.Components.ProductCard.Refresh($(e.currentTarget).attr("data-stock-id"));
$("#stockdetail-productcard-modal").modal("show");
$("#stockentry-productcard-modal").modal("show");
});
function RefreshStockDetailRow(stockRowId)
function RefreshStockEntryRow(stockRowId)
{
Grocy.Api.Get("stock/entry/" + stockRowId,
function(result)
@@ -233,9 +233,9 @@ $(window).on("message", function(e)
{
var data = e.originalEvent.data;
if (data.Message === "StockDetailChanged")
if (data.Message === "StockEntryChanged")
{
RefreshStockDetailRow(data.Payload);
RefreshStockEntryRow(data.Payload);
}
});
@@ -246,7 +246,7 @@ function UndoStockBookingEntry(bookingId, stockRowId)
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', { },
function(result)
{
window.postMessage(WindowMessageBag("StockDetailChanged", stockRowId), Grocy.BaseUrl);
window.postMessage(WindowMessageBag("StockEntryChanged", stockRowId), Grocy.BaseUrl);
toastr.success(__t("Booking successfully undone"));
},
function(xhr)

View File

@@ -1,9 +1,9 @@
$('#save-stockedit-button').on('click', function(e)
$('#save-stockentry-button').on('click', function(e)
{
e.preventDefault();
var jsonForm = $('#stockedit-form').serializeJSON();
Grocy.FrontendHelpers.BeginUiBusy("stockedit-form");
var jsonForm = $('#stockentry-form').serializeJSON();
Grocy.FrontendHelpers.BeginUiBusy("stockentry-form");
if (!jsonForm.price.toString().isEmpty())
{
@@ -31,61 +31,61 @@
{
var successMessage = __t('Stock entry successfully updated') + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBookingEntry(\'' + result.id + '\',\'' + Grocy.EditObjectId + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
window.parent.postMessage(WindowMessageBag("StockDetailChanged", Grocy.EditObjectId), Grocy.BaseUrl);
window.parent.postMessage(WindowMessageBag("StockEntryChanged", Grocy.EditObjectId), Grocy.BaseUrl);
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
window.parent.postMessage(WindowMessageBag("Ready"), Grocy.BaseUrl);
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
},
function(xhr)
{
Grocy.FrontendHelpers.EndUiBusy("stockedit-form");
Grocy.FrontendHelpers.EndUiBusy("stockentry-form");
console.error(xhr);
}
);
});
Grocy.FrontendHelpers.ValidateForm('stockedit-form');
Grocy.FrontendHelpers.ValidateForm('stockentry-form');
$('#stockedit-form input').keyup(function (event)
$('#stockentry-form input').keyup(function (event)
{
Grocy.FrontendHelpers.ValidateForm('stockedit-form');
Grocy.FrontendHelpers.ValidateForm('stockentry-form');
});
$('#stockedit-form input').keydown(function(event)
$('#stockentry-form input').keydown(function(event)
{
if (event.keyCode === 13) //Enter
{
event.preventDefault();
if (document.getElementById('stockedit-form').checkValidity() === false) //There is at least one validation error
if (document.getElementById('stockentry-form').checkValidity() === false) //There is at least one validation error
{
return false;
}
else
{
$('#save-stockedit-button').click();
$('#save-stockentry-button').click();
}
}
});
Grocy.Components.DateTimePicker.GetInputElement().on('change', function(e)
{
Grocy.FrontendHelpers.ValidateForm('stockedit-form');
Grocy.FrontendHelpers.ValidateForm('stockentry-form');
});
Grocy.Components.DateTimePicker.GetInputElement().on('keypress', function(e)
{
Grocy.FrontendHelpers.ValidateForm('stockedit-form');
Grocy.FrontendHelpers.ValidateForm('stockentry-form');
});
Grocy.Components.DateTimePicker2.GetInputElement().on('change', function(e)
{
Grocy.FrontendHelpers.ValidateForm('stockedit-form');
Grocy.FrontendHelpers.ValidateForm('stockentry-form');
});
Grocy.Components.DateTimePicker2.GetInputElement().on('keypress', function(e)
{
Grocy.FrontendHelpers.ValidateForm('stockedit-form');
Grocy.FrontendHelpers.ValidateForm('stockentry-form');
});
Grocy.Api.Get('stock/products/' + Grocy.EditObjectProductId,
@@ -129,4 +129,4 @@ $("#amount").on("focus", function(e)
$(this).select();
});
$("#amount").focus();
Grocy.FrontendHelpers.ValidateForm("stockedit-form");
Grocy.FrontendHelpers.ValidateForm("stockentry-form");