mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
moving to new read/write format...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
84b02c8f7a
commit
3aa03faea6
@ -1111,6 +1111,15 @@ module.Tags = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
this.markChanged('images', gids)
|
this.markChanged('images', gids)
|
||||||
}],
|
}],
|
||||||
|
// XXX
|
||||||
|
['prepareIndexForWrite',
|
||||||
|
function(res, _, full){
|
||||||
|
// XXX move code here from file.buildIndex(..)
|
||||||
|
// - res.raw.tags -> res.index.tags
|
||||||
|
// - ..tags.selected -> .selected
|
||||||
|
// - ..tags.bookmark -> .bookmarked
|
||||||
|
// XXX will need a symmetrical action to reverse all of this...
|
||||||
|
}],
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -130,6 +130,16 @@ var FileSystemLoaderActions = actions.Actions({
|
|||||||
'default-load-method': 'loadIndex',
|
'default-load-method': 'loadIndex',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// NOTE: this is the reverse of .prepareIndexForWrite(..)
|
||||||
|
//
|
||||||
|
// XXX do we need both this and file.buildIndex(..), we essentially create
|
||||||
|
// a Data object and then create it again in .load()...
|
||||||
|
prepareJSONForLoad: ['- File/Prepare JSON for loading',
|
||||||
|
function(json, base_path){
|
||||||
|
// XXX move the code up here from file.js...
|
||||||
|
return file.buildIndex(json, base_path) }],
|
||||||
|
|
||||||
|
|
||||||
// XXX is this a hack???
|
// XXX is this a hack???
|
||||||
// XXX need a more generic form...
|
// XXX need a more generic form...
|
||||||
checkPath: ['- File/',
|
checkPath: ['- File/',
|
||||||
@ -147,8 +157,6 @@ var FileSystemLoaderActions = actions.Actions({
|
|||||||
// NOTE: this will add a .from field to .location, this will indicate
|
// NOTE: this will add a .from field to .location, this will indicate
|
||||||
// the date starting from which saves are loaded.
|
// the date starting from which saves are loaded.
|
||||||
//
|
//
|
||||||
// XXX do we need both this and file.buildIndex(..), we essentially create
|
|
||||||
// a Data object and then create it again in .load()...
|
|
||||||
// XXX look inside...
|
// XXX look inside...
|
||||||
loadIndex: ['- File/Load index',
|
loadIndex: ['- File/Load index',
|
||||||
function(path, from_date, logger){
|
function(path, from_date, logger){
|
||||||
@ -220,7 +228,7 @@ var FileSystemLoaderActions = actions.Actions({
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var part = file.buildIndex(res[k], k)
|
var part = that.prepareJSONForLoad(res[k], k)
|
||||||
|
|
||||||
// load the first index...
|
// load the first index...
|
||||||
if(index == null){
|
if(index == null){
|
||||||
@ -1588,6 +1596,7 @@ var FileSystemWriterActions = actions.Actions({
|
|||||||
//
|
//
|
||||||
// For more info see file.writeIndex(..) and file.loadIndex(..).
|
// For more info see file.writeIndex(..) and file.loadIndex(..).
|
||||||
//
|
//
|
||||||
|
// NOTE: this is the reverse of .prepareJSONForLoad(..)
|
||||||
prepareIndexForWrite: ['- File/Prepare index for writing',
|
prepareIndexForWrite: ['- File/Prepare index for writing',
|
||||||
function(json, full){
|
function(json, full){
|
||||||
json = json || this.json('base')
|
json = json || this.json('base')
|
||||||
|
|||||||
@ -380,10 +380,9 @@ module.SortActions = actions.Actions({
|
|||||||
// XXX add drop/load actions...
|
// XXX add drop/load actions...
|
||||||
saveOrder: ['- Sort/',
|
saveOrder: ['- Sort/',
|
||||||
function(title){
|
function(title){
|
||||||
if(title){
|
title = title || 'Manual'
|
||||||
var cache = this.data.sort_order = this.data.sort_order || {}
|
var cache = this.data.sort_order = this.data.sort_order || {}
|
||||||
cache[title] = this.data.order.slice()
|
cache[title] = this.data.order.slice()
|
||||||
}
|
|
||||||
}],
|
}],
|
||||||
loadOrder: ['- Srot/',
|
loadOrder: ['- Srot/',
|
||||||
function(title, reverse){
|
function(title, reverse){
|
||||||
@ -413,35 +412,32 @@ module.SortActions = actions.Actions({
|
|||||||
// .data.sort_cache - cached sort order (optional)
|
// .data.sort_cache - cached sort order (optional)
|
||||||
load: [function(data){
|
load: [function(data){
|
||||||
return function(){
|
return function(){
|
||||||
if(data.data && data.data.sort_method){
|
var that = this
|
||||||
this.data.sort_method = data.data.sort_method
|
|
||||||
}
|
|
||||||
|
|
||||||
if(data.data && data.sort_order){
|
data.data
|
||||||
this.data.sort_order = data.sort_order
|
&& ['sort_method', 'sort_order', 'sort_cache']
|
||||||
}
|
.forEach(function(attr){
|
||||||
if(data.data && data.sort_cache){
|
if(data.data[attr]){
|
||||||
this.data.sort_cache = data.sort_cache
|
that.data[attr] = data.data[attr]
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
// XXX should .sort_cache be stored separately???
|
|
||||||
json: [function(){
|
json: [function(){
|
||||||
return function(res){
|
return function(res){
|
||||||
if(this.data.sort_method){
|
var that = this
|
||||||
res.data.sort_method = this.data.sort_method
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.data.sort_order){
|
;['sort_method', 'sort_order', 'sort_cache']
|
||||||
res.sort_order = this.data.sort_order
|
.forEach(function(attr){
|
||||||
}
|
if(that.data[attr]){
|
||||||
if(this.data.sort_cache){
|
res.data[attr] = that.data[attr]
|
||||||
res.sort_cache = this.data.sort_cache
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
|
// special case: unsaved manual order...
|
||||||
if(this.toggleImageSort('?') == 'Manual'){
|
if(this.toggleImageSort('?') == 'Manual'){
|
||||||
res.sort_order = res.sort_order || {}
|
res.data.sort_order = res.sort_order || {}
|
||||||
res.sort_order['Manual'] = this.data.order.slice()
|
res.data.sort_order['Manual'] = this.data.order.slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
@ -490,6 +486,11 @@ module.Sort = core.ImageGridFeatures.Feature({
|
|||||||
save('sort_order')
|
save('sort_order')
|
||||||
save('sort_cache')
|
save('sort_cache')
|
||||||
}],
|
}],
|
||||||
|
['prepareJSONForLoad',
|
||||||
|
function(res){
|
||||||
|
// XXX
|
||||||
|
//res.data.sort_cache = res.sort_cache
|
||||||
|
}],
|
||||||
|
|
||||||
// manage changes...
|
// manage changes...
|
||||||
['sortImages',
|
['sortImages',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user