mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
added support for loading collections in .browseImageCollections(..)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6dc1a52109
commit
812e547c12
@ -732,6 +732,7 @@ var CollectionActions = actions.Actions({
|
|||||||
|
|
||||||
// Introspection...
|
// Introspection...
|
||||||
//
|
//
|
||||||
|
// XXX make this check offline collections -- use .ensureCollection(..)
|
||||||
inCollections: ['- Image/',
|
inCollections: ['- Image/',
|
||||||
core.doc`Get list of collections containing item`,
|
core.doc`Get list of collections containing item`,
|
||||||
function(gid){
|
function(gid){
|
||||||
@ -741,6 +742,7 @@ var CollectionActions = actions.Actions({
|
|||||||
return (this.collection_order || [])
|
return (this.collection_order || [])
|
||||||
.filter(function(c){
|
.filter(function(c){
|
||||||
return c != MAIN_COLLECTION_TITLE
|
return c != MAIN_COLLECTION_TITLE
|
||||||
|
&& that.collections[c].data
|
||||||
&& (!gid
|
&& (!gid
|
||||||
|| that.collections[c].data.getImage(gid)) })
|
|| that.collections[c].data.getImage(gid)) })
|
||||||
}],
|
}],
|
||||||
@ -916,7 +918,8 @@ var CollectionActions = actions.Actions({
|
|||||||
// NOTE: if tags are saved to the collection it means that
|
// NOTE: if tags are saved to the collection it means that
|
||||||
// those tags are local to the collection and we do not
|
// those tags are local to the collection and we do not
|
||||||
// need to protect them...
|
// need to protect them...
|
||||||
if(this.data !== this.collections[collection].data){
|
if(this.collections[collection].data
|
||||||
|
&& this.data !== this.collections[collection].data){
|
||||||
this.collections[collection].data
|
this.collections[collection].data
|
||||||
.clear(gids)
|
.clear(gids)
|
||||||
}
|
}
|
||||||
@ -1248,6 +1251,8 @@ 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 mark changed ONLY if actual changes made...
|
||||||
[[
|
[[
|
||||||
// NOTE: no need to handle .collect(..) here as it calls .joinCollect(..)
|
// NOTE: no need to handle .collect(..) here as it calls .joinCollect(..)
|
||||||
'joinCollect',
|
'joinCollect',
|
||||||
@ -2072,7 +2077,6 @@ var UICollectionActions = actions.Actions({
|
|||||||
})],
|
})],
|
||||||
|
|
||||||
// XXX would be nice to make this nested (i.e. path list)...
|
// XXX would be nice to make this nested (i.e. path list)...
|
||||||
// XXX do .markChanged('collections') after sorting...
|
|
||||||
browseCollections: ['Collections/$Collections...',
|
browseCollections: ['Collections/$Collections...',
|
||||||
core.doc`Collection list...
|
core.doc`Collection list...
|
||||||
|
|
||||||
@ -2279,22 +2283,46 @@ var UICollectionActions = actions.Actions({
|
|||||||
.addClass('highlighted')
|
.addClass('highlighted')
|
||||||
})
|
})
|
||||||
|
|
||||||
//all = Object.keys(that.collections || {})
|
all = all || that.collection_order || []
|
||||||
all = that.collection_order = that.collection_order || []
|
|
||||||
|
|
||||||
if(defaults){
|
if(defaults){
|
||||||
all = all.concat(defaults).unique()
|
all.splice.apply(all,
|
||||||
|
[0, all.length]
|
||||||
|
.concat(all.concat(defaults).unique()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// load collections...
|
||||||
|
var loading = all.filter(function(c){
|
||||||
|
return !that.collections[c].data })
|
||||||
|
if(loading.length > 0){
|
||||||
|
Promise
|
||||||
|
.all(loading.map(function(c){
|
||||||
|
return that.ensureCollection(c) }))
|
||||||
|
.then(function(){
|
||||||
|
// update state...
|
||||||
|
var c = that.inCollections(gid || null)
|
||||||
|
loading.forEach(function(t){
|
||||||
|
c.indexOf(t) >= 0 ?
|
||||||
|
collections.push(t)
|
||||||
|
: to_remove.push(t.replace(/\$/g, ''))
|
||||||
|
})
|
||||||
|
|
||||||
|
dialog.update()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// containing collections...
|
||||||
collections = collections
|
collections = collections
|
||||||
|| that.inCollections(gid || null)
|
|| that.inCollections(gid || null)
|
||||||
|
.filter(function(){ return loading.indexOf(title) >= 0 })
|
||||||
|
|
||||||
|
|
||||||
// build the disabled list...
|
// build the disabled list...
|
||||||
if(!to_remove){
|
if(!to_remove){
|
||||||
to_remove = []
|
to_remove = []
|
||||||
all.forEach(function(title){
|
all.forEach(function(title){
|
||||||
collections.indexOf(title) < 0
|
collections.indexOf(title) < 0
|
||||||
&& to_remove.push(title)
|
&& loading.indexOf(title) < 0
|
||||||
|
&& to_remove.push(title.replace(/\$/g, ''))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2303,6 +2331,7 @@ var UICollectionActions = actions.Actions({
|
|||||||
{
|
{
|
||||||
new_item: false,
|
new_item: false,
|
||||||
sortable: 'y',
|
sortable: 'y',
|
||||||
|
disabled: loading,
|
||||||
to_remove: to_remove,
|
to_remove: to_remove,
|
||||||
itemopen: function(_, title){
|
itemopen: function(_, title){
|
||||||
var i = to_remove.indexOf(title)
|
var i = to_remove.indexOf(title)
|
||||||
@ -2313,8 +2342,6 @@ var UICollectionActions = actions.Actions({
|
|||||||
|
|
||||||
dialog.update()
|
dialog.update()
|
||||||
},
|
},
|
||||||
// XXX for some reason after this ordering
|
|
||||||
// does not get saved...
|
|
||||||
itemedit: function(_, from, to){
|
itemedit: function(_, from, to){
|
||||||
that.renameCollection(from, to)
|
that.renameCollection(from, to)
|
||||||
|
|
||||||
|
|||||||
@ -843,8 +843,7 @@ function(list, options){
|
|||||||
.on('edit-abort edit-commit', function(_, title){
|
.on('edit-abort edit-commit', function(_, title){
|
||||||
title = title.trim() == '' ? from : title
|
title = title.trim() == '' ? from : title
|
||||||
dialog.update()
|
dialog.update()
|
||||||
.then(function(){
|
.then(function(){ dialog.select(`"${title}"`) })
|
||||||
dialog.select(title) })
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user