refactored collections UI + added several convinience actions...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-12-23 01:08:49 +03:00
parent 7a66aa6c07
commit 45eadeff76
4 changed files with 64 additions and 24 deletions

View File

@ -2230,6 +2230,19 @@ module.AutoCollections = core.ImageGridFeatures.Feature({
//---------------------------------------------------------------------
// NOTE: if n > 1 and <n args are given then the given args will get
// passed to func with an appended title...
var mixedModeCollectionAction = function(func, n){
return widgets.uiDialog(function(){
var args = [].slice.call(arguments)
// check if minimum number of arguments is reached...
return args.length < (n || 1) ?
//this.browseCollections(func)
this.browseCollections(function(title){
return func.call(this, ...args.concat([title])) })
: func.apply(this, args) }) }
// XXX show collections in image metadata... (???)
// XXX might be nice to indicate if a collection is loaded -- has .data???
// XXX might be nice to add collection previews to the collection list...
@ -2539,39 +2552,57 @@ var UICollectionActions = actions.Actions({
//
// XXX should we warn the user when overwriting???
saveAsCollection: ['Collections/$Save as collection...',
widgets.uiDialog(function(){
return this.browseCollections(function(title){
mixedModeCollectionAction(function(title){
this.saveCollection(title, 'current')
// XXX should we be doing this manually here or in .saveCollection(..)
title == this.collection
&& this.loadCollection('!')
}) })],
})],
addToCollection: ['Collections|Image/Add $image to collection...',
widgets.uiDialog(function(gids){
return this.browseCollections(function(title){
this.collect(gids || 'current', title) }) })],
mixedModeCollectionAction(function(gids, title){
if(title == null){
title = gids
gids = null
}
this.collect(gids || 'current', title) }, 2)],
addRibbonToCollection: ['Collections|Ribbon/Add $ribbon to collection...',
widgets.uiDialog(function(){ return this.addToCollection('ribbon') })],
addLoadedToCollection: ['Collections/$Add loaded images to collection...',
widgets.uiDialog(function(){ return this.addToCollection('loaded') })],
joinToCollection: ['Collections/$Merge view to collection...',
widgets.uiDialog(function(){
return this.browseCollections(function(title){ this.joinCollect(title) }) })],
mixedModeCollectionAction(function(title){ this.joinCollect(title) })],
// XXX should this be here or in marks???
cropOutImagesInCollection: ['Collections/Crop $out images in collection...',
mixedModeCollectionAction(function(title){
var that = this
this.ensureCollection(title)
.then(function(collection){
var to_remove = collection.data.getImages('all')
var images = that.data.getImages('loaded')
.filter(function(gid){ return to_remove.indexOf(gid) < 0 })
that.crop(images, false)
})
})],
// XXX should these be here or in marks-specific feature???
markImagesInCollection: ['Collections|Mark/$Mark images in collection...',
{browseMode: function(){
return (!this.collections
|| Object.keys(this.collections).length == 0)
&& 'disabled' }},
mixedModeCollectionAction(function(title){
var that = this
this.ensureCollection(title)
.then(function(collection){
var images = collection.data.getImages('all')
that.toggleMark(images, 'on')
})
})],
addMarkedToCollection: ['Collections|Mark/Add marked to $collection...',
{browseMode: function(){
return this.marked.length == 0 && 'disabled' }},
widgets.uiDialog(function(){
var that = this
return this.browseCollections(function(title){ this.collectMarked(title) })
.run(function(){
var title = that.config['collection-last-used']
title
&& this.select(`"${title}"`) })
.open(function(_, title){
that.config['collection-last-used'] = title })
})],
mixedModeCollectionAction(function(title){ this.collectMarked(title) })],
// XXX should this be in Collections/ ???
editDefaultCollections: ['Interface|Collections/Edit default collections...',

View File

@ -402,7 +402,7 @@ module.GLOBAL_KEYBOARD = {
ctrl_A: 'toggleMark!: "ribbon" "on" -- Mark all images in ribbon',
ctrl_shift_A: 'toggleMarkBlock!',
ctrl_D: 'toggleMark!: "ribbon" "off" -- Unmark all images in ribbon',
ctrl_I: 'toggleMark!: "ribbon" -- Invert marks in ribbon',
ctrl_I: 'invertRibbonMarks',
',': 'prevMarked',
'.': 'nextMarked',
alt_M: 'browseActions: "/Mark/" -- Mark menu...',

View File

@ -342,6 +342,14 @@ var ImageMarkEditActions = actions.Actions({
return this.toggleMark(block, state ? 'off' : 'on')
}],
// shorthands...
invertRibbonMarks: ['Mark/$Invert marks in ribbon',
{browseMode: 'cropMarked'},
'toggleMark: "ribbon"'],
invertLoadedMarks: ['Mark/$Invert marks',
{browseMode: 'cropMarked'},
'toggleMark: "loaded"'],
unmarkAll: ['Mark/$Unmark all',
{browseMode: 'cropMarked'},
function(){ this.toggleMark(this.marked) }],

View File

@ -1306,6 +1306,7 @@ var BrowseActionsActions = actions.Actions({
'Collections/-70:---',
'Collections/-70:.*remove.*',
'$Mark',
'Mark/-75:.*collection...',
'Mark/-80:---',
'Mark/-80:.*remove.*',
'Mark/-90:.*unmark.*',