[Code Style] Run gulp fixstyle

...to apply code style settings from #142.
This commit is contained in:
Victor Woeltjen
2016-05-19 11:29:13 -07:00
parent f12b9704d9
commit fa77139077
440 changed files with 1885 additions and 1662 deletions

View File

@@ -69,7 +69,7 @@ define(
* @param totalObjects
* @param processed
*/
CopyAction.prototype.progress = function(phase, totalObjects, processed){
CopyAction.prototype.progress = function (phase, totalObjects, processed) {
/*
Copy has two distinct phases. In the first phase a copy plan is
made in memory. During this phase of execution, the user is
@@ -78,7 +78,7 @@ define(
In the second phase, the copying is taking place, and the user
is shown non-invasive banner notifications at the bottom of the screen.
*/
if (phase.toLowerCase() === 'preparing' && !this.dialog){
if (phase.toLowerCase() === 'preparing' && !this.dialog) {
this.dialog = this.dialogService.showBlockingMessage({
title: "Preparing to copy objects",
unknownProgress: true,
@@ -105,15 +105,15 @@ define(
* the AbstractComposeAction, but extends it to support notification
* updates of progress on copy.
*/
CopyAction.prototype.perform = function() {
CopyAction.prototype.perform = function () {
var self = this;
function success(){
function success() {
self.notification.dismiss();
self.notificationService.info("Copying complete.");
}
function error(errorDetails){
function error(errorDetails) {
var errorMessage = {
title: "Error copying objects.",
severity: "error",
@@ -121,7 +121,7 @@ define(
minimized: true, // want the notification to be minimized initially (don't show banner)
options: [{
label: "OK",
callback: function() {
callback: function () {
self.dialogService.dismiss();
}
}]
@@ -138,7 +138,7 @@ define(
self.dialogService.showBlockingMessage(errorMessage);
}
function notification(details){
function notification(details) {
self.progress(details.phase, details.totalObjects, details.processed);
}

View File

@@ -22,7 +22,7 @@
define(
[ "./CopyTask" ],
["./CopyTask"],
function (CopyTask) {
/**

View File

@@ -37,7 +37,7 @@ define(
* @param $q Angular's $q, for promises
* @constructor
*/
function CopyTask (domainObject, parent, filter, $q){
function CopyTask(domainObject, parent, filter, $q) {
this.domainObject = domainObject;
this.parent = parent;
this.firstClone = undefined;
@@ -89,11 +89,11 @@ define(
* result in automatic request batching by the browser.
*/
function persistObjects(self) {
return self.$q.all(self.clones.map(function(clone){
return clone.getCapability("persistence").persist().then(function(){
return self.$q.all(self.clones.map(function (clone) {
return clone.getCapability("persistence").persist().then(function () {
self.deferred.notify({phase: "copying", totalObjects: self.clones.length, processed: ++self.persisted});
});
})).then(function(){
})).then(function () {
return self;
});
}
@@ -147,16 +147,16 @@ define(
* @private
* @returns {*}
*/
CopyTask.prototype.copyComposees = function(composees, clonedParent, originalParent){
CopyTask.prototype.copyComposees = function (composees, clonedParent, originalParent) {
var self = this,
idMap = {};
return (composees || []).reduce(function(promise, originalComposee){
return (composees || []).reduce(function (promise, originalComposee) {
//If the composee is composed of other
// objects, chain a promise..
return promise.then(function(){
return promise.then(function () {
// ...to recursively copy it (and its children)
return self.copy(originalComposee, originalParent).then(function(clonedComposee){
return self.copy(originalComposee, originalParent).then(function (clonedComposee) {
//Map the original composee's ID to that of its
// clone so that we can replace any references to it
// in the parent
@@ -167,17 +167,18 @@ define(
// set, however linked objects will not.
return composeChild(clonedComposee, clonedParent, clonedComposee !== originalComposee);
});
});}, self.$q.when(undefined)
).then(function(){
//Replace any references in the cloned parent to
// contained objects that have been composed with the
// Ids of the clones
self.rewriteIdentifiers(clonedParent.getModel(), idMap);
});
}, self.$q.when(undefined)
).then(function () {
//Replace any references in the cloned parent to
// contained objects that have been composed with the
// Ids of the clones
self.rewriteIdentifiers(clonedParent.getModel(), idMap);
//Add the clone to the list of clones that will
//be returned by this function
self.clones.push(clonedParent);
return clonedParent;
//Add the clone to the list of clones that will
//be returned by this function
self.clones.push(clonedParent);
return clonedParent;
});
};
@@ -192,7 +193,7 @@ define(
* 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,
clone;
@@ -207,7 +208,7 @@ define(
clone = this.parent.useCapability("instantiation", cloneObjectModel(originalObject.getModel()));
//Iterate through child tree
return this.$q.when(originalObject.useCapability('composition')).then(function(composees){
return this.$q.when(originalObject.useCapability('composition')).then(function (composees) {
self.deferred.notify({phase: "preparing"});
//Duplicate the object's children, and their children, and
// so on down to the leaf nodes of the tree.
@@ -234,10 +235,10 @@ define(
* object being copied. The clones are all full composed with
* references to their own children.
*/
CopyTask.prototype.buildCopyPlan = function() {
CopyTask.prototype.buildCopyPlan = function () {
var self = this;
return this.copy(self.domainObject, self.parent).then(function(domainObjectClone){
return this.copy(self.domainObject, self.parent).then(function (domainObjectClone) {
if (domainObjectClone !== self.domainObject) {
domainObjectClone.getModel().location = self.parent.getId();
}
@@ -251,7 +252,7 @@ define(
* @returns {promise} Which will resolve with a clone of the object
* once complete.
*/
CopyTask.prototype.perform = function(){
CopyTask.prototype.perform = function () {
this.deferred = this.$q.defer();
this.buildCopyPlan()
@@ -264,4 +265,4 @@ define(
return CopyTask;
}
);
);

View File

@@ -67,7 +67,9 @@ define(
.then(function (objectInNewContext) {
return parentObject.getCapability('persistence')
.persist()
.then(function () { return objectInNewContext; });
.then(function () {
return objectInNewContext;
});
});
};

View File

@@ -39,8 +39,8 @@ define(
* Resolve the promise, passing the supplied value to all resolve
* handlers.
*/
ControlledPromise.prototype.resolve = function(value) {
this.resolveHandlers.forEach(function(handler) {
ControlledPromise.prototype.resolve = function (value) {
this.resolveHandlers.forEach(function (handler) {
handler(value);
});
};
@@ -49,8 +49,8 @@ define(
* Reject the promise, passing the supplied value to all rejection
* handlers.
*/
ControlledPromise.prototype.reject = function(value) {
this.rejectHandlers.forEach(function(handler) {
ControlledPromise.prototype.reject = function (value) {
this.rejectHandlers.forEach(function (handler) {
handler(value);
});
};
@@ -63,11 +63,11 @@ define(
var returnPromise = new ControlledPromise();
if (onResolve) {
this.resolveHandlers.push(function(resolveWith) {
this.resolveHandlers.push(function (resolveWith) {
var chainResult = onResolve(resolveWith);
if (chainResult && chainResult.then) {
// chainResult is a promise, resolve when it resolves.
chainResult.then(function(pipedResult) {
chainResult.then(function (pipedResult) {
return returnPromise.resolve(pipedResult);
});
} else {
@@ -77,10 +77,10 @@ define(
}
if (onReject) {
this.rejectHandlers.push(function(rejectWith) {
this.rejectHandlers.push(function (rejectWith) {
var chainResult = onReject(rejectWith);
if (chainResult && chainResult.then) {
chainResult.then(function(pipedResult) {
chainResult.then(function (pipedResult) {
returnPromise.reject(pipedResult);
});
} else {

View File

@@ -153,4 +153,4 @@ define(
return domainObjectFactory;
}
);
);

View File

@@ -45,7 +45,7 @@ define(
beforeEach(function () {
policyService = jasmine.createSpyObj(
'policyService',
[ 'allow' ]
['allow']
);
selectedObjectContextCapability = jasmine.createSpyObj(

View File

@@ -51,7 +51,7 @@ define(
beforeEach(function () {
policyService = jasmine.createSpyObj(
'policyService',
[ 'allow' ]
['allow']
);
policyService.allow.andReturn(true);
@@ -105,12 +105,12 @@ define(
]
);
abstractComposePromise.then.andCallFake(function(success, error, notify){
abstractComposePromise.then.andCallFake(function (success, error, notify) {
notify(progress);
success();
});
locationServicePromise.then.andCallFake(function(callback){
locationServicePromise.then.andCallFake(function (callback) {
callback(newParent);
return abstractComposePromise;
});
@@ -191,7 +191,7 @@ define(
.toHaveBeenCalledWith(selectedObject, newParent);
});
it("notifies the user of progress", function(){
it("notifies the user of progress", function () {
expect(notificationService.info).toHaveBeenCalled();
});

View File

@@ -40,11 +40,11 @@ define(
beforeEach(function () {
mockLocationCapability = jasmine.createSpyObj(
'location',
[ 'isLink', 'isOriginal', 'getOriginal' ]
['isLink', 'isOriginal', 'getOriginal']
);
mockOriginalActionCapability = jasmine.createSpyObj(
'action',
[ 'perform', 'getActions' ]
['perform', 'getActions']
);
originalPromise = new ControlledPromise();
mockLocationCapability.getOriginal.andReturn(originalPromise);

View File

@@ -45,7 +45,7 @@ define(
beforeEach(function () {
policyService = jasmine.createSpyObj(
'policyService',
[ 'allow' ]
['allow']
);
policyService.allow.andReturn(true);

View File

@@ -45,7 +45,7 @@ define(
beforeEach(function () {
policyService = jasmine.createSpyObj(
'policyService',
[ 'allow' ]
['allow']
);
policyService.allow.andReturn(true);

View File

@@ -40,7 +40,7 @@ define(
mockLocationCapability = jasmine.createSpyObj(
'location',
[ 'setPrimaryLocation', 'getContextualLocation' ]
['setPrimaryLocation', 'getContextualLocation']
);
mockLocationCapability.getContextualLocation.andReturn(testId);

View File

@@ -54,7 +54,7 @@ define(
// only define those in mocks.
mockAction = jasmine.createSpyObj(
'action',
[ 'getMetadata' ]
['getMetadata']
);
mockAction.getMetadata.andReturn(testActionMetadata);

View File

@@ -145,12 +145,12 @@ define(
instantiationCapability = jasmine.createSpyObj(
"instantiation",
[ "invoke" ]
["invoke"]
);
persistenceCapability = jasmine.createSpyObj(
"persistenceCapability",
[ "persist", "getSpace" ]
["persist", "getSpace"]
);
persistenceCapability.persist.andReturn(persistObjectPromise);
@@ -170,10 +170,12 @@ define(
'mockDeferred',
['notify', 'resolve', 'reject']
);
mockDeferred.notify.andCallFake(function(){});
mockDeferred.resolve.andCallFake(function(value){resolvedValue = value;});
mockDeferred.notify.andCallFake(function () {});
mockDeferred.resolve.andCallFake(function (value) {
resolvedValue = value;
});
mockDeferred.promise = {
then: function(callback){
then: function (callback) {
return synchronousPromise(callback(resolvedValue));
}
};
@@ -187,12 +189,14 @@ define(
mockQ.all.andCallFake(function (promises) {
var result = {};
Object.keys(promises).forEach(function (k) {
promises[k].then(function (v) { result[k] = v; });
promises[k].then(function (v) {
result[k] = v;
});
});
return synchronousPromise(result);
});
mockQ.defer.andReturn(mockDeferred);
});
describe("on domain object without composition", function () {
@@ -238,7 +242,7 @@ define(
});
instantiationCapability.invoke.andCallFake(
function(model){
function (model) {
objectCopy.model = model;
return objectCopy;
}
@@ -254,7 +258,7 @@ define(
expect(persistenceCapability.persist)
.toHaveBeenCalled();
});
it("deep clones object model", function () {
var newModel = copyFinished.calls[0].args[0].getModel();
expect(newModel).toEqual(object.model);
@@ -279,7 +283,7 @@ define(
objectClones;
instantiationCapability.invoke.andCallFake(
function(model){
function (model) {
var cloneToReturn = objectClones[invocationCount++];
cloneToReturn.model = model;
return cloneToReturn;
@@ -362,8 +366,8 @@ define(
copyService = new CopyService(mockQ, policyService);
});
describe("the cloning process", function(){
beforeEach(function() {
describe("the cloning process", function () {
beforeEach(function () {
copyResult = copyService.perform(object, newParent);
copyFinished = jasmine.createSpy('copyFinished');
copyResult.then(copyFinished);
@@ -379,23 +383,23 @@ define(
expect(copyFinished).toHaveBeenCalled();
});
it ("correctly locates cloned objects", function() {
it ("correctly locates cloned objects", function () {
expect(childObjectClone.getModel().location).toEqual(objectClone.getId());
});
});
describe("when cloning non-creatable objects", function() {
describe("when cloning non-creatable objects", function () {
beforeEach(function () {
policyService.allow.andCallFake(function(category){
policyService.allow.andCallFake(function (category) {
//Return false for 'creation' policy
return category !== 'creation';
return category !== 'creation';
});
copyResult = copyService.perform(object, newParent);
copyFinished = jasmine.createSpy('copyFinished');
copyResult.then(copyFinished);
});
it ("creates link instead of clone", function() {
it ("creates link instead of clone", function () {
var copiedObject = copyFinished.calls[0].args[0];
expect(copiedObject).toBe(object);
expect(compositionCapability.add)
@@ -412,7 +416,7 @@ define(
}
it("does not create new instances of objects " +
"rejected by the filter", function() {
"rejected by the filter", function () {
copyService.perform(object, newParent, reject)
.then(copyFinished);
expect(copyFinished.mostRecentCall.args[0])
@@ -420,7 +424,7 @@ define(
});
it("does create new instances of objects " +
"accepted by the filter", function() {
"accepted by the filter", function () {
copyService.perform(object, newParent, accept)
.then(copyFinished);
expect(copyFinished.mostRecentCall.args[0])

View File

@@ -100,11 +100,11 @@ define(
cloneIds = {};
testModel = {
composition: [ ID_A, ID_B ],
composition: [ID_A, ID_B],
someObj: {},
someArr: [ ID_A, ID_B ],
someArr: [ID_A, ID_B],
objArr: [{"id": ID_A}, {"id": ID_B}],
singleElementArr: [ ID_A ]
singleElementArr: [ID_A]
};
testModel.someObj[ID_A] = "some value";
testModel.someObj.someProperty = ID_B;
@@ -120,7 +120,7 @@ define(
mockQ = jasmine.createSpyObj('$q', ['when', 'defer', 'all']);
mockDeferred = jasmine.createSpyObj(
'deferred',
[ 'notify', 'resolve', 'reject' ]
['notify', 'resolve', 'reject']
);
mockFilter.andReturn(true);
@@ -130,7 +130,9 @@ define(
mockQ.all.andCallFake(function (promises) {
return synchronousPromise(promises.map(function (promise) {
var value;
promise.then(function (v) { value = v; });
promise.then(function (v) {
value = v;
});
return value;
}));
});

View File

@@ -76,7 +76,9 @@ define(
mockQ.all.andCallFake(function (promises) {
var result = {};
Object.keys(promises).forEach(function (k) {
promises[k].then(function (v) { result[k] = v; });
promises[k].then(function (v) {
result[k] = v;
});
});
return testPromise(result);
});
@@ -88,7 +90,7 @@ define(
Object.keys(testModels).forEach(function (id) {
testObjects[id] = jasmine.createSpyObj(
"domainObject-" + id,
[ "getId", "getModel", "getCapability" ]
["getId", "getModel", "getCapability"]
);
testObjects[id].getId.andReturn(id);
testObjects[id].getModel.andReturn(testModels[id]);

View File

@@ -63,7 +63,9 @@ define(
beforeEach(function () {
title = "Get a location to do something";
label = "a location";
validate = function () { return true; };
validate = function () {
return true;
};
initialLocation = { key: "a key" };
locationResult = locationService.getLocationFromUser(
title,