Merge branch 'open338' into rems_data

This commit is contained in:
Henry 2015-12-03 18:57:07 -08:00
commit 5fd1f6a055

View File

@ -47,14 +47,14 @@ define(
this.clones = []; this.clones = [];
} }
function composeChild(child, parent) { function composeChild(child, parent, setLocation) {
//Once copied, associate each cloned //Once copied, associate each cloned
// composee with its parent clone // composee with its parent clone
parent.getModel().composition.push(child.getId()); parent.getModel().composition.push(child.getId());
//If a location is not specified, set it. //If a location is not specified, set it.
if (!child.getModel().location) { if (setLocation && child.getModel().location === undefined) {
child.getModel().location = parent.getId(); child.getModel().location = parent.getId();
} }
} }
@ -113,13 +113,16 @@ define(
CopyTask.prototype.copyComposees = function(composees, clonedParent, originalParent){ CopyTask.prototype.copyComposees = function(composees, clonedParent, originalParent){
var self = this; var self = this;
return (composees || []).reduce(function(promise, composee){ return (composees || []).reduce(function(promise, originalComposee){
//If the composee is composed of other //If the composee is composed of other
// objects, chain a promise.. // objects, chain a promise..
return promise.then(function(){ return promise.then(function(){
// ...to recursively copy it (and its children) // ...to recursively copy it (and its children)
return self.copy(composee, originalParent).then(function(composee){ return self.copy(originalComposee, originalParent).then(function(clonedComposee){
return composeChild(composee, clonedParent); //Compose the child within its parent. Cloned
// objects will need to also have their location
// set, however linked objects will not.
return composeChild(clonedComposee, clonedParent, clonedComposee !== originalComposee);
}); });
});}, self.$q.when(undefined) });}, self.$q.when(undefined)
); );
@ -132,6 +135,9 @@ define(
* cloning objects, and composing them with their child clones * cloning objects, and composing them with their child clones
* as it goes * as it goes
* @private * @private
* @returns {DomainObject} If the type of the original object allows for
* duplication, then a duplicate of the object, otherwise the object
* itself (to allow linking to non duplicatable objects).
*/ */
CopyTask.prototype.copy = function(originalObject) { CopyTask.prototype.copy = function(originalObject) {
var self = this, var self = this,