diff --git a/ui (gen4)/features/base.js b/ui (gen4)/features/base.js index 6bd0fdb7..ffc377be 100755 --- a/ui (gen4)/features/base.js +++ b/ui (gen4)/features/base.js @@ -1895,6 +1895,8 @@ module.CropActions = actions.Actions({ : this.data.ribbons[g] ? this.data.getImages(g) : g, // get ribbon and ribbon order... [this.data.getRibbon(g), this.data.getRibbonOrder(g)], + // XXX this is not needed here but is used by .uncollect.undo(..) + this.data.order.indexOf(g), ] }.bind(this)) }, undo: function(d){ (d.placements || []) diff --git a/ui (gen4)/features/collections.js b/ui (gen4)/features/collections.js index 62061031..94158f7e 100755 --- a/ui (gen4)/features/collections.js +++ b/ui (gen4)/features/collections.js @@ -976,10 +976,33 @@ var CollectionActions = actions.Actions({ NOTE: this will remove any gid, be it image or ribbon. `, { - browseMode: function(){ return !this.collection && 'disabled' } - /* XXX - getUndoState: function(d){}, - undo: function(d){}, + browseMode: function(){ return !this.collection && 'disabled' }, + /*/ XXX two ways to go: + // - .collect(..) + .data.placeImage(..) + // - rewrite .collect(..) to use .data.placeImage(..) (like: .addToCrop(..)) + //getUndoState: 'removeFromCrop', + getUndoState: function(d){ + var base = this.getActionAttr('removeFromCrop', 'getUndoState') + base && base.call(this, d) + d.collection = d.args[1] || this.collection + }, + // XXX this does not work yet... + // XXX this use + undo: function(d){ + var that = this + var gids = d.args[0] || [d.current] + gids = gids instanceof Array ? gids : [gids] + var collection = d.collection + this + .collect(gids, collection) + .ensureCollection(collection) + .then(function(){ + d.placements.forEach(function(e){ + // XXX does not place correctly... + that.data.placeImage(e[0], e[1], that.data.order[e[2]]) + that.reload(true) + }) }) + }, //*/ }, function(gids, collection){ diff --git a/ui (gen4)/features/core.js b/ui (gen4)/features/core.js index dcf8b98f..e2b6273c 100755 --- a/ui (gen4)/features/core.js +++ b/ui (gen4)/features/core.js @@ -681,6 +681,9 @@ var JournalActions = actions.Actions({ // get additional undo state... var update = that.getActionAttr(action, 'getUndoState') + while(typeof(update) == typeof('str')){ + update = that.getActionAttr(update, 'getUndoState') + } update && update instanceof Function && update.call(that, data) @@ -795,7 +798,7 @@ var JournalActions = actions.Actions({ // pass the action name... undo.call(this, a) : typeof(undo) == typeof('str') ? - // pass journal structure as-is... + // XXX pass journal structure as-is... (???) this[undo].apply(this, a.args) : null