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

@@ -297,7 +297,7 @@ define([
],
"constants": [
{
"key":"editModeBlacklist",
"key": "editModeBlacklist",
"value": ["copy", "follow", "window", "link", "locate"]
},
{
@@ -315,7 +315,7 @@ define([
"transactionService"
]
}
],
]
}
});
});

View File

@@ -44,7 +44,7 @@ define(
CancelAction.prototype.perform = function () {
var domainObject = this.domainObject;
function returnToBrowse () {
function returnToBrowse() {
var parent;
//If the object existed already, navigate to refresh view

View File

@@ -70,7 +70,7 @@ define(
*/
EditAction.prototype.perform = function () {
var self = this;
function cancelEditing(){
function cancelEditing() {
self.domainObject.getCapability('editor').cancel();
self.navigationService.removeListener(cancelEditing);
}

View File

@@ -57,10 +57,10 @@ define(
});
}
function showDialog(type) {
function showDialog(objType) {
// Create a dialog object to generate the form structure, etc.
var dialog =
new PropertiesDialog(type, domainObject.getModel());
new PropertiesDialog(objType, domainObject.getModel());
// Show the dialog
return dialogService.getUserInput(

View File

@@ -48,7 +48,7 @@ define(
SaveAction.prototype.perform = function () {
var domainObject = this.domainObject;
function resolveWith(object){
function resolveWith(object) {
return function () {
return object;
};

View File

@@ -42,7 +42,7 @@ define(
context
) {
this.domainObject = (context || {}).domainObject;
this.injectObjectService = function(){
this.injectObjectService = function () {
this.objectService = $injector.get("objectService");
};
this.policyService = policyService;
@@ -65,7 +65,7 @@ define(
/**
* @private
*/
SaveAsAction.prototype.getObjectService = function(){
SaveAsAction.prototype.getObjectService = function () {
// Lazily acquire object service (avoids cyclical dependency)
if (!this.objectService) {
this.injectObjectService();
@@ -73,7 +73,7 @@ define(
return this.objectService;
};
function resolveWith(object){
function resolveWith(object) {
return function () {
return object;
};
@@ -116,13 +116,13 @@ define(
).then(wizard.populateObjectFromInput.bind(wizard));
}
function fetchObject(objectId){
return self.getObjectService().getObjects([objectId]).then(function(objects){
function fetchObject(objectId) {
return self.getObjectService().getObjects([objectId]).then(function (objects) {
return objects[objectId];
});
}
function getParent(object){
function getParent(object) {
return fetchObject(object.getModel().location);
}

View File

@@ -52,11 +52,11 @@ define(
this.domainObject.getCapability('status').set('editing', true);
};
function isEditContextRoot (domainObject) {
function isEditContextRoot(domainObject) {
return domainObject.getCapability('status').get('editing');
}
function isEditing (domainObject) {
function isEditing(domainObject) {
return isEditContextRoot(domainObject) ||
domainObject.hasCapability('context') &&
isEditing(domainObject.getCapability('context').getParent());
@@ -87,7 +87,7 @@ define(
*/
EditorCapability.prototype.save = function () {
var domainObject = this.domainObject;
return this.transactionService.commit().then(function() {
return this.transactionService.commit().then(function () {
domainObject.getCapability('status').set('editing', false);
});
};
@@ -101,7 +101,7 @@ define(
*/
EditorCapability.prototype.cancel = function () {
var domainObject = this.domainObject;
return this.transactionService.cancel().then(function(){
return this.transactionService.cancel().then(function () {
domainObject.getCapability("status").set("editing", false);
return domainObject;
});

View File

@@ -60,14 +60,14 @@ define(
var self = this;
function onCommit() {
return self.persistenceCapability.persist().then(function(result) {
return self.persistenceCapability.persist().then(function (result) {
self.persistPending = false;
return result;
});
}
function onCancel() {
return self.persistenceCapability.refresh().then(function(result) {
return self.persistenceCapability.refresh().then(function (result) {
self.persistPending = false;
return result;
});

View File

@@ -59,7 +59,7 @@ define(
$scope.$watch('domainObject', setViewForDomainObject);
$scope.doAction = function (action){
$scope.doAction = function (action) {
return $scope[action] && $scope[action]();
};
}
@@ -74,8 +74,8 @@ define(
var navigatedObject = this.scope.domainObject,
policyMessage;
this.policyService.allow("navigation", navigatedObject, undefined, function(message) {
policyMessage = message;
this.policyService.allow("navigation", navigatedObject, undefined, function (message) {
policyMessage = message;
});
return policyMessage;

View File

@@ -30,7 +30,7 @@ define(
* @constructor
*/
function ElementsController($scope) {
function filterBy(text){
function filterBy(text) {
if (typeof text === 'undefined') {
return $scope.searchText;
} else {

View File

@@ -45,7 +45,7 @@ define(
count = 0,
type, views;
if (!domainObject){
if (!domainObject) {
return count;
}

View File

@@ -56,7 +56,7 @@ define(
actionMetadata = action.getMetadata ? action.getMetadata() : {};
if (navigatedObject.hasCapability("editor") && navigatedObject.getCapability("editor").isEditContextRoot()) {
if (selectedObject.hasCapability("editor") && selectedObject.getCapability("editor").inEditContext()){
if (selectedObject.hasCapability("editor") && selectedObject.getCapability("editor").inEditContext()) {
return this.editModeBlacklist.indexOf(actionMetadata.key) === -1;
} else {
//Target is in the context menu

View File

@@ -38,7 +38,7 @@ define(
/**
* @private
*/
EditNavigationPolicy.prototype.isDirty = function(domainObject) {
EditNavigationPolicy.prototype.isDirty = function (domainObject) {
var navigatedObject = domainObject,
editorCapability = navigatedObject &&
navigatedObject.getCapability("editor");

View File

@@ -115,7 +115,7 @@ define(
// Ensure existing watches are released
this.destroy();
function setEditing(){
function setEditing() {
scope.viewObjectTemplate = 'edit-object';
}
@@ -124,15 +124,15 @@ define(
* editable then change the view and inspector regions
* object representation accordingly
*/
this.listenHandle = this.domainObject.getCapability('status').listen(function(statuses){
if (statuses.indexOf('editing') !== -1){
this.listenHandle = this.domainObject.getCapability('status').listen(function (statuses) {
if (statuses.indexOf('editing') !== -1) {
setEditing();
} else {
delete scope.viewObjectTemplate;
}
});
if (representedObject.hasCapability('editor') && representedObject.getCapability('editor').isEditContextRoot()){
if (representedObject.hasCapability('editor') && representedObject.getCapability('editor').isEditContextRoot()) {
setEditing();
}
};

View File

@@ -24,8 +24,12 @@ define(
function () {
// Utility functions for reducing truth arrays
function and(a, b) { return a && b; }
function or(a, b) { return a || b; }
function and(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
// selection which have this property.
function updateProperties(property, value) {
function updateProperties(property, val) {
var changed = false;
// Update property in a selected element
@@ -229,12 +233,12 @@ define(
// Check if this is a setter, or just assignable
if (typeof selected[property] === 'function') {
changed =
changed || (selected[property]() !== value);
selected[property](value);
changed || (selected[property]() !== val);
selected[property](val);
} else {
changed =
changed || (selected[property] !== value);
selected[property] = value;
changed || (selected[property] !== val);
selected[property] = val;
}
}
}

View File

@@ -133,11 +133,11 @@ define(
self = this;
// Initialize toolbar (expose object to parent scope)
function initialize(definition) {
function initialize(def) {
// If we have been asked to expose toolbar state...
if (self.attrs.toolbar) {
// Initialize toolbar object
self.toolbar = new EditToolbar(definition, self.commit);
self.toolbar = new EditToolbar(def, self.commit);
// Ensure toolbar state is exposed
self.exposeToolbar();
}

View File

@@ -22,7 +22,7 @@
/*global define*/
define(
[],
function() {
function () {
/**
* Implements an application-wide transaction state. Once a
* transaction is started, calls to
@@ -103,7 +103,7 @@ define(
this.$log.error("Error committing transaction.");
}
}
return this.$q.all(promises).then( function () {
return this.$q.all(promises).then(function () {
self.transaction = false;
self.onCommits = [];
@@ -145,4 +145,4 @@ define(
};
return TransactionService;
});
});

View File

@@ -44,15 +44,15 @@ define(
beforeEach(function () {
mockLocation = jasmine.createSpyObj(
"$location",
[ "path" ]
["path"]
);
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getCapability", "hasCapability" ]
["getCapability", "hasCapability"]
);
mockEditorCapability = jasmine.createSpyObj(
"editor",
[ "save", "cancel" ]
["save", "cancel"]
);
mockUrlService = jasmine.createSpyObj(
"urlService",
@@ -100,4 +100,4 @@ define(
});
});
}
);
);

View File

@@ -38,23 +38,23 @@ define(
beforeEach(function () {
mockLocation = jasmine.createSpyObj(
"$location",
[ "path" ]
["path"]
);
mockNavigationService = jasmine.createSpyObj(
"navigationService",
[ "setNavigation", "getNavigation", "addListener", "removeListener" ]
["setNavigation", "getNavigation", "addListener", "removeListener"]
);
mockLog = jasmine.createSpyObj(
"$log",
[ "error", "warn", "info", "debug" ]
["error", "warn", "info", "debug"]
);
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability", "hasCapability", "useCapability" ]
["getId", "getModel", "getCapability", "hasCapability", "useCapability"]
);
mockType = jasmine.createSpyObj(
"type",
[ "hasFeature" ]
["hasFeature"]
);
mockEditor = jasmine.createSpyObj(
"editorCapability",
@@ -66,7 +66,7 @@ define(
editor: mockEditor
};
mockDomainObject.getCapability.andCallFake( function (name) {
mockDomainObject.getCapability.andCallFake(function (name) {
return capabilities[name];
});
mockDomainObject.hasCapability.andReturn(true);
@@ -112,4 +112,4 @@ define(
});
}
);
);

View File

@@ -51,7 +51,7 @@ define(
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockQ = { when: mockPromise };
mockParent = {
@@ -65,10 +65,10 @@ define(
return capabilities[k].invoke(v);
}
};
mockContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockComposition = jasmine.createSpyObj("composition", [ "invoke", "add" ]);
mockType = jasmine.createSpyObj("type", [ "hasFeature", "getKey" ]);
mockActionCapability = jasmine.createSpyObj("actionCapability", [ "getActions"]);
mockContext = jasmine.createSpyObj("context", ["getParent"]);
mockComposition = jasmine.createSpyObj("composition", ["invoke", "add"]);
mockType = jasmine.createSpyObj("type", ["hasFeature", "getKey"]);
mockActionCapability = jasmine.createSpyObj("actionCapability", ["getActions"]);
mockEditAction = jasmine.createSpyObj("editAction", ["perform"]);
mockDomainObject.getId.andReturn("test");
@@ -86,7 +86,7 @@ define(
type: mockType
};
model = {
composition: [ "a", "b", "c" ]
composition: ["a", "b", "c"]
};
actionContext = {

View File

@@ -38,7 +38,9 @@ define(
beforeEach(function () {
capabilities = {
type: {
getProperties: function () { return []; },
getProperties: function () {
return [];
},
hasFeature: jasmine.createSpy('hasFeature')
},
mutation: jasmine.createSpy("mutation")
@@ -46,11 +48,21 @@ define(
model = {};
input = {};
object = {
getId: function () { return 'test-id'; },
getCapability: function (k) { return capabilities[k]; },
getModel: function () { return model; },
useCapability: function (k, v) { return capabilities[k](v); },
hasCapability: function () { return true; }
getId: function () {
return 'test-id';
},
getCapability: function (k) {
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 };
dialogService = {

View File

@@ -30,14 +30,22 @@ define(
beforeEach(function () {
type = {
getProperties: function () { return properties; }
getProperties: function () {
return properties;
}
};
model = { x: "initial value" };
properties = ["x", "y", "z"].map(function (k) {
return {
getValue: function (model) { return model[k]; },
setValue: function (model, v) { model[k] = v; },
getDefinition: function () { return { control: 'textfield '}; }
getValue: function (m) {
return m[k];
},
setValue: function (m, v) {
m[k] = v;
},
getDefinition: function () {
return { control: 'textfield '};
}
};
});

View File

@@ -54,19 +54,19 @@ define(
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockChildObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockGrandchildObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockRootObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockQ = { when: mockPromise };
mockParent = {
@@ -80,12 +80,12 @@ define(
return capabilities[k].invoke(v);
}
};
mockContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockChildContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockGrandchildContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockRootContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockMutation = jasmine.createSpyObj("mutation", [ "invoke" ]);
mockType = jasmine.createSpyObj("type", [ "hasFeature" ]);
mockContext = jasmine.createSpyObj("context", ["getParent"]);
mockChildContext = jasmine.createSpyObj("context", ["getParent"]);
mockGrandchildContext = jasmine.createSpyObj("context", ["getParent"]);
mockRootContext = jasmine.createSpyObj("context", ["getParent"]);
mockMutation = jasmine.createSpyObj("mutation", ["invoke"]);
mockType = jasmine.createSpyObj("type", ["hasFeature"]);
mockNavigationService = jasmine.createSpyObj(
"navigationService",
[
@@ -96,8 +96,8 @@ define(
]
);
mockNavigationService.getNavigation.andReturn(mockDomainObject);
mockDomainObject.getId.andReturn("test");
mockDomainObject.getCapability.andReturn(mockContext);
mockContext.getParent.andReturn(mockParent);
@@ -108,7 +108,7 @@ define(
type: mockType
};
model = {
composition: [ "a", "test", "b" ]
composition: ["a", "test", "b"]
};
actionContext = { domainObject: mockDomainObject };
@@ -150,56 +150,56 @@ define(
// mock domain object's id.
expect(result.composition).toEqual(["a", "b"]);
});
it("removes parent of object currently navigated to", function () {
// Navigates to child object
mockNavigationService.getNavigation.andReturn(mockChildObject);
// Test is id of object being removed
// Child object has different id
mockDomainObject.getId.andReturn("test");
mockChildObject.getId.andReturn("not test");
// Sets context for the child and domainObject
mockDomainObject.getCapability.andReturn(mockContext);
mockChildObject.getCapability.andReturn(mockChildContext);
// Parents of child and domainObject are set
mockContext.getParent.andReturn(mockParent);
mockChildContext.getParent.andReturn(mockDomainObject);
mockType.hasFeature.andReturn(true);
action.perform();
// Expects navigation to parent of domainObject (removed object)
expect(mockNavigationService.setNavigation).toHaveBeenCalledWith(mockParent);
});
it("checks if removing object not in ascendent path (reaches ROOT)", function () {
// Navigates to grandchild of ROOT
mockNavigationService.getNavigation.andReturn(mockGrandchildObject);
// domainObject (grandparent) is set as ROOT, child and grandchild
// are set objects not being removed
mockDomainObject.getId.andReturn("test 1");
mockRootObject.getId.andReturn("ROOT");
mockChildObject.getId.andReturn("not test 2");
mockGrandchildObject.getId.andReturn("not test 3");
// Sets context for the grandchild, child, and domainObject
mockRootObject.getCapability.andReturn(mockRootContext);
mockChildObject.getCapability.andReturn(mockChildContext);
mockGrandchildObject.getCapability.andReturn(mockGrandchildContext);
// Parents of grandchild and child are set
mockChildContext.getParent.andReturn(mockRootObject);
mockGrandchildContext.getParent.andReturn(mockChildObject);
mockType.hasFeature.andReturn(true);
action.perform();
// Expects no navigation to occur
expect(mockNavigationService.setNavigation).not.toHaveBeenCalled();
});

View File

@@ -52,11 +52,11 @@ define(
);
mockEditorCapability = jasmine.createSpyObj(
"editor",
[ "save", "cancel", "isEditContextRoot" ]
["save", "cancel", "isEditContextRoot"]
);
mockActionCapability = jasmine.createSpyObj(
"actionCapability",
[ "perform"]
["perform"]
);
capabilities.editor = mockEditorCapability;
capabilities.action = mockActionCapability;
@@ -90,7 +90,7 @@ define(
function () {
mockDomainObject.getModel.andReturn({persisted: undefined});
expect(SaveAction.appliesTo(actionContext)).toBe(false);
});
});
it("uses the editor capability to save the object",
function () {
@@ -106,4 +106,4 @@ define(
});
}
);
);

View File

@@ -38,7 +38,7 @@ define(
capabilities = {},
action;
function noop () {}
function noop() {}
function mockPromise(value) {
return (value || {}).then ? value :
@@ -49,7 +49,7 @@ define(
catch: function (callback) {
return mockPromise(callback(value));
}
} ;
} ;
}
beforeEach(function () {
@@ -78,7 +78,7 @@ define(
mockEditorCapability = jasmine.createSpyObj(
"editor",
[ "save", "cancel", "isEditContextRoot" ]
["save", "cancel", "isEditContextRoot"]
);
mockEditorCapability.cancel.andReturn(mockPromise(undefined));
mockEditorCapability.save.andReturn(mockPromise(true));
@@ -130,7 +130,7 @@ define(
action.createWizard.andReturn({
getFormStructure: noop,
getInitialFormValue: noop,
populateObjectFromInput: function() {
populateObjectFromInput: function () {
return mockDomainObject;
}
});

View File

@@ -82,7 +82,7 @@ define(
status: mockStatusCapability
};
mockDomainObject.hasCapability.andCallFake(function(name) {
mockDomainObject.hasCapability.andCallFake(function (name) {
return capabilities[name] !== undefined;
});
@@ -126,8 +126,8 @@ define(
expect(capability.inEditContext()).toBe(true);
});
describe("save", function() {
beforeEach(function() {
describe("save", function () {
beforeEach(function () {
capability.edit();
capability.save();
});
@@ -139,8 +139,8 @@ define(
});
});
describe("cancel", function() {
beforeEach(function() {
describe("cancel", function () {
beforeEach(function () {
capability.edit();
capability.cancel();
});
@@ -152,10 +152,10 @@ define(
});
});
describe("dirty", function() {
describe("dirty", function () {
var model = {};
beforeEach(function() {
beforeEach(function () {
mockDomainObject.getModel.andReturn(model);
capability.edit();
capability.cancel();
@@ -170,4 +170,4 @@ define(
});
});
}
);
);

View File

@@ -33,22 +33,22 @@ define(
mockCapabilityService,
provider;
beforeEach(function() {
beforeEach(function () {
mockQ = {};
mockTransactionService = {};
mockCapabilityService = jasmine.createSpyObj("capabilityService", ["getCapabilities"]);
mockCapabilityService.getCapabilities.andReturn({
persistence: function() {}
persistence: function () {}
});
provider = new TransactionCapabilityDecorator(mockQ, mockTransactionService, mockCapabilityService);
});
it("decorates the persistence capability", function() {
it("decorates the persistence capability", function () {
var capabilities = provider.getCapabilities();
expect(capabilities.persistence({}) instanceof TransactionalPersistenceCapability).toBe(true);
});
});
}
);
);

View File

@@ -29,7 +29,7 @@ define(
function fastPromise(val) {
return {
then: function(callback) {
then: function (callback) {
return callback(val);
}
};
@@ -42,7 +42,7 @@ define(
mockDomainObject,
capability;
beforeEach(function() {
beforeEach(function () {
mockQ = jasmine.createSpyObj("$q", ["when"]);
mockQ.when.andCallFake(function (val) {
return fastPromise(val);
@@ -61,14 +61,14 @@ define(
});
it("if no transaction is active, passes through to persistence" +
" provider", function() {
" provider", function () {
mockTransactionService.isActive.andReturn(false);
capability.persist();
expect(mockPersistence.persist).toHaveBeenCalled();
});
it("if transaction is active, persist and cancel calls are" +
" queued", function() {
" queued", function () {
mockTransactionService.isActive.andReturn(true);
capability.persist();
expect(mockTransactionService.addToTransaction).toHaveBeenCalled();
@@ -78,7 +78,7 @@ define(
expect(mockPersistence.refresh).toHaveBeenCalled();
});
it("persist call is only added to transaction once", function() {
it("persist call is only added to transaction once", function () {
mockTransactionService.isActive.andReturn(true);
capability.persist();
expect(mockTransactionService.addToTransaction).toHaveBeenCalled();
@@ -89,4 +89,4 @@ define(
});
}
);
);

View File

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

View File

@@ -52,15 +52,15 @@ define(
);
mockScope = jasmine.createSpyObj(
"$scope",
[ "$on", "$watch" ]
["$on", "$watch"]
);
mockObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability", "hasCapability", "useCapability" ]
["getId", "getModel", "getCapability", "hasCapability", "useCapability"]
);
mockType = jasmine.createSpyObj(
"type",
[ "hasFeature" ]
["hasFeature"]
);
mockStatusCapability = jasmine.createSpyObj('statusCapability',
["get"]
@@ -99,8 +99,8 @@ define(
expect(controller.getUnloadWarning()).toBeUndefined();
// Override the policy service to prevent navigation
mockPolicyService.allow.andCallFake(function(category, object, context, callback){
callback(errorMessage);
mockPolicyService.allow.andCallFake(function (category, object, context, callback) {
callback(errorMessage);
});
// Should have some warning message here now

View File

@@ -34,11 +34,11 @@ define(
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getCapability' ]
['getId', 'getCapability']
);
mockContext = jasmine.createSpyObj(
'context',
[ 'getTrueRoot' ]
['getTrueRoot']
);
mockDomainObject.getId.andReturn('test-id');
@@ -110,4 +110,4 @@ define(
});
});
}
);
);

View File

@@ -34,8 +34,8 @@ define(
controller = new ElementsController(mockScope);
});
function getModel (model) {
return function() {
function getModel(model) {
return function () {
return model;
};
}

View File

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

View File

@@ -58,10 +58,10 @@ define(
mockEditAction = jasmine.createSpyObj('edit', ['getMetadata']);
mockPropertiesAction = jasmine.createSpyObj('edit', ['getMetadata']);
mockDomainObject.getCapability.andCallFake(function(capability){
mockDomainObject.getCapability.andCallFake(function (capability) {
return capabilities[capability];
});
mockDomainObject.hasCapability.andCallFake(function(capability){
mockDomainObject.hasCapability.andCallFake(function (capability) {
return !!capabilities[capability];
});
@@ -88,42 +88,42 @@ define(
});
it("allows the edit action when there are editable views", function () {
testViews = [ editableView ];
testViews = [editableView];
expect(policy.allow(mockEditAction, testContext)).toBe(true);
});
it("allows the edit properties action when there are no editable views", function () {
testViews = [ nonEditableView, nonEditableView ];
testViews = [nonEditableView, nonEditableView];
expect(policy.allow(mockPropertiesAction, testContext)).toBe(true);
});
it("disallows the edit action when there are no editable views", function () {
testViews = [ nonEditableView, nonEditableView ];
testViews = [nonEditableView, nonEditableView];
expect(policy.allow(mockEditAction, testContext)).toBe(false);
});
it("disallows the edit properties action when there are" +
" editable views", function () {
testViews = [ editableView ];
testViews = [editableView];
expect(policy.allow(mockPropertiesAction, testContext)).toBe(false);
});
it("disallows the edit action when object is already being" +
" edited", function () {
testViews = [ editableView ];
testViews = [editableView];
mockEditorCapability.isEditContextRoot.andReturn(true);
expect(policy.allow(mockEditAction, testContext)).toBe(false);
});
it("allows editing of panels in plot view", function () {
testViews = [ plotView ];
testViews = [plotView];
mockTypeCapability.getKey.andReturn('telemetry.panel');
expect(policy.allow(mockEditAction, testContext)).toBe(true);
});
it("disallows editing of plot view when object not a panel type", function () {
testViews = [ plotView ];
testViews = [plotView];
mockTypeCapability.getKey.andReturn('something.else');
expect(policy.allow(mockEditAction, testContext)).toBe(false);
@@ -131,10 +131,10 @@ define(
it("allows the edit properties outside of the 'view-control' category", function () {
testViews = [ nonEditableView ];
testViews = [nonEditableView];
testContext.category = "something-else";
expect(policy.allow(mockPropertiesAction, testContext)).toBe(true);
});
});
}
);
);

View File

@@ -61,12 +61,12 @@ define(
policy = new EditContextualActionPolicy(navigationService, editModeBlacklist, nonEditContextBlacklist);
});
it('Allows all actions when navigated object not in edit mode', function() {
it('Allows all actions when navigated object not in edit mode', function () {
expect(policy.allow(mockAction, context)).toBe(true);
});
it('Allows "window" action when navigated object in edit mode,' +
' but selected object not in edit mode ', function() {
' but selected object not in edit mode ', function () {
navigatedObject.hasCapability.andReturn(true);
mockEditorCapability.isEditContextRoot.andReturn(true);
metadata.key = "window";
@@ -75,7 +75,7 @@ define(
it('Allows "remove" action when navigated object in edit mode,' +
' and selected object not editable, but its parent is.',
function() {
function () {
var mockParent = jasmine.createSpyObj("parentObject", ["hasCapability"]),
mockContextCapability = jasmine.createSpyObj("contextCapability", ["getParent"]);
@@ -93,10 +93,10 @@ define(
metadata.key = "remove";
expect(policy.allow(mockAction, context)).toBe(true);
});
});
it('Disallows "move" action when navigated object in edit mode,' +
' but selected object not in edit mode ', function() {
' but selected object not in edit mode ', function () {
navigatedObject.hasCapability.andReturn(true);
mockEditorCapability.isEditContextRoot.andReturn(true);
mockEditorCapability.inEditContext.andReturn(false);
@@ -105,7 +105,7 @@ define(
});
it('Disallows copy action when navigated object and' +
' selected object in edit mode', function() {
' selected object in edit mode', function () {
navigatedObject.hasCapability.andReturn(true);
mockDomainObject.hasCapability.andReturn(true);
mockEditorCapability.isEditContextRoot.andReturn(true);

View File

@@ -36,7 +36,7 @@ define(
['hasCapability', 'getCapability']
);
mockDomainObject.getCapability.andReturn({
inEditContext: function () {
inEditContext: function () {
return true;
}
});
@@ -76,4 +76,4 @@ define(
});
});
}
);
);

View File

@@ -68,7 +68,7 @@ define(
mockDomainObject.getModel.andReturn({});
mockDomainObject.hasCapability.andReturn(true);
mockDomainObject.useCapability.andReturn(true);
mockDomainObject.getCapability.andCallFake(function(capability){
mockDomainObject.getCapability.andCallFake(function (capability) {
return mockCapabilities[capability];
});

View File

@@ -34,13 +34,13 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
'$scope',
[ '$on', '$watch', '$watchCollection', "commit" ]
['$on', '$watch', '$watchCollection', "commit"]
);
mockElement = {};
testAttrs = { toolbar: 'testToolbar' };
mockScope.$parent = jasmine.createSpyObj(
'$parent',
[ '$watch', '$watchCollection' ]
['$watch', '$watchCollection']
);
mockUnwatch = jasmine.createSpy('unwatch');
@@ -92,7 +92,7 @@ define(
// Provide a view which has a toolbar
representer.represent({
toolbar: { sections: [ { items: [ { property: 'k' } ] } ] }
toolbar: { sections: [{ items: [{ property: 'k' }] }] }
});
// Update the selection
@@ -120,7 +120,7 @@ define(
// Provide a view which has a toolbar
representer.represent({
toolbar: { sections: [ { items: [ { property: 'k' } ] } ] }
toolbar: { sections: [{ items: [{ property: 'k' }] }] }
});
// Update the selection
@@ -140,4 +140,4 @@ define(
});
}
);
);

View File

@@ -76,7 +76,7 @@ define(
it("provides properties from the original structure", function () {
expect(
new EditToolbar(testStructure, [ testABC ])
new EditToolbar(testStructure, [testABC])
.getStructure()
.sections[0]
.items[1]
@@ -87,7 +87,7 @@ define(
// This is needed by mct-toolbar
it("adds keys to form structure", function () {
expect(
new EditToolbar(testStructure, [ testABC ])
new EditToolbar(testStructure, [testABC])
.getStructure()
.sections[0]
.items[1]
@@ -97,20 +97,20 @@ define(
it("marks empty sections as hidden", function () {
// Verify that all sections are included when applicable...
toolbar.setSelection([ testABCXYZ ]);
toolbar.setSelection([testABCXYZ]);
expect(toolbar.getStructure().sections.map(getVisibility))
.toEqual([ true, true, false ]);
.toEqual([true, true, false]);
// ...but omitted when only some are applicable
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
expect(toolbar.getStructure().sections.map(getVisibility))
.toEqual([ true, false, false ]);
.toEqual([true, false, false]);
});
it("reads properties from selections", function () {
var structure, state;
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
structure = toolbar.getStructure();
state = toolbar.getState();
@@ -126,9 +126,11 @@ define(
it("reads properties from getters", function () {
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();
state = toolbar.getState();
@@ -137,7 +139,7 @@ define(
});
it("sets properties on update", function () {
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
toolbar.updateState(
toolbar.getStructure().sections[0].items[0].key,
"new value"
@@ -151,7 +153,7 @@ define(
testABC.a = jasmine.createSpy('a');
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
structure = toolbar.getStructure();
toolbar.updateState(
@@ -165,7 +167,7 @@ define(
it("provides a return value describing update status", function () {
// Should return true if actually updated, otherwise false
var key;
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
key = toolbar.getStructure().sections[0].items[0].key;
expect(toolbar.updateState(key, testABC.a)).toBeFalsy();
expect(toolbar.updateState(key, "new value")).toBeTruthy();
@@ -173,35 +175,35 @@ define(
it("removes inapplicable items", function () {
// First, verify with all items
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
expect(toolbar.getStructure().sections[0].items.map(getVisibility))
.toEqual([ true, true, true ]);
.toEqual([true, true, true]);
// Then, try with some items omitted
toolbar.setSelection([ testABC, testAB ]);
toolbar.setSelection([testABC, testAB]);
expect(toolbar.getStructure().sections[0].items.map(getVisibility))
.toEqual([ true, true, false ]);
.toEqual([true, true, false]);
});
it("removes inconsistent states", function () {
// Only two of three values match among these selections
toolbar.setSelection([ testABC, testABC2 ]);
toolbar.setSelection([testABC, testABC2]);
expect(toolbar.getStructure().sections[0].items.map(getVisibility))
.toEqual([ false, true, true ]);
.toEqual([false, true, true]);
});
it("allows inclusive items", function () {
// One inclusive item is in the set, property 'x' of the
// second section; make sure items are pruned down
// when only some of the selection has x,y,z properties
toolbar.setSelection([ testABC, testABCXYZ ]);
toolbar.setSelection([testABC, testABCXYZ]);
expect(toolbar.getStructure().sections[1].items.map(getVisibility))
.toEqual([ true, false, false ]);
.toEqual([true, false, false]);
});
it("removes inclusive items when there are no matches", function () {
toolbar.setSelection([ testABCYZ ]);
toolbar.setSelection([testABCYZ]);
expect(toolbar.getStructure().sections[1].items.map(getVisibility))
.toEqual([ false, true, true ]);
.toEqual([false, true, true]);
});
it("adds click functions when a method is specified", function () {

View File

@@ -30,7 +30,7 @@ define(
mockLog,
transactionService;
function fastPromise (val) {
function fastPromise(val) {
return {
then: function (callback) {
return fastPromise(callback(val));
@@ -75,8 +75,8 @@ define(
describe("commit", function () {
var onCommits;
beforeEach(function() {
onCommits = [0, 1, 2].map(function(val) {
beforeEach(function () {
onCommits = [0, 1, 2].map(function (val) {
return jasmine.createSpy("onCommit" + val);
});
@@ -87,7 +87,7 @@ define(
it("commit calls all queued commit functions", function () {
expect(transactionService.onCommits.length).toBe(3);
transactionService.commit();
onCommits.forEach( function (spy) {
onCommits.forEach(function (spy) {
expect(spy).toHaveBeenCalled();
});
});
@@ -104,8 +104,8 @@ define(
describe("cancel", function () {
var onCancels;
beforeEach(function() {
onCancels = [0, 1, 2].map(function(val) {
beforeEach(function () {
onCancels = [0, 1, 2].map(function (val) {
return jasmine.createSpy("onCancel" + val);
});
@@ -118,7 +118,7 @@ define(
it("cancel calls all queued cancel functions", function () {
expect(transactionService.onCancels.length).toBe(3);
transactionService.cancel();
onCancels.forEach( function (spy) {
onCancels.forEach(function (spy) {
expect(spy).toHaveBeenCalled();
});
});
@@ -134,4 +134,4 @@ define(
});
}
);
);