mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
minor tweaking, docs and notes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
33d4b2ec12
commit
f3f6c820db
@ -1933,56 +1933,36 @@ module.Timers = ImageGridFeatures.Feature({
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// XXX need a mechanism to store the journal in sync (localStorage/fs)
|
||||||
|
// and be able to execute the journal from last save position if
|
||||||
|
// recovering from close/crash...
|
||||||
|
// XXX should this be a separate feature???
|
||||||
|
//
|
||||||
// XXX would be great to add a mechanism define how to reverse actions...
|
// XXX would be great to add a mechanism define how to reverse actions...
|
||||||
// ...one way to do this at this point is to revert to last state
|
// ...one way to do this at this point is to revert to last state
|
||||||
// and re-run the journal until the desired event...
|
// and re-run the journal until the desired event...
|
||||||
// XXX need to define a clear journaling strategy in the lines of:
|
// XXX need to define a clear journaling strategy in the lines of:
|
||||||
// - save state clears journal and adds a state load action
|
// - save state clears journal and adds a state load action
|
||||||
// - .load(..) clears journal
|
// - .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...
|
// XXX needs careful testing...
|
||||||
var JournalActions = actions.Actions({
|
var JournalActions = actions.Actions({
|
||||||
|
|
||||||
clone: [function(full){
|
clone: [function(full){
|
||||||
return function(res){
|
return function(res){
|
||||||
res.rjournal = null
|
res.rjournal = null
|
||||||
res.journal = null
|
res.journal = null
|
||||||
if(full && this.hasOwnProperty('journal') && this.journal){
|
if(full && this.hasOwnProperty('journal') && this.journal){
|
||||||
res.journal = JSON.parse(JSON.stringify(this.journal))
|
res.journal = JSON.parse(JSON.stringify(this.journal)) } } }],
|
||||||
}
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
|
|
||||||
// Format:
|
// for format docs see: .updateJournalableActions(..)
|
||||||
// [
|
|
||||||
// {
|
|
||||||
// type: 'basic' | ...,
|
|
||||||
//
|
|
||||||
// action: <action-name>,
|
|
||||||
// args: [ ... ],
|
|
||||||
//
|
|
||||||
// // the current image before the action...
|
|
||||||
// current: undefined | <gid>
|
|
||||||
//
|
|
||||||
// // the target (current) image after action...
|
|
||||||
// target: undefined | <gid>
|
|
||||||
//
|
|
||||||
// // additional data, can be set via:
|
|
||||||
// // <action>.getUndoState(<data>)...
|
|
||||||
// ...
|
|
||||||
// },
|
|
||||||
// ...
|
|
||||||
// ]
|
|
||||||
//
|
|
||||||
journal: null,
|
journal: null,
|
||||||
rjournal: null,
|
rjournal: null,
|
||||||
|
|
||||||
journalable: null,
|
journalable: null,
|
||||||
|
|
||||||
|
// XXX docs...
|
||||||
|
// XXX <action>.getUndoState(..) should be called for every action
|
||||||
|
// in chain...
|
||||||
// XXX should aliases support explicit undo??? (test)
|
// XXX should aliases support explicit undo??? (test)
|
||||||
updateJournalableActions: ['System/Update list of journalable actions',
|
updateJournalableActions: ['System/Update list of journalable actions',
|
||||||
doc`
|
doc`
|
||||||
@ -1990,8 +1970,34 @@ var JournalActions = actions.Actions({
|
|||||||
This will setup the action journal handler as a .pre handler
|
This will setup the action journal handler as a .pre handler
|
||||||
(tagged: 'journal-handler'), calling this again will reset the existing
|
(tagged: 'journal-handler'), calling this again will reset the existing
|
||||||
handlers and add new ones.
|
handlers and add new ones.
|
||||||
|
|
||||||
NOTE: action aliases can not handle undo.
|
NOTE: action aliases can not handle undo.
|
||||||
|
|
||||||
|
.journal / .rjournal format:
|
||||||
|
[
|
||||||
|
// journaled action..
|
||||||
|
{
|
||||||
|
type: 'basic' | ...,
|
||||||
|
date: <timestamp>,
|
||||||
|
|
||||||
|
action: <action-name>,
|
||||||
|
args: [ ... ],
|
||||||
|
|
||||||
|
// the current image before the action...
|
||||||
|
current: undefined | <gid>
|
||||||
|
|
||||||
|
// the target (current) image after action...
|
||||||
|
target: undefined | <gid>
|
||||||
|
|
||||||
|
// additional data, can be set via:
|
||||||
|
// <action>.getUndoState(<data>)...
|
||||||
|
...
|
||||||
|
},
|
||||||
|
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
NOTE: newer journal items are pushed to the .journal tail...
|
||||||
`,
|
`,
|
||||||
function(){
|
function(){
|
||||||
var that = this
|
var that = this
|
||||||
@ -2000,8 +2006,11 @@ var JournalActions = actions.Actions({
|
|||||||
return function(){
|
return function(){
|
||||||
var data = {
|
var data = {
|
||||||
type: 'basic',
|
type: 'basic',
|
||||||
|
date: Date.now(),
|
||||||
|
|
||||||
action: action,
|
action: action,
|
||||||
args: [...arguments],
|
args: [...arguments],
|
||||||
|
|
||||||
current: this.current,
|
current: this.current,
|
||||||
// NOTE: we set this after the action is done...
|
// NOTE: we set this after the action is done...
|
||||||
target: undefined,
|
target: undefined,
|
||||||
@ -2023,6 +2032,7 @@ var JournalActions = actions.Actions({
|
|||||||
return function(){
|
return function(){
|
||||||
data.target = this.current
|
data.target = this.current
|
||||||
// prep to get additional undo state...
|
// prep to get additional undo state...
|
||||||
|
// XXX this should be called for all actions in chain...
|
||||||
var update = _getActionMethod(action, 'getUndoState')
|
var update = _getActionMethod(action, 'getUndoState')
|
||||||
update
|
update
|
||||||
&& update instanceof Function
|
&& update instanceof Function
|
||||||
|
|||||||
4
Viewer/package-lock.json
generated
4
Viewer/package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ImageGrid.Viewer.g4",
|
"name": "ImageGrid.Viewer.g4",
|
||||||
"version": "4.0.2a",
|
"version": "4.0.3a",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ImageGrid.Viewer.g4",
|
"name": "ImageGrid.Viewer.g4",
|
||||||
"version": "4.0.2a",
|
"version": "4.0.3a",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"app-module-path": "^1.0.6",
|
"app-module-path": "^1.0.6",
|
||||||
"async-json": "0.0.2",
|
"async-json": "0.0.2",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user