From 8e2c6945d82c7abce31d4250eeec08d53b08e1a1 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 15 Feb 2017 05:35:28 +0300 Subject: [PATCH] file store format construction and loading framework is working, still need to refactor legacy code... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/sort.js | 40 ++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/ui (gen4)/features/sort.js b/ui (gen4)/features/sort.js index f496ca4d..736ff115 100755 --- a/ui (gen4)/features/sort.js +++ b/ui (gen4)/features/sort.js @@ -468,28 +468,34 @@ module.Sort = core.ImageGridFeatures.Feature({ function(res, _, full){ var c = this.changes - var save = function(attr){ - if((full || c == null || c[attr]) && res.raw[attr]){ - // full save... - if(full || c == null){ - res.index[attr] = res.raw[attr] + ;['sort_order', 'sort_cache'] + .forEach(function(attr){ + if((full || c == null || c[attr]) && res.raw.data[attr]){ + // full save... + if(full || c == null){ + res.index[attr] = res.raw.data[attr] - // build diff... - } else { - var diff = {} - c[attr].forEach(function(k){ diff[k] = res.raw[attr][k] }) - res.index[attr +'-diff'] = diff + // build diff... + } else { + var diff = {} + c[attr].forEach(function(k){ + diff[k] = res.raw.data[attr][k] }) + res.index[attr +'-diff'] = diff + } + + // cleanup... + delete res.index.data[attr] } - } - } - - save('sort_order') - save('sort_cache') + }) }], ['prepareJSONForLoad', function(res){ - // XXX - //res.data.sort_cache = res.sort_cache + ['sort_order', 'sort_cache'] + .forEach(function(attr){ + if(res[attr]){ + res.data[attr] = res[attr] + } + }) }], // manage changes...