mirror of
https://github.com/grocy/grocy.git
synced 2025-04-30 01:55:47 +00:00
Only reload the page on external changes when there is no unsaved form data (fixes #73)
This commit is contained in:
parent
77d82f22dc
commit
d11dcb38fe
@ -191,3 +191,12 @@ Grocy.FrontendHelpers.ShowGenericError = function(message, exception)
|
|||||||
|
|
||||||
console.error(exception);
|
console.error(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$("form").on("keyup paste", "input, textarea", function()
|
||||||
|
{
|
||||||
|
$(this).closest("form").addClass("is-dirty");
|
||||||
|
});
|
||||||
|
$("form").on("click", "select", function()
|
||||||
|
{
|
||||||
|
$(this).closest("form").addClass("is-dirty");
|
||||||
|
});
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
// Check if the database has changed once a minute
|
// Check if the database has changed once a minute
|
||||||
// If a change is detected, reload the current page, but only if already idling for at least 50 seconds
|
// If a change is detected, reload the current page, but only if already idling for at least 50 seconds
|
||||||
|
// and when there is no unsaved form data
|
||||||
setInterval(function()
|
setInterval(function()
|
||||||
{
|
{
|
||||||
Grocy.Api.Get('system/get-db-changed-time',
|
Grocy.Api.Get('system/get-db-changed-time',
|
||||||
@ -21,7 +22,10 @@ setInterval(function()
|
|||||||
{
|
{
|
||||||
if (Grocy.IdleTime >= 50)
|
if (Grocy.IdleTime >= 50)
|
||||||
{
|
{
|
||||||
window.location.reload();
|
if ($("form.is-dirty").length === 0)
|
||||||
|
{
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Grocy.DatabaseChangedTime = newDbChangedTime;
|
Grocy.DatabaseChangedTime = newDbChangedTime;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user