From 0e146352818e0db4b9937179326e8b52b0c740a6 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 2 Dec 2017 04:04:10 +0300 Subject: [PATCH] updated journalling -- needs testing... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/base.js | 10 +++++++++- ui (gen4)/features/core.js | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ui (gen4)/features/base.js b/ui (gen4)/features/base.js index b83ee26e..e50f6a23 100755 --- a/ui (gen4)/features/base.js +++ b/ui (gen4)/features/base.js @@ -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){ diff --git a/ui (gen4)/features/core.js b/ui (gen4)/features/core.js index 7cb58629..edcf3625 100755 --- a/ui (gen4)/features/core.js +++ b/ui (gen4)/features/core.js @@ -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) } }