Removed usage of function.prototype.bind

This commit is contained in:
Henry 2015-11-06 10:06:17 -08:00
parent 2f658348a8
commit 31d3ec5d20

View File

@ -71,33 +71,31 @@ define(
* Will persist a list of {@link objectClones}. It will persist all * Will persist a list of {@link objectClones}. It will persist all
* simultaneously, irrespective of order in the list. This may * simultaneously, irrespective of order in the list. This may
* result in automatic request batching by the browser. * result in automatic request batching by the browser.
* @private
*/ */
CopyTask.prototype.persistObjects = function() { function persistObjects(self) {
var self = this;
return this.$q.all(this.clones.map(function(clone){ return self.$q.all(self.clones.map(function(clone){
clone.model.persisted = self.now(); clone.model.persisted = self.now();
return self.persistenceService.createObject(clone.persistenceSpace, clone.id, clone.model) return self.persistenceService.createObject(clone.persistenceSpace, clone.id, clone.model)
.then(function(){ .then(function(){
return self.deferred.notify({phase: "copying", totalObjects: self.clones.length, processed: ++self.persisted}); self.deferred.notify({phase: "copying", totalObjects: self.clones.length, processed: ++self.persisted});
});
})).then(function(){
return self;
}); });
}));
}; };
/** /**
* Will add a list of clones to the specified parent's composition * Will add a list of clones to the specified parent's composition
* @private
*/ */
CopyTask.prototype.addClonesToParent = function() { function addClonesToParent(self) {
var parentClone = this.clones[this.clones.length-1], var parentClone = self.clones[self.clones.length-1];
self = this;
if (!this.parent.hasCapability('composition')){ if (!self.parent.hasCapability('composition')){
return this.$q.reject(); return self.$q.reject();
} }
return this.persistenceService return self.persistenceService
.updateObject(parentClone.persistenceSpace, parentClone.id, parentClone.model) .updateObject(parentClone.persistenceSpace, parentClone.id, parentClone.model)
.then(function(){return self.parent.getCapability("composition").add(parentClone.id);}) .then(function(){return self.parent.getCapability("composition").add(parentClone.id);})
.then(function(){return self.parent.getCapability("persistence").persist();}) .then(function(){return self.parent.getCapability("persistence").persist();})
@ -175,6 +173,7 @@ define(
return this.copy(self.domainObject, self.parent).then(function(domainObjectClone){ return this.copy(self.domainObject, self.parent).then(function(domainObjectClone){
domainObjectClone.model.location = self.parent.getId(); domainObjectClone.model.location = self.parent.getId();
return self;
}); });
}; };
@ -184,9 +183,6 @@ define(
* once complete. * once complete.
*/ */
CopyTask.prototype.perform = function(){ CopyTask.prototype.perform = function(){
var persistObjects = this.persistObjects.bind(this),
addClonesToParent = this.addClonesToParent.bind(this);
this.deferred = this.$q.defer(); this.deferred = this.$q.defer();
this.buildCopyPlan() this.buildCopyPlan()