mirror of
https://github.com/nasa/openmct.git
synced 2025-02-22 10:11:06 +00:00
Merge pull request #927 from nasa/jscs-rebase-142
[Code Style] Enforce code style
This commit is contained in:
commit
25a2321578
4
.jscsrc
4
.jscsrc
@ -1,3 +1,5 @@
|
|||||||
{
|
{
|
||||||
"preset": "crockford"
|
"preset": "crockford",
|
||||||
|
"requireMultipleVarDecl": false,
|
||||||
|
"requireVarDeclFirst": false
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"eqeqeq": true,
|
"eqeqeq": true,
|
||||||
"forin": true,
|
"forin": true,
|
||||||
"freeze": true,
|
"freeze": true,
|
||||||
"funcscope": true,
|
"funcscope": false,
|
||||||
"futurehostile": true,
|
"futurehostile": true,
|
||||||
"latedef": true,
|
"latedef": true,
|
||||||
"noarg": true,
|
"noarg": true,
|
||||||
@ -16,6 +16,7 @@
|
|||||||
"define",
|
"define",
|
||||||
"Promise"
|
"Promise"
|
||||||
],
|
],
|
||||||
|
"shadow": "outer",
|
||||||
"strict": "implied",
|
"strict": "implied",
|
||||||
"undef": true,
|
"undef": true,
|
||||||
"unused": "vars"
|
"unused": "vars"
|
||||||
|
@ -147,6 +147,6 @@ gulp.task('develop', ['serve', 'stylesheets', 'watch']);
|
|||||||
|
|
||||||
gulp.task('install', [ 'static', 'scripts' ]);
|
gulp.task('install', [ 'static', 'scripts' ]);
|
||||||
|
|
||||||
gulp.task('verify', [ 'lint', 'test' ]);
|
gulp.task('verify', [ 'lint', 'test', 'checkstyle' ]);
|
||||||
|
|
||||||
gulp.task('build', [ 'verify', 'install' ]);
|
gulp.task('build', [ 'verify', 'install' ]);
|
||||||
|
@ -152,7 +152,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("validates selection types using policy", function () {
|
it("validates selection types using policy", function () {
|
||||||
var mockDomainObject = jasmine.createSpyObj(
|
var mockDomainObj = jasmine.createSpyObj(
|
||||||
'domainObject',
|
'domainObject',
|
||||||
['getCapability']
|
['getCapability']
|
||||||
),
|
),
|
||||||
@ -166,8 +166,8 @@ define(
|
|||||||
rows = structure.sections[sections.length - 1].rows,
|
rows = structure.sections[sections.length - 1].rows,
|
||||||
locationRow = rows[rows.length - 1];
|
locationRow = rows[rows.length - 1];
|
||||||
|
|
||||||
mockDomainObject.getCapability.andReturn(mockOtherType);
|
mockDomainObj.getCapability.andReturn(mockOtherType);
|
||||||
locationRow.validate(mockDomainObject);
|
locationRow.validate(mockDomainObj);
|
||||||
|
|
||||||
// Should check policy to see if the user-selected location
|
// Should check policy to see if the user-selected location
|
||||||
// can actually contain objects of this type
|
// can actually contain objects of this type
|
||||||
|
@ -316,7 +316,7 @@ define([
|
|||||||
"transactionService"
|
"transactionService"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -63,10 +63,10 @@ define(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showDialog(type) {
|
function showDialog(objType) {
|
||||||
// Create a dialog object to generate the form structure, etc.
|
// Create a dialog object to generate the form structure, etc.
|
||||||
var dialog =
|
var dialog =
|
||||||
new PropertiesDialog(type, domainObject.getModel());
|
new PropertiesDialog(objType, domainObject.getModel());
|
||||||
|
|
||||||
// Show the dialog
|
// Show the dialog
|
||||||
return dialogService.getUserInput(
|
return dialogService.getUserInput(
|
||||||
|
@ -75,8 +75,8 @@ define(
|
|||||||
* Invoke persistence on a domain object. This will be called upon
|
* Invoke persistence on a domain object. This will be called upon
|
||||||
* the removed object's parent (as its composition will have changed.)
|
* the removed object's parent (as its composition will have changed.)
|
||||||
*/
|
*/
|
||||||
function doPersist(domainObject) {
|
function doPersist(domainObj) {
|
||||||
var persistence = domainObject.getCapability('persistence');
|
var persistence = domainObj.getCapability('persistence');
|
||||||
return persistence && persistence.persist();
|
return persistence && persistence.persist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,12 @@ define(
|
|||||||
function () {
|
function () {
|
||||||
|
|
||||||
// Utility functions for reducing truth arrays
|
// Utility functions for reducing truth arrays
|
||||||
function and(a, b) { return a && b; }
|
function and(a, b) {
|
||||||
function or(a, b) { return a || b; }
|
return a && b;
|
||||||
|
}
|
||||||
|
function or(a, b) {
|
||||||
|
return a || b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -219,7 +223,7 @@ define(
|
|||||||
|
|
||||||
// Update value for this property in all elements of the
|
// Update value for this property in all elements of the
|
||||||
// selection which have this property.
|
// selection which have this property.
|
||||||
function updateProperties(property, value) {
|
function updateProperties(property, val) {
|
||||||
var changed = false;
|
var changed = false;
|
||||||
|
|
||||||
// Update property in a selected element
|
// Update property in a selected element
|
||||||
@ -229,12 +233,12 @@ define(
|
|||||||
// Check if this is a setter, or just assignable
|
// Check if this is a setter, or just assignable
|
||||||
if (typeof selected[property] === 'function') {
|
if (typeof selected[property] === 'function') {
|
||||||
changed =
|
changed =
|
||||||
changed || (selected[property]() !== value);
|
changed || (selected[property]() !== val);
|
||||||
selected[property](value);
|
selected[property](val);
|
||||||
} else {
|
} else {
|
||||||
changed =
|
changed =
|
||||||
changed || (selected[property] !== value);
|
changed || (selected[property] !== val);
|
||||||
selected[property] = value;
|
selected[property] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,11 +133,11 @@ define(
|
|||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
// Initialize toolbar (expose object to parent scope)
|
// Initialize toolbar (expose object to parent scope)
|
||||||
function initialize(definition) {
|
function initialize(def) {
|
||||||
// If we have been asked to expose toolbar state...
|
// If we have been asked to expose toolbar state...
|
||||||
if (self.attrs.toolbar) {
|
if (self.attrs.toolbar) {
|
||||||
// Initialize toolbar object
|
// Initialize toolbar object
|
||||||
self.toolbar = new EditToolbar(definition, self.commit);
|
self.toolbar = new EditToolbar(def, self.commit);
|
||||||
// Ensure toolbar state is exposed
|
// Ensure toolbar state is exposed
|
||||||
self.exposeToolbar();
|
self.exposeToolbar();
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,9 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
capabilities = {
|
capabilities = {
|
||||||
type: {
|
type: {
|
||||||
getProperties: function () { return []; },
|
getProperties: function () {
|
||||||
|
return [];
|
||||||
|
},
|
||||||
hasFeature: jasmine.createSpy('hasFeature')
|
hasFeature: jasmine.createSpy('hasFeature')
|
||||||
},
|
},
|
||||||
persistence: jasmine.createSpyObj("persistence", ["persist"]),
|
persistence: jasmine.createSpyObj("persistence", ["persist"]),
|
||||||
@ -47,11 +49,21 @@ define(
|
|||||||
model = {};
|
model = {};
|
||||||
input = {};
|
input = {};
|
||||||
object = {
|
object = {
|
||||||
getId: function () { return 'test-id'; },
|
getId: function () {
|
||||||
getCapability: function (k) { return capabilities[k]; },
|
return 'test-id';
|
||||||
getModel: function () { return model; },
|
},
|
||||||
useCapability: function (k, v) { return capabilities[k](v); },
|
getCapability: function (k) {
|
||||||
hasCapability: function () { return true; }
|
return capabilities[k];
|
||||||
|
},
|
||||||
|
getModel: function () {
|
||||||
|
return model;
|
||||||
|
},
|
||||||
|
useCapability: function (k, v) {
|
||||||
|
return capabilities[k](v);
|
||||||
|
},
|
||||||
|
hasCapability: function () {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
context = { someKey: "some value", domainObject: object };
|
context = { someKey: "some value", domainObject: object };
|
||||||
dialogService = {
|
dialogService = {
|
||||||
|
@ -30,14 +30,22 @@ define(
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
type = {
|
type = {
|
||||||
getProperties: function () { return properties; }
|
getProperties: function () {
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
model = { x: "initial value" };
|
model = { x: "initial value" };
|
||||||
properties = ["x", "y", "z"].map(function (k) {
|
properties = ["x", "y", "z"].map(function (k) {
|
||||||
return {
|
return {
|
||||||
getValue: function (model) { return model[k]; },
|
getValue: function (m) {
|
||||||
setValue: function (model, v) { model[k] = v; },
|
return m[k];
|
||||||
getDefinition: function () { return { control: 'textfield '}; }
|
},
|
||||||
|
setValue: function (m, v) {
|
||||||
|
m[k] = v;
|
||||||
|
},
|
||||||
|
getDefinition: function () {
|
||||||
|
return { control: 'textfield '};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -126,7 +126,9 @@ define(
|
|||||||
it("reads properties from getters", function () {
|
it("reads properties from getters", function () {
|
||||||
var structure, state;
|
var structure, state;
|
||||||
|
|
||||||
testABC.a = function () { return "from a getter!"; };
|
testABC.a = function () {
|
||||||
|
return "from a getter!";
|
||||||
|
};
|
||||||
|
|
||||||
toolbar.setSelection([testABC]);
|
toolbar.setSelection([testABC]);
|
||||||
structure = toolbar.getStructure();
|
structure = toolbar.getStructure();
|
||||||
|
@ -40,7 +40,9 @@ define(
|
|||||||
});
|
});
|
||||||
// Return constructors
|
// Return constructors
|
||||||
mockFormats = KEYS.map(function (k, i) {
|
mockFormats = KEYS.map(function (k, i) {
|
||||||
function MockFormat() { return mockFormatInstances[i]; }
|
function MockFormat() {
|
||||||
|
return mockFormatInstances[i];
|
||||||
|
}
|
||||||
MockFormat.key = k;
|
MockFormat.key = k;
|
||||||
return MockFormat;
|
return MockFormat;
|
||||||
});
|
});
|
||||||
|
@ -69,7 +69,9 @@ define(
|
|||||||
function updateList(ids) {
|
function updateList(ids) {
|
||||||
function updateSelectedObjects(objects) {
|
function updateSelectedObjects(objects) {
|
||||||
// Look up from the
|
// Look up from the
|
||||||
function getObject(id) { return objects[id]; }
|
function getObject(id) {
|
||||||
|
return objects[id];
|
||||||
|
}
|
||||||
self.selectedObjects =
|
self.selectedObjects =
|
||||||
ids.filter(getObject).map(getObject);
|
ids.filter(getObject).map(getObject);
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,8 @@ define(
|
|||||||
var context = domainObject &&
|
var context = domainObject &&
|
||||||
domainObject.getCapability('context'),
|
domainObject.getCapability('context'),
|
||||||
objectPath = context ? context.getPath() : [],
|
objectPath = context ? context.getPath() : [],
|
||||||
ids = objectPath.map(function (domainObject) {
|
ids = objectPath.map(function (domainObj) {
|
||||||
return domainObject.getId();
|
return domainObj.getId();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Parses the path together. Starts with the
|
// Parses the path together. Starts with the
|
||||||
|
@ -105,8 +105,8 @@ define([
|
|||||||
function getIdPath(domainObject) {
|
function getIdPath(domainObject) {
|
||||||
var context = domainObject && domainObject.getCapability('context');
|
var context = domainObject && domainObject.getCapability('context');
|
||||||
|
|
||||||
function getId(domainObject) {
|
function getId(domainObj) {
|
||||||
return domainObject.getId();
|
return domainObj.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
return context ? context.getPath().map(getId) : [];
|
return context ? context.getPath().map(getId) : [];
|
||||||
|
@ -62,8 +62,8 @@ define([
|
|||||||
var self = this,
|
var self = this,
|
||||||
domainObject = this.activeObject;
|
domainObject = this.activeObject;
|
||||||
|
|
||||||
function addNode(domainObject, index) {
|
function addNode(domainObj, index) {
|
||||||
self.nodeViews[index].model(domainObject);
|
self.nodeViews[index].model(domainObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addNodes(domainObjects) {
|
function addNodes(domainObjects) {
|
||||||
|
@ -39,7 +39,9 @@ define(
|
|||||||
);
|
);
|
||||||
|
|
||||||
testIndicatorA = {};
|
testIndicatorA = {};
|
||||||
testIndicatorB = function () { return mockIndicator; };
|
testIndicatorB = function () {
|
||||||
|
return mockIndicator;
|
||||||
|
};
|
||||||
testIndicatorC = { template: "someTemplate" };
|
testIndicatorC = { template: "someTemplate" };
|
||||||
|
|
||||||
testIndicators = [
|
testIndicators = [
|
||||||
|
@ -32,7 +32,9 @@ define(
|
|||||||
|
|
||||||
function TestObject(id, context) {
|
function TestObject(id, context) {
|
||||||
return {
|
return {
|
||||||
getId: function () { return id; },
|
getId: function () {
|
||||||
|
return id;
|
||||||
|
},
|
||||||
getCapability: function (key) {
|
getCapability: function (key) {
|
||||||
return key === 'context' ? context : undefined;
|
return key === 'context' ? context : undefined;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,9 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
|
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
|
||||||
mockTimeout = jasmine.createSpy("$timeout");
|
mockTimeout = jasmine.createSpy("$timeout");
|
||||||
mockTimeout.andCallFake(function (cb) { cb(); });
|
mockTimeout.andCallFake(function (cb) {
|
||||||
|
cb();
|
||||||
|
});
|
||||||
mockScope.ngModel = {};
|
mockScope.ngModel = {};
|
||||||
controller = new ViewSwitcherController(mockScope, mockTimeout);
|
controller = new ViewSwitcherController(mockScope, mockTimeout);
|
||||||
});
|
});
|
||||||
|
@ -36,7 +36,7 @@ define([
|
|||||||
treeView;
|
treeView;
|
||||||
|
|
||||||
function makeMockDomainObject(id, model, capabilities) {
|
function makeMockDomainObject(id, model, capabilities) {
|
||||||
var mockDomainObject = jasmine.createSpyObj(
|
var mockDomainObj = jasmine.createSpyObj(
|
||||||
'domainObject-' + id,
|
'domainObject-' + id,
|
||||||
[
|
[
|
||||||
'getId',
|
'getId',
|
||||||
@ -46,18 +46,18 @@ define([
|
|||||||
'useCapability'
|
'useCapability'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
mockDomainObject.getId.andReturn(id);
|
mockDomainObj.getId.andReturn(id);
|
||||||
mockDomainObject.getModel.andReturn(model);
|
mockDomainObj.getModel.andReturn(model);
|
||||||
mockDomainObject.hasCapability.andCallFake(function (c) {
|
mockDomainObj.hasCapability.andCallFake(function (c) {
|
||||||
return !!(capabilities[c]);
|
return !!(capabilities[c]);
|
||||||
});
|
});
|
||||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
mockDomainObj.getCapability.andCallFake(function (c) {
|
||||||
return capabilities[c];
|
return capabilities[c];
|
||||||
});
|
});
|
||||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
mockDomainObj.useCapability.andCallFake(function (c) {
|
||||||
return capabilities[c] && capabilities[c].invoke();
|
return capabilities[c] && capabilities[c].invoke();
|
||||||
});
|
});
|
||||||
return mockDomainObject;
|
return mockDomainObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
@ -99,24 +99,16 @@ define([
|
|||||||
var mockComposition;
|
var mockComposition;
|
||||||
|
|
||||||
function makeGenericCapabilities() {
|
function makeGenericCapabilities() {
|
||||||
var mockContext =
|
var mockStatus =
|
||||||
jasmine.createSpyObj('context', [ 'getPath' ]),
|
|
||||||
mockType =
|
|
||||||
jasmine.createSpyObj('type', [ 'getGlyph' ]),
|
|
||||||
mockLocation =
|
|
||||||
jasmine.createSpyObj('location', [ 'isLink' ]),
|
|
||||||
mockMutation =
|
|
||||||
jasmine.createSpyObj('mutation', [ 'listen' ]),
|
|
||||||
mockStatus =
|
|
||||||
jasmine.createSpyObj('status', ['listen', 'list']);
|
jasmine.createSpyObj('status', ['listen', 'list']);
|
||||||
|
|
||||||
mockStatus.list.andReturn([]);
|
mockStatus.list.andReturn([]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
context: mockContext,
|
context: jasmine.createSpyObj('context', ['getPath']),
|
||||||
type: mockType,
|
type: jasmine.createSpyObj('type', ['getGlyph']),
|
||||||
mutation: mockMutation,
|
location: jasmine.createSpyObj('location', ['isLink']),
|
||||||
location: mockLocation,
|
mutation: jasmine.createSpyObj('mutation', ['listen']),
|
||||||
status: mockStatus
|
status: mockStatus
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -133,11 +125,11 @@ define([
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockComposition = ['a', 'b', 'c'].map(function (id) {
|
mockComposition = ['a', 'b', 'c'].map(function (id) {
|
||||||
var testCapabilities = makeGenericCapabilities(),
|
var testCaps = makeGenericCapabilities(),
|
||||||
mockChild =
|
mockChild =
|
||||||
makeMockDomainObject(id, {}, testCapabilities);
|
makeMockDomainObject(id, {}, testCaps);
|
||||||
|
|
||||||
testCapabilities.context.getPath
|
testCaps.context.getPath
|
||||||
.andReturn([mockDomainObject, mockChild]);
|
.andReturn([mockDomainObject, mockChild]);
|
||||||
|
|
||||||
return mockChild;
|
return mockChild;
|
||||||
@ -207,11 +199,11 @@ define([
|
|||||||
|
|
||||||
describe("when a context-less object is selected", function () {
|
describe("when a context-less object is selected", function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
var testCapabilities = makeGenericCapabilities(),
|
var testCaps = makeGenericCapabilities(),
|
||||||
mockDomainObject =
|
mockDomainObj =
|
||||||
makeMockDomainObject('xyz', {}, testCapabilities);
|
makeMockDomainObject('xyz', {}, testCaps);
|
||||||
delete testCapabilities.context;
|
delete testCaps.context;
|
||||||
treeView.value(mockDomainObject);
|
treeView.value(mockDomainObj);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("clears all selection state", function () {
|
it("clears all selection state", function () {
|
||||||
|
@ -79,8 +79,8 @@ define(
|
|||||||
// On any touch on the body, default body touches/events
|
// On any touch on the body, default body touches/events
|
||||||
// are prevented, the bubble is dismissed, and the touchstart
|
// are prevented, the bubble is dismissed, and the touchstart
|
||||||
// body event is unbound, reallowing gestures
|
// body event is unbound, reallowing gestures
|
||||||
body.on('touchstart', function (event) {
|
body.on('touchstart', function (evt) {
|
||||||
event.preventDefault();
|
evt.preventDefault();
|
||||||
hideBubble();
|
hideBubble();
|
||||||
body.unbind('touchstart');
|
body.unbind('touchstart');
|
||||||
});
|
});
|
||||||
|
@ -69,7 +69,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("detects display orientation", function () {
|
it("detects display orientation", function () {
|
||||||
var agentService = new AgentService(testWindow);
|
agentService = new AgentService(testWindow);
|
||||||
testWindow.innerWidth = 1024;
|
testWindow.innerWidth = 1024;
|
||||||
testWindow.innerHeight = 400;
|
testWindow.innerHeight = 400;
|
||||||
expect(agentService.isPortrait()).toBeFalsy();
|
expect(agentService.isPortrait()).toBeFalsy();
|
||||||
|
@ -81,8 +81,8 @@ define(
|
|||||||
// additionally fills in the action's getMetadata method
|
// additionally fills in the action's getMetadata method
|
||||||
// with the extension definition (if no getMetadata
|
// with the extension definition (if no getMetadata
|
||||||
// method was supplied.)
|
// method was supplied.)
|
||||||
function instantiateAction(Action, context) {
|
function instantiateAction(Action, ctxt) {
|
||||||
var action = new Action(context),
|
var action = new Action(ctxt),
|
||||||
metadata;
|
metadata;
|
||||||
|
|
||||||
// Provide a getMetadata method that echos
|
// Provide a getMetadata method that echos
|
||||||
@ -90,7 +90,7 @@ define(
|
|||||||
// unless the action has defined its own.
|
// unless the action has defined its own.
|
||||||
if (!action.getMetadata) {
|
if (!action.getMetadata) {
|
||||||
metadata = Object.create(Action.definition || {});
|
metadata = Object.create(Action.definition || {});
|
||||||
metadata.context = context;
|
metadata.context = ctxt;
|
||||||
action.getMetadata = function () {
|
action.getMetadata = function () {
|
||||||
return metadata;
|
return metadata;
|
||||||
};
|
};
|
||||||
@ -103,14 +103,14 @@ define(
|
|||||||
// applicable in a given context, according to the static
|
// applicable in a given context, according to the static
|
||||||
// appliesTo method of given actions (if defined), and
|
// appliesTo method of given actions (if defined), and
|
||||||
// instantiate those applicable actions.
|
// instantiate those applicable actions.
|
||||||
function createIfApplicable(actions, context) {
|
function createIfApplicable(actions, ctxt) {
|
||||||
function isApplicable(Action) {
|
function isApplicable(Action) {
|
||||||
return Action.appliesTo ? Action.appliesTo(context) : true;
|
return Action.appliesTo ? Action.appliesTo(ctxt) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function instantiate(Action) {
|
function instantiate(Action) {
|
||||||
try {
|
try {
|
||||||
return instantiateAction(Action, context);
|
return instantiateAction(Action, ctxt);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
$log.error([
|
$log.error([
|
||||||
"Could not instantiate action",
|
"Could not instantiate action",
|
||||||
|
@ -82,7 +82,7 @@ define(
|
|||||||
return mutationResult && self.invoke().then(findObject);
|
return mutationResult && self.invoke().then(findObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addIdToModel(model) {
|
function addIdToModel(objModel) {
|
||||||
// Pick a specific index if needed.
|
// Pick a specific index if needed.
|
||||||
index = isNaN(index) ? composition.length : index;
|
index = isNaN(index) ? composition.length : index;
|
||||||
// Also, don't put past the end of the array
|
// Also, don't put past the end of the array
|
||||||
@ -90,11 +90,11 @@ define(
|
|||||||
|
|
||||||
// Remove the existing instance of the id
|
// Remove the existing instance of the id
|
||||||
if (oldIndex !== -1) {
|
if (oldIndex !== -1) {
|
||||||
model.composition.splice(oldIndex, 1);
|
objModel.composition.splice(oldIndex, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...and add it back at the appropriate index.
|
// ...and add it back at the appropriate index.
|
||||||
model.composition.splice(index, 0, id);
|
objModel.composition.splice(index, 0, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no index has been specified already and the id is already
|
// If no index has been specified already and the id is already
|
||||||
|
@ -62,9 +62,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Package capabilities as key-value pairs
|
// Package capabilities as key-value pairs
|
||||||
function packageCapabilities(capabilities) {
|
function packageCapabilities(caps) {
|
||||||
var result = {};
|
var result = {};
|
||||||
capabilities.forEach(function (capability) {
|
caps.forEach(function (capability) {
|
||||||
if (capability.key) {
|
if (capability.key) {
|
||||||
result[capability.key] =
|
result[capability.key] =
|
||||||
result[capability.key] || capability;
|
result[capability.key] || capability;
|
||||||
|
@ -124,9 +124,9 @@ define(
|
|||||||
clone = JSON.parse(JSON.stringify(model)),
|
clone = JSON.parse(JSON.stringify(model)),
|
||||||
useTimestamp = arguments.length > 1;
|
useTimestamp = arguments.length > 1;
|
||||||
|
|
||||||
function notifyListeners(model) {
|
function notifyListeners(newModel) {
|
||||||
generalTopic.notify(domainObject);
|
generalTopic.notify(domainObject);
|
||||||
specificTopic.notify(model);
|
specificTopic.notify(newModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to handle copying values to the actual
|
// Function to handle copying values to the actual
|
||||||
|
@ -124,8 +124,8 @@ define(
|
|||||||
this.persistenceService.createObject;
|
this.persistenceService.createObject;
|
||||||
|
|
||||||
// Update persistence timestamp...
|
// Update persistence timestamp...
|
||||||
domainObject.useCapability("mutation", function (model) {
|
domainObject.useCapability("mutation", function (m) {
|
||||||
model.persisted = modified;
|
m.persisted = modified;
|
||||||
}, modified);
|
}, modified);
|
||||||
|
|
||||||
// ...and persist
|
// ...and persist
|
||||||
|
@ -82,9 +82,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Package the result as id->model
|
// Package the result as id->model
|
||||||
function packageResult(parsedIds, models) {
|
function packageResult(parsedIdsToPackage, models) {
|
||||||
var result = {};
|
var result = {};
|
||||||
parsedIds.forEach(function (parsedId, index) {
|
parsedIdsToPackage.forEach(function (parsedId, index) {
|
||||||
var id = parsedId.id;
|
var id = parsedId.id;
|
||||||
if (models[index]) {
|
if (models[index]) {
|
||||||
result[id] = models[index];
|
result[id] = models[index];
|
||||||
@ -93,11 +93,11 @@ define(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadModels(parsedIds) {
|
function loadModels(parsedIdsToLoad) {
|
||||||
return $q.all(parsedIds.map(loadModel))
|
return $q.all(parsedIdsToLoad.map(loadModel))
|
||||||
.then(function (models) {
|
.then(function (models) {
|
||||||
return packageResult(
|
return packageResult(
|
||||||
parsedIds,
|
parsedIdsToLoad,
|
||||||
models.map(addPersistedTimestamp)
|
models.map(addPersistedTimestamp)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -46,7 +46,9 @@ define(
|
|||||||
*/
|
*/
|
||||||
function RootModelProvider(roots, $q, $log) {
|
function RootModelProvider(roots, $q, $log) {
|
||||||
// Pull out identifiers to used as ROOT's
|
// Pull out identifiers to used as ROOT's
|
||||||
var ids = roots.map(function (root) { return root.id; });
|
var ids = roots.map(function (root) {
|
||||||
|
return root.id;
|
||||||
|
});
|
||||||
|
|
||||||
// Assign an initial location to root models
|
// Assign an initial location to root models
|
||||||
roots.forEach(function (root) {
|
roots.forEach(function (root) {
|
||||||
|
@ -58,14 +58,14 @@ define(
|
|||||||
* corresponding keys in the recursive step.
|
* corresponding keys in the recursive step.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param a the first object to be merged
|
* @param modelA the first object to be merged
|
||||||
* @param b the second object to be merged
|
* @param modelB the second object to be merged
|
||||||
* @param merger the merger, as described above
|
* @param merger the merger, as described above
|
||||||
* @returns {*} the result of merging `a` and `b`
|
* @returns {*} the result of merging `modelA` and `modelB`
|
||||||
* @constructor
|
* @constructor
|
||||||
* @memberof platform/core
|
* @memberof platform/core
|
||||||
*/
|
*/
|
||||||
function mergeModels(a, b, merger) {
|
function mergeModels(modelA, modelB, merger) {
|
||||||
var mergeFunction;
|
var mergeFunction;
|
||||||
|
|
||||||
function mergeArrays(a, b) {
|
function mergeArrays(a, b) {
|
||||||
@ -93,11 +93,11 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
mergeFunction = (merger && Function.isFunction(merger)) ? merger :
|
mergeFunction = (merger && Function.isFunction(merger)) ? merger :
|
||||||
(Array.isArray(a) && Array.isArray(b)) ? mergeArrays :
|
(Array.isArray(modelA) && Array.isArray(modelB)) ? mergeArrays :
|
||||||
(a instanceof Object && b instanceof Object) ? mergeObjects :
|
(modelA instanceof Object && modelB instanceof Object) ? mergeObjects :
|
||||||
mergeOther;
|
mergeOther;
|
||||||
|
|
||||||
return mergeFunction(a, b);
|
return mergeFunction(modelA, modelB);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mergeModels;
|
return mergeModels;
|
||||||
|
@ -33,8 +33,12 @@ define(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
identity: {
|
identity: {
|
||||||
toModelValue: function (v) { return v; },
|
toModelValue: function (v) {
|
||||||
toFormValue: function (v) { return v; }
|
return v;
|
||||||
|
},
|
||||||
|
toFormValue: function (v) {
|
||||||
|
return v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ARRAY_SUFFIX = '[]';
|
ARRAY_SUFFIX = '[]';
|
||||||
|
@ -159,8 +159,8 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function lookupTypeDef(typeKey) {
|
function lookupTypeDef(typeKey) {
|
||||||
function buildTypeDef(typeKey) {
|
function buildTypeDef(typeKeyToBuild) {
|
||||||
var typeDefs = typeDefinitions[typeKey] || [],
|
var typeDefs = typeDefinitions[typeKeyToBuild] || [],
|
||||||
inherits = typeDefs.map(function (typeDef) {
|
inherits = typeDefs.map(function (typeDef) {
|
||||||
return asArray(typeDef.inherits || []);
|
return asArray(typeDef.inherits || []);
|
||||||
}).reduce(function (a, b) {
|
}).reduce(function (a, b) {
|
||||||
|
@ -105,15 +105,15 @@ define(
|
|||||||
// Check if an object has all capabilities designated as `needs`
|
// Check if an object has all capabilities designated as `needs`
|
||||||
// for a view. Exposing a capability via delegation is taken to
|
// for a view. Exposing a capability via delegation is taken to
|
||||||
// satisfy this filter if `allowDelegation` is true.
|
// satisfy this filter if `allowDelegation` is true.
|
||||||
function capabilitiesMatch(domainObject, capabilities, allowDelegation) {
|
function capabilitiesMatch(domainObj, capabilities, allowDelegation) {
|
||||||
var delegation = domainObject.getCapability("delegation");
|
var delegation = domainObj.getCapability("delegation");
|
||||||
|
|
||||||
allowDelegation = allowDelegation && (delegation !== undefined);
|
allowDelegation = allowDelegation && (delegation !== undefined);
|
||||||
|
|
||||||
// Check if an object has (or delegates, if allowed) a
|
// Check if an object has (or delegates, if allowed) a
|
||||||
// capability.
|
// capability.
|
||||||
function hasCapability(c) {
|
function hasCapability(c) {
|
||||||
return domainObject.hasCapability(c) ||
|
return domainObj.hasCapability(c) ||
|
||||||
(allowDelegation && delegation.doesDelegateCapability(c));
|
(allowDelegation && delegation.doesDelegateCapability(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,13 +128,13 @@ define(
|
|||||||
|
|
||||||
// Check if a view and domain object type can be paired;
|
// Check if a view and domain object type can be paired;
|
||||||
// both can restrict the others they accept.
|
// both can restrict the others they accept.
|
||||||
function viewMatchesType(view, type) {
|
function viewMatchesType(view, objType) {
|
||||||
var views = type && (type.getDefinition() || {}).views,
|
var views = objType && (objType.getDefinition() || {}).views,
|
||||||
matches = true;
|
matches = true;
|
||||||
|
|
||||||
// View is restricted to a certain type
|
// View is restricted to a certain type
|
||||||
if (view.type) {
|
if (view.type) {
|
||||||
matches = matches && type && type.instanceOf(view.type);
|
matches = matches && objType && objType.instanceOf(view.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type wishes to restrict its specific views
|
// Type wishes to restrict its specific views
|
||||||
|
@ -33,29 +33,41 @@ define(
|
|||||||
actionProvider;
|
actionProvider;
|
||||||
|
|
||||||
function SimpleAction() {
|
function SimpleAction() {
|
||||||
return { perform: function () { return "simple"; } };
|
return { perform: function () {
|
||||||
|
return "simple";
|
||||||
|
} };
|
||||||
}
|
}
|
||||||
|
|
||||||
function CategorizedAction() {
|
function CategorizedAction() {
|
||||||
return { perform: function () { return "categorized"; } };
|
return { perform: function () {
|
||||||
|
return "categorized";
|
||||||
|
} };
|
||||||
}
|
}
|
||||||
CategorizedAction.category = "someCategory";
|
CategorizedAction.category = "someCategory";
|
||||||
|
|
||||||
function KeyedAction() {
|
function KeyedAction() {
|
||||||
return { perform: function () { return "keyed"; } };
|
return { perform: function () {
|
||||||
|
return "keyed";
|
||||||
|
} };
|
||||||
}
|
}
|
||||||
KeyedAction.key = "someKey";
|
KeyedAction.key = "someKey";
|
||||||
|
|
||||||
function CategorizedKeyedAction() {
|
function CategorizedKeyedAction() {
|
||||||
return { perform: function () { return "both"; } };
|
return { perform: function () {
|
||||||
|
return "both";
|
||||||
|
} };
|
||||||
}
|
}
|
||||||
CategorizedKeyedAction.key = "someKey";
|
CategorizedKeyedAction.key = "someKey";
|
||||||
CategorizedKeyedAction.category = "someCategory";
|
CategorizedKeyedAction.category = "someCategory";
|
||||||
|
|
||||||
function MetadataAction() {
|
function MetadataAction() {
|
||||||
return {
|
return {
|
||||||
perform: function () { return "metadata"; },
|
perform: function () {
|
||||||
getMetadata: function () { return "custom metadata"; }
|
return "metadata";
|
||||||
|
},
|
||||||
|
getMetadata: function () {
|
||||||
|
return "custom metadata";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
MetadataAction.key = "metadata";
|
MetadataAction.key = "metadata";
|
||||||
|
@ -114,7 +114,9 @@ define(
|
|||||||
mockObjectService.getObjects.andReturn(mockPromise({x: mockChild}));
|
mockObjectService.getObjects.andReturn(mockPromise({x: mockChild}));
|
||||||
mockChild.getCapability.andReturn(undefined);
|
mockChild.getCapability.andReturn(undefined);
|
||||||
|
|
||||||
composition.invoke().then(function (c) { result = c; });
|
composition.invoke().then(function (c) {
|
||||||
|
result = c;
|
||||||
|
});
|
||||||
|
|
||||||
// Should have been added by a wrapper
|
// Should have been added by a wrapper
|
||||||
expect(result[0].getCapability('context')).toBeDefined();
|
expect(result[0].getCapability('context')).toBeDefined();
|
||||||
|
@ -31,16 +31,22 @@ define(
|
|||||||
var mockLog,
|
var mockLog,
|
||||||
provider;
|
provider;
|
||||||
|
|
||||||
function BasicCapability() { return; }
|
function BasicCapability() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
BasicCapability.key = "basic";
|
BasicCapability.key = "basic";
|
||||||
|
|
||||||
function ApplicableCapability() { return; }
|
function ApplicableCapability() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ApplicableCapability.key = "applicable";
|
ApplicableCapability.key = "applicable";
|
||||||
ApplicableCapability.appliesTo = function (model) {
|
ApplicableCapability.appliesTo = function (model) {
|
||||||
return !model.isNotApplicable;
|
return !model.isNotApplicable;
|
||||||
};
|
};
|
||||||
|
|
||||||
function KeylessCapability() { return; }
|
function KeylessCapability() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockLog = jasmine.createSpyObj(
|
mockLog = jasmine.createSpyObj(
|
||||||
|
@ -36,7 +36,11 @@ define(
|
|||||||
object = {},
|
object = {},
|
||||||
delegation;
|
delegation;
|
||||||
|
|
||||||
function capture(k) { return function (v) { captured[k] = v; }; }
|
function capture(k) {
|
||||||
|
return function (v) {
|
||||||
|
captured[k] = v;
|
||||||
|
};
|
||||||
|
}
|
||||||
function TestDomainObject(caps, id) {
|
function TestDomainObject(caps, id) {
|
||||||
return {
|
return {
|
||||||
getId: function () {
|
getId: function () {
|
||||||
@ -68,11 +72,15 @@ define(
|
|||||||
captured = {};
|
captured = {};
|
||||||
typeDef = {};
|
typeDef = {};
|
||||||
typeDef.delegates = ["foo"];
|
typeDef.delegates = ["foo"];
|
||||||
type = { getDefinition: function () { return typeDef; } };
|
type = { getDefinition: function () {
|
||||||
|
return typeDef;
|
||||||
|
} };
|
||||||
children = [];
|
children = [];
|
||||||
capabilities = {
|
capabilities = {
|
||||||
type: type,
|
type: type,
|
||||||
composition: { invoke: function () { return mockPromise(children); } }
|
composition: { invoke: function () {
|
||||||
|
return mockPromise(children);
|
||||||
|
} }
|
||||||
};
|
};
|
||||||
object = new TestDomainObject(capabilities);
|
object = new TestDomainObject(capabilities);
|
||||||
|
|
||||||
|
@ -73,16 +73,16 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("uses the instantiate service to create domain objects", function () {
|
it("uses the instantiate service to create domain objects", function () {
|
||||||
var mockDomainObject = jasmine.createSpyObj('domainObject', [
|
var mockDomainObj = jasmine.createSpyObj('domainObject', [
|
||||||
'getId',
|
'getId',
|
||||||
'getModel',
|
'getModel',
|
||||||
'getCapability',
|
'getCapability',
|
||||||
'useCapability',
|
'useCapability',
|
||||||
'hasCapability'
|
'hasCapability'
|
||||||
]), testModel = { someKey: "some value" };
|
]), testModel = { someKey: "some value" };
|
||||||
mockInstantiate.andReturn(mockDomainObject);
|
mockInstantiate.andReturn(mockDomainObj);
|
||||||
expect(instantiation.instantiate(testModel))
|
expect(instantiation.instantiate(testModel))
|
||||||
.toBe(mockDomainObject);
|
.toBe(mockDomainObj);
|
||||||
expect(mockInstantiate)
|
expect(mockInstantiate)
|
||||||
.toHaveBeenCalledWith({
|
.toHaveBeenCalledWith({
|
||||||
someKey: "some value",
|
someKey: "some value",
|
||||||
|
@ -35,8 +35,12 @@ define(
|
|||||||
topic,
|
topic,
|
||||||
mockNow,
|
mockNow,
|
||||||
domainObject = {
|
domainObject = {
|
||||||
getId: function () { return "test-id"; },
|
getId: function () {
|
||||||
getModel: function () { return testModel; }
|
return "test-id";
|
||||||
|
},
|
||||||
|
getModel: function () {
|
||||||
|
return testModel;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mutation;
|
mutation;
|
||||||
|
|
||||||
|
@ -85,8 +85,12 @@ define(
|
|||||||
);
|
);
|
||||||
|
|
||||||
mockDomainObject = {
|
mockDomainObject = {
|
||||||
getId: function () { return id; },
|
getId: function () {
|
||||||
getModel: function () { return model; },
|
return id;
|
||||||
|
},
|
||||||
|
getModel: function () {
|
||||||
|
return model;
|
||||||
|
},
|
||||||
useCapability: jasmine.createSpy()
|
useCapability: jasmine.createSpy()
|
||||||
};
|
};
|
||||||
// Simulate mutation capability
|
// Simulate mutation capability
|
||||||
|
@ -99,7 +99,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("ensures a single object instance, even for multiple concurrent calls", function () {
|
it("ensures a single object instance, even for multiple concurrent calls", function () {
|
||||||
var promiseA, promiseB, mockCallback = jasmine.createSpy();
|
var promiseA, promiseB;
|
||||||
|
|
||||||
promiseA = fakePromise();
|
promiseA = fakePromise();
|
||||||
promiseB = fakePromise();
|
promiseB = fakePromise();
|
||||||
@ -126,7 +126,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("is robust against updating with undefined values", function () {
|
it("is robust against updating with undefined values", function () {
|
||||||
var promiseA, promiseB, mockCallback = jasmine.createSpy();
|
var promiseA, promiseB;
|
||||||
|
|
||||||
promiseA = fakePromise();
|
promiseA = fakePromise();
|
||||||
promiseB = fakePromise();
|
promiseB = fakePromise();
|
||||||
|
@ -61,14 +61,18 @@ define(
|
|||||||
it("provides models for any IDs which are missing", function () {
|
it("provides models for any IDs which are missing", function () {
|
||||||
var models;
|
var models;
|
||||||
decorator.getModels(['testId', 'otherId'])
|
decorator.getModels(['testId', 'otherId'])
|
||||||
.then(function (m) { models = m; });
|
.then(function (m) {
|
||||||
|
models = m;
|
||||||
|
});
|
||||||
expect(models.otherId).toBeDefined();
|
expect(models.otherId).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not overwrite existing models", function () {
|
it("does not overwrite existing models", function () {
|
||||||
var models;
|
var models;
|
||||||
decorator.getModels(['testId', 'otherId'])
|
decorator.getModels(['testId', 'otherId'])
|
||||||
.then(function (m) { models = m; });
|
.then(function (m) {
|
||||||
|
models = m;
|
||||||
|
});
|
||||||
expect(models.testId).toEqual({ someKey: "some value" });
|
expect(models.testId).toEqual({ someKey: "some value" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -48,7 +48,9 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
mockQ.all.andReturn({
|
mockQ.all.andReturn({
|
||||||
then: function (c) { return c(modelList); }
|
then: function (c) {
|
||||||
|
return c(modelList);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
aggregator = new ModelAggregator(mockQ, mockProviders);
|
aggregator = new ModelAggregator(mockQ, mockProviders);
|
||||||
|
@ -57,7 +57,9 @@ define(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function capture(value) { captured = value; }
|
function capture(value) {
|
||||||
|
captured = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
@ -55,7 +55,9 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("provides models from extension declarations", function () {
|
it("provides models from extension declarations", function () {
|
||||||
var mockPromise = { then: function () { return; } };
|
var mockPromise = { then: function () {
|
||||||
|
return;
|
||||||
|
} };
|
||||||
mockQ.when.andReturn(mockPromise);
|
mockQ.when.andReturn(mockPromise);
|
||||||
|
|
||||||
// Verify that we got the promise as the return value
|
// Verify that we got the promise as the return value
|
||||||
|
@ -74,10 +74,14 @@ define(
|
|||||||
|
|
||||||
it("supports instance-of checks by type object", function () {
|
it("supports instance-of checks by type object", function () {
|
||||||
expect(type.instanceOf({
|
expect(type.instanceOf({
|
||||||
getKey: function () { return 'test-parent-1'; }
|
getKey: function () {
|
||||||
|
return 'test-parent-1';
|
||||||
|
}
|
||||||
})).toBeTruthy();
|
})).toBeTruthy();
|
||||||
expect(type.instanceOf({
|
expect(type.instanceOf({
|
||||||
getKey: function () { return 'some-other-type'; }
|
getKey: function () {
|
||||||
|
return 'some-other-type';
|
||||||
|
}
|
||||||
})).toBeFalsy();
|
})).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ define(
|
|||||||
it("restricts typed views to matching types", function () {
|
it("restricts typed views to matching types", function () {
|
||||||
var testType = "testType",
|
var testType = "testType",
|
||||||
testView = { key: "x", type: testType },
|
testView = { key: "x", type: testType },
|
||||||
provider = new ViewProvider([testView], mockLog);
|
viewProvider = new ViewProvider([testView], mockLog);
|
||||||
|
|
||||||
// Include a "type" capability
|
// Include a "type" capability
|
||||||
capabilities.type = jasmine.createSpyObj(
|
capabilities.type = jasmine.createSpyObj(
|
||||||
@ -120,21 +120,21 @@ define(
|
|||||||
|
|
||||||
// Should be included when types match
|
// Should be included when types match
|
||||||
capabilities.type.instanceOf.andReturn(true);
|
capabilities.type.instanceOf.andReturn(true);
|
||||||
expect(provider.getViews(mockDomainObject))
|
expect(viewProvider.getViews(mockDomainObject))
|
||||||
.toEqual([testView]);
|
.toEqual([testView]);
|
||||||
expect(capabilities.type.instanceOf)
|
expect(capabilities.type.instanceOf)
|
||||||
.toHaveBeenCalledWith(testType);
|
.toHaveBeenCalledWith(testType);
|
||||||
|
|
||||||
// ...but not when they don't
|
// ...but not when they don't
|
||||||
capabilities.type.instanceOf.andReturn(false);
|
capabilities.type.instanceOf.andReturn(false);
|
||||||
expect(provider.getViews(mockDomainObject))
|
expect(viewProvider.getViews(mockDomainObject))
|
||||||
.toEqual([]);
|
.toEqual([]);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("enforces view restrictions from types", function () {
|
it("enforces view restrictions from types", function () {
|
||||||
var testView = { key: "x" },
|
var testView = { key: "x" },
|
||||||
provider = new ViewProvider([testView], mockLog);
|
viewProvider = new ViewProvider([testView], mockLog);
|
||||||
|
|
||||||
// Include a "type" capability
|
// Include a "type" capability
|
||||||
capabilities.type = jasmine.createSpyObj(
|
capabilities.type = jasmine.createSpyObj(
|
||||||
@ -146,13 +146,13 @@ define(
|
|||||||
// Should be included when view keys match
|
// Should be included when view keys match
|
||||||
capabilities.type.getDefinition
|
capabilities.type.getDefinition
|
||||||
.andReturn({ views: [testView.key]});
|
.andReturn({ views: [testView.key]});
|
||||||
expect(provider.getViews(mockDomainObject))
|
expect(viewProvider.getViews(mockDomainObject))
|
||||||
.toEqual([testView]);
|
.toEqual([testView]);
|
||||||
|
|
||||||
// ...but not when they don't
|
// ...but not when they don't
|
||||||
capabilities.type.getDefinition
|
capabilities.type.getDefinition
|
||||||
.andReturn({ views: ["somethingElse"]});
|
.andReturn({ views: ["somethingElse"]});
|
||||||
expect(provider.getViews(mockDomainObject))
|
expect(viewProvider.getViews(mockDomainObject))
|
||||||
.toEqual([]);
|
.toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -126,11 +126,11 @@ define(
|
|||||||
|
|
||||||
label = this.verb + " To";
|
label = this.verb + " To";
|
||||||
|
|
||||||
validateLocation = function (newParent) {
|
validateLocation = function (newParentObj) {
|
||||||
var newContext = self.cloneContext();
|
var newContext = self.cloneContext();
|
||||||
newContext.selectedObject = object;
|
newContext.selectedObject = object;
|
||||||
newContext.domainObject = newParent;
|
newContext.domainObject = newParentObj;
|
||||||
return composeService.validate(object, newParent) &&
|
return composeService.validate(object, newParentObj) &&
|
||||||
self.policyService.allow("action", self, newContext);
|
self.policyService.allow("action", self, newContext);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -139,8 +139,8 @@ define(
|
|||||||
label,
|
label,
|
||||||
validateLocation,
|
validateLocation,
|
||||||
currentParent
|
currentParent
|
||||||
).then(function (newParent) {
|
).then(function (newParentObj) {
|
||||||
return composeService.perform(object, newParent);
|
return composeService.perform(object, newParentObj);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,11 +83,11 @@ define(
|
|||||||
|
|
||||||
// Combines caller-provided filter (if any) with the
|
// Combines caller-provided filter (if any) with the
|
||||||
// baseline behavior of respecting creation policy.
|
// baseline behavior of respecting creation policy.
|
||||||
function filterWithPolicy(domainObject) {
|
function filterWithPolicy(domainObj) {
|
||||||
return (!filter || filter(domainObject)) &&
|
return (!filter || filter(domainObj)) &&
|
||||||
policyService.allow(
|
policyService.allow(
|
||||||
"creation",
|
"creation",
|
||||||
domainObject.getCapability("type")
|
domainObj.getCapability("type")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,8 @@ define(
|
|||||||
// set, however linked objects will not.
|
// set, however linked objects will not.
|
||||||
return composeChild(clonedComposee, clonedParent, clonedComposee !== originalComposee);
|
return composeChild(clonedComposee, clonedParent, clonedComposee !== originalComposee);
|
||||||
});
|
});
|
||||||
});}, self.$q.when(undefined)
|
});
|
||||||
|
}, self.$q.when(undefined)
|
||||||
).then(function () {
|
).then(function () {
|
||||||
//Replace any references in the cloned parent to
|
//Replace any references in the cloned parent to
|
||||||
// contained objects that have been composed with the
|
// contained objects that have been composed with the
|
||||||
|
@ -67,7 +67,9 @@ define(
|
|||||||
.then(function (objectInNewContext) {
|
.then(function (objectInNewContext) {
|
||||||
return parentObject.getCapability('persistence')
|
return parentObject.getCapability('persistence')
|
||||||
.persist()
|
.persist()
|
||||||
.then(function () { return objectInNewContext; });
|
.then(function () {
|
||||||
|
return objectInNewContext;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,8 +77,8 @@ define(
|
|||||||
|
|
||||||
return dialogService
|
return dialogService
|
||||||
.getUserInput(formStructure, formState)
|
.getUserInput(formStructure, formState)
|
||||||
.then(function (formState) {
|
.then(function (userFormState) {
|
||||||
return formState.location;
|
return userFormState.location;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -171,7 +171,9 @@ define(
|
|||||||
['notify', 'resolve', 'reject']
|
['notify', 'resolve', 'reject']
|
||||||
);
|
);
|
||||||
mockDeferred.notify.andCallFake(function () {});
|
mockDeferred.notify.andCallFake(function () {});
|
||||||
mockDeferred.resolve.andCallFake(function(value){resolvedValue = value;});
|
mockDeferred.resolve.andCallFake(function (value) {
|
||||||
|
resolvedValue = value;
|
||||||
|
});
|
||||||
mockDeferred.promise = {
|
mockDeferred.promise = {
|
||||||
then: function (callback) {
|
then: function (callback) {
|
||||||
return synchronousPromise(callback(resolvedValue));
|
return synchronousPromise(callback(resolvedValue));
|
||||||
@ -187,7 +189,9 @@ define(
|
|||||||
mockQ.all.andCallFake(function (promises) {
|
mockQ.all.andCallFake(function (promises) {
|
||||||
var result = {};
|
var result = {};
|
||||||
Object.keys(promises).forEach(function (k) {
|
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);
|
return synchronousPromise(result);
|
||||||
});
|
});
|
||||||
@ -454,17 +458,17 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("throws an error", function () {
|
it("throws an error", function () {
|
||||||
var copyService =
|
var service =
|
||||||
new CopyService(mockQ, policyService);
|
new CopyService(mockQ, policyService);
|
||||||
|
|
||||||
function perform() {
|
function perform() {
|
||||||
copyService.perform(object, newParent);
|
service.perform(object, newParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
spyOn(copyService, "validate");
|
spyOn(service, "validate");
|
||||||
copyService.validate.andReturn(true);
|
service.validate.andReturn(true);
|
||||||
expect(perform).not.toThrow();
|
expect(perform).not.toThrow();
|
||||||
copyService.validate.andReturn(false);
|
service.validate.andReturn(false);
|
||||||
expect(perform).toThrow();
|
expect(perform).toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -130,7 +130,9 @@ define(
|
|||||||
mockQ.all.andCallFake(function (promises) {
|
mockQ.all.andCallFake(function (promises) {
|
||||||
return synchronousPromise(promises.map(function (promise) {
|
return synchronousPromise(promises.map(function (promise) {
|
||||||
var value;
|
var value;
|
||||||
promise.then(function (v) { value = v; });
|
promise.then(function (v) {
|
||||||
|
value = v;
|
||||||
|
});
|
||||||
return value;
|
return value;
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -76,7 +76,9 @@ define(
|
|||||||
mockQ.all.andCallFake(function (promises) {
|
mockQ.all.andCallFake(function (promises) {
|
||||||
var result = {};
|
var result = {};
|
||||||
Object.keys(promises).forEach(function (k) {
|
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);
|
return testPromise(result);
|
||||||
});
|
});
|
||||||
|
@ -63,7 +63,9 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
title = "Get a location to do something";
|
title = "Get a location to do something";
|
||||||
label = "a location";
|
label = "a location";
|
||||||
validate = function () { return true; };
|
validate = function () {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
initialLocation = { key: "a key" };
|
initialLocation = { key: "a key" };
|
||||||
locationResult = locationService.getLocationFromUser(
|
locationResult = locationService.getLocationFromUser(
|
||||||
title,
|
title,
|
||||||
|
@ -27,7 +27,9 @@
|
|||||||
define(
|
define(
|
||||||
function () {
|
function () {
|
||||||
|
|
||||||
function identity(x) { return x; }
|
function identity(x) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The PlotPreparer is responsible for handling data sets and
|
* The PlotPreparer is responsible for handling data sets and
|
||||||
|
@ -96,7 +96,9 @@ define(
|
|||||||
);
|
);
|
||||||
|
|
||||||
mockHandler.handle.andReturn(mockHandle);
|
mockHandler.handle.andReturn(mockHandle);
|
||||||
mockThrottle.andCallFake(function (fn) { return fn; });
|
mockThrottle.andCallFake(function (fn) {
|
||||||
|
return fn;
|
||||||
|
});
|
||||||
mockHandle.getTelemetryObjects.andReturn([mockDomainObject]);
|
mockHandle.getTelemetryObjects.andReturn([mockDomainObject]);
|
||||||
mockHandle.getMetadata.andReturn([{}]);
|
mockHandle.getMetadata.andReturn([{}]);
|
||||||
mockHandle.getDomainValue.andReturn(123);
|
mockHandle.getDomainValue.andReturn(123);
|
||||||
|
@ -120,7 +120,7 @@ define(
|
|||||||
|
|
||||||
it("on changes in form values, updates the object model", function () {
|
it("on changes in form values, updates the object model", function () {
|
||||||
var scopeConfiguration = mockScope.configuration,
|
var scopeConfiguration = mockScope.configuration,
|
||||||
model = mockDomainObject.getModel();
|
objModel = mockDomainObject.getModel();
|
||||||
|
|
||||||
scopeConfiguration.plot.yAxis.autoScale = true;
|
scopeConfiguration.plot.yAxis.autoScale = true;
|
||||||
scopeConfiguration.plot.yAxis.key = 'eu';
|
scopeConfiguration.plot.yAxis.key = 'eu';
|
||||||
@ -130,10 +130,10 @@ define(
|
|||||||
mockScope.$watchCollection.calls[0].args[1]();
|
mockScope.$watchCollection.calls[0].args[1]();
|
||||||
expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function));
|
expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function));
|
||||||
|
|
||||||
mockDomainObject.useCapability.mostRecentCall.args[1](model);
|
mockDomainObject.useCapability.mostRecentCall.args[1](objModel);
|
||||||
expect(model.configuration.plot.yAxis.autoScale).toBe(true);
|
expect(objModel.configuration.plot.yAxis.autoScale).toBe(true);
|
||||||
expect(model.configuration.plot.yAxis.key).toBe('eu');
|
expect(objModel.configuration.plot.yAxis.key).toBe('eu');
|
||||||
expect(model.configuration.plot.xAxis.key).toBe('lst');
|
expect(objModel.configuration.plot.xAxis.key).toBe('lst');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -32,15 +32,15 @@ define(
|
|||||||
/**
|
/**
|
||||||
* Set default values for optional parameters on a given scope
|
* Set default values for optional parameters on a given scope
|
||||||
*/
|
*/
|
||||||
function setDefaults($scope) {
|
function setDefaults(scope) {
|
||||||
if (typeof $scope.enableFilter === 'undefined') {
|
if (typeof scope.enableFilter === 'undefined') {
|
||||||
$scope.enableFilter = true;
|
scope.enableFilter = true;
|
||||||
$scope.filters = {};
|
scope.filters = {};
|
||||||
}
|
}
|
||||||
if (typeof $scope.enableSort === 'undefined') {
|
if (typeof scope.enableSort === 'undefined') {
|
||||||
$scope.enableSort = true;
|
scope.enableSort = true;
|
||||||
$scope.sortColumn = undefined;
|
scope.sortColumn = undefined;
|
||||||
$scope.sortDirection = undefined;
|
scope.sortDirection = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,13 +485,13 @@ define(
|
|||||||
/**
|
/**
|
||||||
* Returns true if row matches all filters.
|
* Returns true if row matches all filters.
|
||||||
*/
|
*/
|
||||||
function matchRow(filters, row) {
|
function matchRow(filterMap, row) {
|
||||||
return Object.keys(filters).every(function (key) {
|
return Object.keys(filterMap).every(function (key) {
|
||||||
if (!row[key]) {
|
if (!row[key]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var testVal = String(row[key].text).toLowerCase();
|
var testVal = String(row[key].text).toLowerCase();
|
||||||
return testVal.indexOf(filters[key]) !== -1;
|
return testVal.indexOf(filterMap[key]) !== -1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ define(
|
|||||||
enableFilter: "=?",
|
enableFilter: "=?",
|
||||||
enableSort: "=?",
|
enableSort: "=?",
|
||||||
autoScroll: "=?"
|
autoScroll: "=?"
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ define(
|
|||||||
'column1': true,
|
'column1': true,
|
||||||
'column2': true,
|
'column2': true,
|
||||||
'column3': false,
|
'column3': false,
|
||||||
'column4': true,
|
'column4': true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,25 +52,25 @@ define(
|
|||||||
// Set the start time associated with this object
|
// Set the start time associated with this object
|
||||||
function setStart(value) {
|
function setStart(value) {
|
||||||
var end = getEnd();
|
var end = getEnd();
|
||||||
mutation.mutate(function (model) {
|
mutation.mutate(function (m) {
|
||||||
model.start.timestamp = Math.max(value, 0);
|
m.start.timestamp = Math.max(value, 0);
|
||||||
// Update duration to keep end time
|
// Update duration to keep end time
|
||||||
model.duration.timestamp = Math.max(end - value, 0);
|
m.duration.timestamp = Math.max(end - value, 0);
|
||||||
}, model.modified);
|
}, model.modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the duration associated with this object
|
// Set the duration associated with this object
|
||||||
function setDuration(value) {
|
function setDuration(value) {
|
||||||
mutation.mutate(function (model) {
|
mutation.mutate(function (m) {
|
||||||
model.duration.timestamp = Math.max(value, 0);
|
m.duration.timestamp = Math.max(value, 0);
|
||||||
}, model.modified);
|
}, model.modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the end time associated with this object
|
// Set the end time associated with this object
|
||||||
function setEnd(value) {
|
function setEnd(value) {
|
||||||
var start = getStart();
|
var start = getStart();
|
||||||
mutation.mutate(function (model) {
|
mutation.mutate(function (m) {
|
||||||
model.duration.timestamp = Math.max(value - start, 0);
|
m.duration.timestamp = Math.max(value - start, 0);
|
||||||
}, model.modified);
|
}, model.modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,21 +53,21 @@ define(
|
|||||||
|
|
||||||
// Initialize the data values
|
// Initialize the data values
|
||||||
function initializeValues() {
|
function initializeValues() {
|
||||||
var values = [],
|
var vals = [],
|
||||||
slope = 0,
|
slope = 0,
|
||||||
i;
|
i;
|
||||||
|
|
||||||
// Add a point (or points, if needed) reaching to the provided
|
// Add a point (or points, if needed) reaching to the provided
|
||||||
// domain and/or range value
|
// domain and/or range value
|
||||||
function addPoint(domain, range) {
|
function addPoint(domain, range) {
|
||||||
var previous = values[values.length - 1],
|
var previous = vals[vals.length - 1],
|
||||||
delta = domain - previous.domain, // time delta
|
delta = domain - previous.domain, // time delta
|
||||||
change = delta * slope * rate, // change
|
change = delta * slope * rate, // change
|
||||||
next = previous.range + change;
|
next = previous.range + change;
|
||||||
|
|
||||||
// Crop to minimum boundary...
|
// Crop to minimum boundary...
|
||||||
if (next < minimum) {
|
if (next < minimum) {
|
||||||
values.push({
|
vals.push({
|
||||||
domain: intercept(
|
domain: intercept(
|
||||||
previous.domain,
|
previous.domain,
|
||||||
previous.range,
|
previous.range,
|
||||||
@ -81,7 +81,7 @@ define(
|
|||||||
|
|
||||||
// ...and maximum boundary
|
// ...and maximum boundary
|
||||||
if (next > maximum) {
|
if (next > maximum) {
|
||||||
values.push({
|
vals.push({
|
||||||
domain: intercept(
|
domain: intercept(
|
||||||
previous.domain,
|
previous.domain,
|
||||||
previous.range,
|
previous.range,
|
||||||
@ -95,19 +95,19 @@ define(
|
|||||||
|
|
||||||
// Add the new data value
|
// Add the new data value
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
values.push({ domain: domain, range: next });
|
vals.push({ domain: domain, range: next });
|
||||||
}
|
}
|
||||||
|
|
||||||
slope = range;
|
slope = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
values.push({ domain: 0, range: initial });
|
vals.push({ domain: 0, range: initial });
|
||||||
|
|
||||||
for (i = 0; i < graph.getPointCount(); i += 1) {
|
for (i = 0; i < graph.getPointCount(); i += 1) {
|
||||||
addPoint(graph.getDomainValue(i), graph.getRangeValue(i));
|
addPoint(graph.getDomainValue(i), graph.getRangeValue(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return values;
|
return vals;
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertToPercent(point) {
|
function convertToPercent(point) {
|
||||||
|
@ -72,13 +72,13 @@ define(
|
|||||||
|
|
||||||
// If there are sequences of points with the same timestamp,
|
// If there are sequences of points with the same timestamp,
|
||||||
// allow only the first and last.
|
// allow only the first and last.
|
||||||
function filterPoint(value, index, values) {
|
function filterPoint(value, index, vals) {
|
||||||
// Allow the first or last point as a base case; aside from
|
// Allow the first or last point as a base case; aside from
|
||||||
// that, allow only points that have different timestamps
|
// that, allow only points that have different timestamps
|
||||||
// from their predecessor or successor.
|
// from their predecessor or successor.
|
||||||
return (index === 0) || (index === values.length - 1) ||
|
return (index === 0) || (index === vals.length - 1) ||
|
||||||
(value.domain !== values[index - 1].domain) ||
|
(value.domain !== vals[index - 1].domain) ||
|
||||||
(value.domain !== values[index + 1].domain);
|
(value.domain !== vals[index + 1].domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a step up or down (Step 3c above)
|
// Add a step up or down (Step 3c above)
|
||||||
|
@ -57,8 +57,8 @@ define(
|
|||||||
|
|
||||||
// Set the start time associated with this object
|
// Set the start time associated with this object
|
||||||
function setStart(value) {
|
function setStart(value) {
|
||||||
mutation.mutate(function (model) {
|
mutation.mutate(function (m) {
|
||||||
model.start.timestamp = Math.max(value, 0);
|
m.start.timestamp = Math.max(value, 0);
|
||||||
}, model.modified);
|
}, model.modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,13 +120,13 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Look up a specific object's resource utilization
|
// Look up a specific object's resource utilization
|
||||||
function lookupUtilization(domainObject) {
|
function lookupUtilization(object) {
|
||||||
return domainObject.useCapability('utilization');
|
return object.useCapability('utilization');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look up a specific object's resource utilization keys
|
// Look up a specific object's resource utilization keys
|
||||||
function lookupUtilizationResources(domainObject) {
|
function lookupUtilizationResources(object) {
|
||||||
var utilization = domainObject.getCapability('utilization');
|
var utilization = object.getCapability('utilization');
|
||||||
return utilization && utilization.resources();
|
return utilization && utilization.resources();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,19 +47,19 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the timespan associated with this domain object
|
// Get the timespan associated with this domain object
|
||||||
function populateCapabilityMaps(domainObject) {
|
function populateCapabilityMaps(object) {
|
||||||
var id = domainObject.getId(),
|
var id = object.getId(),
|
||||||
timespanPromise = domainObject.useCapability('timespan');
|
timespanPromise = object.useCapability('timespan');
|
||||||
if (timespanPromise) {
|
if (timespanPromise) {
|
||||||
timespanPromise.then(function (timespan) {
|
timespanPromise.then(function (timespan) {
|
||||||
// Cache that timespan
|
// Cache that timespan
|
||||||
timespans[id] = timespan;
|
timespans[id] = timespan;
|
||||||
// And its mutation capability
|
// And its mutation capability
|
||||||
mutations[id] = domainObject.getCapability('mutation');
|
mutations[id] = object.getCapability('mutation');
|
||||||
// Also cache the persistence capability for later
|
// Also cache the persistence capability for later
|
||||||
persists[id] = domainObject.getCapability('persistence');
|
persists[id] = object.getCapability('persistence');
|
||||||
// And the composition, for bulk moves
|
// And the composition, for bulk moves
|
||||||
compositions[id] = domainObject.getModel().composition || [];
|
compositions[id] = object.getModel().composition || [];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,8 +199,8 @@ define(
|
|||||||
minStart;
|
minStart;
|
||||||
|
|
||||||
// Update start & end, in that order
|
// Update start & end, in that order
|
||||||
function updateStartEnd(id) {
|
function updateStartEnd(spanId) {
|
||||||
var timespan = timespans[id], start, end;
|
var timespan = timespans[spanId], start, end;
|
||||||
if (timespan) {
|
if (timespan) {
|
||||||
// Get start/end so we don't get fooled by our
|
// Get start/end so we don't get fooled by our
|
||||||
// own adjustments
|
// own adjustments
|
||||||
@ -210,7 +210,7 @@ define(
|
|||||||
timespan.setStart(start + delta);
|
timespan.setStart(start + delta);
|
||||||
timespan.setEnd(end + delta);
|
timespan.setEnd(end + delta);
|
||||||
// Mark as dirty for subsequent persistence
|
// Mark as dirty for subsequent persistence
|
||||||
dirty[toId(id)] = true;
|
dirty[toId(spanId)] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,12 +228,12 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the minimum start time
|
// Find the minimum start time
|
||||||
minStart = Object.keys(ids).map(function (id) {
|
minStart = Object.keys(ids).map(function (spanId) {
|
||||||
// Get the start time; default to +Inf if not
|
// Get the start time; default to +Inf if not
|
||||||
// found, since this will not survive a min
|
// found, since this will not survive a min
|
||||||
// test if any real timespans are present
|
// test if any real timespans are present
|
||||||
return timespans[id] ?
|
return timespans[spanId] ?
|
||||||
timespans[id].getStart() :
|
timespans[spanId].getStart() :
|
||||||
Number.POSITIVE_INFINITY;
|
Number.POSITIVE_INFINITY;
|
||||||
}).reduce(function (a, b) {
|
}).reduce(function (a, b) {
|
||||||
// Reduce with a minimum test
|
// Reduce with a minimum test
|
||||||
|
@ -42,7 +42,9 @@ define(
|
|||||||
candidates;
|
candidates;
|
||||||
|
|
||||||
// Filter an id for inclustion
|
// Filter an id for inclustion
|
||||||
function include(id) { return id !== exclude; }
|
function include(id) {
|
||||||
|
return id !== exclude;
|
||||||
|
}
|
||||||
|
|
||||||
// Evaluate a candidate timestamp as a snap-to location
|
// Evaluate a candidate timestamp as a snap-to location
|
||||||
function evaluate(candidate) {
|
function evaluate(candidate) {
|
||||||
|
@ -75,11 +75,14 @@ define(
|
|||||||
|
|
||||||
// Look up resources for a domain object
|
// Look up resources for a domain object
|
||||||
function lookupResources(swimlane) {
|
function lookupResources(swimlane) {
|
||||||
var graphs = swimlane.domainObject.useCapability('graph');
|
var graphPromise =
|
||||||
|
swimlane.domainObject.useCapability('graph');
|
||||||
function getKeys(obj) {
|
function getKeys(obj) {
|
||||||
return Object.keys(obj);
|
return Object.keys(obj);
|
||||||
}
|
}
|
||||||
return $q.when(graphs ? (graphs.then(getKeys)) : []);
|
return $q.when(
|
||||||
|
graphPromise ? (graphPromise.then(getKeys)) : []
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all graph assignments appropriate for this swimlane
|
// Add all graph assignments appropriate for this swimlane
|
||||||
|
@ -34,8 +34,8 @@ define(
|
|||||||
var actionMap = {};
|
var actionMap = {};
|
||||||
|
|
||||||
// Populate available Create actions for this domain object
|
// Populate available Create actions for this domain object
|
||||||
function populateActionMap(domainObject) {
|
function populateActionMap(object) {
|
||||||
var actionCapability = domainObject.getCapability('action'),
|
var actionCapability = object.getCapability('action'),
|
||||||
actions = actionCapability ?
|
actions = actionCapability ?
|
||||||
actionCapability.getActions('add') : [];
|
actionCapability.getActions('add') : [];
|
||||||
actions.forEach(function (action) {
|
actions.forEach(function (action) {
|
||||||
|
@ -47,9 +47,7 @@ define(
|
|||||||
depth = parent ? (parent.depth + 1) : 0,
|
depth = parent ? (parent.depth + 1) : 0,
|
||||||
timespan,
|
timespan,
|
||||||
path = (!parent || !parent.parent) ? "" : parent.path +
|
path = (!parent || !parent.parent) ? "" : parent.path +
|
||||||
//(parent.path.length > 0 ? " / " : "") +
|
parent.domainObject.getModel().name + " > ";
|
||||||
parent.domainObject.getModel().name +
|
|
||||||
" > ";
|
|
||||||
|
|
||||||
// Look up timespan for this object
|
// Look up timespan for this object
|
||||||
domainObject.useCapability('timespan').then(function (t) {
|
domainObject.useCapability('timespan').then(function (t) {
|
||||||
|
@ -45,9 +45,9 @@ define(
|
|||||||
if (arguments.length > 0 && Array.isArray(value)) {
|
if (arguments.length > 0 && Array.isArray(value)) {
|
||||||
if ((model.relationships || {})[ACTIVITY_RELATIONSHIP] !== value) {
|
if ((model.relationships || {})[ACTIVITY_RELATIONSHIP] !== value) {
|
||||||
// Update the relationships
|
// Update the relationships
|
||||||
mutator.mutate(function (model) {
|
mutator.mutate(function (m) {
|
||||||
model.relationships = model.relationships || {};
|
m.relationships = m.relationships || {};
|
||||||
model.relationships[ACTIVITY_RELATIONSHIP] = value;
|
m.relationships[ACTIVITY_RELATIONSHIP] = value;
|
||||||
}).then(persister.persist);
|
}).then(persister.persist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,8 +61,8 @@ define(
|
|||||||
if (arguments.length > 0 && (typeof value === 'string') &&
|
if (arguments.length > 0 && (typeof value === 'string') &&
|
||||||
value !== model.link) {
|
value !== model.link) {
|
||||||
// Update the link
|
// Update the link
|
||||||
mutator.mutate(function (model) {
|
mutator.mutate(function (m) {
|
||||||
model.link = value;
|
m.link = value;
|
||||||
}).then(persister.persist);
|
}).then(persister.persist);
|
||||||
}
|
}
|
||||||
return model.link;
|
return model.link;
|
||||||
|
@ -51,7 +51,7 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if pathA entirely contains pathB
|
// Check if pathA entirely contains pathB
|
||||||
function pathContains(swimlane, id) {
|
function pathContains(swimlaneToCheck, id) {
|
||||||
// Check if id at a specific index matches (for map below)
|
// Check if id at a specific index matches (for map below)
|
||||||
function matches(pathId) {
|
function matches(pathId) {
|
||||||
return pathId === id;
|
return pathId === id;
|
||||||
@ -59,18 +59,18 @@ define(
|
|||||||
|
|
||||||
// Path A contains Path B if it is longer, and all of
|
// Path A contains Path B if it is longer, and all of
|
||||||
// B's ids match the ids in A.
|
// B's ids match the ids in A.
|
||||||
return swimlane.idPath.map(matches).reduce(or, false);
|
return swimlaneToCheck.idPath.map(matches).reduce(or, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a swimlane contains a child with the specified id
|
// Check if a swimlane contains a child with the specified id
|
||||||
function contains(swimlane, id) {
|
function contains(swimlaneToCheck, id) {
|
||||||
// Check if a child swimlane has a matching domain object id
|
// Check if a child swimlane has a matching domain object id
|
||||||
function matches(child) {
|
function matches(child) {
|
||||||
return child.domainObject.getId() === id;
|
return child.domainObject.getId() === id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find any one child id that matches this id
|
// Find any one child id that matches this id
|
||||||
return swimlane.children.map(matches).reduce(or, false);
|
return swimlaneToCheck.children.map(matches).reduce(or, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initiate mutation of a domain object
|
// Initiate mutation of a domain object
|
||||||
|
@ -61,8 +61,8 @@ define(
|
|||||||
swimlane;
|
swimlane;
|
||||||
|
|
||||||
// For the recursive step
|
// For the recursive step
|
||||||
function populate(childSubgraph, index) {
|
function populate(childSubgraph, nextIndex) {
|
||||||
populateSwimlanes(childSubgraph, swimlane, index);
|
populateSwimlanes(childSubgraph, swimlane, nextIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we have a valid object instance...
|
// Make sure we have a valid object instance...
|
||||||
|
@ -41,13 +41,13 @@ define(
|
|||||||
filter;
|
filter;
|
||||||
|
|
||||||
// Check object existence (for criterion-less filtering)
|
// Check object existence (for criterion-less filtering)
|
||||||
function exists(domainObject) {
|
function exists(object) {
|
||||||
return !!domainObject;
|
return !!object;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for capability matching criterion
|
// Check for capability matching criterion
|
||||||
function hasCapability(domainObject) {
|
function hasCapability(object) {
|
||||||
return domainObject && domainObject.hasCapability(criterion);
|
return object && object.hasCapability(criterion);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the recursive step...
|
// For the recursive step...
|
||||||
@ -61,8 +61,8 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Avoid infinite recursion
|
// Avoid infinite recursion
|
||||||
function notVisiting(domainObject) {
|
function notVisiting(object) {
|
||||||
return !visiting[domainObject.getId()];
|
return !visiting[object.getId()];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put the composition of this domain object into the result
|
// Put the composition of this domain object into the result
|
||||||
|
@ -55,8 +55,8 @@ define([
|
|||||||
if (!!model.composition) {
|
if (!!model.composition) {
|
||||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
mockDomainObject.useCapability.andCallFake(function (c) {
|
||||||
return c === 'composition' &&
|
return c === 'composition' &&
|
||||||
Promise.resolve(model.composition.map(function (id) {
|
Promise.resolve(model.composition.map(function (cid) {
|
||||||
return mockDomainObjects[id];
|
return mockDomainObjects[cid];
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -68,8 +68,8 @@ define([
|
|||||||
);
|
);
|
||||||
mockRelationships.getRelatedObjects.andCallFake(function (k) {
|
mockRelationships.getRelatedObjects.andCallFake(function (k) {
|
||||||
var ids = model.relationships[k] || [];
|
var ids = model.relationships[k] || [];
|
||||||
return Promise.resolve(ids.map(function (id) {
|
return Promise.resolve(ids.map(function (objId) {
|
||||||
return mockDomainObjects[id];
|
return mockDomainObjects[objId];
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||||
|
@ -67,8 +67,12 @@ define(
|
|||||||
mockQ.when.andCallFake(asPromise);
|
mockQ.when.andCallFake(asPromise);
|
||||||
mockQ.all.andCallFake(function (values) {
|
mockQ.all.andCallFake(function (values) {
|
||||||
var result = [];
|
var result = [];
|
||||||
function addResult(v) { result.push(v); }
|
function addResult(v) {
|
||||||
function promiseResult(v) { asPromise(v).then(addResult); }
|
result.push(v);
|
||||||
|
}
|
||||||
|
function promiseResult(v) {
|
||||||
|
asPromise(v).then(addResult);
|
||||||
|
}
|
||||||
values.forEach(promiseResult);
|
values.forEach(promiseResult);
|
||||||
return asPromise(result);
|
return asPromise(result);
|
||||||
});
|
});
|
||||||
|
@ -69,8 +69,8 @@ define(
|
|||||||
resources: function () {
|
resources: function () {
|
||||||
return Object.keys(costs).sort();
|
return Object.keys(costs).sort();
|
||||||
},
|
},
|
||||||
cost: function (c) {
|
cost: function (k) {
|
||||||
return costs[c];
|
return costs[k];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -61,7 +61,9 @@ define(
|
|||||||
mockTimespan.getDuration.andReturn(50);
|
mockTimespan.getDuration.andReturn(50);
|
||||||
mockTimespan.getEnd.andReturn(150);
|
mockTimespan.getEnd.andReturn(150);
|
||||||
|
|
||||||
mockToPixels.andCallFake(function (t) { return t * 10; });
|
mockToPixels.andCallFake(function (t) {
|
||||||
|
return t * 10;
|
||||||
|
});
|
||||||
|
|
||||||
controller = new TimelineGanttController(TEST_MAX_OFFSCREEN);
|
controller = new TimelineGanttController(TEST_MAX_OFFSCREEN);
|
||||||
});
|
});
|
||||||
|
@ -90,7 +90,9 @@ define(
|
|||||||
mockScope.domainObject.getCapability.andCallFake(function (c) {
|
mockScope.domainObject.getCapability.andCallFake(function (c) {
|
||||||
if (c === 'editor') {
|
if (c === 'editor') {
|
||||||
return {
|
return {
|
||||||
inEditContext: function () {return true;}
|
inEditContext: function () {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -56,22 +56,22 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function makeMockDomainObject(id, composition) {
|
function makeMockDomainObject(id, composition) {
|
||||||
var mockDomainObject = jasmine.createSpyObj(
|
var mockDomainObj = jasmine.createSpyObj(
|
||||||
'domainObject-' + id,
|
'domainObject-' + id,
|
||||||
['getId', 'getModel', 'getCapability', 'useCapability']
|
['getId', 'getModel', 'getCapability', 'useCapability']
|
||||||
);
|
);
|
||||||
|
|
||||||
mockDomainObject.getId.andReturn(id);
|
mockDomainObj.getId.andReturn(id);
|
||||||
mockDomainObject.getModel.andReturn({ composition: composition });
|
mockDomainObj.getModel.andReturn({ composition: composition });
|
||||||
mockDomainObject.useCapability.andReturn(asPromise(mockTimespans[id]));
|
mockDomainObj.useCapability.andReturn(asPromise(mockTimespans[id]));
|
||||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
mockDomainObj.getCapability.andCallFake(function (c) {
|
||||||
return {
|
return {
|
||||||
persistence: mockPersists[id],
|
persistence: mockPersists[id],
|
||||||
mutation: mockMutations[id]
|
mutation: mockMutations[id]
|
||||||
}[c];
|
}[c];
|
||||||
});
|
});
|
||||||
|
|
||||||
return mockDomainObject;
|
return mockDomainObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
@ -49,10 +49,14 @@ define(
|
|||||||
var colors = {}, i, ids = [];
|
var colors = {}, i, ids = [];
|
||||||
|
|
||||||
// Add item to set
|
// Add item to set
|
||||||
function set(c) { colors[c] = true; }
|
function set(c) {
|
||||||
|
colors[c] = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Generate ids
|
// Generate ids
|
||||||
for (i = 0; i < 30; i += 1) { ids.push("id" + i); }
|
for (i = 0; i < 30; i += 1) {
|
||||||
|
ids.push("id" + i);
|
||||||
|
}
|
||||||
|
|
||||||
// Assign colors to each id, then retrieve colors,
|
// Assign colors to each id, then retrieve colors,
|
||||||
// storing into the set
|
// storing into the set
|
||||||
|
@ -42,16 +42,16 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function makeMockDomainObject(id, composition) {
|
function makeMockDomainObject(id, composition) {
|
||||||
var mockDomainObject = jasmine.createSpyObj(
|
var mockDomainObj = jasmine.createSpyObj(
|
||||||
'domainObject-' + id,
|
'domainObject-' + id,
|
||||||
['getId', 'getModel', 'getCapability', 'useCapability']
|
['getId', 'getModel', 'getCapability', 'useCapability']
|
||||||
);
|
);
|
||||||
|
|
||||||
mockDomainObject.getId.andReturn(id);
|
mockDomainObj.getId.andReturn(id);
|
||||||
mockDomainObject.getModel.andReturn({ composition: composition });
|
mockDomainObj.getModel.andReturn({ composition: composition });
|
||||||
mockDomainObject.useCapability.andReturn(asPromise(false));
|
mockDomainObj.useCapability.andReturn(asPromise(false));
|
||||||
|
|
||||||
return mockDomainObject;
|
return mockDomainObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subgraph(domainObject, objects) {
|
function subgraph(domainObject, objects) {
|
||||||
|
@ -36,7 +36,9 @@ define(
|
|||||||
testConfiguration;
|
testConfiguration;
|
||||||
|
|
||||||
function asPromise(v) {
|
function asPromise(v) {
|
||||||
return { then: function (cb) { cb(v); } };
|
return { then: function (cb) {
|
||||||
|
cb(v);
|
||||||
|
} };
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
@ -82,8 +82,12 @@ define(
|
|||||||
mockQ.when.andCallFake(asPromise);
|
mockQ.when.andCallFake(asPromise);
|
||||||
mockQ.all.andCallFake(function (values) {
|
mockQ.all.andCallFake(function (values) {
|
||||||
var result = [];
|
var result = [];
|
||||||
function addResult(v) { result.push(v); }
|
function addResult(v) {
|
||||||
function promiseResult(v) { asPromise(v).then(addResult); }
|
result.push(v);
|
||||||
|
}
|
||||||
|
function promiseResult(v) {
|
||||||
|
asPromise(v).then(addResult);
|
||||||
|
}
|
||||||
values.forEach(promiseResult);
|
values.forEach(promiseResult);
|
||||||
return asPromise(result);
|
return asPromise(result);
|
||||||
});
|
});
|
||||||
|
@ -73,7 +73,9 @@ define(
|
|||||||
// loadBundleDefinition, so at this point they are safe
|
// loadBundleDefinition, so at this point they are safe
|
||||||
// to discard.
|
// to discard.
|
||||||
function filterBundles(array) {
|
function filterBundles(array) {
|
||||||
return array.filter(function (x) { return x !== undefined; });
|
return array.filter(function (x) {
|
||||||
|
return x !== undefined;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load a definition for a bundle
|
// Load a definition for a bundle
|
||||||
|
@ -92,7 +92,9 @@ define(
|
|||||||
// Always return a static value; used to represent plain
|
// Always return a static value; used to represent plain
|
||||||
// metadata as a single dependency in Angular.
|
// metadata as a single dependency in Angular.
|
||||||
function staticFunction(value) {
|
function staticFunction(value) {
|
||||||
return function () { return value; };
|
return function () {
|
||||||
|
return value;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utility function; create the second argument for Angular's
|
// Utility function; create the second argument for Angular's
|
||||||
@ -162,15 +164,15 @@ define(
|
|||||||
|
|
||||||
// Examine a group of resolved dependencies to determine
|
// Examine a group of resolved dependencies to determine
|
||||||
// which extension categories still need to be satisfied.
|
// which extension categories still need to be satisfied.
|
||||||
function findEmptyExtensionDependencies(extensionGroup) {
|
function findEmptyExtensionDependencies(extGroup) {
|
||||||
var needed = {},
|
var needed = {},
|
||||||
categories = Object.keys(extensionGroup),
|
categories = Object.keys(extGroup),
|
||||||
allExtensions = [];
|
allExtensions = [];
|
||||||
|
|
||||||
// Build up an array of all extensions
|
// Build up an array of all extensions
|
||||||
categories.forEach(function (category) {
|
categories.forEach(function (category) {
|
||||||
allExtensions =
|
allExtensions =
|
||||||
allExtensions.concat(extensionGroup[category]);
|
allExtensions.concat(extGroup[category]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Track all extension dependencies exposed therefrom
|
// Track all extension dependencies exposed therefrom
|
||||||
@ -195,10 +197,9 @@ define(
|
|||||||
// Register any extension categories that are depended-upon but
|
// Register any extension categories that are depended-upon but
|
||||||
// have not been declared anywhere; such dependencies are then
|
// have not been declared anywhere; such dependencies are then
|
||||||
// satisfied by an empty array, instead of not at all.
|
// satisfied by an empty array, instead of not at all.
|
||||||
function registerEmptyDependencies(extensionGroup) {
|
function registerEmptyDependencies(extGroup) {
|
||||||
findEmptyExtensionDependencies(
|
findEmptyExtensionDependencies(extGroup)
|
||||||
extensionGroup
|
.forEach(function (name) {
|
||||||
).forEach(function (name) {
|
|
||||||
$log.info("Registering empty extension category " + name);
|
$log.info("Registering empty extension category " + name);
|
||||||
app.factory(name, [staticFunction([])]);
|
app.factory(name, [staticFunction([])]);
|
||||||
});
|
});
|
||||||
|
@ -58,11 +58,11 @@ define(
|
|||||||
var loader = this.loader,
|
var loader = this.loader,
|
||||||
$log = this.$log;
|
$log = this.$log;
|
||||||
|
|
||||||
function loadImplementation(extension) {
|
function loadImplementation(ext) {
|
||||||
var implPromise = extension.hasImplementationValue() ?
|
var implPromise = ext.hasImplementationValue() ?
|
||||||
Promise.resolve(extension.getImplementationValue()) :
|
Promise.resolve(ext.getImplementationValue()) :
|
||||||
loader.load(extension.getImplementationPath()),
|
loader.load(ext.getImplementationPath()),
|
||||||
definition = extension.getDefinition();
|
definition = ext.getDefinition();
|
||||||
|
|
||||||
// Wrap a constructor function (to avoid modifying the original)
|
// Wrap a constructor function (to avoid modifying the original)
|
||||||
function constructorFor(impl) {
|
function constructorFor(impl) {
|
||||||
@ -94,7 +94,7 @@ define(
|
|||||||
result.definition = definition;
|
result.definition = definition;
|
||||||
|
|
||||||
// Log that this load was successful
|
// Log that this load was successful
|
||||||
$log.info("Resolved " + extension.getLogName());
|
$log.info("Resolved " + ext.getLogName());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ define(
|
|||||||
// Build up a log message from parts
|
// Build up a log message from parts
|
||||||
var message = [
|
var message = [
|
||||||
"Could not load implementation for extension ",
|
"Could not load implementation for extension ",
|
||||||
extension.getLogName(),
|
ext.getLogName(),
|
||||||
" due to ",
|
" due to ",
|
||||||
err.message
|
err.message
|
||||||
].join("");
|
].join("");
|
||||||
@ -113,16 +113,16 @@ define(
|
|||||||
// Log that the extension was not loaded
|
// Log that the extension was not loaded
|
||||||
$log.warn(message);
|
$log.warn(message);
|
||||||
|
|
||||||
return extension.getDefinition();
|
return ext.getDefinition();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!extension.hasImplementationValue()) {
|
if (!ext.hasImplementationValue()) {
|
||||||
// Log that loading has begun
|
// Log that loading has begun
|
||||||
$log.info([
|
$log.info([
|
||||||
"Loading implementation ",
|
"Loading implementation ",
|
||||||
extension.getImplementationPath(),
|
ext.getImplementationPath(),
|
||||||
" for extension ",
|
" for extension ",
|
||||||
extension.getLogName()
|
ext.getLogName()
|
||||||
].join(""));
|
].join(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,10 +50,14 @@ define(
|
|||||||
it("calls injected stages in order", function () {
|
it("calls injected stages in order", function () {
|
||||||
var result;
|
var result;
|
||||||
|
|
||||||
initializer.runApplication([]).then(function (v) { result = v; });
|
initializer.runApplication([]).then(function (v) {
|
||||||
|
result = v;
|
||||||
|
});
|
||||||
|
|
||||||
waitsFor(
|
waitsFor(
|
||||||
function () { return result !== undefined; },
|
function () {
|
||||||
|
return result !== undefined;
|
||||||
|
},
|
||||||
"promise resolution",
|
"promise resolution",
|
||||||
250
|
250
|
||||||
);
|
);
|
||||||
|
@ -40,7 +40,9 @@ define(
|
|||||||
mockSorter = jasmine.createSpyObj("sorter", ["sort"]);
|
mockSorter = jasmine.createSpyObj("sorter", ["sort"]);
|
||||||
customRegistrars = {};
|
customRegistrars = {};
|
||||||
|
|
||||||
mockSorter.sort.andCallFake(function (v) { return v; });
|
mockSorter.sort.andCallFake(function (v) {
|
||||||
|
return v;
|
||||||
|
});
|
||||||
|
|
||||||
registrar = new ExtensionRegistrar(
|
registrar = new ExtensionRegistrar(
|
||||||
mockApp,
|
mockApp,
|
||||||
@ -98,7 +100,9 @@ define(
|
|||||||
var a = { a: 'a' }, b = { b: 'b' }, c = { c: 'c' };
|
var a = { a: 'a' }, b = { b: 'b' }, c = { c: 'c' };
|
||||||
|
|
||||||
// Fake sorting; just reverse the array
|
// Fake sorting; just reverse the array
|
||||||
mockSorter.sort.andCallFake(function (v) { return v.reverse(); });
|
mockSorter.sort.andCallFake(function (v) {
|
||||||
|
return v.reverse();
|
||||||
|
});
|
||||||
|
|
||||||
// Register the extensions
|
// Register the extensions
|
||||||
registrar.registerExtensions({ things: [a, b, c] });
|
registrar.registerExtensions({ things: [a, b, c] });
|
||||||
|
@ -66,11 +66,21 @@ define(
|
|||||||
it("allows composite services to be registered", function () {
|
it("allows composite services to be registered", function () {
|
||||||
// Prepare components that look like resolved extensions
|
// Prepare components that look like resolved extensions
|
||||||
var components, name;
|
var components, name;
|
||||||
function MyDecorator() { return {}; }
|
function MyDecorator() {
|
||||||
function MyOtherDecorator() { return {}; }
|
return {};
|
||||||
function MyProvider() { return {}; }
|
}
|
||||||
function MyOtherProvider() { return {}; }
|
function MyOtherDecorator() {
|
||||||
function MyAggregator() { return {}; }
|
return {};
|
||||||
|
}
|
||||||
|
function MyProvider() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
function MyOtherProvider() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
function MyAggregator() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
components = [
|
components = [
|
||||||
MyDecorator,
|
MyDecorator,
|
||||||
@ -85,7 +95,9 @@ define(
|
|||||||
MyProvider.type = "provider";
|
MyProvider.type = "provider";
|
||||||
MyOtherProvider.type = "provider";
|
MyOtherProvider.type = "provider";
|
||||||
MyAggregator.type = "aggregator";
|
MyAggregator.type = "aggregator";
|
||||||
components.forEach(function (c) { c.provides = "testService"; });
|
components.forEach(function (c) {
|
||||||
|
c.provides = "testService";
|
||||||
|
});
|
||||||
|
|
||||||
// Add some test dependencies, to check prepending
|
// Add some test dependencies, to check prepending
|
||||||
MyOtherDecorator.depends = ["someOtherService"];
|
MyOtherDecorator.depends = ["someOtherService"];
|
||||||
@ -117,16 +129,24 @@ define(
|
|||||||
it("allows registered composite services to be instantiated", function () {
|
it("allows registered composite services to be instantiated", function () {
|
||||||
// Prepare components that look like resolved extensions
|
// Prepare components that look like resolved extensions
|
||||||
var components, name;
|
var components, name;
|
||||||
function MyProvider() { return {}; }
|
function MyProvider() {
|
||||||
function MyOtherProvider() { return {}; }
|
return {};
|
||||||
function MyAggregator() { return {}; }
|
}
|
||||||
|
function MyOtherProvider() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
function MyAggregator() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
components = [MyProvider, MyAggregator, MyOtherProvider];
|
components = [MyProvider, MyAggregator, MyOtherProvider];
|
||||||
|
|
||||||
MyProvider.type = "provider";
|
MyProvider.type = "provider";
|
||||||
MyOtherProvider.type = "provider";
|
MyOtherProvider.type = "provider";
|
||||||
MyAggregator.type = "aggregator";
|
MyAggregator.type = "aggregator";
|
||||||
components.forEach(function (c) { c.provides = "testService"; });
|
components.forEach(function (c) {
|
||||||
|
c.provides = "testService";
|
||||||
|
});
|
||||||
|
|
||||||
// Register!
|
// Register!
|
||||||
compositor.registerCompositeServices(components);
|
compositor.registerCompositeServices(components);
|
||||||
@ -149,9 +169,15 @@ define(
|
|||||||
it("warns and skips components with no service type", function () {
|
it("warns and skips components with no service type", function () {
|
||||||
// Prepare components that look like resolved extensions
|
// Prepare components that look like resolved extensions
|
||||||
var components;
|
var components;
|
||||||
function MyProvider() { return {}; }
|
function MyProvider() {
|
||||||
function MyDecorator() { return {}; }
|
return {};
|
||||||
function MyAggregator() { return {}; }
|
}
|
||||||
|
function MyDecorator() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
function MyAggregator() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
components = [MyProvider, MyAggregator, MyDecorator];
|
components = [MyProvider, MyAggregator, MyDecorator];
|
||||||
|
|
||||||
@ -175,7 +201,9 @@ define(
|
|||||||
it("warns about and skips aggregators with zero providers", function () {
|
it("warns about and skips aggregators with zero providers", function () {
|
||||||
// Prepare components that look like resolved extensions
|
// Prepare components that look like resolved extensions
|
||||||
var components;
|
var components;
|
||||||
function MyAggregator() { return {}; }
|
function MyAggregator() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
components = [MyAggregator];
|
components = [MyAggregator];
|
||||||
|
|
||||||
@ -195,7 +223,9 @@ define(
|
|||||||
it("warns about and skips decorators with nothing to decorate", function () {
|
it("warns about and skips decorators with nothing to decorate", function () {
|
||||||
// Prepare components that look like resolved extensions
|
// Prepare components that look like resolved extensions
|
||||||
var components;
|
var components;
|
||||||
function MyDecorator() { return {}; }
|
function MyDecorator() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
components = [MyDecorator];
|
components = [MyDecorator];
|
||||||
|
|
||||||
|
@ -63,10 +63,14 @@ define(
|
|||||||
new Bundle("x", { extensions: { tests: [{}, {}, {}] } }),
|
new Bundle("x", { extensions: { tests: [{}, {}, {}] } }),
|
||||||
new Bundle("y", { extensions: { tests: [{}, {}], others: [{}, {}] } }),
|
new Bundle("y", { extensions: { tests: [{}, {}], others: [{}, {}] } }),
|
||||||
new Bundle("z", { extensions: { others: [{}] } })
|
new Bundle("z", { extensions: { others: [{}] } })
|
||||||
]).then(function (v) { result = v; });
|
]).then(function (v) {
|
||||||
|
result = v;
|
||||||
|
});
|
||||||
|
|
||||||
waitsFor(
|
waitsFor(
|
||||||
function () { return result !== undefined; },
|
function () {
|
||||||
|
return result !== undefined;
|
||||||
|
},
|
||||||
"promise resolution",
|
"promise resolution",
|
||||||
250
|
250
|
||||||
);
|
);
|
||||||
|
@ -33,7 +33,9 @@ define(
|
|||||||
resolver;
|
resolver;
|
||||||
|
|
||||||
// Test implementation, to load from the mock loader
|
// Test implementation, to load from the mock loader
|
||||||
function Constructor() { return { someKey: "some value" }; }
|
function Constructor() {
|
||||||
|
return { someKey: "some value" };
|
||||||
|
}
|
||||||
Constructor.someProperty = "some static value";
|
Constructor.someProperty = "some static value";
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
@ -57,10 +59,14 @@ define(
|
|||||||
extension = bundle.getExtensions("tests")[0],
|
extension = bundle.getExtensions("tests")[0],
|
||||||
result;
|
result;
|
||||||
|
|
||||||
resolver.resolve(extension).then(function (v) { result = v; });
|
resolver.resolve(extension).then(function (v) {
|
||||||
|
result = v;
|
||||||
|
});
|
||||||
|
|
||||||
waitsFor(
|
waitsFor(
|
||||||
function () { return result !== undefined; },
|
function () {
|
||||||
|
return result !== undefined;
|
||||||
|
},
|
||||||
"promise resolution",
|
"promise resolution",
|
||||||
250
|
250
|
||||||
);
|
);
|
||||||
@ -88,10 +94,14 @@ define(
|
|||||||
result;
|
result;
|
||||||
|
|
||||||
mockLoader.load.andReturn(Promise.reject(new Error("test error")));
|
mockLoader.load.andReturn(Promise.reject(new Error("test error")));
|
||||||
resolver.resolve(extension).then(function (v) { result = v; });
|
resolver.resolve(extension).then(function (v) {
|
||||||
|
result = v;
|
||||||
|
});
|
||||||
|
|
||||||
waitsFor(
|
waitsFor(
|
||||||
function () { return result !== undefined; },
|
function () {
|
||||||
|
return result !== undefined;
|
||||||
|
},
|
||||||
"promise resolution",
|
"promise resolution",
|
||||||
250
|
250
|
||||||
);
|
);
|
||||||
@ -114,10 +124,14 @@ define(
|
|||||||
extension = bundle.getExtensions("tests")[0],
|
extension = bundle.getExtensions("tests")[0],
|
||||||
result;
|
result;
|
||||||
|
|
||||||
resolver.resolve(extension).then(function (v) { result = v; });
|
resolver.resolve(extension).then(function (v) {
|
||||||
|
result = v;
|
||||||
|
});
|
||||||
|
|
||||||
waitsFor(
|
waitsFor(
|
||||||
function () { return result !== undefined; },
|
function () {
|
||||||
|
return result !== undefined;
|
||||||
|
},
|
||||||
"promise resolution",
|
"promise resolution",
|
||||||
250
|
250
|
||||||
);
|
);
|
||||||
|
@ -53,14 +53,18 @@ define(
|
|||||||
var result;
|
var result;
|
||||||
|
|
||||||
// Load and get the result
|
// Load and get the result
|
||||||
loader.load("xyz.js").then(function (v) { result = v; });
|
loader.load("xyz.js").then(function (v) {
|
||||||
|
result = v;
|
||||||
|
});
|
||||||
|
|
||||||
expect(result).toBeUndefined();
|
expect(result).toBeUndefined();
|
||||||
|
|
||||||
required.fulfill("test result");
|
required.fulfill("test result");
|
||||||
|
|
||||||
waitsFor(
|
waitsFor(
|
||||||
function () { return result !== undefined; },
|
function () {
|
||||||
|
return result !== undefined;
|
||||||
|
},
|
||||||
"promise resolution",
|
"promise resolution",
|
||||||
250
|
250
|
||||||
);
|
);
|
||||||
@ -76,8 +80,12 @@ define(
|
|||||||
|
|
||||||
// Load and get the result
|
// Load and get the result
|
||||||
loader.load("xyz.js").then(
|
loader.load("xyz.js").then(
|
||||||
function (v) { result = v; },
|
function (v) {
|
||||||
function (v) { rejection = v; }
|
result = v;
|
||||||
|
},
|
||||||
|
function (v) {
|
||||||
|
rejection = v;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result).toBeUndefined();
|
expect(result).toBeUndefined();
|
||||||
@ -85,7 +93,9 @@ define(
|
|||||||
required.reject("test result");
|
required.reject("test result");
|
||||||
|
|
||||||
waitsFor(
|
waitsFor(
|
||||||
function () { return rejection !== undefined; },
|
function () {
|
||||||
|
return rejection !== undefined;
|
||||||
|
},
|
||||||
"promise resolution",
|
"promise resolution",
|
||||||
250
|
250
|
||||||
);
|
);
|
||||||
|
@ -61,7 +61,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.providerMapPromise = $q.all(providers.map(addToMap))
|
this.providerMapPromise = $q.all(providers.map(addToMap))
|
||||||
.then(function () { return providerMap; });
|
.then(function () {
|
||||||
|
return providerMap;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
PersistenceAggregator.prototype.listSpaces = function () {
|
PersistenceAggregator.prototype.listSpaces = function () {
|
||||||
|
@ -70,7 +70,9 @@ define(
|
|||||||
mockQ.all.andCallFake(function (fakePromises) {
|
mockQ.all.andCallFake(function (fakePromises) {
|
||||||
var result = [];
|
var result = [];
|
||||||
fakePromises.forEach(function (p) {
|
fakePromises.forEach(function (p) {
|
||||||
p.then(function (v) { result.push(v); });
|
p.then(function (v) {
|
||||||
|
result.push(v);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return fakePromise(result);
|
return fakePromise(result);
|
||||||
});
|
});
|
||||||
|
@ -57,7 +57,9 @@ define(
|
|||||||
// Pull out a list of document IDs from CouchDB's
|
// Pull out a list of document IDs from CouchDB's
|
||||||
// _all_docs response
|
// _all_docs response
|
||||||
function getIdsFromAllDocs(allDocs) {
|
function getIdsFromAllDocs(allDocs) {
|
||||||
return allDocs.rows.map(function (r) { return r.id; });
|
return allDocs.rows.map(function (r) {
|
||||||
|
return r.id;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the response to a create/update/delete request;
|
// Check the response to a create/update/delete request;
|
||||||
|
@ -92,8 +92,8 @@ define(
|
|||||||
if ((response || {}).status === CONFLICT) {
|
if ((response || {}).status === CONFLICT) {
|
||||||
error.key = "revision";
|
error.key = "revision";
|
||||||
// Load the updated model, then reject the promise
|
// Load the updated model, then reject the promise
|
||||||
return this.get(key).then(function (response) {
|
return this.get(key).then(function (res) {
|
||||||
error.model = response[SRC];
|
error.model = res[SRC];
|
||||||
return $q.reject(error);
|
return $q.reject(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user