added comments to export/save dialog + some bugs squashed (in progress)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-05-11 06:59:56 +03:00
parent df378430c1
commit b6577a4e3b
2 changed files with 69 additions and 11 deletions

View File

@ -94,6 +94,12 @@ var FileSystemLoaderActions = actions.Actions({
// NOTE: this will add a .from field to .location, this will indicate // NOTE: this will add a .from field to .location, this will indicate
// the date starting from which saves are loaded. // the date starting from which saves are loaded.
// //
// XXX BUG: if no <keyword>.json files exist this will not load
// anything...
// To reproduce:
// .loadImages(..)
// .saveIndex()
// .loadIndex(..)
// XXX add a symmetric equivalent to .prepareIndexForWrite(..) so as // XXX add a symmetric equivalent to .prepareIndexForWrite(..) so as
// to enable features to load their data... // to enable features to load their data...
// XXX should this return a promise??? ...a clean promise??? // XXX should this return a promise??? ...a clean promise???
@ -642,6 +648,9 @@ var FileSystemSaveHistoryActions = actions.Actions({
// } // }
savecomments: null, savecomments: null,
getSaveComment: ['- File/',
function(save){
return this.savecomments && this.savecomments[save || 'current'] || '' }],
// Comment a save... // Comment a save...
// //
// Comment current save... // Comment current save...
@ -1228,12 +1237,14 @@ var FileSystemWriterActions = actions.Actions({
// NOTE: with no arguments this will save index to .location.path // NOTE: with no arguments this will save index to .location.path
// XXX should this return a promise??? ...a clean promise??? // XXX should this return a promise??? ...a clean promise???
// XXX BUG: after .loadImages(..) and without arguments this produces
// a result that is not loaded....
saveIndex: ['- File/', saveIndex: ['- File/',
function(path, logger){ function(path, logger){
var that = this var that = this
path = path || this.location.loaded path = path || this.location.loaded
path = path.length == 1 ? path[0] : path path = path && path.length == 1 ? path[0] : path
// XXX // XXX
if(path instanceof Array){ if(path instanceof Array){
@ -1241,6 +1252,11 @@ var FileSystemWriterActions = actions.Actions({
return return
} }
// XXX
if(path == null && this.location.method != 'loadIndex'){
path = this.location.path
}
// resolve relative paths... // resolve relative paths...
if(/^(\.\.?[\\\/]|[^\\\/])/.test(path) if(/^(\.\.?[\\\/]|[^\\\/])/.test(path)
// and skip windows drives... // and skip windows drives...
@ -1644,16 +1660,15 @@ module.FileSystemWriter = core.ImageGridFeatures.Feature({
// - save if not base path present (browser) // - save if not base path present (browser)
var FileSystemWriterUIActions = actions.Actions({ var FileSystemWriterUIActions = actions.Actions({
config: { config: {
'export-dialog-mode': 'Directories', 'export-dialog-mode': 'Full index',
'export-dialog-modes': { 'export-dialog-modes': {
'Images only': { // XXX is this the right title???
action: 'exportDirs', // XXX this is not yet working...
'Save index to current location': {
action: 'saveIndexHere',
data: [ data: [
'pattern', 'comment'
'size',
'level_dir',
'target_dir',
], ],
}, },
'Full index': { 'Full index': {
@ -1661,6 +1676,16 @@ var FileSystemWriterUIActions = actions.Actions({
data: [ data: [
//'size', //'size',
'target_dir', 'target_dir',
'comment',
],
},
'Images only': {
action: 'exportDirs',
data: [
'pattern',
'size',
'level_dir',
'target_dir',
], ],
}, },
}, },
@ -1807,7 +1832,34 @@ var FileSystemWriterUIActions = actions.Actions({
}) })
}) })
}) })
} },
'comment': function(actions, make, parent){
var elem = make(['Comment: ',
// XXX get staged comment???
function(){ return actions.getSaveComment() }])
.on('open', function(){
event.preventDefault()
// XXX multiline???
var path = elem.find('.text').last()
.makeEditable({
multiline: true,
clear_on_edit: false,
abort_keys: [
'Esc',
],
})
.on('edit-done', function(_, text){
actions.setSaveComment(text)
})
.on('edit-aborted edit-done', function(evt, text){
parent.update()
.then(function(){
parent.select(text)
})
})
})
},
}, },
// XXX indicate export state: index, crop, image... // XXX indicate export state: index, crop, image...
exportDialog: ['File/Export/Export optioons...', exportDialog: ['File/Export/Export optioons...',
@ -1817,11 +1869,15 @@ var FileSystemWriterUIActions = actions.Actions({
var o = browse.makeLister(null, function(path, make){ var o = browse.makeLister(null, function(path, make){
var dialog = this var dialog = this
var mode = that.config['export-dialog-mode'] || 'Images only' var mode = that.config['export-dialog-mode'] || 'Images only'
// if invalid mode get the first...
mode = !that.config['export-dialog-modes'][mode] ?
Object.keys(that.config['export-dialog-modes']).shift()
: mode
var data = that.config['export-dialog-modes'][mode].data var data = that.config['export-dialog-modes'][mode].data
// mode selector... // mode selector...
make(['Export mode: ', make(['Export mode: ',
function(){ return that.config['export-dialog-mode'] || 'Directories' }]) function(){ return mode }])
.on('open', .on('open',
widgets.makeNestedConfigListEditor(that, o, widgets.makeNestedConfigListEditor(that, o,
'export-dialog-modes', 'export-dialog-modes',
@ -1849,7 +1905,7 @@ var FileSystemWriterUIActions = actions.Actions({
.on('open', function(){ .on('open', function(){
var mode = that.config['export-dialog-modes'][that.config['export-dialog-mode']] var mode = that.config['export-dialog-modes'][that.config['export-dialog-mode']]
that[mode.action]( that[mode.action](
that.config['export-path'] || that.location.path) that.config['export-path'] || undefined)
dialog.parent.close() dialog.parent.close()
}) })
.addClass('selected') .addClass('selected')

View File

@ -1922,6 +1922,8 @@ var ControlActions = actions.Actions({
// on... // on...
if(state == 'on'){ if(state == 'on'){
// NOTE: we are resetting this to avoid multiple setting
// handlers...
this.off('updateRibbon', handler) this.off('updateRibbon', handler)
this.on('updateRibbon', handler) this.on('updateRibbon', handler)