mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
tweaking and cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
a3f5248b4c
commit
ab69925510
@ -782,8 +782,7 @@ var CollectionActions = actions.Actions({
|
|||||||
// // this is run after .collect(..)
|
// // this is run after .collect(..)
|
||||||
// ...
|
// ...
|
||||||
// })
|
// })
|
||||||
//
|
// XXX need to figure out error handling for this scheme...
|
||||||
// XXX need to figure out error handling for this scheme...
|
|
||||||
collect: ['- Collections/',
|
collect: ['- Collections/',
|
||||||
core.doc`Add items to collection
|
core.doc`Add items to collection
|
||||||
|
|
||||||
@ -1339,11 +1338,6 @@ module.Collection = core.ImageGridFeatures.Feature({
|
|||||||
.markChanged('collection: '
|
.markChanged('collection: '
|
||||||
+ JSON.stringify(this.collections[to].gid), ['metadata']) }],
|
+ JSON.stringify(this.collections[to].gid), ['metadata']) }],
|
||||||
// basic collection edits...
|
// basic collection edits...
|
||||||
//
|
|
||||||
// XXX .joinCollect(..) should set change for a collection if
|
|
||||||
// it changes the topology...
|
|
||||||
// ...this can happen when multiple ribbons are joined...
|
|
||||||
// Q: can this happen through .collect(..)???
|
|
||||||
[[
|
[[
|
||||||
// NOTE: no need to handle .collect(..) here as it calls .joinCollect(..)
|
// NOTE: no need to handle .collect(..) here as it calls .joinCollect(..)
|
||||||
'joinCollect.pre',
|
'joinCollect.pre',
|
||||||
@ -1352,7 +1346,7 @@ module.Collection = core.ImageGridFeatures.Feature({
|
|||||||
function(){
|
function(){
|
||||||
var that = this
|
var that = this
|
||||||
var args = [].slice.call(arguments)
|
var args = [].slice.call(arguments)
|
||||||
var title = args.length == 1 ? args[0] : args[1]
|
var title = (args.length == 1 ? args[0] : args[1]) || this.collection
|
||||||
var collection = (this.collections || {})[title] || {}
|
var collection = (this.collections || {})[title] || {}
|
||||||
|
|
||||||
var count = collection.data ?
|
var count = collection.data ?
|
||||||
@ -1360,20 +1354,38 @@ module.Collection = core.ImageGridFeatures.Feature({
|
|||||||
: collection.count
|
: collection.count
|
||||||
|
|
||||||
return function(){
|
return function(){
|
||||||
this.ensureCollection(title)
|
// NOTE: if a collection does not exist by this point
|
||||||
.then(function(){
|
// it will be handled by collection .collectionCreated(..)
|
||||||
var new_count = collection.data ?
|
// ...this means we are either creating a new collection
|
||||||
collection.data.length
|
// or removing from a non-existing collection.
|
||||||
: collection.count
|
title in this.collections
|
||||||
|
&& this.ensureCollection(title)
|
||||||
|
.then(function(){
|
||||||
|
var new_count = collection.data ?
|
||||||
|
collection.data.length
|
||||||
|
: collection.count
|
||||||
|
|
||||||
new_count != count
|
new_count != count
|
||||||
&& that.markChanged('collections')
|
&& that.markChanged('collections')
|
||||||
&& that.markChanged(
|
&& that.markChanged(
|
||||||
'collection: '
|
'collection: '
|
||||||
+JSON.stringify(collection.gid || title),
|
+JSON.stringify(collection.gid || title),
|
||||||
['data'])
|
['data'])
|
||||||
})
|
}) }
|
||||||
}
|
}],
|
||||||
|
['joinCollect',
|
||||||
|
function(_, align, collection, data){
|
||||||
|
var args = [].slice.call(arguments)
|
||||||
|
var title = (args.length == 1 ? args[0] : args[1]) || this.collection
|
||||||
|
var collection = (this.collections || {})[title] || {}
|
||||||
|
|
||||||
|
data = data || this.data
|
||||||
|
|
||||||
|
(!data || data.ribbon_order.length > 1)
|
||||||
|
&& that.markChanged(
|
||||||
|
'collection: '
|
||||||
|
+JSON.stringify(collection.gid || title),
|
||||||
|
['data'])
|
||||||
}],
|
}],
|
||||||
// transfer changes on load/unload collection...
|
// transfer changes on load/unload collection...
|
||||||
['collectionLoading.pre',
|
['collectionLoading.pre',
|
||||||
@ -1554,6 +1566,9 @@ module.Collection = core.ImageGridFeatures.Feature({
|
|||||||
//
|
//
|
||||||
// NOTE: the base collection (MAIN_COLLECTION_TITLE) is not saved
|
// NOTE: the base collection (MAIN_COLLECTION_TITLE) is not saved
|
||||||
// in collections, it is stored in the root index...
|
// in collections, it is stored in the root index...
|
||||||
|
//
|
||||||
|
// XXX we do not need .count in collection metadata as it is
|
||||||
|
// stored in collections...
|
||||||
['prepareIndexForWrite',
|
['prepareIndexForWrite',
|
||||||
function(res){
|
function(res){
|
||||||
if(!res.changes){
|
if(!res.changes){
|
||||||
@ -1912,7 +1927,7 @@ module.CollectionTags = core.ImageGridFeatures.Feature({
|
|||||||
local_tag_names
|
local_tag_names
|
||||||
.forEach(function(tag){
|
.forEach(function(tag){
|
||||||
local_tags[tag] = (!new_set || title == MAIN_COLLECTION_TITLE) ?
|
local_tags[tag] = (!new_set || title == MAIN_COLLECTION_TITLE) ?
|
||||||
(that.data.tags[tag] || [])
|
((that.data.tags || {})[tag] || [])
|
||||||
: []
|
: []
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user