added undo to .addToCrop(..) + notes, tweaks and fixes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-12-29 18:33:59 +03:00
parent 4553a25f2f
commit bead309555
7 changed files with 43 additions and 16 deletions

View File

@ -1801,8 +1801,6 @@ module.CropActions = actions.Actions({
}], }],
// crop edit actions... // crop edit actions...
// XXX undo -- .removeFromCrop(..) but only the gids that were
// actually added... (???)
// XXX BUG? order does odd things... // XXX BUG? order does odd things...
addToCrop: ['- Crop/', addToCrop: ['- Crop/',
core.doc`Add gids to current crop... core.doc`Add gids to current crop...
@ -1840,13 +1838,27 @@ module.CropActions = actions.Actions({
different in that it does not require the images to be loaded different in that it does not require the images to be loaded
in the current crop... in the current crop...
NOTE: this can only add gids to current crop... NOTE: this can only add gids to current crop...
NOTE; passing this a gid of an unloaded ribbon is pointless, so
it is not supported.
`, `,
// NOTE: we do not need undo here as we'll not use this directly
{
getUndoState: function(d){
var a = d.args[0] || []
a = a instanceof Array ? a : [a]
d.args[0] = a.filter(function(g){
return !this.data.getImage(g, 'loaded') }.bind(this)) },
undo: 'removeFromCrop',
},
function(gids, ribbon, reference, mode){ function(gids, ribbon, reference, mode){
if(!this.cropped){ if(!this.cropped){
return return
} }
gids = gids instanceof Array ? gids : [gids] gids = (gids instanceof Array ? gids : [gids])
// filter out gids that are already loaded...
.filter(function(g){
return !this.data.getImage(g, 'loaded') }.bind(this))
var r = this.data.ribbons[this.current_ribbon] var r = this.data.ribbons[this.current_ribbon]
var o = this.data.order var o = this.data.order
@ -1933,6 +1945,7 @@ module.CropActions = actions.Actions({
data.getImage(this.direction == 'left' ? 'before' : 'after') data.getImage(this.direction == 'left' ? 'before' : 'after')
|| data.getImage(this.direction == 'left' ? 'after' : 'before')) || data.getImage(this.direction == 'left' ? 'after' : 'before'))
}], }],
// NOTE: this is undone by .removeFromCrop(..)
removeRibbonFromCrop:['Crop|Ribbon/Remove ribbon from crop', removeRibbonFromCrop:['Crop|Ribbon/Remove ribbon from crop',
core.doc` core.doc`

View File

@ -311,6 +311,8 @@ var CollectionActions = actions.Actions({
// handle collection... // handle collection...
p = running[collection] = new Promise(function(resolve, reject){ p = running[collection] = new Promise(function(resolve, reject){
// NOTE: we do not need to return this as we'll resolve/reject
// manually in .then(..) / .catch(..)
Promise Promise
.all(Object.keys(handlers) .all(Object.keys(handlers)
// filter relevant handlers... // filter relevant handlers...
@ -853,6 +855,7 @@ var CollectionActions = actions.Actions({
// add to collection... // add to collection...
var data = this.data.constructor.fromArray(gids) var data = this.data.constructor.fromArray(gids)
// XXX should we use collection.data.placeImage(..)???
return this.joinCollect(null, collection, data) return this.joinCollect(null, collection, data)
}).bind(this)) }).bind(this))
}], }],
@ -1804,12 +1807,20 @@ var CollectionLocalConfig = actions.Actions({
}, },
// handle collection .config // handle collection .config
// XXX problems:
// - config leaks -- when moving crom collection to collection
// with individual option sets some options may not get
// restored if handled incorrectly...
// ...one way to deal with this is to restore the base config
// on every load before loading the new config...
collectionConfigLoader: ['- Collections/', collectionConfigLoader: ['- Collections/',
{collectionFormat: 'config'}, {collectionFormat: 'config'},
function(title, state, logger){ function(title, state, logger){
// XXX save old config... // XXX save old config -- in their respective collection...
// XXX load new config... // XXX load MAIN_COLLECTION_TITLE config...
// XXX load new config -- from target collection...
}], }],
}) })
@ -2650,6 +2661,9 @@ var UICollectionActions = actions.Actions({
}) })
})], })],
// Collection actions with collection selection...
//
// XXX need to add "ALL" -- might need to rework .browseCollections(..) for this... // XXX need to add "ALL" -- might need to rework .browseCollections(..) for this...
// XXX also do: // XXX also do:
// .saveCollection(..) // .saveCollection(..)
@ -2664,9 +2678,6 @@ var UICollectionActions = actions.Actions({
}, },
`loadCollection: "${MAIN_COLLECTION_TITLE}"`], `loadCollection: "${MAIN_COLLECTION_TITLE}"`],
// Collection actions with collection selection...
//
// XXX extend .saveCollection(..) and remove this... // XXX extend .saveCollection(..) and remove this...
// ...see .loadCollection(..) notes above... // ...see .loadCollection(..) notes above...
// XXX should we warn the user when overwriting??? // XXX should we warn the user when overwriting???

View File

@ -796,7 +796,7 @@ var JournalActions = actions.Actions({
undo.call(this, a) undo.call(this, a)
: typeof(undo) == typeof('str') ? : typeof(undo) == typeof('str') ?
// pass journal structure as-is... // pass journal structure as-is...
this[undo].apply(this, a) this[undo].apply(this, a.args)
: null : null
// push the undone command to the reverse journal... // push the undone command to the reverse journal...

View File

@ -135,14 +135,11 @@ module.GLOBAL_KEYBOARD = {
Esc: 'uncrop', Esc: 'uncrop',
shift_Esc: 'uncropAll', shift_Esc: 'uncropAll',
// XXX
//ctrl_S: 'saveAsCollection',
W: 'testAction2 -- XXX DEBUG: remove when done...', W: 'testAction2 -- XXX DEBUG: remove when done...',
// XXX not sure about this...
Del: 'removeFromCrop', Del: 'removeFromCrop',
shift_Del: 'removeMarkedFromCrop', shift_Del: 'removeMarkedFromCrop',
ctrl_Del: 'removeRibbonFromCrop',
}, },
'Collection': { 'Collection': {

View File

@ -788,6 +788,9 @@ module.writeIndex =
function(json, path, date, filename_tpl, logger){ function(json, path, date, filename_tpl, logger){
logger = logger && logger.push('Index') logger = logger && logger.push('Index')
// XXX get this from args/config...
var spaces = null
path = util.normalizePath(path) path = util.normalizePath(path)
filename_tpl = filename_tpl || FILENAME filename_tpl = filename_tpl || FILENAME
// XXX for some reason this gets the unpatched node.js Date, so we // XXX for some reason this gets the unpatched node.js Date, so we
@ -810,7 +813,8 @@ function(json, path, date, filename_tpl, logger){
// be too many files... // be too many files...
return Promise return Promise
.all(Object.keys(json).map(function(keyword){ .all(Object.keys(json).map(function(keyword){
var data = JSON.stringify(json[keyword]) //var data = JSON.stringify(json[keyword])
var data = JSON.stringify(json[keyword], null, spaces)
// get the sub-path and keyword... // get the sub-path and keyword...
var sub_path = keyword.split(/[\\\/]/g) var sub_path = keyword.split(/[\\\/]/g)

View File

@ -8824,7 +8824,7 @@
"deep-extend": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.1.tgz", "deep-extend": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.1.tgz",
"ini": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", "ini": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz",
"minimist": "1.2.0", "minimist": "1.2.0",
"strip-json-comments": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz" "strip-json-comments": "2.0.1"
}, },
"dependencies": { "dependencies": {
"minimist": { "minimist": {
@ -9331,7 +9331,8 @@
} }
}, },
"strip-json-comments": { "strip-json-comments": {
"version": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
"integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo="
}, },
"supports-color": { "supports-color": {

View File

@ -34,6 +34,7 @@
"requirejs": "^2.3.5", "requirejs": "^2.3.5",
"requirejs-plugins": "^1.0.2", "requirejs-plugins": "^1.0.2",
"sharp": "^0.17.3", "sharp": "^0.17.3",
"strip-json-comments": "^2.0.1",
"wildglob": "^0.1.1" "wildglob": "^0.1.1"
}, },
"optionalDependencies": { "optionalDependencies": {