mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
saving collections almost done...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
7f52830f61
commit
931374641f
@ -649,6 +649,7 @@ core.ImageGridFeatures.Feature({
|
|||||||
actions: BaseActions,
|
actions: BaseActions,
|
||||||
|
|
||||||
handlers: [
|
handlers: [
|
||||||
|
// XXX handle 'full'???
|
||||||
['prepareIndexForWrite',
|
['prepareIndexForWrite',
|
||||||
function(res){
|
function(res){
|
||||||
// we save .current unconditionally...
|
// we save .current unconditionally...
|
||||||
|
|||||||
@ -1099,15 +1099,11 @@ module.Collection = core.ImageGridFeatures.Feature({
|
|||||||
}],
|
}],
|
||||||
|
|
||||||
|
|
||||||
// XXX account for 'base' mode changes...
|
// XXX account for 'base' mode changes... (???)
|
||||||
// use : .config['collection-transfer-changes']
|
// use : .config['collection-transfer-changes']
|
||||||
// XXX use .prepareIndexForWrite(...) for collection data stuff...
|
// XXX might be a good idea to replace 'full' with changes to
|
||||||
// i.e.
|
// override .changes...
|
||||||
// this.prepareIndexForWrite({
|
// XXX need to account for collection local .changes...
|
||||||
// data: raw.data,
|
|
||||||
// ...
|
|
||||||
// }, mode)
|
|
||||||
// ...use this as a base for collection serialization...
|
|
||||||
['prepareIndexForWrite',
|
['prepareIndexForWrite',
|
||||||
function(res, _, full){
|
function(res, _, full){
|
||||||
var that = this
|
var that = this
|
||||||
@ -1123,12 +1119,14 @@ module.Collection = core.ImageGridFeatures.Feature({
|
|||||||
: changed
|
: changed
|
||||||
|
|
||||||
// collection index...
|
// collection index...
|
||||||
// XXX should this be at root or in collections/???
|
//
|
||||||
// ...root seems better as it will let us lazy-load
|
// NOTE: we are placing this in the index root to
|
||||||
// collection list without any extra effort...
|
// simplify lazy-loading of the collection
|
||||||
//var index = res.index['collections/index'] = {}
|
// index...
|
||||||
|
// XXX need lazy-load handler in fs-loader for this...
|
||||||
|
// XXX don't like the name...
|
||||||
var index = res.index['collection-index'] = {}
|
var index = res.index['collection-index'] = {}
|
||||||
Object.keys(collections)
|
Object.keys(res.raw.collections)
|
||||||
.forEach(function(title){
|
.forEach(function(title){
|
||||||
index[collections[title].gid || title] = title })
|
index[collections[title].gid || title] = title })
|
||||||
|
|
||||||
@ -1146,9 +1144,10 @@ module.Collection = core.ImageGridFeatures.Feature({
|
|||||||
.forEach(function(key){ metadata[key] = raw[key] })
|
.forEach(function(key){ metadata[key] = raw[key] })
|
||||||
|
|
||||||
raw.date = res.date
|
raw.date = res.date
|
||||||
// XXX set changes???
|
// XXX use collection changes!!!
|
||||||
// XXX would be nice to have collections' .tags here... (???)
|
// ...this will need .prepareIndexForWrite(..)
|
||||||
var prepared = that.prepareIndexForWrite(raw, full).index
|
// refactoring to replace 'full' with 'changed'...
|
||||||
|
var prepared = that.prepareIndexForWrite(raw, true).index
|
||||||
|
|
||||||
Object.keys(prepared)
|
Object.keys(prepared)
|
||||||
.forEach(function(key){
|
.forEach(function(key){
|
||||||
@ -1355,22 +1354,25 @@ module.CollectionTags = core.ImageGridFeatures.Feature({
|
|||||||
var c = this.collections
|
var c = this.collections
|
||||||
var rc = res.collections
|
var rc = res.collections
|
||||||
|
|
||||||
|
// NOTE: at this point .crop_stack is handled, so we
|
||||||
|
// do not need to care about it...
|
||||||
|
|
||||||
// in 'base' mode set .data.tags and .local_tags to
|
// in 'base' mode set .data.tags and .local_tags to
|
||||||
// the base collection data...
|
// the base collection data...
|
||||||
if(mode == 'base'
|
if(mode == 'base'
|
||||||
&& this.collection != null
|
&& this.collection != null
|
||||||
&& this.collection != MAIN_COLLECTION_TITLE){
|
&& this.collection != MAIN_COLLECTION_TITLE){
|
||||||
// NOTE: at this point .crop_stack is handled, so we
|
var tags = this.data.tags || {}
|
||||||
// do not need to care about it...
|
var ltags = c[MAIN_COLLECTION_TITLE].local_tags || {}
|
||||||
var tags = c[MAIN_COLLECTION_TITLE].local_tags || {}
|
var rtags = res.data.tags = {}
|
||||||
var rtags =
|
|
||||||
res.data.tags =
|
|
||||||
res.collections[this.collection].data.tags || {}
|
|
||||||
|
|
||||||
// compact and overwrite the local tags for the base...
|
// move all the tags...
|
||||||
Object.keys(tags)
|
Object.keys(tags)
|
||||||
.forEach(function(tag){
|
.filter(function(tag){ return ltags[tag] == null })
|
||||||
rtags[tag] = tags[tag].compact() })
|
.forEach(function(tag){ rtags[tag] = tags[tag].compact() })
|
||||||
|
// overwrite the local tags for the base...
|
||||||
|
Object.keys(ltags)
|
||||||
|
.forEach(function(tag){ rtags[tag] = ltags[tag].compact() })
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear and compact tags for all collections...
|
// clear and compact tags for all collections...
|
||||||
@ -1378,20 +1380,36 @@ module.CollectionTags = core.ImageGridFeatures.Feature({
|
|||||||
&& Object.keys(rc || {})
|
&& Object.keys(rc || {})
|
||||||
.forEach(function(title){
|
.forEach(function(title){
|
||||||
var tags = c[title].local_tags || {}
|
var tags = c[title].local_tags || {}
|
||||||
var rtags = rc[title].local_tags = {}
|
var rtags = {}
|
||||||
|
|
||||||
// compact the local tags...
|
// compact the local tags...
|
||||||
Object.keys(tags)
|
Object.keys(tags)
|
||||||
.forEach(function(tag){
|
.forEach(function(tag){
|
||||||
rtags[tag] = tags[tag].compact() })
|
rtags[tag] = tags[tag].compact() })
|
||||||
|
|
||||||
// no need to save the tags in more than the
|
// move .local_tags to .data.tags
|
||||||
// root .data...
|
rc[title].data.tags = rtags
|
||||||
if(rc[title].data){
|
|
||||||
delete rc[title].data.tags
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}],
|
}],
|
||||||
|
// load collection local tags from .data.tags to .local_tags...
|
||||||
|
['load',
|
||||||
|
function(_, json){
|
||||||
|
var that = this
|
||||||
|
Object.keys(json.collections || {})
|
||||||
|
// skip loaded collections that are already Data objects...
|
||||||
|
// XXX not sure about this...
|
||||||
|
.filter(function(title){
|
||||||
|
return !(json.collections[title] instanceof data.Data) })
|
||||||
|
// do the loading...
|
||||||
|
.forEach(function(title){
|
||||||
|
var c = that.collections[title]
|
||||||
|
|
||||||
|
c.local_tags = c.local_tags || {}
|
||||||
|
;(that.config['collection-local-tags'] || [])
|
||||||
|
.forEach(function(tag){
|
||||||
|
c.local_tags[tag] = c.local_tags[tag] || c.data.tags[tag] })
|
||||||
|
})
|
||||||
|
}],
|
||||||
|
|
||||||
|
|
||||||
// XXX handle .config['collection-transfer-changes']...
|
// XXX handle .config['collection-transfer-changes']...
|
||||||
@ -1873,9 +1891,8 @@ var UICollectionActions = actions.Actions({
|
|||||||
addMarkedToCollection: ['Collections|Mark/Add marked to $collection...',
|
addMarkedToCollection: ['Collections|Mark/Add marked to $collection...',
|
||||||
{browseMode: function(){
|
{browseMode: function(){
|
||||||
return this.marked.length == 0 && 'disabled' }},
|
return this.marked.length == 0 && 'disabled' }},
|
||||||
widgets.uiDialog(function(gids){
|
widgets.uiDialog(function(){
|
||||||
return this.browseCollections(function(title){
|
return this.browseCollections(function(title){ this.collectMarked(title) }) })],
|
||||||
this.collectMarked(gids || this.current, title) }) })],
|
|
||||||
|
|
||||||
/*/ XXX this is not used by metadata yet...
|
/*/ XXX this is not used by metadata yet...
|
||||||
metadataSection: ['- Image/',
|
metadataSection: ['- Image/',
|
||||||
|
|||||||
@ -73,6 +73,8 @@ var IndexFormatActions = actions.Actions({
|
|||||||
'preview-path-template': '${INDEX}/${RESOLUTION}px/${GID} - ${NAME}.jpg',
|
'preview-path-template': '${INDEX}/${RESOLUTION}px/${GID} - ${NAME}.jpg',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// XXX might be a good idea to replace 'full' with changes to
|
||||||
|
// override .changes...
|
||||||
prepareIndexForWrite: ['- File/Prepare index for writing',
|
prepareIndexForWrite: ['- File/Prepare index for writing',
|
||||||
core.doc`Convert json index to a format compatible with file.writeIndex(..)
|
core.doc`Convert json index to a format compatible with file.writeIndex(..)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user