From: Bill Erickson Date: Tue, 8 Jul 2014 18:16:53 +0000 (-0400) Subject: grid persist only stores necessary data X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9a9be74a8d27244a730c47395d4c94c4c7295695;p=working%2FEvergreen.git grid persist only stores necessary data Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/web/js/ui/default/staff/services/grid.js b/Open-ILS/web/js/ui/default/staff/services/grid.js index 9c0126953f..416afb60b7 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -277,19 +277,20 @@ angular.module('egGridMod', "Cannot save settings without a grid persist-key"); return; } - var conf = grid.columnsProvider.columns.map( - function(col) { - var c = { - name : col.name, - flex : col.flex, - }; - // preserve prefs space by only storing values that - // are non-default - if (Number(col.sort)) c.sort = Number(col.sort); - if (Boolean(col.visible)) c.visible = true; - return c; - } - ); + + // only store information about visible columns. + var conf = grid.columnsProvider.columns.filter( + function(col) {return Boolean(col.visible) }); + + // now scrunch the data down to just the needed info + conf = conf.map(function(col) { + var c = {name : col.name} + // Apart from the name, only store non-default values. + // No need to store col.visible, since that's implicit + if (col.flex != 2) c.flex = col.flex; + if (Number(col.sort)) c.sort = Number(c.sort); + return c; + }); egCore.hatch.setItem('eg.grid.' + grid.persistKey, conf) .then(function() { @@ -323,19 +324,23 @@ angular.module('egGridMod', return; } - grid_col.flex = col.flex; + grid_col.flex = col.flex || 2; grid_col.sort = col.sort || 0; - grid_col.visible = col.visible || false; + // all saved columns are assumed to be true + grid_col.visible = true; new_cols.push(grid_col); }); - // check for new columns which are not yet expressed - // within the saved configuration and tack them onto - // the end of the columns list + // columns which are not expressed within the saved + // configuration are marked as non-visible and + // appended to the end of the new list of columns. angular.forEach(columns, function(col) { var found = conf.filter( function(c) {return (c.name == col.name)})[0]; - if (!found) new_cols.push(col); + if (!found) { + col.visible = false; + new_cols.push(col); + } }); grid.columnsProvider.columns = new_cols;