updated journalling -- needs testing...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-12-02 04:04:10 +03:00
parent d183e7621c
commit 0e14635281
2 changed files with 24 additions and 1 deletions

View File

@ -1802,6 +1802,7 @@ module.CropActions = actions.Actions({
// ...after we remove images from a crop we lose their containing
// ribbon information and the order might get messed up by
// horizontal shifting if not undone correctly...
// ...add a way to store additional info in the journal...
// XXX undo -- .removeFromCrop(..) but only the gids that were
// actually added... (???)
addToCrop: ['- Crop/',
@ -1865,7 +1866,14 @@ module.CropActions = actions.Actions({
}],
// XXX undo -- need containing ribbon info per gid to undo correctly...
removeFromCrop: ['Crop|Image/Remove from crop',
{browseMode: 'uncrop'},
core.doc`
`,
{
browseMode: 'uncrop',
// XXX group gid - ribbon
//getUndoState: function(data){ },
//undo: function(data){},
},
function(gids){
var that = this
if(!this.cropped){

View File

@ -620,6 +620,11 @@ module.Util = ImageGridFeatures.Feature({
// XXX need to define a clear journaling strategy in the lines of:
// - save state clears journal and adds a state load action
// - .load(..) clears journal
// XXX need a way to store additional info in the journal...
// can either be done as:
// - a hook (action handler and/or attr)
// - inline code inside the action...
// can't say I like #2 as it will mess the code up...
// XXX needs careful testing...
var JournalActions = actions.Actions({
@ -638,6 +643,10 @@ var JournalActions = actions.Actions({
journalable: null,
// XXX doc supported attrs:
// undo
// undoable
// getUndoState
// XXX should the action have control over what gets journaled and how???
updateJournalableActions: ['System/Update list of journalable actions',
function(){
@ -665,6 +674,12 @@ var JournalActions = actions.Actions({
return
}
// get additional undo state...
var update = that.getActionAttr(action, 'getUndoState')
update
&& update instanceof Function
&& update.call(that, data)
// journal after the action is done...
return function(){ this.journalPush(data) }
}