export dialog now can be extended and configured...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-04-16 05:19:31 +03:00
parent a62e144570
commit a15397c1af
2 changed files with 103 additions and 69 deletions

View File

@ -796,14 +796,9 @@ var FileSystemWriterActions = actions.Actions({
}) })
}], }],
// XXX same as ctrl-shif-s in gen3
exportView: ['File/Export current view',
function(){
}],
// Export current state as a full loadable index // Export current state as a full loadable index
// //
// XXX might be interesting to unify this and .exportView(..) // XXX handle relative paths...
// XXX should this return a promise??? ...a clean promise??? // XXX should this return a promise??? ...a clean promise???
// XXX add preview selection... // XXX add preview selection...
// XXX handle .image.path and other stack files... // XXX handle .image.path and other stack files...
@ -899,6 +894,7 @@ var FileSystemWriterActions = actions.Actions({
}], }],
// XXX handle relative paths...
// XXX use options: // XXX use options:
// - level dir name // - level dir name
// - size // - size
@ -1115,8 +1111,22 @@ var FileSystemWriterUIActions = actions.Actions({
'export-dialog-mode': 'Directories', 'export-dialog-mode': 'Directories',
'export-dialog-modes': { 'export-dialog-modes': {
'Images only': 'exportDirs', 'Images only': {
'Full index': 'exportIndex', action: 'exportDirs',
data: [
'pattern',
'size',
'level_dir',
'target_dir',
],
},
'Full index': {
action: 'exportIndex',
data: [
//'size',
'target_dir',
],
},
}, },
}, },
@ -1140,13 +1150,13 @@ var FileSystemWriterUIActions = actions.Actions({
return this return this
.markChanged('all') .markChanged('all')
.saveIndexHere()}], .saveIndexHere()}],
// XXX add ability to create dirs... // XXX add ability to create dirs...
// XXX this needs feedback... // XXX this needs feedback...
// XXX should this return a promise??? // XXX should this return a promise???
browseSaveIndex: ['File/Save index to...', browseSaveIndex: ['File/Save index to...',
makeBrowseProxy('saveIndex', function(){ makeBrowseProxy('saveIndex', function(){
this.location.method = 'loadIndex' })], this.location.method = 'loadIndex' })],
// XXX need to be able to make dirs... // XXX need to be able to make dirs...
browseExportIndex: ['File/Export/Index to...', browseExportIndex: ['File/Export/Index to...',
makeBrowseProxy('exportIndex')], makeBrowseProxy('exportIndex')],
@ -1155,10 +1165,72 @@ var FileSystemWriterUIActions = actions.Actions({
browseExportDirs: ['File/Export/Images to...', browseExportDirs: ['File/Export/Images to...',
makeBrowseProxy('exportDirs')], makeBrowseProxy('exportDirs')],
// XXX make this a multi format export dialog...
// - index // Export dialog...
// - dirs //
// - ... __export_dialog_fields__: {
'pattern': function(actions, make, overlay){
return make(['Filename pattern: ',
function(){
return actions.config['export-preview-name-pattern'] || '%f' }])
.on('open',
widgets.makeNestedConfigListEditor(actions, overlay,
'export-preview-name-patterns',
'export-preview-name-pattern'))
},
'level_dir': function(actions, make, overlay){
return make(['Level directory: ',
function(){
return actions.config['export-level-directory-name'] || 'fav' }])
.on('open',
widgets.makeNestedConfigListEditor(actions, overlay,
'export-level-directory-names',
'export-level-directory-name'))
},
'size': function(actions, make, overlay){
return make(['Image size: ',
function(){
return actions.config['export-preview-size'] || 1000 }])
// XXX add validation???
.on('open',
widgets.makeNestedConfigListEditor(actions, overlay,
'export-preview-sizes',
'export-preview-size'))
},
'target_dir': function(actions, make, overlay){
return make(['To: ',
function(){ return actions.config['export-path'] || './' }],
{ buttons: [
['browse', function(p){
var e = this.filter('"'+p+'"', false)
var path = e.find('.text').last().text()
var txt = e.find('.text').first().text()
// XXX add new dir global button...
return actions.browsePath(path,
function(path){
actions.config['export-path'] = path
actions.config['export-paths'].splice(0, 0, path)
overlay.client.update()
overlay.client.select(txt)
// XXX ugly...
overlay.focus()
})
}]
]})
.on('open',
widgets.makeNestedConfigListEditor(actions, overlay,
'export-paths',
'export-path',
{
// XXX add 'edit' button...
//itemButtons: []
}))
}
},
// XXX indicate export state: index, crop, image... // XXX indicate export state: index, crop, image...
exportDialog: ['File/Export/Images...', exportDialog: ['File/Export/Images...',
function(){ function(){
@ -1166,7 +1238,10 @@ var FileSystemWriterUIActions = actions.Actions({
var o = overlay.Overlay(this.ribbons.viewer, var o = overlay.Overlay(this.ribbons.viewer,
browse.makeLister(null, function(path, make){ browse.makeLister(null, function(path, make){
// XXX disable 'x' buttons... var mode = that.config['export-dialog-mode'] || 'Images only'
var data = that.config['export-dialog-modes'][mode].data
// mode selector...
make(['Export mode: ', make(['Export mode: ',
function(){ return that.config['export-dialog-mode'] || 'Directories' }]) function(){ return that.config['export-dialog-mode'] || 'Directories' }])
.on('open', .on('open',
@ -1178,67 +1253,26 @@ var FileSystemWriterUIActions = actions.Actions({
itemButtons: [], itemButtons: [],
})) }))
make(['Filename pattern: ', // get the root and user fields...
function(){ return that.config['export-preview-name-pattern'] || '%f' }]) var fields = that.__export_dialog_fields__ || {}
.on('open', var base_fields = FileSystemWriterUIActions.__export_dialog_fields__ || {}
widgets.makeNestedConfigListEditor(that, o, // build the fields...
'export-preview-name-patterns', data.forEach(function(k){
'export-preview-name-pattern')) (fields[k]
&& fields[k].call(that, that, make, o))
|| (base_fields[k]
&& base_fields[k].call(that, that, make, o))
})
make(['Level directory: ', // Start/stop action...
function(){ return that.config['export-level-directory-name'] || 'fav' }])
.on('open',
widgets.makeNestedConfigListEditor(that, o,
'export-level-directory-names',
'export-level-directory-name'))
make(['Target image: ',
function(){ return that.config['export-preview-size'] || 1000 }])
// XXX add validation???
.on('open',
widgets.makeNestedConfigListEditor(that, o,
'export-preview-sizes',
'export-preview-size'))
make(['To: ',
function(){ return that.config['export-path'] || './' }],
{ buttons: [
['browse', function(p){
var e = this.filter('"'+p+'"', false)
var path = e.find('.text').last().text()
var txt = e.find('.text').first().text()
// XXX add new dir global button...
return that.browsePath(path,
function(path){
that.config['export-path'] = path
that.config['export-paths'].splice(0, 0, path)
o.client.update()
o.client.select(txt)
// XXX ugly...
o.focus()
})
}]
]})
.on('open',
widgets.makeNestedConfigListEditor(that, o,
'export-paths',
'export-path',
{
// XXX add 'edit' button...
//itemButtons: []
}))
// Start/stop...
make([function(){ make([function(){
// XXX indicate export state: index, crop, image... // XXX indicate export state: index, crop, image...
return 'Export'}]) return 'Export'}])
.on('open', function(){ .on('open', function(){
// XXX is this correct??? // XXX is this correct???
// XXX handle relative paths!!! // XXX handle relative paths!!!
that[that.config['export-mode']](that.config['export-path'] || that.location.path) that[that.config['export-mode'].action](
that.config['export-path'] || that.location.path)
o.close() o.close()
}) })
})) }))

View File

@ -266,7 +266,7 @@ module.GLOBAL_KEYBOARD = {
// XXX need to make this save to base_path if it exists and // XXX need to make this save to base_path if it exists and
// ask the user if it does not... now it always asks. // ask the user if it does not... now it always asks.
ctrl: 'saveIndexHere', ctrl: 'saveIndexHere',
'ctrl+shift': 'browseSaveIndex', 'ctrl+shift': 'exportDialog',
}, },
// XXX still experimental... // XXX still experimental...