now changes are maintained across collections, still need to account for lots of details whe saving...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-09-21 01:20:08 +03:00
parent fbc8e686a2
commit 0b120a1189
2 changed files with 56 additions and 34 deletions

View File

@ -56,6 +56,12 @@ var CollectionActions = actions.Actions({
// 'main' - save crop state for main state only // 'main' - save crop state for main state only
// 'none' - do not save crop state // 'none' - do not save crop state
'collection-save-crop-state': 'all', 'collection-save-crop-state': 'all',
// XXX should this be in config???
// ...technically no, but we need shit to resolve correctly
// to a relevant feature...
'collection-transfer-changes': ['data'],
}, },
// Format: // Format:
@ -319,8 +325,10 @@ var CollectionActions = actions.Actions({
// load collection... // load collection...
Promise Promise
.all(Object.keys(handlers) .all(Object.keys(handlers)
// filter relevant handlers...
.filter(function(format){ .filter(function(format){
return format == '*' || collection_data[format] }) return format == '*' || collection_data[format] })
// run handlers...
.map(function(format){ .map(function(format){
return that[handlers[format]](collection, collection_data) })) return that[handlers[format]](collection, collection_data) }))
.then(function(){ .then(function(){
@ -985,8 +993,6 @@ module.Collection = core.ImageGridFeatures.Feature({
// 'collections' - collection list changes // 'collections' - collection list changes
// 'collection: <gid>' - holds collection-specific changes // 'collection: <gid>' - holds collection-specific changes
// //
// XXX need to maintain changes when loading / unloading collections...
// changes['data'] <-> changes['collection: <gid>': ['data']]
// collection-list... // collection-list...
[[ [[
'collectionCreated', 'collectionCreated',
@ -1015,56 +1021,59 @@ module.Collection = core.ImageGridFeatures.Feature({
['data']) ['data'])
}], }],
// transfer changes on load/unload collection... // transfer changes on load/unload collection...
// XXX also need to account for changes when doing .prepareIndexForWrite(..) ['collectionLoading.pre',
// in 'base' mode... function(to){
// XXX use the event .collectionLoading(..) instead of .loadCollection(..) action??? var that = this
//['collectionLoading.pre',
['loadCollection.pre',
function(collection){
var from = this.collection || MAIN_COLLECTION_TITLE var from = this.collection || MAIN_COLLECTION_TITLE
var to = collection
if(from == to || this.changes === undefined || this.changes === true){ if(from == to || this.changes === undefined || this.changes === true){
return return
} }
var data = this.changes === true || (this.changes || {}).data // XXX this should not be in config...
var change_tags = this.config['collection-transfer-changes'] || ['data']
var from_changes = change_tags
.filter(function(item){
return that.changes === true || (that.changes || {})[item] })
return function(){ return function(){
if(to == from){ if(to == from){
return return
} }
var gid = this.collections[to].gid || to var gid = (this.collections[to] || {}).gid || to
var changes = this.changes !== false ? var changes = this.changes !== false ?
this.changes['collection: '+JSON.stringify(gid)] this.changes['collection: '+JSON.stringify(gid)]
: [] : []
var from_id = 'collection: '
+JSON.stringify(from == MAIN_COLLECTION_TITLE ?
'0'
: this.collections[from].gid || from)
// XXX // everything has changed, no need to bother with details...
if(changes === true){ if(changes === true){
return return
} }
// save data to 'from'... // save changes to 'from'...
if(data){ from_changes.length > 0
this.markChanged( && this.markChanged(from_id, from_changes)
'collection: '
+JSON.stringify(from == MAIN_COLLECTION_TITLE ?
'0'
: this.collections[from].gid || from),
['data'])
}
// load data from 'to'.. // load changes from 'to'..
if(changes && changes.indexOf('data') >= 0){ change_tags.forEach(function(item){
this.markChanged('data') if(changes && changes.indexOf(item) >= 0){
that.markChanged(item)
} else if(this.changes && this.changes.data){ } else if(that.changes && that.changes[item]){
delete this.changes.data delete that.changes[item]
} }
})
} }
}], }],
// XXX should this handle the input (_)??? // XXX handle changes correctly...
// XXX account for 'base' mode changes...
// use : .config['collection-transfer-changes']
['prepareIndexForWrite', ['prepareIndexForWrite',
function(res, _, full){ function(res, _, full){
var changed = full == true var changed = full == true
@ -1131,6 +1140,13 @@ var CollectionTagsActions = actions.Actions({
'bookmark', 'bookmark',
'selected', 'selected',
], ],
// XXX this should not be in config -- see CollectionActions.config for details...
'collection-transfer-changes': CollectionActions.config['collection-transfer-changes']
.concat([
'bookmarked',
'selected',
]),
}, },
collectTagged: ['- Collections|Tag/', collectTagged: ['- Collections|Tag/',

View File

@ -63,12 +63,18 @@ module.SortActions = actions.Actions({
// also takes into account file sequence number... // also takes into account file sequence number...
// NOTE: this is descending by default... // NOTE: this is descending by default...
//'Date': 'metadata.createDate birthtime name-sequence keep-position reverse', //'Date': 'metadata.createDate birthtime name-sequence keep-position reverse',
'Date': 'metadata.createDate birthtime keep-position reverse', 'Date':
'File date': 'birthtime keep-position reverse', 'metadata.createDate birthtime keep-position reverse',
'File sequence number (with overflow)': 'name-sequence-overflow name path keep-position', 'File date':
'File sequence number': 'name-sequence name path keep-position', 'birthtime keep-position reverse',
'Name': 'name path keep-position', 'File sequence number (with overflow)':
'Name (XP-style)': 'name-leading-sequence name path keep-position', 'name-sequence-overflow name path keep-position',
'File sequence number':
'name-sequence name path keep-position',
'Name':
'name path keep-position',
'Name (natural number order)':
'name-leading-sequence name path keep-position',
}, },
}, },