fixed .clone(..) + some refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-08-27 22:17:47 +03:00
parent 6b15446bcc
commit 4d169b91b4
4 changed files with 66 additions and 17 deletions

View File

@ -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',

View File

@ -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() })
}
})
}
} }],
})

View File

@ -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,
})

View File

@ -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() }],
})