diff --git a/public/css/grocy.css b/public/css/grocy.css
index 44348439..8f6a2e75 100644
--- a/public/css/grocy.css
+++ b/public/css/grocy.css
@@ -160,6 +160,14 @@ input::-webkit-inner-spin-button {
margin-right: 0;
}
+.cursor-link {
+ cursor: pointer;
+}
+
+.cursor-busy {
+ cursor: wait;
+}
+
/* Third party component customizations - DataTables */
td {
vertical-align: middle !important;
diff --git a/public/js/grocy.js b/public/js/grocy.js
index f15ffc25..4da46fe7 100644
--- a/public/js/grocy.js
+++ b/public/js/grocy.js
@@ -255,6 +255,26 @@ Grocy.FrontendHelpers.ValidateForm = function(formId)
$(form).addClass('was-validated');
}
+Grocy.FrontendHelpers.BeginUiBusy = function(formId = null)
+{
+ $("body").addClass("cursor-busy");
+
+ if (formId !== null)
+ {
+ $("#" + formId + " :input").attr("disabled", true);
+ }
+}
+
+Grocy.FrontendHelpers.EndUiBusy = function(formId = null)
+{
+ $("body").removeClass("cursor-busy");
+
+ if (formId !== null)
+ {
+ $("#" + formId + " :input").attr("disabled", false);
+ }
+}
+
Grocy.FrontendHelpers.ShowGenericError = function(message, exception)
{
toastr.error(L(message) + '
' + L('Click to show technical details'), '', {
diff --git a/public/viewjs/batteriesoverview.js b/public/viewjs/batteriesoverview.js
index 4a2248ce..a96e0cc8 100644
--- a/public/viewjs/batteriesoverview.js
+++ b/public/viewjs/batteriesoverview.js
@@ -58,6 +58,8 @@ $(document).on('click', '.track-charge-cycle-button', function(e)
// Remove the focus from the current button
// to prevent that the tooltip stays until clicked anywhere else
document.activeElement.blur();
+
+ Grocy.FrontendHelpers.BeginUiBusy();
var batteryId = $(e.currentTarget).attr('data-battery-id');
var batteryName = $(e.currentTarget).attr('data-battery-name');
@@ -102,18 +104,21 @@ $(document).on('click', '.track-charge-cycle-button', function(e)
$('#battery-' + batteryId + '-next-charge-time-timeago').attr('datetime', result.next_estimated_charge_time);
}
+ Grocy.FrontendHelpers.EndUiBusy();
toastr.success(L('Tracked charge cycle of battery #1 on #2', batteryName, trackedTime));
RefreshContextualTimeago();
RefreshStatistics();
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy();
console.error(xhr);
}
);
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy();
console.error(xhr);
}
);
diff --git a/public/viewjs/batteryform.js b/public/viewjs/batteryform.js
index 0a3aef7f..46970ab8 100644
--- a/public/viewjs/batteryform.js
+++ b/public/viewjs/batteryform.js
@@ -2,28 +2,33 @@
{
e.preventDefault();
+ var jsonData = $('#battery-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("battery-form");
+
if (Grocy.EditMode === 'create')
{
- Grocy.Api.Post('add-object/batteries', $('#battery-form').serializeJSON(),
+ Grocy.Api.Post('add-object/batteries', jsonData,
function(result)
{
window.location.href = U('/batteries');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("battery-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
}
else
{
- Grocy.Api.Post('edit-object/batteries/' + Grocy.EditObjectId, $('#battery-form').serializeJSON(),
+ Grocy.Api.Post('edit-object/batteries/' + Grocy.EditObjectId, jsonData,
function(result)
{
window.location.href = U('/batteries');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("battery-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
diff --git a/public/viewjs/batterytracking.js b/public/viewjs/batterytracking.js
index 8ee60a37..2047e406 100644
--- a/public/viewjs/batterytracking.js
+++ b/public/viewjs/batterytracking.js
@@ -3,6 +3,7 @@
e.preventDefault();
var jsonForm = $('#batterytracking-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("batterytracking-form");
Grocy.Api.Get('batteries/get-battery-details/' + jsonForm.battery_id,
function (batteryDetails)
@@ -10,6 +11,7 @@
Grocy.Api.Get('batteries/track-charge-cycle/' + jsonForm.battery_id + '?tracked_time=' + $('#tracked_time').find('input').val(),
function(result)
{
+ Grocy.FrontendHelpers.EndUiBusy("batterytracking-form");
toastr.success(L('Tracked charge cycle of battery #1 on #2', batteryDetails.battery.name, $('#tracked_time').find('input').val()) + '
' + L("Undo") + '');
$('#battery_id').val('');
@@ -22,12 +24,14 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("batterytracking-form");
console.error(xhr);
}
);
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("batterytracking-form");
console.error(xhr);
}
);
diff --git a/public/viewjs/choreform.js b/public/viewjs/choreform.js
index 885e6cfb..ca8a4543 100644
--- a/public/viewjs/choreform.js
+++ b/public/viewjs/choreform.js
@@ -2,28 +2,33 @@
{
e.preventDefault();
+ var jsonData = $('#chore-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("chore-form");
+
if (Grocy.EditMode === 'create')
{
- Grocy.Api.Post('add-object/chores', $('#chore-form').serializeJSON(),
+ Grocy.Api.Post('add-object/chores', jsonData,
function(result)
{
window.location.href = U('/chores');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("chore-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
}
else
{
- Grocy.Api.Post('edit-object/chores/' + Grocy.EditObjectId, $('#chore-form').serializeJSON(),
+ Grocy.Api.Post('edit-object/chores/' + Grocy.EditObjectId, jsonData,
function(result)
{
window.location.href = U('/chores');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("chore-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
diff --git a/public/viewjs/choresoverview.js b/public/viewjs/choresoverview.js
index eea8def4..5a15a66e 100644
--- a/public/viewjs/choresoverview.js
+++ b/public/viewjs/choresoverview.js
@@ -58,6 +58,8 @@ $(document).on('click', '.track-chore-button', function(e)
// Remove the focus from the current button
// to prevent that the tooltip stays until clicked anywhere else
document.activeElement.blur();
+
+ Grocy.FrontendHelpers.BeginUiBusy();
var choreId = $(e.currentTarget).attr('data-chore-id');
var choreName = $(e.currentTarget).attr('data-chore-name');
@@ -102,18 +104,21 @@ $(document).on('click', '.track-chore-button', function(e)
$('#chore-' + choreId + '-next-execution-time-timeago').attr('datetime', result.next_estimated_execution_time);
}
+ Grocy.FrontendHelpers.EndUiBusy();
toastr.success(L('Tracked execution of chore #1 on #2', choreName, trackedTime));
RefreshContextualTimeago();
RefreshStatistics();
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy();
console.error(xhr);
}
);
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy();
console.error(xhr);
}
);
diff --git a/public/viewjs/choretracking.js b/public/viewjs/choretracking.js
index 4ecbcb20..548af50f 100644
--- a/public/viewjs/choretracking.js
+++ b/public/viewjs/choretracking.js
@@ -3,6 +3,7 @@
e.preventDefault();
var jsonForm = $('#choretracking-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("choretracking-form");
Grocy.Api.Get('chores/get-chore-details/' + jsonForm.chore_id,
function (choreDetails)
@@ -10,6 +11,7 @@
Grocy.Api.Get('chores/track-chore-execution/' + jsonForm.chore_id + '?tracked_time=' + Grocy.Components.DateTimePicker.GetValue() + "&done_by=" + Grocy.Components.UserPicker.GetValue(),
function(result)
{
+ Grocy.FrontendHelpers.EndUiBusy("choretracking-form");
toastr.success(L('Tracked execution of chore #1 on #2', choreDetails.chore.name, Grocy.Components.DateTimePicker.GetValue()) + '
' + L("Undo") + '');
$('#chore_id').val('');
@@ -21,12 +23,14 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("choretracking-form");
console.error(xhr);
}
);
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("choretracking-form");
console.error(xhr);
}
);
diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js
index 65841cdb..32025657 100644
--- a/public/viewjs/consume.js
+++ b/public/viewjs/consume.js
@@ -3,6 +3,7 @@
e.preventDefault();
var jsonForm = $('#consume-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("consume-form");
if ($("#use_specific_stock_entry").is(":checked"))
{
@@ -34,6 +35,7 @@
$("#use_specific_stock_entry").click();
}
+ Grocy.FrontendHelpers.EndUiBusy("consume-form");
toastr.success(L('Removed #1 #2 of #3 from stock', jsonForm.amount, Pluralize(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '
' + L("Undo") + '');
$('#amount').val(1);
@@ -43,12 +45,14 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("consume-form");
console.error(xhr);
}
);
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("consume-form");
console.error(xhr);
}
);
@@ -59,6 +63,7 @@ $('#save-mark-as-open-button').on('click', function(e)
e.preventDefault();
var jsonForm = $('#consume-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("consume-form");
if ($("#use_specific_stock_entry").is(":checked"))
{
@@ -84,6 +89,7 @@ $('#save-mark-as-open-button').on('click', function(e)
$("#use_specific_stock_entry").click();
}
+ Grocy.FrontendHelpers.EndUiBusy("consume-form");
toastr.success(L('Marked #1 #2 of #3 as opened', jsonForm.amount, Pluralize(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '
' + L("Undo") + '');
$('#amount').val(1);
@@ -93,12 +99,14 @@ $('#save-mark-as-open-button').on('click', function(e)
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("consume-form");
console.error(xhr);
}
);
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("consume-form");
console.error(xhr);
}
);
diff --git a/public/viewjs/equipmentform.js b/public/viewjs/equipmentform.js
index aa5895c1..e0340cbe 100644
--- a/public/viewjs/equipmentform.js
+++ b/public/viewjs/equipmentform.js
@@ -3,6 +3,8 @@
e.preventDefault();
var jsonData = $('#equipment-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("equipment-form");
+
if ($("#instruction-manual")[0].files.length > 0)
{
var someRandomStuff = Math.random().toString(36).substring(2, 100) + Math.random().toString(36).substring(2, 100);
@@ -28,6 +30,7 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("equipment-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
@@ -39,6 +42,7 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("equipment-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
@@ -54,6 +58,7 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("equipment-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
@@ -71,6 +76,7 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("equipment-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
@@ -82,6 +88,7 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("equipment-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
diff --git a/public/viewjs/inventory.js b/public/viewjs/inventory.js
index 32cddae7..1a4d69b7 100644
--- a/public/viewjs/inventory.js
+++ b/public/viewjs/inventory.js
@@ -3,6 +3,7 @@
e.preventDefault();
var jsonForm = $('#inventory-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("inventory-form");
Grocy.Api.Get('stock/get-product-details/' + jsonForm.product_id,
function (productDetails)
@@ -32,6 +33,7 @@
);
}
+ Grocy.FrontendHelpers.EndUiBusy("inventory-form");
toastr.success(L('Stock amount of #1 is now #2 #3', productDetails.product.name, jsonForm.new_amount, Pluralize(jsonForm.new_amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural)) + '
' + L("Undo") + '');
if (addBarcode !== undefined)
@@ -50,12 +52,14 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("inventory-form");
console.error(xhr);
}
);
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("inventory-form");
console.error(xhr);
}
);
diff --git a/public/viewjs/locationform.js b/public/viewjs/locationform.js
index fb82f0c4..a077081f 100644
--- a/public/viewjs/locationform.js
+++ b/public/viewjs/locationform.js
@@ -2,15 +2,19 @@
{
e.preventDefault();
+ var jsonData = $('#location-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("location-form");
+
if (Grocy.EditMode === 'create')
{
- Grocy.Api.Post('add-object/locations', $('#location-form').serializeJSON(),
+ Grocy.Api.Post('add-object/locations', jsonData,
function(result)
{
window.location.href = U('/locations');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("location-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
@@ -24,6 +28,7 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("location-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js
index 311ae065..3bc540ec 100644
--- a/public/viewjs/productform.js
+++ b/public/viewjs/productform.js
@@ -10,6 +10,8 @@
}
var jsonData = $('#product-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("product-form");
+
if ($("#product-picture")[0].files.length > 0)
{
var someRandomStuff = Math.random().toString(36).substring(2, 100) + Math.random().toString(36).substring(2, 100);
@@ -35,6 +37,7 @@
},
function (xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("product-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
@@ -46,6 +49,7 @@
},
function (xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("product-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
@@ -61,6 +65,7 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("product-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
@@ -78,6 +83,7 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("product-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
@@ -89,6 +95,7 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("product-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
diff --git a/public/viewjs/productgroupform.js b/public/viewjs/productgroupform.js
index b4aba32b..48140375 100644
--- a/public/viewjs/productgroupform.js
+++ b/public/viewjs/productgroupform.js
@@ -2,28 +2,33 @@
{
e.preventDefault();
+ var jsonData = $('#product-group-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("product-group-form");
+
if (Grocy.EditMode === 'create')
{
- Grocy.Api.Post('add-object/product_groups', $('#product-group-form').serializeJSON(),
+ Grocy.Api.Post('add-object/product_groups', jsonData,
function(result)
{
window.location.href = U('/productgroups');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("product-group-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
}
else
{
- Grocy.Api.Post('edit-object/product_groups/' + Grocy.EditObjectId, $('#product-group-form').serializeJSON(),
+ Grocy.Api.Post('edit-object/product_groups/' + Grocy.EditObjectId, jsonData,
function(result)
{
window.location.href = U('/productgroups');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("product-group-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js
index c0a8306b..c3bf5a1d 100644
--- a/public/viewjs/purchase.js
+++ b/public/viewjs/purchase.js
@@ -3,6 +3,7 @@
e.preventDefault();
var jsonForm = $('#purchase-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("purchase-form");
Grocy.Api.Get('stock/get-product-details/' + jsonForm.product_id,
function(productDetails)
@@ -35,6 +36,7 @@
function (result) { },
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("purchase-form");
console.error(xhr);
}
);
@@ -54,6 +56,7 @@
}
else
{
+ Grocy.FrontendHelpers.EndUiBusy("purchase-form");
toastr.success(successMessage);
$('#amount').val(0);
$('#price').val('');
@@ -65,12 +68,14 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("purchase-form");
console.error(xhr);
}
);
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("purchase-form");
console.error(xhr);
}
);
diff --git a/public/viewjs/quantityunitform.js b/public/viewjs/quantityunitform.js
index c1b89261..83238b7b 100644
--- a/public/viewjs/quantityunitform.js
+++ b/public/viewjs/quantityunitform.js
@@ -2,28 +2,33 @@
{
e.preventDefault();
+ var jsonData = $('#quantityunit-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("quantityunit-form");
+
if (Grocy.EditMode === 'create')
{
- Grocy.Api.Post('add-object/quantity_units', $('#quantityunit-form').serializeJSON(),
+ Grocy.Api.Post('add-object/quantity_units', jsonData,
function(result)
{
window.location.href = U('/quantityunits');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("quantityunit-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
}
else
{
- Grocy.Api.Post('edit-object/quantity_units/' + Grocy.EditObjectId, $('#quantityunit-form').serializeJSON(),
+ Grocy.Api.Post('edit-object/quantity_units/' + Grocy.EditObjectId, jsonData,
function(result)
{
window.location.href = U('/quantityunits');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("quantityunit-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
diff --git a/public/viewjs/recipeform.js b/public/viewjs/recipeform.js
index 54d16231..9a0a52c0 100644
--- a/public/viewjs/recipeform.js
+++ b/public/viewjs/recipeform.js
@@ -2,13 +2,17 @@
{
e.preventDefault();
- Grocy.Api.Post('edit-object/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(),
+ var jsonData = $('#recipe-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("recipe-form");
+
+ Grocy.Api.Post('edit-object/recipes/' + Grocy.EditObjectId, jsonData,
function(result)
{
window.location.href = U('/recipes');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("recipe-form");
console.error(xhr);
}
);
diff --git a/public/viewjs/recipeposform.js b/public/viewjs/recipeposform.js
index a8dd2458..bf1fcdd2 100644
--- a/public/viewjs/recipeposform.js
+++ b/public/viewjs/recipeposform.js
@@ -4,6 +4,9 @@
var jsonData = $('#recipe-pos-form').serializeJSON({ checkboxUncheckedValue: "0" });
jsonData.recipe_id = Grocy.EditObjectParentId;
+
+ Grocy.FrontendHelpers.BeginUiBusy("recipe-pos-form");
+
if (Grocy.EditMode === 'create')
{
Grocy.Api.Post('add-object/recipes_pos', jsonData,
@@ -13,6 +16,7 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("recipe-pos-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
@@ -26,6 +30,7 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("recipe-pos-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
diff --git a/public/viewjs/recipes.js b/public/viewjs/recipes.js
index a15b3f6c..d24131ae 100644
--- a/public/viewjs/recipes.js
+++ b/public/viewjs/recipes.js
@@ -95,6 +95,8 @@ $(document).on('click', '.recipe-order-missing-button', function(e)
{
if (result === true)
{
+ Grocy.FrontendHelpers.BeginUiBusy();
+
Grocy.Api.Get('recipes/add-not-fulfilled-products-to-shopping-list/' + objectId,
function(result)
{
@@ -102,6 +104,7 @@ $(document).on('click', '.recipe-order-missing-button', function(e)
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy();
console.error(xhr);
}
);
@@ -131,13 +134,17 @@ $("#selectedRecipeConsumeButton").on('click', function(e)
{
if (result === true)
{
+ Grocy.FrontendHelpers.BeginUiBusy();
+
Grocy.Api.Get('recipes/consume-recipe/' + objectId,
function(result)
{
+ Grocy.FrontendHelpers.EndUiBusy();
toastr.success(L('Removed all ingredients of recipe "#1" from stock', objectName));
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy();
console.error(xhr);
}
);
diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js
index 680800c4..293123a7 100644
--- a/public/viewjs/shoppinglist.js
+++ b/public/viewjs/shoppinglist.js
@@ -61,18 +61,21 @@ $(document).on('click', '.shoppinglist-delete-button', function (e)
e.preventDefault();
var shoppingListItemId = $(e.currentTarget).attr('data-shoppinglist-id');
+ Grocy.FrontendHelpers.BeginUiBusy();
Grocy.Api.Get('delete-object/shopping_list/' + shoppingListItemId,
function(result)
{
$('#shoppinglistitem-' + shoppingListItemId + '-row').fadeOut(500, function()
{
+ Grocy.FrontendHelpers.EndUiBusy();
$(this).remove();
OnListItemRemoved();
});
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy();
console.error(xhr);
}
);
@@ -110,17 +113,21 @@ $(document).on('click', '#clear-shopping-list', function(e)
{
if (result === true)
{
+ Grocy.FrontendHelpers.BeginUiBusy();
+
Grocy.Api.Get('stock/clear-shopping-list',
function(result)
{
$('#shoppinglist-table tbody tr').fadeOut(500, function()
{
+ Grocy.FrontendHelpers.EndUiBusy();
$(this).remove();
OnListItemRemoved();
});
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy();
console.error(xhr);
}
);
diff --git a/public/viewjs/shoppinglistform.js b/public/viewjs/shoppinglistform.js
index 0d7742b2..b4076d02 100644
--- a/public/viewjs/shoppinglistform.js
+++ b/public/viewjs/shoppinglistform.js
@@ -2,28 +2,33 @@
{
e.preventDefault();
+ var jsonData = $('#shoppinglist-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("shoppinglist-form");
+
if (Grocy.EditMode === 'create')
{
- Grocy.Api.Post('add-object/shopping_list', $('#shoppinglist-form').serializeJSON(),
+ Grocy.Api.Post('add-object/shopping_list', jsonData,
function(result)
{
window.location.href = U('/shoppinglist');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("shoppinglist-form");
console.error(xhr);
}
);
}
else
{
- Grocy.Api.Post('edit-object/shopping_list/' + Grocy.EditObjectId, $('#shoppinglist-form').serializeJSON(),
+ Grocy.Api.Post('edit-object/shopping_list/' + Grocy.EditObjectId, jsonData,
function(result)
{
window.location.href = U('/shoppinglist');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("shoppinglist-form");
console.error(xhr);
}
);
diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js
index 74017812..649cf538 100644
--- a/public/viewjs/stockoverview.js
+++ b/public/viewjs/stockoverview.js
@@ -81,6 +81,8 @@ $(document).on('click', '.product-consume-button', function(e)
// Remove the focus from the current button
// to prevent that the tooltip stays until clicked anywhere else
document.activeElement.blur();
+
+ Grocy.FrontendHelpers.BeginUiBusy();
var productId = $(e.currentTarget).attr('data-product-id');
var productName = $(e.currentTarget).attr('data-product-name');
@@ -135,18 +137,21 @@ $(document).on('click', '.product-consume-button', function(e)
$('#product-' + productId + '-next-best-before-date-timeago').attr('datetime', result.next_best_before_date);
}
+ Grocy.FrontendHelpers.EndUiBusy();
toastr.success(L('Removed #1 #2 of #3 from stock', consumeAmount, productQuName, productName));
RefreshContextualTimeago();
RefreshStatistics();
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy();
console.error(xhr);
}
);
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy();
console.error(xhr);
}
);
@@ -159,6 +164,8 @@ $(document).on('click', '.product-open-button', function(e)
// Remove the focus from the current button
// to prevent that the tooltip stays until clicked anywhere else
document.activeElement.blur();
+
+ Grocy.FrontendHelpers.BeginUiBusy();
var productId = $(e.currentTarget).attr('data-product-id');
var productName = $(e.currentTarget).attr('data-product-name');
@@ -205,18 +212,21 @@ $(document).on('click', '.product-open-button', function(e)
button.addClass("disabled");
}
+ Grocy.FrontendHelpers.EndUiBusy();
toastr.success(L('Marked #1 #2 of #3 as opened', 1, productQuName, productName));
RefreshContextualTimeago();
RefreshStatistics();
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy();
console.error(xhr);
}
);
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy();
console.error(xhr);
}
);
diff --git a/public/viewjs/taskcategoryform.js b/public/viewjs/taskcategoryform.js
index 4f070eef..adca8e66 100644
--- a/public/viewjs/taskcategoryform.js
+++ b/public/viewjs/taskcategoryform.js
@@ -2,28 +2,33 @@
{
e.preventDefault();
+ var jsonData = $('#task-category-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("task-category-form");
+
if (Grocy.EditMode === 'create')
{
- Grocy.Api.Post('add-object/task_categories', $('#task-category-form').serializeJSON(),
+ Grocy.Api.Post('add-object/task_categories', jsonData,
function(result)
{
window.location.href = U('/taskcategories');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("task-category-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
}
else
{
- Grocy.Api.Post('edit-object/task_categories/' + Grocy.EditObjectId, $('#task-category-form').serializeJSON(),
+ Grocy.Api.Post('edit-object/task_categories/' + Grocy.EditObjectId, jsonData,
function(result)
{
window.location.href = U('/taskcategories');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("task-category-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
diff --git a/public/viewjs/taskform.js b/public/viewjs/taskform.js
index 53f8de74..00d5a1c2 100644
--- a/public/viewjs/taskform.js
+++ b/public/viewjs/taskform.js
@@ -7,6 +7,8 @@
delete jsonData.user_id;
jsonData.due_date = Grocy.Components.DateTimePicker.GetValue();
+ Grocy.FrontendHelpers.BeginUiBusy("task-form");
+
if (Grocy.EditMode === 'create')
{
Grocy.Api.Post('add-object/tasks', jsonData,
@@ -16,6 +18,7 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("task-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
@@ -29,6 +32,7 @@
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("task-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
diff --git a/public/viewjs/tasks.js b/public/viewjs/tasks.js
index 26d27091..38633309 100644
--- a/public/viewjs/tasks.js
+++ b/public/viewjs/tasks.js
@@ -62,6 +62,8 @@ $(document).on('click', '.do-task-button', function(e)
// Remove the focus from the current button
// to prevent that the tooltip stays until clicked anywhere else
document.activeElement.blur();
+
+ Grocy.FrontendHelpers.BeginUiBusy();
var taskId = $(e.currentTarget).attr('data-task-id');
var taskName = $(e.currentTarget).attr('data-task-name');
@@ -84,12 +86,14 @@ $(document).on('click', '.do-task-button', function(e)
$('.do-task-button[data-task-id="' + taskId + '"]').addClass("disabled");
}
+ Grocy.FrontendHelpers.EndUiBusy();
toastr.success(L('Marked task #1 as completed on #2', taskName, doneTime));
RefreshContextualTimeago();
RefreshStatistics();
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy();
console.error(xhr);
}
);
diff --git a/public/viewjs/userform.js b/public/viewjs/userform.js
index 5f851041..c39e39b5 100644
--- a/public/viewjs/userform.js
+++ b/public/viewjs/userform.js
@@ -2,28 +2,33 @@
{
e.preventDefault();
+ var jsonData = $('#user-form').serializeJSON();
+ Grocy.FrontendHelpers.BeginUiBusy("user-form");
+
if (Grocy.EditMode === 'create')
{
- Grocy.Api.Post('users/create', $('#user-form').serializeJSON(),
+ Grocy.Api.Post('users/create', jsonData,
function(result)
{
window.location.href = U('/users');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("user-form");
console.error(xhr);
}
);
}
else
{
- Grocy.Api.Post('users/edit/' + Grocy.EditObjectId, $('#user-form').serializeJSON(),
+ Grocy.Api.Post('users/edit/' + Grocy.EditObjectId, jsonData,
function(result)
{
window.location.href = U('/users');
},
function(xhr)
{
+ Grocy.FrontendHelpers.EndUiBusy("user-form");
console.error(xhr);
}
);
diff --git a/views/batteriesoverview.blade.php b/views/batteriesoverview.blade.php
index 8ab8d5ef..711f8125 100644
--- a/views/batteriesoverview.blade.php
+++ b/views/batteriesoverview.blade.php
@@ -22,6 +22,10 @@