mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
working on .uncollect(..) undo...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c428d9c4dc
commit
8a6659383d
@ -1895,6 +1895,8 @@ module.CropActions = actions.Actions({
|
|||||||
: this.data.ribbons[g] ? this.data.getImages(g) : g,
|
: this.data.ribbons[g] ? this.data.getImages(g) : g,
|
||||||
// get ribbon and ribbon order...
|
// get ribbon and ribbon order...
|
||||||
[this.data.getRibbon(g), this.data.getRibbonOrder(g)],
|
[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)) },
|
] }.bind(this)) },
|
||||||
undo: function(d){
|
undo: function(d){
|
||||||
(d.placements || [])
|
(d.placements || [])
|
||||||
|
|||||||
@ -976,10 +976,33 @@ var CollectionActions = actions.Actions({
|
|||||||
NOTE: this will remove any gid, be it image or ribbon.
|
NOTE: this will remove any gid, be it image or ribbon.
|
||||||
`,
|
`,
|
||||||
{
|
{
|
||||||
browseMode: function(){ return !this.collection && 'disabled' }
|
browseMode: function(){ return !this.collection && 'disabled' },
|
||||||
/* XXX
|
/*/ XXX two ways to go:
|
||||||
getUndoState: function(d){},
|
// - .collect(..) + .data.placeImage(..)
|
||||||
undo: function(d){},
|
// - 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){
|
function(gids, collection){
|
||||||
|
|||||||
@ -681,6 +681,9 @@ var JournalActions = actions.Actions({
|
|||||||
|
|
||||||
// get additional undo state...
|
// get additional undo state...
|
||||||
var update = that.getActionAttr(action, 'getUndoState')
|
var update = that.getActionAttr(action, 'getUndoState')
|
||||||
|
while(typeof(update) == typeof('str')){
|
||||||
|
update = that.getActionAttr(update, 'getUndoState')
|
||||||
|
}
|
||||||
update
|
update
|
||||||
&& update instanceof Function
|
&& update instanceof Function
|
||||||
&& update.call(that, data)
|
&& update.call(that, data)
|
||||||
@ -795,7 +798,7 @@ var JournalActions = actions.Actions({
|
|||||||
// pass the action name...
|
// pass the action name...
|
||||||
undo.call(this, a)
|
undo.call(this, a)
|
||||||
: typeof(undo) == typeof('str') ?
|
: typeof(undo) == typeof('str') ?
|
||||||
// pass journal structure as-is...
|
// XXX pass journal structure as-is... (???)
|
||||||
this[undo].apply(this, a.args)
|
this[undo].apply(this, a.args)
|
||||||
: null
|
: null
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user