mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Optimized DataTables state save handling performance
This commit is contained in:
parent
fdbb8a045a
commit
82d899d609
@ -10,7 +10,8 @@
|
|||||||
|
|
||||||
### Stock
|
### Stock
|
||||||
|
|
||||||
- xxx
|
- Performance improvements related to the stock overview page / displaying a product card
|
||||||
|
- Performance improvements related to consuming products (thanks @alkuzman)
|
||||||
|
|
||||||
### Shopping list
|
### Shopping list
|
||||||
|
|
||||||
@ -18,7 +19,7 @@
|
|||||||
|
|
||||||
### Recipes
|
### Recipes
|
||||||
|
|
||||||
- Performance improvements when consuming recipes (thanks @alkuzman)
|
- xxx
|
||||||
|
|
||||||
### Meal plan
|
### Meal plan
|
||||||
|
|
||||||
@ -50,7 +51,7 @@
|
|||||||
|
|
||||||
### General
|
### General
|
||||||
|
|
||||||
- xxx
|
- Performance improvements related to table (layout) loading handling
|
||||||
|
|
||||||
### API
|
### API
|
||||||
|
|
||||||
|
@ -20,14 +20,32 @@ $.extend(true, $.fn.dataTable.defaults, {
|
|||||||
'stateSaveCallback': function(settings, data)
|
'stateSaveCallback': function(settings, data)
|
||||||
{
|
{
|
||||||
var settingKey = 'datatables_state_' + settings.sTableId;
|
var settingKey = 'datatables_state_' + settings.sTableId;
|
||||||
|
|
||||||
if ($.isEmptyObject(data))
|
if ($.isEmptyObject(data))
|
||||||
{
|
{
|
||||||
//state.clear was called and unfortunately the table is not refresh, so we are reloading the page
|
// state.clear() was called (resetting table layout)
|
||||||
Grocy.FrontendHelpers.DeleteUserSetting(settingKey, true);
|
Grocy.FrontendHelpers.DeleteUserSetting(settingKey, true);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
var stateData = JSON.stringify(data);
|
// Don't save when the state data hasn't actually changed
|
||||||
Grocy.FrontendHelpers.SaveUserSetting(settingKey, stateData);
|
if (Grocy.UserSettings[settingKey] !== undefined)
|
||||||
|
{
|
||||||
|
var data1 = JSON.parse(Grocy.UserSettings[settingKey]);
|
||||||
|
delete data1.time;
|
||||||
|
delete data1.childRows;
|
||||||
|
|
||||||
|
var data2 = Object.assign({}, data); // Clone `data` without reference
|
||||||
|
delete data2.time;
|
||||||
|
delete data2.childRows;
|
||||||
|
|
||||||
|
if (JSON.stringify(data1) == JSON.stringify(data2))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Grocy.FrontendHelpers.SaveUserSetting(settingKey, JSON.stringify(data));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'stateLoadCallback': function(settings, data)
|
'stateLoadCallback': function(settings, data)
|
||||||
@ -277,6 +295,7 @@ $(".change-table-columns-visibility-button").on("click", function(e)
|
|||||||
{
|
{
|
||||||
bootbox.confirm({
|
bootbox.confirm({
|
||||||
message: __t("Are you sure to reset the table options?"),
|
message: __t("Are you sure to reset the table options?"),
|
||||||
|
closeButton: false,
|
||||||
buttons: {
|
buttons: {
|
||||||
cancel: {
|
cancel: {
|
||||||
label: 'No',
|
label: 'No',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user