Merge branch 'master' into persist-on-mutation-825

Conflicts:
	platform/commonUI/edit/src/actions/RemoveAction.js
	platform/commonUI/edit/test/actions/EditAndComposeActionSpec.js
	platform/commonUI/edit/test/actions/RemoveActionSpec.js
	platform/entanglement/src/services/LinkService.js
	platform/features/timeline/src/controllers/drag/TimelineDragHandler.js
	platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDecorator.js
	platform/features/timeline/test/controllers/drag/TimelineDragHandlerSpec.js
	platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDropHandlerSpec.js
This commit is contained in:
Victor Woeltjen
2016-05-20 14:26:39 -07:00
468 changed files with 2151 additions and 1919 deletions

View File

@@ -91,7 +91,7 @@ define([
"name": "Export Timeline as CSV",
"category": "contextual",
"implementation": ExportTimelineAsCSVAction,
"depends": [ "exportService", "notificationService" ]
"depends": ["exportService", "notificationService"]
}
],
"constants": [

View File

@@ -29,7 +29,7 @@
}">
<div class="l-cols">
<span class="l-col l-col-icon l-plot-resource"
ng-click="ngModel.toggleGraph()"
ng-click="ngModel.toggleGraph(); parameters.commit()"
title="Click to enable or disable inclusion in Resource Graphing">
<span class="ui-symbol"
ng-show="ngModel.graph()"

View File

@@ -43,6 +43,7 @@
<div class="t-swimlanes-holder l-swimlanes-holder"
mct-scroll-y="scroll.y">
<mct-include key="'timeline-tabular-swimlane-cols-tree'"
parameters="{ commit: commit }"
ng-repeat="swimlane in timelineController.swimlanes()"
ng-model="swimlane">
</mct-include>

View File

@@ -28,4 +28,4 @@ define({
HANDLE_WIDTH: 32,
// Pixel tolerance for snapping behavior
SNAP_WIDTH: 16
});
});

View File

@@ -73,4 +73,4 @@ define(
return TimelineFormatter;
}
);
);

View File

@@ -65,4 +65,4 @@ define(["./ExportTimelineAsCSVTask"], function (ExportTimelineAsCSVTask) {
};
return ExportTimelineAsCSVAction;
});
});

View File

@@ -80,4 +80,4 @@ define([], function () {
return TimelineTraverser;
});
});

View File

@@ -52,25 +52,25 @@ define(
// Set the start time associated with this object
function setStart(value) {
var end = getEnd();
mutation.mutate(function (model) {
model.start.timestamp = Math.max(value, 0);
mutation.mutate(function (m) {
m.start.timestamp = Math.max(value, 0);
// Update duration to keep end time
model.duration.timestamp = Math.max(end - value, 0);
m.duration.timestamp = Math.max(end - value, 0);
}, model.modified);
}
// Set the duration associated with this object
function setDuration(value) {
mutation.mutate(function (model) {
model.duration.timestamp = Math.max(value, 0);
mutation.mutate(function (m) {
m.duration.timestamp = Math.max(value, 0);
}, model.modified);
}
// Set the end time associated with this object
function setEnd(value) {
var start = getStart();
mutation.mutate(function (model) {
model.duration.timestamp = Math.max(value - start, 0);
mutation.mutate(function (m) {
m.duration.timestamp = Math.max(value - start, 0);
}, model.modified);
}
@@ -116,4 +116,4 @@ define(
return ActivityTimespan;
}
);
);

View File

@@ -47,4 +47,4 @@ define(
return ActivityUtilization;
}
);
);

View File

@@ -53,21 +53,21 @@ define(
// Initialize the data values
function initializeValues() {
var values = [],
var vals = [],
slope = 0,
i;
// Add a point (or points, if needed) reaching to the provided
// domain and/or range value
function addPoint(domain, range) {
var previous = values[values.length - 1],
var previous = vals[vals.length - 1],
delta = domain - previous.domain, // time delta
change = delta * slope * rate, // change
next = previous.range + change;
// Crop to minimum boundary...
if (next < minimum) {
values.push({
vals.push({
domain: intercept(
previous.domain,
previous.range,
@@ -81,7 +81,7 @@ define(
// ...and maximum boundary
if (next > maximum) {
values.push({
vals.push({
domain: intercept(
previous.domain,
previous.range,
@@ -95,19 +95,19 @@ define(
// Add the new data value
if (delta > 0) {
values.push({ domain: domain, range: next });
vals.push({ domain: domain, range: next });
}
slope = range;
}
values.push({ domain: 0, range: initial });
vals.push({ domain: 0, range: initial });
for (i = 0; i < graph.getPointCount(); i += 1) {
addPoint(graph.getDomainValue(i), graph.getRangeValue(i));
}
return values;
return vals;
}
function convertToPercent(point) {
@@ -149,4 +149,4 @@ define(
return CumulativeGraph;
}
);
);

View File

@@ -72,13 +72,13 @@ define(
// If there are sequences of points with the same timestamp,
// 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
// that, allow only points that have different timestamps
// from their predecessor or successor.
return (index === 0) || (index === values.length - 1) ||
(value.domain !== values[index - 1].domain) ||
(value.domain !== values[index + 1].domain);
return (index === 0) || (index === vals.length - 1) ||
(value.domain !== vals[index - 1].domain) ||
(value.domain !== vals[index + 1].domain);
}
// Add a step up or down (Step 3c above)
@@ -144,4 +144,4 @@ define(
return ResourceGraph;
}
);
);

View File

@@ -57,8 +57,8 @@ define(
// Set the start time associated with this object
function setStart(value) {
mutation.mutate(function (model) {
model.start.timestamp = Math.max(value, 0);
mutation.mutate(function (m) {
m.start.timestamp = Math.max(value, 0);
}, model.modified);
}
@@ -121,4 +121,4 @@ define(
return TimelineTimespan;
}
);
);

View File

@@ -47,4 +47,4 @@ define(
return TimelineUtilization;
}
);
);

View File

@@ -120,13 +120,13 @@ define(
}
// Look up a specific object's resource utilization
function lookupUtilization(domainObject) {
return domainObject.useCapability('utilization');
function lookupUtilization(object) {
return object.useCapability('utilization');
}
// Look up a specific object's resource utilization keys
function lookupUtilizationResources(domainObject) {
var utilization = domainObject.getCapability('utilization');
function lookupUtilizationResources(object) {
var utilization = object.getCapability('utilization');
return utilization && utilization.resources();
}

View File

@@ -96,7 +96,7 @@ define(
});
}
}
// Recalculate swimlane state on changes
$scope.$watch("domainObject", swimlanePopulator.populate);

View File

@@ -88,4 +88,4 @@ define(
return DateTimeController;
}
);
);

View File

@@ -83,4 +83,4 @@ define(
return TimelineGanttController;
}
);
);

View File

@@ -92,4 +92,4 @@ define(
return TimelineGraphController;
}
);
);

View File

@@ -113,4 +113,4 @@ define(
return TimelineTickController;
}
);
);

View File

@@ -29,7 +29,7 @@ define(
*/
function TimelineZoomController($scope, ZOOM_CONFIGURATION) {
// Prefer to start with the middle index
var zoomLevels = ZOOM_CONFIGURATION.levels || [ 1000 ],
var zoomLevels = ZOOM_CONFIGURATION.levels || [1000],
zoomIndex = Math.floor(zoomLevels.length / 2),
tickWidth = ZOOM_CONFIGURATION.width || 200,
duration = 86400000; // Default duration in view

View File

@@ -46,17 +46,17 @@ define(
}
// Get the timespan associated with this domain object
function populateCapabilityMaps(domainObject) {
var id = domainObject.getId(),
timespanPromise = domainObject.useCapability('timespan');
function populateCapabilityMaps(object) {
var id = object.getId(),
timespanPromise = object.useCapability('timespan');
if (timespanPromise) {
timespanPromise.then(function (timespan) {
// Cache that timespan
timespans[id] = timespan;
// And its mutation capability
mutations[id] = domainObject.getCapability('mutation');
mutations[id] = object.getCapability('mutation');
// And the composition, for bulk moves
compositions[id] = domainObject.getModel().composition || [];
compositions[id] = object.getModel().composition || [];
});
}
}
@@ -191,8 +191,8 @@ define(
minStart;
// Update start & end, in that order
function updateStartEnd(id) {
var timespan = timespans[id], start, end;
function updateStartEnd(spanId) {
var timespan = timespans[spanId], start, end;
if (timespan) {
// Get start/end so we don't get fooled by our
// own adjustments
@@ -202,7 +202,7 @@ define(
timespan.setStart(start + delta);
timespan.setEnd(end + delta);
// Mark as dirty for subsequent persistence
dirty[toId(id)] = true;
dirty[toId(spanId)] = true;
}
}
@@ -220,12 +220,12 @@ define(
}
// 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
// found, since this will not survive a min
// test if any real timespans are present
return timespans[id] ?
timespans[id].getStart() :
return timespans[spanId] ?
timespans[spanId].getStart() :
Number.POSITIVE_INFINITY;
}).reduce(function (a, b) {
// Reduce with a minimum test

View File

@@ -92,4 +92,4 @@ define(
return TimelineDragPopulator;
}
);
);

View File

@@ -93,4 +93,4 @@ define(
return TimelineEndHandle;
}
);
);

View File

@@ -128,4 +128,4 @@ define(
return TimelineMoveHandle;
}
);
);

View File

@@ -42,7 +42,9 @@ define(
candidates;
// 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
function evaluate(candidate) {
@@ -101,4 +103,4 @@ define(
return TimelineSnapHandler;
}
);
);

View File

@@ -93,4 +93,4 @@ define(
return TimelineStartHandle;
}
);
);

View File

@@ -168,8 +168,8 @@ define(
setBounds: function (offset, duration) {
// We don't update in-place, because we need the change
// to trigger a watch in mct-chart.
drawingObject.origin = [ offset, drawingObject.origin[1] ];
drawingObject.dimensions = [ duration, drawingObject.dimensions[1] ];
drawingObject.origin = [offset, drawingObject.origin[1]];
drawingObject.dimensions = [duration, drawingObject.dimensions[1]];
},
/**
* Redraw lines in this graph.
@@ -186,4 +186,4 @@ define(
return TimelineGraph;
}
);
);

View File

@@ -75,11 +75,14 @@ define(
// Look up resources for a domain object
function lookupResources(swimlane) {
var graphs = swimlane.domainObject.useCapability('graph');
var graphPromise =
swimlane.domainObject.useCapability('graph');
function getKeys(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
@@ -152,4 +155,4 @@ define(
return TimelineGraphPopulator;
}
);
);

View File

@@ -78,4 +78,4 @@ define(
return TimelineGraphRenderer;
}
);
);

View File

@@ -117,4 +117,4 @@ define(
return TimelineColorAssigner;
}
);
);

View File

@@ -34,8 +34,8 @@ define(
var actionMap = {};
// Populate available Create actions for this domain object
function populateActionMap(domainObject) {
var actionCapability = domainObject.getCapability('action'),
function populateActionMap(object) {
var actionCapability = object.getCapability('action'),
actions = actionCapability ?
actionCapability.getActions('add') : [];
actions.forEach(function (action) {
@@ -74,4 +74,4 @@ define(
return TimelineProxy;
}
);
);

View File

@@ -47,9 +47,7 @@ define(
depth = parent ? (parent.depth + 1) : 0,
timespan,
path = (!parent || !parent.parent) ? "" : parent.path +
//(parent.path.length > 0 ? " / " : "") +
parent.domainObject.getModel().name +
" > ";
parent.domainObject.getModel().name + " > ";
// Look up timespan for this object
domainObject.useCapability('timespan').then(function (t) {
@@ -172,4 +170,4 @@ define(
return TimelineSwimlane;
}
);
);

View File

@@ -44,9 +44,9 @@ define(
if (arguments.length > 0 && Array.isArray(value)) {
if ((model.relationships || {})[ACTIVITY_RELATIONSHIP] !== value) {
// Update the relationships
mutator.mutate(function (model) {
model.relationships = model.relationships || {};
model.relationships[ACTIVITY_RELATIONSHIP] = value;
mutator.mutate(function (m) {
m.relationships = m.relationships || {};
m.relationships[ACTIVITY_RELATIONSHIP] = value;
});
}
}
@@ -60,8 +60,8 @@ define(
if (arguments.length > 0 && (typeof value === 'string') &&
value !== model.link) {
// Update the link
mutator.mutate(function (model) {
model.link = value;
mutator.mutate(function (m) {
m.link = value;
});
}
return model.link;

View File

@@ -41,7 +41,7 @@ define(
}
// 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)
function matches(pathId) {
return pathId === id;
@@ -49,18 +49,18 @@ define(
// Path A contains Path B if it is longer, and all of
// 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
function contains(swimlane, id) {
function contains(swimlaneToCheck, id) {
// Check if a child swimlane has a matching domain object id
function matches(child) {
return child.domainObject.getId() === 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

View File

@@ -61,8 +61,8 @@ define(
swimlane;
// For the recursive step
function populate(childSubgraph, index) {
populateSwimlanes(childSubgraph, swimlane, index);
function populate(childSubgraph, nextIndex) {
populateSwimlanes(childSubgraph, swimlane, nextIndex);
}
// Make sure we have a valid object instance...
@@ -194,4 +194,4 @@ define(
return TimelineSwimlanePopulator;
}
);
);

View File

@@ -41,13 +41,13 @@ define(
filter;
// Check object existence (for criterion-less filtering)
function exists(domainObject) {
return !!domainObject;
function exists(object) {
return !!object;
}
// Check for capability matching criterion
function hasCapability(domainObject) {
return domainObject && domainObject.hasCapability(criterion);
function hasCapability(object) {
return object && object.hasCapability(criterion);
}
// For the recursive step...
@@ -61,8 +61,8 @@ define(
}
// Avoid infinite recursion
function notVisiting(domainObject) {
return !visiting[domainObject.getId()];
function notVisiting(object) {
return !visiting[object.getId()];
}
// Put the composition of this domain object into the result
@@ -130,4 +130,4 @@ define(
return ObjectLoader;
}
);
);

View File

@@ -57,4 +57,4 @@ define(
});
});
}
);
);

View File

@@ -44,10 +44,10 @@ define(
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getModel', 'getCapability' ]
['getId', 'getModel', 'getCapability']
);
testModel = {
composition: [ 'a', 'b', 'c', 'd', 'e', 'f' ]
composition: ['a', 'b', 'c', 'd', 'e', 'f']
};
mockDomainObject.getModel.andReturn(testModel);
});
@@ -58,7 +58,7 @@ define(
});
it("returns nothing when composition is exceeded", function () {
testModel.composition = [ 'foo' ];
testModel.composition = ['foo'];
expect(column.value(mockDomainObject)).toEqual("");
});
@@ -70,4 +70,4 @@ define(
});
}
);
);

View File

@@ -36,20 +36,20 @@ define(
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getModel', 'getCapability', 'hasCapability' ]
['getId', 'getModel', 'getCapability', 'hasCapability']
);
mockType = jasmine.createSpyObj('type', [ 'instanceOf' ]);
mockType = jasmine.createSpyObj('type', ['instanceOf']);
mockExportService = jasmine.createSpyObj(
'exportService',
[ 'exportCSV' ]
['exportCSV']
);
mockNotificationService = jasmine.createSpyObj(
'notificationService',
[ 'notify', 'error' ]
['notify', 'error']
);
mockNotification = jasmine.createSpyObj(
'notification',
[ 'dismiss' ]
['dismiss']
);
mockNotificationService.notify.andReturn(mockNotification);
@@ -149,4 +149,4 @@ define(
});
});
}
);
);

View File

@@ -34,7 +34,7 @@ define(
beforeEach(function () {
mockExportService = jasmine.createSpyObj(
'exportService',
[ 'exportCSV' ]
['exportCSV']
);
mockDomainObject = jasmine.createSpyObj(
'domainObject',

View File

@@ -42,7 +42,7 @@ define(
testId = "foo";
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getModel', 'getCapability' ]
['getId', 'getModel', 'getCapability']
);
mockDomainObject.getId.andReturn(testId);
});
@@ -55,4 +55,4 @@ define(
});
}
);
);

View File

@@ -44,7 +44,7 @@ define(
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getModel', 'getCapability', 'useCapability' ]
['getId', 'getModel', 'getCapability', 'useCapability']
);
testMetadata = [
{ name: "Something else", value: 123 },
@@ -72,4 +72,4 @@ define(
});
}
);
);

View File

@@ -44,11 +44,11 @@ define(
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getModel', 'getCapability' ]
['getId', 'getModel', 'getCapability']
);
testModel = {
relationships: {
modes: [ 'a', 'b', 'c', 'd', 'e', 'f' ]
modes: ['a', 'b', 'c', 'd', 'e', 'f']
}
};
mockDomainObject.getModel.andReturn(testModel);
@@ -60,7 +60,7 @@ define(
});
it("returns nothing when relationships are exceeded", function () {
testModel.relationships.modes = [ 'foo' ];
testModel.relationships.modes = ['foo'];
expect(column.value(mockDomainObject)).toEqual("");
});
@@ -72,4 +72,4 @@ define(
});
}
);
);

View File

@@ -50,7 +50,7 @@ define(
beforeEach(function () {
var mockTimespan = jasmine.createSpyObj(
'timespan',
[ 'getStart', 'getEnd' ]
['getStart', 'getEnd']
);
testMetadata = [
@@ -59,8 +59,8 @@ define(
];
mockDomainObjects = [
{ composition: [ 'a', 'b', 'c' ] },
{ relationships: { modes: [ 'x', 'y' ] } },
{ composition: ['a', 'b', 'c'] },
{ relationships: { modes: ['x', 'y'] } },
{ }
].map(makeMockDomainObject);

View File

@@ -55,8 +55,8 @@ define([
if (!!model.composition) {
mockDomainObject.useCapability.andCallFake(function (c) {
return c === 'composition' &&
Promise.resolve(model.composition.map(function (id) {
return mockDomainObjects[id];
Promise.resolve(model.composition.map(function (cid) {
return mockDomainObjects[cid];
}));
});
}
@@ -68,8 +68,8 @@ define([
);
mockRelationships.getRelatedObjects.andCallFake(function (k) {
var ids = model.relationships[k] || [];
return Promise.resolve(ids.map(function (id) {
return mockDomainObjects[id];
return Promise.resolve(ids.map(function (objId) {
return mockDomainObjects[objId];
}));
});
mockDomainObject.getCapability.andCallFake(function (c) {
@@ -82,9 +82,9 @@ define([
beforeEach(function () {
testModels = {
a: { composition: [ 'b', 'c' ]},
b: { composition: [ 'c' ] },
c: { relationships: { modes: [ 'd' ] } },
a: { composition: ['b', 'c']},
b: { composition: ['c'] },
c: { relationships: { modes: ['d'] } },
d: {},
unreachable: {}
};
@@ -132,4 +132,4 @@ define([
});
});
});
});

View File

@@ -36,11 +36,11 @@ define(
};
mockTimespan = jasmine.createSpyObj(
'timespan',
[ 'getStart', 'getEnd' ]
['getStart', 'getEnd']
);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'useCapability', 'hasCapability' ]
['useCapability', 'hasCapability']
);
mockTimespan.getStart.andReturn(testTimes.start);
mockTimespan.getEnd.andReturn(testTimes.end);
@@ -52,7 +52,7 @@ define(
});
});
[ "start", "end" ].forEach(function (bound) {
["start", "end"].forEach(function (bound) {
describe("when referring to " + bound + " times", function () {
var name = bound.charAt(0).toUpperCase() + bound.slice(1);
@@ -90,4 +90,4 @@ define(
});
}
);
);

View File

@@ -41,7 +41,7 @@ define(
mockQ = jasmine.createSpyObj('$q', ['when']);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getModel', 'getCapability' ]
['getModel', 'getCapability']
);
mockQ.when.andCallFake(asPromise);

View File

@@ -96,4 +96,4 @@ define(
});
}
);
);

View File

@@ -36,4 +36,4 @@ define(
});
}
);
);

View File

@@ -31,7 +31,7 @@ define(
beforeEach(function () {
var mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getModel', 'getId' ]
['getModel', 'getId']
);
testModel = {

View File

@@ -30,11 +30,11 @@ define(
graph;
beforeEach(function () {
points = [ 0, 10, -10, -100, 20, 100, 0 ];
points = [0, 10, -10, -100, 20, 100, 0];
mockGraph = jasmine.createSpyObj(
'graph',
[ 'getPointCount', 'getDomainValue', 'getRangeValue' ]
['getPointCount', 'getDomainValue', 'getRangeValue']
);
mockGraph.getPointCount.andReturn(points.length * 2);
@@ -83,4 +83,4 @@ define(
});
}
);
);

View File

@@ -42,7 +42,7 @@ define(
mockQ = jasmine.createSpyObj('$q', ['when']);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getModel', 'useCapability' ]
['getId', 'getModel', 'useCapability']
);
testModel = {

View File

@@ -43,14 +43,14 @@ define(
expect(graph.getPointCount()).toEqual(16);
// Should get two values at every time stamp, for step-like appearance
[ 5, 15, 40, 50, 100, 120, 150, 180].forEach(function (v, i) {
[5, 15, 40, 50, 100, 120, 150, 180].forEach(function (v, i) {
expect(graph.getDomainValue(i * 2)).toEqual(v);
expect(graph.getDomainValue(i * 2 + 1)).toEqual(v);
});
// Should also repeat values at subsequent indexes, but offset differently,
// for horizontal spans between steps
[ 0, 42, 72, 42, 20, -22, 0, -10].forEach(function (v, i) {
[0, 42, 72, 42, 20, -22, 0, -10].forEach(function (v, i) {
expect(graph.getRangeValue(i * 2)).toEqual(v);
// Offset backwards; wrap around end of the series
expect(graph.getRangeValue((16 + i * 2 - 1) % 16)).toEqual(v);
@@ -72,4 +72,4 @@ define(
});
}
);
);

View File

@@ -45,30 +45,34 @@ define(
mockQ = jasmine.createSpyObj('$q', ['when', 'all']);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getModel', 'getCapability', 'useCapability' ]
['getModel', 'getCapability', 'useCapability']
);
mockChildA = jasmine.createSpyObj(
'childA',
[ 'getModel', 'useCapability', 'hasCapability' ]
['getModel', 'useCapability', 'hasCapability']
);
mockChildB = jasmine.createSpyObj(
'childA',
[ 'getModel', 'useCapability', 'hasCapability' ]
['getModel', 'useCapability', 'hasCapability']
);
mockTimespanA = jasmine.createSpyObj(
'timespanA',
[ 'getEnd' ]
['getEnd']
);
mockTimespanB = jasmine.createSpyObj(
'timespanB',
[ 'getEnd' ]
['getEnd']
);
mockQ.when.andCallFake(asPromise);
mockQ.all.andCallFake(function (values) {
var result = [];
function addResult(v) { result.push(v); }
function promiseResult(v) { asPromise(v).then(addResult); }
function addResult(v) {
result.push(v);
}
function promiseResult(v) {
asPromise(v).then(addResult);
}
values.forEach(promiseResult);
return asPromise(result);
});
@@ -83,7 +87,7 @@ define(
});
mockDomainObject.useCapability.andCallFake(function (c) {
if (c === 'composition') {
return asPromise([ mockChildA, mockChildB ]);
return asPromise([mockChildA, mockChildB]);
}
});
mockChildA.hasCapability.andReturn(true);

View File

@@ -51,7 +51,7 @@ define(
mutationModel = JSON.parse(JSON.stringify(testModel));
mockMutation = jasmine.createSpyObj("mutation", ["mutate"]);
mockTimespans = [ 44000, 65000, 1100 ].map(makeMockTimespan);
mockTimespans = [44000, 65000, 1100].map(makeMockTimespan);
mockMutation.mutate.andCallFake(function (mutator) {
mutator(mutationModel);
@@ -107,4 +107,4 @@ define(
});
});
}
);
);

View File

@@ -36,4 +36,4 @@ define(
});
}
);
);

View File

@@ -69,8 +69,8 @@ define(
resources: function () {
return Object.keys(costs).sort();
},
cost: function (c) {
return costs[c];
cost: function (k) {
return costs[k];
}
});
},
@@ -84,15 +84,15 @@ define(
mockQ = jasmine.createSpyObj('$q', ['when', 'all']);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getModel', 'getCapability', 'useCapability' ]
['getId', 'getModel', 'getCapability', 'useCapability']
);
mockRelationship = jasmine.createSpyObj(
'relationship',
[ 'getRelatedObjects' ]
['getRelatedObjects']
);
mockComposition = jasmine.createSpyObj(
'composition',
[ 'invoke' ]
['invoke']
);
mockCallback = jasmine.createSpy('callback');

View File

@@ -48,4 +48,4 @@ define(
});
});
}
);
);

View File

@@ -99,7 +99,7 @@ define(
mockScope = jasmine.createSpyObj(
"$scope",
[ '$watch', '$on' ]
['$watch', '$on']
);
mockLoader = jasmine.createSpyObj('objectLoader', ['load']);
mockDomainObject = mockA;
@@ -245,4 +245,4 @@ define(
});
}
);
);

View File

@@ -61,7 +61,9 @@ define(
mockTimespan.getDuration.andReturn(50);
mockTimespan.getEnd.andReturn(150);
mockToPixels.andCallFake(function (t) { return t * 10; });
mockToPixels.andCallFake(function (t) {
return t * 10;
});
controller = new TimelineGanttController(TEST_MAX_OFFSCREEN);
});
@@ -96,4 +98,4 @@ define(
});
}
);
);

View File

@@ -32,7 +32,7 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
'$scope',
[ '$watchCollection' ]
['$watchCollection']
);
testResources = [
{ key: 'abc', name: "Some name" },
@@ -58,7 +58,7 @@ define(
// Supply new parameters
mockScope.$watchCollection.mostRecentCall.args[1]({
graphs: [ mockGraphA, mockGraphB ],
graphs: [mockGraphA, mockGraphB],
origin: 9,
duration: 144
});

View File

@@ -38,7 +38,7 @@ define(
// This controller's job is just to expose the formatter
// in scope, so simply verify that the two agree.
it("formats durations", function () {
[ 0, 100, 4123, 93600, 748801230012].forEach(function (n) {
[0, 100, 4123, 93600, 748801230012].forEach(function (n) {
expect(controller.niceTime(n))
.toEqual(formatter.format(n));
});

View File

@@ -83,4 +83,4 @@ define(
});
}
);
);

View File

@@ -90,7 +90,9 @@ define(
mockScope.domainObject.getCapability.andCallFake(function (c) {
if (c === 'editor') {
return {
inEditContext: function () {return true;}
inEditContext: function () {
return true;
}
};
}
});

View File

@@ -35,19 +35,19 @@ define(
beforeEach(function () {
mockDragHandler = jasmine.createSpyObj(
'dragHandler',
[ 'start' ]
['start']
);
mockSnapHandler = jasmine.createSpyObj(
'snapHandler',
[ 'snap' ]
['snap']
);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getCapability', 'getId' ]
['getCapability', 'getId']
);
mockType = jasmine.createSpyObj(
'type',
[ 'instanceOf' ]
['instanceOf']
);
mockDomainObject.getId.andReturn('test-id');

View File

@@ -55,21 +55,21 @@ define(
}
function makeMockDomainObject(id, composition) {
var mockDomainObject = jasmine.createSpyObj(
var mockDomainObj = jasmine.createSpyObj(
'domainObject-' + id,
['getId', 'getModel', 'getCapability', 'useCapability']
);
mockDomainObject.getId.andReturn(id);
mockDomainObject.getModel.andReturn({ composition: composition });
mockDomainObject.useCapability.andReturn(asPromise(mockTimespans[id]));
mockDomainObject.getCapability.andCallFake(function (c) {
mockDomainObj.getId.andReturn(id);
mockDomainObj.getModel.andReturn({ composition: composition });
mockDomainObj.useCapability.andReturn(asPromise(mockTimespans[id]));
mockDomainObj.getCapability.andCallFake(function (c) {
return {
mutation: mockMutations[id]
}[c];
});
return mockDomainObject;
return mockDomainObj;
}
beforeEach(function () {
@@ -78,11 +78,11 @@ define(
['a', 'b', 'c', 'd', 'e', 'f'].forEach(function (id, index) {
mockTimespans[id] = jasmine.createSpyObj(
'timespan-' + id,
[ 'getStart', 'getEnd', 'getDuration', 'setStart', 'setEnd', 'setDuration' ]
['getStart', 'getEnd', 'getDuration', 'setStart', 'setEnd', 'setDuration']
);
mockMutations[id] = jasmine.createSpyObj(
'mutation-' + id,
[ 'mutate' ]
['mutate']
);
mockTimespans[id].getStart.andReturn(index * 1000);
mockTimespans[id].getDuration.andReturn(4000 + index);

View File

@@ -69,4 +69,4 @@ define(
});
}
);
);

View File

@@ -33,15 +33,15 @@ define(
beforeEach(function () {
mockDragHandler = jasmine.createSpyObj(
'dragHandler',
[ 'end', 'persist' ]
['end', 'persist']
);
mockSnapHandler = jasmine.createSpyObj(
'snapHandler',
[ 'snap' ]
['snap']
);
mockZoomController = jasmine.createSpyObj(
'zoom',
[ 'toMillis', 'toPixels' ]
['toMillis', 'toPixels']
);
mockDragHandler.end.andReturn(12321);
@@ -112,4 +112,4 @@ define(
});
}
);
);

View File

@@ -33,15 +33,15 @@ define(
beforeEach(function () {
mockDragHandler = jasmine.createSpyObj(
'dragHandler',
[ 'start', 'duration', 'end', 'move', 'persist' ]
['start', 'duration', 'end', 'move', 'persist']
);
mockSnapHandler = jasmine.createSpyObj(
'snapHandler',
[ 'snap' ]
['snap']
);
mockZoomController = jasmine.createSpyObj(
'zoom',
[ 'toMillis', 'toPixels' ]
['toMillis', 'toPixels']
);
mockDragHandler.start.andReturn(12321);
@@ -179,4 +179,4 @@ define(
});
}
);
);

View File

@@ -34,7 +34,7 @@ define(
mockDragHandler = jasmine.createSpyObj(
'dragHandler',
[ 'start', 'end', 'ids' ]
['start', 'end', 'ids']
);
mockDragHandler.ids.andReturn(['a', 'b', 'c', 'd']);
@@ -76,4 +76,4 @@ define(
});
}
);
);

View File

@@ -33,15 +33,15 @@ define(
beforeEach(function () {
mockDragHandler = jasmine.createSpyObj(
'dragHandler',
[ 'start', 'persist' ]
['start', 'persist']
);
mockSnapHandler = jasmine.createSpyObj(
'snapHandler',
[ 'snap' ]
['snap']
);
mockZoomController = jasmine.createSpyObj(
'zoom',
[ 'toMillis', 'toPixels' ]
['toMillis', 'toPixels']
);
mockDragHandler.start.andReturn(12321);
@@ -111,4 +111,4 @@ define(
});
}
);
);

View File

@@ -48,9 +48,9 @@ define(
beforeEach(function () {
testResources = {
a: [ 'xyz', 'abc' ],
b: [ 'xyz' ],
c: [ 'xyz', 'abc', 'def', 'ghi' ]
a: ['xyz', 'abc'],
b: ['xyz'],
c: ['xyz', 'abc', 'def', 'ghi']
};
mockQ = jasmine.createSpyObj('$q', ['when', 'all']);
@@ -58,16 +58,16 @@ define(
mockSwimlanes = ['a', 'b', 'c'].map(function (k) {
var mockSwimlane = jasmine.createSpyObj(
'swimlane-' + k,
[ 'graph', 'color' ]
['graph', 'color']
),
mockGraph = jasmine.createSpyObj(
'graph-' + k,
[ 'getPointCount', 'getDomainValue', 'getRangeValue' ]
['getPointCount', 'getDomainValue', 'getRangeValue']
);
mockSwimlane.graph.andReturn(true);
mockSwimlane.domainObject = jasmine.createSpyObj(
'domainObject-' + k,
[ 'getCapability', 'hasCapability', 'useCapability', 'getId' ]
['getCapability', 'hasCapability', 'useCapability', 'getId']
);
mockSwimlane.color.andReturn('#' + k);
// Provide just enough information about graphs to support
@@ -148,4 +148,4 @@ define(
});
}
);
);

View File

@@ -72,4 +72,4 @@ define(
});
}
);
);

View File

@@ -42,9 +42,9 @@ define(
beforeEach(function () {
testColors = {
a: [ 0, 1, 0 ],
b: [ 1, 0, 1 ],
c: [ 1, 0, 0 ]
a: [0, 1, 0],
b: [1, 0, 1],
c: [1, 0, 0]
};
mockGraphs = [];
@@ -53,11 +53,11 @@ define(
['a', 'b', 'c'].forEach(function (k, i) {
var mockGraph = jasmine.createSpyObj(
'utilization-' + k,
[ 'getPointCount', 'getDomainValue', 'getRangeValue' ]
['getPointCount', 'getDomainValue', 'getRangeValue']
);
mockDomainObjects[k] = jasmine.createSpyObj(
'domainObject-' + k,
[ 'getCapability', 'useCapability' ]
['getCapability', 'useCapability']
);
mockDomainObjects[k].useCapability.andReturn(asPromise({
testResource: mockGraph
@@ -72,7 +72,7 @@ define(
mockRenderer = jasmine.createSpyObj(
'renderer',
[ 'render', 'decode' ]
['render', 'decode']
);
mockRenderer.render.andCallFake(function (utilization) {
@@ -167,4 +167,4 @@ define(
});
}
);
);

View File

@@ -49,10 +49,14 @@ define(
var colors = {}, i, ids = [];
// Add item to set
function set(c) { colors[c] = true; }
function set(c) {
colors[c] = true;
}
// 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,
// storing into the set

View File

@@ -38,16 +38,16 @@ define(
);
mockSelection = jasmine.createSpyObj(
'selection',
[ 'get' ]
['get']
);
mockActionCapability = jasmine.createSpyObj(
'action',
[ 'getActions' ]
['getActions']
);
mockActions = ['a', 'b', 'c'].map(function (type) {
var mockAction = jasmine.createSpyObj(
'action-' + type,
[ 'perform', 'getMetadata' ]
['perform', 'getMetadata']
);
mockAction.getMetadata.andReturn({ type: type });
return mockAction;

View File

@@ -43,7 +43,7 @@ define(
mockSwimlane.domainObject = jasmine.createSpyObj(
'domainObject',
[ 'getCapability', 'getModel' ]
['getCapability', 'getModel']
);
mockCapabilities.mutation = jasmine.createSpyObj(
@@ -144,11 +144,11 @@ define(
it("fires the 'remove' action when remove is called", function () {
var mockChild = jasmine.createSpyObj(
'childObject',
[ 'getCapability', 'getModel' ]
['getCapability', 'getModel']
),
mockAction = jasmine.createSpyObj(
'action',
[ 'perform' ]
['perform']
);
mockChild.getCapability.andCallFake(function (c) {

View File

@@ -40,28 +40,28 @@ define(
mockSwimlane = jasmine.createSpyObj(
"swimlane",
[ "highlight", "highlightBottom" ]
["highlight", "highlightBottom"]
);
// domainObject, idPath, children, expanded
mockSwimlane.domainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability", "useCapability", "hasCapability" ]
["getId", "getCapability", "useCapability", "hasCapability"]
);
mockSwimlane.idPath = [ 'a', 'b' ];
mockSwimlane.children = [ {} ];
mockSwimlane.idPath = ['a', 'b'];
mockSwimlane.children = [{}];
mockSwimlane.expanded = true;
mockSwimlane.parent = {};
mockSwimlane.parent.idPath = ['a'];
mockSwimlane.parent.domainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability", "useCapability", "hasCapability" ]
["getId", "getCapability", "useCapability", "hasCapability"]
);
mockSwimlane.parent.children = [ mockSwimlane ];
mockSwimlane.parent.children = [mockSwimlane];
mockSwimlane.children[0].domainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability", "useCapability", "hasCapability" ]
["getId", "getCapability", "useCapability", "hasCapability"]
);
mockAction = jasmine.createSpyObj('action', ['perform']);
@@ -72,10 +72,10 @@ define(
mockOtherObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability", "useCapability", "hasCapability" ]
["getId", "getCapability", "useCapability", "hasCapability"]
);
mockActionCapability = jasmine.createSpyObj("action", ["perform", "getActions"]);
mockContext = jasmine.createSpyObj('context', [ 'getParent' ]);
mockContext = jasmine.createSpyObj('context', ['getParent']);
mockActionCapability.getActions.andReturn([mockAction]);
mockSwimlane.parent.domainObject.getId.andReturn('a');
@@ -148,7 +148,7 @@ define(
});
it("inserts into when highlighted", function () {
var testModel = { composition: [ 'c' ] };
var testModel = { composition: ['c'] };
mockSwimlane.highlight.andReturn(true);
handler.drop('d', mockOtherObject);
// Should have mutated
@@ -161,7 +161,7 @@ define(
});
it("inserts after as a peer when highlighted at the bottom", function () {
var testModel = { composition: [ 'x', 'b', 'y' ] };
var testModel = { composition: ['x', 'b', 'y'] };
mockSwimlane.highlightBottom.andReturn(true);
mockSwimlane.expanded = false;
handler.drop('d', mockOtherObject);
@@ -171,11 +171,11 @@ define(
// Run the mutator
mockSwimlane.parent.domainObject.useCapability.mostRecentCall
.args[1](testModel);
expect(testModel.composition).toEqual([ 'x', 'b', 'd', 'y']);
expect(testModel.composition).toEqual(['x', 'b', 'd', 'y']);
});
it("inserts into when highlighted at the bottom and expanded", function () {
var testModel = { composition: [ 'c' ] };
var testModel = { composition: ['c'] };
mockSwimlane.highlightBottom.andReturn(true);
mockSwimlane.expanded = true;
handler.drop('d', mockOtherObject);
@@ -185,11 +185,11 @@ define(
// Run the mutator
mockSwimlane.domainObject.useCapability.mostRecentCall
.args[1](testModel);
expect(testModel.composition).toEqual([ 'd', 'c' ]);
expect(testModel.composition).toEqual(['d', 'c']);
});
it("inserts after as a peer when highlighted at the bottom and childless", function () {
var testModel = { composition: [ 'x', 'b', 'y' ] };
var testModel = { composition: ['x', 'b', 'y'] };
mockSwimlane.highlightBottom.andReturn(true);
mockSwimlane.expanded = true;
mockSwimlane.children = [];
@@ -200,11 +200,11 @@ define(
// Run the mutator
mockSwimlane.parent.domainObject.useCapability.mostRecentCall
.args[1](testModel);
expect(testModel.composition).toEqual([ 'x', 'b', 'd', 'y']);
expect(testModel.composition).toEqual(['x', 'b', 'd', 'y']);
});
it("allows reordering within a parent", function () {
var testModel = { composition: [ 'x', 'b', 'y', 'd' ] };
var testModel = { composition: ['x', 'b', 'y', 'd'] };
mockSwimlane.highlightBottom.andReturn(true);
mockSwimlane.expanded = true;
@@ -221,7 +221,7 @@ define(
runs(function () {
mockSwimlane.parent.domainObject.useCapability.mostRecentCall
.args[1](testModel);
expect(testModel.composition).toEqual([ 'x', 'b', 'd', 'y']);
expect(testModel.composition).toEqual(['x', 'b', 'd', 'y']);
});
});

View File

@@ -42,16 +42,16 @@ define(
}
function makeMockDomainObject(id, composition) {
var mockDomainObject = jasmine.createSpyObj(
var mockDomainObj = jasmine.createSpyObj(
'domainObject-' + id,
['getId', 'getModel', 'getCapability', 'useCapability']
);
mockDomainObject.getId.andReturn(id);
mockDomainObject.getModel.andReturn({ composition: composition });
mockDomainObject.useCapability.andReturn(asPromise(false));
mockDomainObj.getId.andReturn(id);
mockDomainObj.getModel.andReturn({ composition: composition });
mockDomainObj.useCapability.andReturn(asPromise(false));
return mockDomainObject;
return mockDomainObj;
}
function subgraph(domainObject, objects) {
@@ -160,4 +160,4 @@ define(
});
}
);
);

View File

@@ -36,7 +36,9 @@ define(
testConfiguration;
function asPromise(v) {
return { then: function (cb) { cb(v); } };
return { then: function (cb) {
cb(v);
} };
}
beforeEach(function () {
@@ -218,4 +220,4 @@ define(
});
});
}
);
);

View File

@@ -57,11 +57,11 @@ define(
testAttrs = { mctSwimlaneDrop: "mockSwimlane" };
mockSwimlane = jasmine.createSpyObj(
"swimlane",
[ "allowDropIn", "allowDropAfter", "drop", "highlight", "highlightBottom" ]
["allowDropIn", "allowDropAfter", "drop", "highlight", "highlightBottom"]
);
mockElement[0] = jasmine.createSpyObj(
"realElement",
[ "getBoundingClientRect" ]
["getBoundingClientRect"]
);
mockElement[0].offsetHeight = TEST_HEIGHT;
mockElement[0].getBoundingClientRect.andReturn({ top: TEST_TOP });

View File

@@ -54,7 +54,7 @@ define(
function addDomainObject(id, children, capabilities) {
var mockDomainObject = jasmine.createSpyObj(
'object-' + id,
[ 'useCapability', 'hasCapability', 'getId' ]
['useCapability', 'hasCapability', 'getId']
);
mockDomainObject.getId.andReturn(id);
@@ -72,7 +72,7 @@ define(
}
beforeEach(function () {
mockQ = jasmine.createSpyObj('$q', [ 'when', 'all' ]);
mockQ = jasmine.createSpyObj('$q', ['when', 'all']);
mockCallback = jasmine.createSpy('callback');
mockDomainObjects = {};
testCompositions = {};
@@ -82,8 +82,12 @@ define(
mockQ.when.andCallFake(asPromise);
mockQ.all.andCallFake(function (values) {
var result = [];
function addResult(v) { result.push(v); }
function promiseResult(v) { asPromise(v).then(addResult); }
function addResult(v) {
result.push(v);
}
function promiseResult(v) {
asPromise(v).then(addResult);
}
values.forEach(promiseResult);
return asPromise(result);
});
@@ -152,4 +156,4 @@ define(
});
}
);
);