diff --git a/ui (gen4)/features/base.js b/ui (gen4)/features/base.js index 5e629a1b..ea58014a 100755 --- a/ui (gen4)/features/base.js +++ b/ui (gen4)/features/base.js @@ -235,18 +235,14 @@ actions.Actions({ // NOTE: for complete isolation it is best to completely copy the // .config... clone: ['- File/', - function(full){ - var res = actions.MetaActions.clone.call(this, full) - + function(full){ return function(res){ if(this.data){ res.data = this.data.clone() } if(this.images){ res.images = this.images.clone() } - - return res - }], + } }], dataFromURLs: ['- File/', function(lst, base){ @@ -613,6 +609,7 @@ core.ImageGridFeatures.Feature({ tag: 'base', depends: [ + 'serialization', ], suggested: [ 'edit', diff --git a/ui (gen4)/features/collections.js b/ui (gen4)/features/collections.js index 5ddcc763..7ca38b00 100755 --- a/ui (gen4)/features/collections.js +++ b/ui (gen4)/features/collections.js @@ -464,8 +464,6 @@ var CollectionActions = actions.Actions({ .removeEmptyRibbons() }], - // manage serialization and loading... - // // NOTE: this will handle collection title and data only, the rest // is copied in as-is. // It is the responsibility of the extending features to transform @@ -577,10 +575,6 @@ var CollectionActions = actions.Actions({ }) } } }], - // XXX - clone: [function(){ - // XXX - }], clear: [function(){ this.collection && this.collectionUnloaded('*') @@ -588,6 +582,35 @@ var CollectionActions = actions.Actions({ delete this.__collection_order delete this.location.collection }], + + clone: [function(full){ + return function(res){ + if(this.collections){ + var cur = this.collections + + if(this.collection){ + res.location.collection = this.collection + } + + collections = res.collections = {} + this.collection_order + .forEach(function(title){ + var c = collections[title] = { + title: title, + } + + if(cur[title].data){ + c.data = cur[title].data.clone() + } + + if(cur[title].crop_stack){ + c.crop_stack = cur[title].crop_stack + .map(function(d){ return d.clone() }) + } + }) + } + + } }], }) diff --git a/ui (gen4)/features/core.js b/ui (gen4)/features/core.js index a19a2a7a..2274f84a 100755 --- a/ui (gen4)/features/core.js +++ b/ui (gen4)/features/core.js @@ -17,6 +17,8 @@ * - introspection * - lifecycle * base life-cycle events (start/stop/..) +* - serialization +* base methods to handle loading, serialization and cloning... * - util * - journal * action journaling and undo/redo functionality @@ -537,6 +539,29 @@ module.LifeCycle = ImageGridFeatures.Feature({ }) +//--------------------------------------------------------------------- + +var SerializationActions = actions.Actions({ + clone: ['- System/', + function(full){ return actions.MetaActions.clone.call(this, full) }], + json: ['- System/', + function(){ return {} }], + load: ['- System/', + function(){ }], + clear: ['- Sustem/', + function(){ }], +}) + +var Serialization = +module.Serialization = ImageGridFeatures.Feature({ + title: '', + + tag: 'serialization', + + actions: SerializationActions, +}) + + //--------------------------------------------------------------------- var UtilActions = actions.Actions({ @@ -554,7 +579,6 @@ var UtilActions = actions.Actions({ }], }) - var Util = module.Util = ImageGridFeatures.Feature({ title: '', @@ -798,6 +822,9 @@ module.Journal = ImageGridFeatures.Feature({ title: 'Action Journal', tag: 'journal', + depends: [ + 'serialization', + ], actions: JournalActions, @@ -933,7 +960,9 @@ module.Changes = ImageGridFeatures.Feature({ doc: '', tag: 'changes', - depends: [ ], + depends: [ + 'serialization', + ], actions: ChangesActions, }) diff --git a/ui (gen4)/features/location.js b/ui (gen4)/features/location.js index baf59aa6..f9943507 100755 --- a/ui (gen4)/features/location.js +++ b/ui (gen4)/features/location.js @@ -345,12 +345,12 @@ var LocationActions = actions.Actions({ // .location too... this.__location = data.location }}], - clone: [ - function(res){ + clone: [function(){ + return function(res){ if(this.location){ res.__location = JSON.parse(JSON.stringify(this.__location)) } - }], + }}], clear: [function(){ this.clearLoaction() }], })