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:
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' ]);
|
||||||
|
|||||||
4
main.js
4
main.js
@@ -41,10 +41,10 @@ requirejs.config({
|
|||||||
"exports": "angular"
|
"exports": "angular"
|
||||||
},
|
},
|
||||||
"angular-route": {
|
"angular-route": {
|
||||||
"deps": [ "angular" ]
|
"deps": ["angular"]
|
||||||
},
|
},
|
||||||
"moment-duration-format": {
|
"moment-duration-format": {
|
||||||
"deps": [ "moment" ]
|
"deps": ["moment"]
|
||||||
},
|
},
|
||||||
"screenfull": {
|
"screenfull": {
|
||||||
"exports": "screenfull"
|
"exports": "screenfull"
|
||||||
|
|||||||
@@ -80,12 +80,12 @@ define(
|
|||||||
function setNavigation(domainObject) {
|
function setNavigation(domainObject) {
|
||||||
var navigationAllowed = true;
|
var navigationAllowed = true;
|
||||||
|
|
||||||
if (domainObject === $scope.navigatedObject){
|
if (domainObject === $scope.navigatedObject) {
|
||||||
//do nothing;
|
//do nothing;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
policyService.allow("navigation", $scope.navigatedObject, domainObject, function(message){
|
policyService.allow("navigation", $scope.navigatedObject, domainObject, function (message) {
|
||||||
navigationAllowed = $window.confirm(message + "\r\n\r\n" +
|
navigationAllowed = $window.confirm(message + "\r\n\r\n" +
|
||||||
" Are you sure you want to continue?");
|
" Are you sure you want to continue?");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ define(
|
|||||||
$scope.$watch('domainObject', setViewForDomainObject);
|
$scope.$watch('domainObject', setViewForDomainObject);
|
||||||
$scope.$watch('representation.selected.key', updateQueryParam);
|
$scope.$watch('representation.selected.key', updateQueryParam);
|
||||||
|
|
||||||
$scope.doAction = function (action){
|
$scope.doAction = function (action) {
|
||||||
return $scope[action] && $scope[action]();
|
return $scope[action] && $scope[action]();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ define(
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
InspectorRegion.prototype.buildRegion = function() {
|
InspectorRegion.prototype.buildRegion = function () {
|
||||||
var metadataRegion = {
|
var metadataRegion = {
|
||||||
name: 'metadata',
|
name: 'metadata',
|
||||||
title: 'Metadata Region',
|
title: 'Metadata Region',
|
||||||
|
|||||||
@@ -81,13 +81,13 @@ define(
|
|||||||
|
|
||||||
newModel.type = this.type.getKey();
|
newModel.type = this.type.getKey();
|
||||||
newObject = parentObject.getCapability('instantiation').instantiate(newModel);
|
newObject = parentObject.getCapability('instantiation').instantiate(newModel);
|
||||||
newObject.useCapability('mutation', function(model){
|
newObject.useCapability('mutation', function (model) {
|
||||||
model.location = parentObject.getId();
|
model.location = parentObject.getId();
|
||||||
});
|
});
|
||||||
|
|
||||||
wizard = new CreateWizard(newObject, this.parent, this.policyService);
|
wizard = new CreateWizard(newObject, this.parent, this.policyService);
|
||||||
|
|
||||||
function populateObjectFromInput (formValue) {
|
function populateObjectFromInput(formValue) {
|
||||||
return wizard.populateObjectFromInput(formValue, newObject);
|
return wizard.populateObjectFromInput(formValue, newObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ define(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addToParent (populatedObject) {
|
function addToParent(populatedObject) {
|
||||||
parentObject.getCapability('composition').add(populatedObject);
|
parentObject.getCapability('composition').add(populatedObject);
|
||||||
return persistAndReturn(parentObject);
|
return persistAndReturn(parentObject);
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ define(
|
|||||||
* @returns {AddActionMetadata} metadata about this action
|
* @returns {AddActionMetadata} metadata about this action
|
||||||
*/
|
*/
|
||||||
AddAction.prototype.getMetadata = function () {
|
AddAction.prototype.getMetadata = function () {
|
||||||
return this.metadata;
|
return this.metadata;
|
||||||
};
|
};
|
||||||
|
|
||||||
return AddAction;
|
return AddAction;
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ define(
|
|||||||
return editorCapability.save();
|
return editorCapability.save();
|
||||||
}, function () {
|
}, function () {
|
||||||
return editorCapability.cancel();
|
return editorCapability.cancel();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ define(
|
|||||||
* @returns {CreateActionMetadata} metadata about this action
|
* @returns {CreateActionMetadata} metadata about this action
|
||||||
*/
|
*/
|
||||||
CreateAction.prototype.getMetadata = function () {
|
CreateAction.prototype.getMetadata = function () {
|
||||||
return this.metadata;
|
return this.metadata;
|
||||||
};
|
};
|
||||||
|
|
||||||
return CreateAction;
|
return CreateAction;
|
||||||
|
|||||||
@@ -111,12 +111,12 @@ define(
|
|||||||
* @param formValue
|
* @param formValue
|
||||||
* @returns {DomainObject}
|
* @returns {DomainObject}
|
||||||
*/
|
*/
|
||||||
CreateWizard.prototype.populateObjectFromInput = function(formValue) {
|
CreateWizard.prototype.populateObjectFromInput = function (formValue) {
|
||||||
var parent = this.getLocation(formValue),
|
var parent = this.getLocation(formValue),
|
||||||
formModel = this.createModel(formValue);
|
formModel = this.createModel(formValue);
|
||||||
|
|
||||||
formModel.location = parent.getId();
|
formModel.location = parent.getId();
|
||||||
this.domainObject.useCapability("mutation", function(){
|
this.domainObject.useCapability("mutation", function () {
|
||||||
return formModel;
|
return formModel;
|
||||||
});
|
});
|
||||||
return this.domainObject;
|
return this.domainObject;
|
||||||
|
|||||||
@@ -50,14 +50,14 @@ define(
|
|||||||
$scope.rootObject =
|
$scope.rootObject =
|
||||||
(context && context.getRoot()) || $scope.rootObject;
|
(context && context.getRoot()) || $scope.rootObject;
|
||||||
}, 0);
|
}, 0);
|
||||||
} else if (!contextRoot){
|
} else if (!contextRoot) {
|
||||||
//If no context root is available, default to the root
|
//If no context root is available, default to the root
|
||||||
// object
|
// object
|
||||||
$scope.rootObject = undefined;
|
$scope.rootObject = undefined;
|
||||||
// Update the displayed tree on a timeout to avoid
|
// Update the displayed tree on a timeout to avoid
|
||||||
// an infinite digest exception.
|
// an infinite digest exception.
|
||||||
objectService.getObjects(['ROOT'])
|
objectService.getObjects(['ROOT'])
|
||||||
.then(function(objects){
|
.then(function (objects) {
|
||||||
$timeout(function () {
|
$timeout(function () {
|
||||||
$scope.rootObject = objects.ROOT;
|
$scope.rootObject = objects.ROOT;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|||||||
@@ -78,12 +78,12 @@ define(
|
|||||||
|
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
"$scope",
|
"$scope",
|
||||||
[ "$on", "$watch" ]
|
["$on", "$watch"]
|
||||||
);
|
);
|
||||||
mockRoute = { current: { params: {} } };
|
mockRoute = { current: { params: {} } };
|
||||||
mockLocation = jasmine.createSpyObj(
|
mockLocation = jasmine.createSpyObj(
|
||||||
"$location",
|
"$location",
|
||||||
[ "path" ]
|
["path"]
|
||||||
);
|
);
|
||||||
mockUrlService = jasmine.createSpyObj(
|
mockUrlService = jasmine.createSpyObj(
|
||||||
"urlService",
|
"urlService",
|
||||||
@@ -91,7 +91,7 @@ define(
|
|||||||
);
|
);
|
||||||
mockObjectService = jasmine.createSpyObj(
|
mockObjectService = jasmine.createSpyObj(
|
||||||
"objectService",
|
"objectService",
|
||||||
[ "getObjects" ]
|
["getObjects"]
|
||||||
);
|
);
|
||||||
mockNavigationService = jasmine.createSpyObj(
|
mockNavigationService = jasmine.createSpyObj(
|
||||||
"navigationService",
|
"navigationService",
|
||||||
@@ -104,15 +104,15 @@ define(
|
|||||||
);
|
);
|
||||||
mockRootObject = jasmine.createSpyObj(
|
mockRootObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getCapability", "getModel", "useCapability" ]
|
["getId", "getCapability", "getModel", "useCapability"]
|
||||||
);
|
);
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getCapability", "getModel", "useCapability" ]
|
["getId", "getCapability", "getModel", "useCapability"]
|
||||||
);
|
);
|
||||||
mockNextObject = jasmine.createSpyObj(
|
mockNextObject = jasmine.createSpyObj(
|
||||||
"nextObject",
|
"nextObject",
|
||||||
[ "getId", "getCapability", "getModel", "useCapability" ]
|
["getId", "getCapability", "getModel", "useCapability"]
|
||||||
);
|
);
|
||||||
|
|
||||||
mockObjectService.getObjects.andReturn(mockPromise({
|
mockObjectService.getObjects.andReturn(mockPromise({
|
||||||
@@ -255,7 +255,7 @@ define(
|
|||||||
" object", function () {
|
" object", function () {
|
||||||
mockScope.navigatedObject = mockDomainObject;
|
mockScope.navigatedObject = mockDomainObject;
|
||||||
mockWindow.confirm.andReturn(false);
|
mockWindow.confirm.andReturn(false);
|
||||||
mockPolicyService.allow.andCallFake(function(category, object, context, callback){
|
mockPolicyService.allow.andCallFake(function (category, object, context, callback) {
|
||||||
callback("unsaved changes");
|
callback("unsaved changes");
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -44,12 +44,12 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
"$scope",
|
"$scope",
|
||||||
[ "$on", "$watch" ]
|
["$on", "$watch"]
|
||||||
);
|
);
|
||||||
mockRoute = { current: { params: {} } };
|
mockRoute = { current: { params: {} } };
|
||||||
mockLocation = jasmine.createSpyObj(
|
mockLocation = jasmine.createSpyObj(
|
||||||
"$location",
|
"$location",
|
||||||
[ "path", "search" ]
|
["path", "search"]
|
||||||
);
|
);
|
||||||
mockUnlisten = jasmine.createSpy("unlisten");
|
mockUnlisten = jasmine.createSpy("unlisten");
|
||||||
|
|
||||||
|
|||||||
@@ -38,23 +38,23 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
"$scope",
|
"$scope",
|
||||||
[ "" ]
|
[""]
|
||||||
);
|
);
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getCapability" ]
|
["getCapability"]
|
||||||
);
|
);
|
||||||
mockEvent = jasmine.createSpyObj(
|
mockEvent = jasmine.createSpyObj(
|
||||||
"event",
|
"event",
|
||||||
[ "preventDefault" ]
|
["preventDefault"]
|
||||||
);
|
);
|
||||||
mockContextMenuAction = jasmine.createSpyObj(
|
mockContextMenuAction = jasmine.createSpyObj(
|
||||||
"action",
|
"action",
|
||||||
[ "perform", "getActions" ]
|
["perform", "getActions"]
|
||||||
);
|
);
|
||||||
mockActionContext = jasmine.createSpyObj(
|
mockActionContext = jasmine.createSpyObj(
|
||||||
"actionContext",
|
"actionContext",
|
||||||
[ "" ]
|
[""]
|
||||||
);
|
);
|
||||||
|
|
||||||
mockActionContext.domainObject = mockDomainObject;
|
mockActionContext.domainObject = mockDomainObject;
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj("$scope", [ "$on" ]);
|
mockScope = jasmine.createSpyObj("$scope", ["$on"]);
|
||||||
mockDomainObjects = ['a', 'b'].map(function (id) {
|
mockDomainObjects = ['a', 'b'].map(function (id) {
|
||||||
var mockDomainObject = jasmine.createSpyObj(
|
var mockDomainObject = jasmine.createSpyObj(
|
||||||
'domainObject-' + id,
|
'domainObject-' + id,
|
||||||
[ 'getId', 'getModel', 'getCapability' ]
|
['getId', 'getModel', 'getCapability']
|
||||||
);
|
);
|
||||||
|
|
||||||
mockDomainObject.getId.andReturn(id);
|
mockDomainObject.getId.andReturn(id);
|
||||||
@@ -56,7 +56,7 @@ define(
|
|||||||
});
|
});
|
||||||
mockAgentService = jasmine.createSpyObj(
|
mockAgentService = jasmine.createSpyObj(
|
||||||
"agentService",
|
"agentService",
|
||||||
[ "isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape" ]
|
["isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape"]
|
||||||
);
|
);
|
||||||
mockWindow = jasmine.createSpyObj("$window", ["open"]);
|
mockWindow = jasmine.createSpyObj("$window", ["open"]);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -60,37 +60,37 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockTypeService = jasmine.createSpyObj(
|
mockTypeService = jasmine.createSpyObj(
|
||||||
"typeService",
|
"typeService",
|
||||||
[ "listTypes" ]
|
["listTypes"]
|
||||||
);
|
);
|
||||||
mockDialogService = jasmine.createSpyObj(
|
mockDialogService = jasmine.createSpyObj(
|
||||||
"dialogService",
|
"dialogService",
|
||||||
[ "getUserInput" ]
|
["getUserInput"]
|
||||||
);
|
);
|
||||||
mockPolicyService = jasmine.createSpyObj(
|
mockPolicyService = jasmine.createSpyObj(
|
||||||
"policyService",
|
"policyService",
|
||||||
[ "allow" ]
|
["allow"]
|
||||||
);
|
);
|
||||||
|
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getCapability" ]
|
["getCapability"]
|
||||||
);
|
);
|
||||||
|
|
||||||
//Mocking getCapability because AddActionProvider uses the
|
//Mocking getCapability because AddActionProvider uses the
|
||||||
// type capability of the destination object.
|
// type capability of the destination object.
|
||||||
mockDomainObject.getCapability.andReturn({});
|
mockDomainObject.getCapability.andReturn({});
|
||||||
|
|
||||||
mockTypes = [ "A", "B", "C" ].map(createMockType);
|
mockTypes = ["A", "B", "C"].map(createMockType);
|
||||||
|
|
||||||
mockTypes.forEach(function(type){
|
mockTypes.forEach(function (type) {
|
||||||
mockPolicyMap[type.getName()] = true;
|
mockPolicyMap[type.getName()] = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
mockCreationPolicy = function(type){
|
mockCreationPolicy = function (type) {
|
||||||
return mockPolicyMap[type.getName()];
|
return mockPolicyMap[type.getName()];
|
||||||
};
|
};
|
||||||
|
|
||||||
mockCompositionPolicy = function(){
|
mockCompositionPolicy = function () {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -59,32 +59,32 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockTypeService = jasmine.createSpyObj(
|
mockTypeService = jasmine.createSpyObj(
|
||||||
"typeService",
|
"typeService",
|
||||||
[ "listTypes" ]
|
["listTypes"]
|
||||||
);
|
);
|
||||||
mockDialogService = jasmine.createSpyObj(
|
mockDialogService = jasmine.createSpyObj(
|
||||||
"dialogService",
|
"dialogService",
|
||||||
[ "getUserInput" ]
|
["getUserInput"]
|
||||||
);
|
);
|
||||||
mockNavigationService = jasmine.createSpyObj(
|
mockNavigationService = jasmine.createSpyObj(
|
||||||
"navigationService",
|
"navigationService",
|
||||||
[ "setNavigation" ]
|
["setNavigation"]
|
||||||
);
|
);
|
||||||
mockPolicyService = jasmine.createSpyObj(
|
mockPolicyService = jasmine.createSpyObj(
|
||||||
"policyService",
|
"policyService",
|
||||||
[ "allow" ]
|
["allow"]
|
||||||
);
|
);
|
||||||
|
|
||||||
mockTypes = [ "A", "B", "C" ].map(createMockType);
|
mockTypes = ["A", "B", "C"].map(createMockType);
|
||||||
|
|
||||||
mockTypes.forEach(function(type){
|
mockTypes.forEach(function (type) {
|
||||||
mockPolicyMap[type.getName()] = true;
|
mockPolicyMap[type.getName()] = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
mockCreationPolicy = function(type){
|
mockCreationPolicy = function (type) {
|
||||||
return mockPolicyMap[type.getName()];
|
return mockPolicyMap[type.getName()];
|
||||||
};
|
};
|
||||||
|
|
||||||
mockPolicyService.allow.andCallFake(function(category, type){
|
mockPolicyService.allow.andCallFake(function (category, type) {
|
||||||
return category === "creation" && mockCreationPolicy(type) ? true : false;
|
return category === "creation" && mockCreationPolicy(type) ? true : false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -68,11 +68,11 @@ define(
|
|||||||
};
|
};
|
||||||
mockDialogService = jasmine.createSpyObj(
|
mockDialogService = jasmine.createSpyObj(
|
||||||
"dialogService",
|
"dialogService",
|
||||||
[ "getUserInput" ]
|
["getUserInput"]
|
||||||
);
|
);
|
||||||
mockCreationService = jasmine.createSpyObj(
|
mockCreationService = jasmine.createSpyObj(
|
||||||
"creationService",
|
"creationService",
|
||||||
[ "createObject" ]
|
["createObject"]
|
||||||
);
|
);
|
||||||
|
|
||||||
mockType.getKey.andReturn("test");
|
mockType.getKey.andReturn("test");
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ define(
|
|||||||
function createMockProperty(name) {
|
function createMockProperty(name) {
|
||||||
var mockProperty = jasmine.createSpyObj(
|
var mockProperty = jasmine.createSpyObj(
|
||||||
"property" + name,
|
"property" + name,
|
||||||
[ "getDefinition", "getValue", "setValue" ]
|
["getDefinition", "getValue", "setValue"]
|
||||||
);
|
);
|
||||||
mockProperty.getDefinition.andReturn({
|
mockProperty.getDefinition.andReturn({
|
||||||
control: "textfield"
|
control: "textfield"
|
||||||
@@ -68,7 +68,7 @@ define(
|
|||||||
"getCapability"
|
"getCapability"
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
mockProperties = [ "A", "B", "C" ].map(createMockProperty);
|
mockProperties = ["A", "B", "C"].map(createMockProperty);
|
||||||
mockPolicyService = jasmine.createSpyObj('policyService', ['allow']);
|
mockPolicyService = jasmine.createSpyObj('policyService', ['allow']);
|
||||||
|
|
||||||
testModel = { someKey: "some value" };
|
testModel = { someKey: "some value" };
|
||||||
@@ -144,15 +144,15 @@ define(
|
|||||||
"A": "ValueA",
|
"A": "ValueA",
|
||||||
"B": "ValueB",
|
"B": "ValueB",
|
||||||
"C": "ValueC"
|
"C": "ValueC"
|
||||||
},
|
},
|
||||||
compareModel = wizard.createModel(formValue);
|
compareModel = wizard.createModel(formValue);
|
||||||
wizard.populateObjectFromInput(formValue);
|
wizard.populateObjectFromInput(formValue);
|
||||||
expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function));
|
expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function));
|
||||||
expect(mockDomainObject.useCapability.mostRecentCall.args[1]()).toEqual(compareModel);
|
expect(mockDomainObject.useCapability.mostRecentCall.args[1]()).toEqual(compareModel);
|
||||||
});
|
});
|
||||||
|
|
||||||
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
|
||||||
@@ -179,7 +179,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("creates a form model without a location if not requested", function () {
|
it("creates a form model without a location if not requested", function () {
|
||||||
expect(wizard.getFormStructure(false).sections.some(function(section){
|
expect(wizard.getFormStructure(false).sections.some(function (section) {
|
||||||
return section.name === 'Location';
|
return section.name === 'Location';
|
||||||
})).toEqual(false);
|
})).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -61,23 +61,23 @@ define(
|
|||||||
mockQ = { when: mockPromise, reject: mockReject };
|
mockQ = { when: mockPromise, reject: mockReject };
|
||||||
mockLog = jasmine.createSpyObj(
|
mockLog = jasmine.createSpyObj(
|
||||||
"$log",
|
"$log",
|
||||||
[ "error", "warn", "info", "debug" ]
|
["error", "warn", "info", "debug"]
|
||||||
);
|
);
|
||||||
mockParentObject = jasmine.createSpyObj(
|
mockParentObject = jasmine.createSpyObj(
|
||||||
"parentObject",
|
"parentObject",
|
||||||
[ "getId", "getCapability", "useCapability" ]
|
["getId", "getCapability", "useCapability"]
|
||||||
);
|
);
|
||||||
mockNewObject = jasmine.createSpyObj(
|
mockNewObject = jasmine.createSpyObj(
|
||||||
"newObject",
|
"newObject",
|
||||||
[ "getId", "getCapability", "useCapability" ]
|
["getId", "getCapability", "useCapability"]
|
||||||
);
|
);
|
||||||
mockMutationCapability = jasmine.createSpyObj(
|
mockMutationCapability = jasmine.createSpyObj(
|
||||||
"mutation",
|
"mutation",
|
||||||
[ "invoke" ]
|
["invoke"]
|
||||||
);
|
);
|
||||||
mockPersistenceCapability = jasmine.createSpyObj(
|
mockPersistenceCapability = jasmine.createSpyObj(
|
||||||
"persistence",
|
"persistence",
|
||||||
[ "persist", "getSpace" ]
|
["persist", "getSpace"]
|
||||||
);
|
);
|
||||||
mockCompositionCapability = jasmine.createSpyObj(
|
mockCompositionCapability = jasmine.createSpyObj(
|
||||||
"composition",
|
"composition",
|
||||||
@@ -100,7 +100,7 @@ define(
|
|||||||
};
|
};
|
||||||
mockNewPersistenceCapability = jasmine.createSpyObj(
|
mockNewPersistenceCapability = jasmine.createSpyObj(
|
||||||
"new-persistence",
|
"new-persistence",
|
||||||
[ "persist", "getSpace" ]
|
["persist", "getSpace"]
|
||||||
);
|
);
|
||||||
|
|
||||||
mockParentObject.getCapability.andCallFake(function (key) {
|
mockParentObject.getCapability.andCallFake(function (key) {
|
||||||
|
|||||||
@@ -40,20 +40,20 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
"$scope",
|
"$scope",
|
||||||
[ "$watch" ]
|
["$watch"]
|
||||||
);
|
);
|
||||||
mockTimeout = jasmine.createSpy("$timeout");
|
mockTimeout = jasmine.createSpy("$timeout");
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getCapability" ]
|
["getCapability"]
|
||||||
);
|
);
|
||||||
mockRootObject = jasmine.createSpyObj(
|
mockRootObject = jasmine.createSpyObj(
|
||||||
"rootObject",
|
"rootObject",
|
||||||
[ "getCapability" ]
|
["getCapability"]
|
||||||
);
|
);
|
||||||
mockContext = jasmine.createSpyObj(
|
mockContext = jasmine.createSpyObj(
|
||||||
"context",
|
"context",
|
||||||
[ "getRoot" ]
|
["getRoot"]
|
||||||
);
|
);
|
||||||
mockObjectService = jasmine.createSpyObj(
|
mockObjectService = jasmine.createSpyObj(
|
||||||
"objectService",
|
"objectService",
|
||||||
@@ -73,18 +73,18 @@ define(
|
|||||||
|
|
||||||
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
|
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
|
||||||
});
|
});
|
||||||
describe("when context is available", function () {
|
describe("when context is available", function () {
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockContext.getRoot.andReturn(mockRootObject);
|
mockContext.getRoot.andReturn(mockRootObject);
|
||||||
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
|
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("adds a treeModel to scope", function () {
|
it("adds a treeModel to scope", function () {
|
||||||
expect(mockScope.treeModel).toBeDefined();
|
expect(mockScope.treeModel).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("watches for changes to treeModel", function () {
|
it("watches for changes to treeModel", function () {
|
||||||
// This is what the embedded tree representation
|
// This is what the embedded tree representation
|
||||||
// will be modifying.
|
// will be modifying.
|
||||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||||
@@ -93,7 +93,7 @@ define(
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("changes its own model on embedded model updates", function () {
|
it("changes its own model on embedded model updates", function () {
|
||||||
// Need to pass on selection changes as updates to
|
// Need to pass on selection changes as updates to
|
||||||
// the control's value
|
// the control's value
|
||||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||||
@@ -107,7 +107,7 @@ define(
|
|||||||
.toHaveBeenCalledWith("context");
|
.toHaveBeenCalledWith("context");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("rejects changes which fail validation", function () {
|
it("rejects changes which fail validation", function () {
|
||||||
mockScope.structure = { validate: jasmine.createSpy('validate') };
|
mockScope.structure = { validate: jasmine.createSpy('validate') };
|
||||||
mockScope.structure.validate.andReturn(false);
|
mockScope.structure.validate.andReturn(false);
|
||||||
|
|
||||||
@@ -120,10 +120,10 @@ define(
|
|||||||
expect(mockScope.ngModel.someField).not.toEqual(mockDomainObject);
|
expect(mockScope.ngModel.someField).not.toEqual(mockDomainObject);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("treats a lack of a selection as invalid", function () {
|
it("treats a lack of a selection as invalid", function () {
|
||||||
mockScope.ngModelController = jasmine.createSpyObj(
|
mockScope.ngModelController = jasmine.createSpyObj(
|
||||||
'ngModelController',
|
'ngModelController',
|
||||||
[ '$setValidity' ]
|
['$setValidity']
|
||||||
);
|
);
|
||||||
|
|
||||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||||
@@ -136,14 +136,14 @@ define(
|
|||||||
expect(mockScope.ngModelController.$setValidity)
|
expect(mockScope.ngModelController.$setValidity)
|
||||||
.toHaveBeenCalledWith(jasmine.any(String), false);
|
.toHaveBeenCalledWith(jasmine.any(String), false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("when no context is available", function () {
|
describe("when no context is available", function () {
|
||||||
var defaultRoot = "DEFAULT_ROOT";
|
var defaultRoot = "DEFAULT_ROOT";
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockContext.getRoot.andReturn(undefined);
|
mockContext.getRoot.andReturn(undefined);
|
||||||
getObjectsPromise.then.andCallFake(function(callback){
|
getObjectsPromise.then.andCallFake(function (callback) {
|
||||||
callback({'ROOT':defaultRoot});
|
callback({'ROOT': defaultRoot});
|
||||||
});
|
});
|
||||||
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
|
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -44,12 +44,12 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockNavigationService = jasmine.createSpyObj(
|
mockNavigationService = jasmine.createSpyObj(
|
||||||
"navigationService",
|
"navigationService",
|
||||||
[ "setNavigation" ]
|
["setNavigation"]
|
||||||
);
|
);
|
||||||
mockQ = { when: mockPromise };
|
mockQ = { when: mockPromise };
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getModel", "getCapability" ]
|
["getId", "getModel", "getCapability"]
|
||||||
);
|
);
|
||||||
|
|
||||||
action = new NavigateAction(
|
action = new NavigateAction(
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockNavigationService = jasmine.createSpyObj(
|
mockNavigationService = jasmine.createSpyObj(
|
||||||
'navigationService',
|
'navigationService',
|
||||||
[ 'getNavigation' ]
|
['getNavigation']
|
||||||
);
|
);
|
||||||
mockRootScope = jasmine.createSpyObj(
|
mockRootScope = jasmine.createSpyObj(
|
||||||
'$rootScope',
|
'$rootScope',
|
||||||
[ '$watch' ]
|
['$watch']
|
||||||
);
|
);
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
'domainObject',
|
'domainObject',
|
||||||
|
|||||||
@@ -155,8 +155,8 @@ define(
|
|||||||
* @returns {boolean} true if dialog is currently visible, false
|
* @returns {boolean} true if dialog is currently visible, false
|
||||||
* otherwise
|
* otherwise
|
||||||
*/
|
*/
|
||||||
DialogService.prototype.canShowDialog = function(dialogModel){
|
DialogService.prototype.canShowDialog = function (dialogModel) {
|
||||||
if (this.dialogVisible){
|
if (this.dialogVisible) {
|
||||||
// Only one dialog should be shown at a time.
|
// Only one dialog should be shown at a time.
|
||||||
// The application design should be such that
|
// The application design should be such that
|
||||||
// we never even try to do this.
|
// we never even try to do this.
|
||||||
@@ -224,7 +224,7 @@ define(
|
|||||||
* @param {typeClass} string tells overlayService that this overlay should use appropriate CSS class
|
* @param {typeClass} string tells overlayService that this overlay should use appropriate CSS class
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
DialogService.prototype.showBlockingMessage = function(dialogModel) {
|
DialogService.prototype.showBlockingMessage = function (dialogModel) {
|
||||||
if (this.canShowDialog(dialogModel)) {
|
if (this.canShowDialog(dialogModel)) {
|
||||||
// Add the overlay using the OverlayService, which
|
// Add the overlay using the OverlayService, which
|
||||||
// will handle actual insertion into the DOM
|
// will handle actual insertion into the DOM
|
||||||
|
|||||||
@@ -38,23 +38,23 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockOverlayService = jasmine.createSpyObj(
|
mockOverlayService = jasmine.createSpyObj(
|
||||||
"overlayService",
|
"overlayService",
|
||||||
[ "createOverlay" ]
|
["createOverlay"]
|
||||||
);
|
);
|
||||||
mockQ = jasmine.createSpyObj(
|
mockQ = jasmine.createSpyObj(
|
||||||
"$q",
|
"$q",
|
||||||
[ "defer" ]
|
["defer"]
|
||||||
);
|
);
|
||||||
mockLog = jasmine.createSpyObj(
|
mockLog = jasmine.createSpyObj(
|
||||||
"$log",
|
"$log",
|
||||||
[ "warn", "info", "debug" ]
|
["warn", "info", "debug"]
|
||||||
);
|
);
|
||||||
mockOverlay = jasmine.createSpyObj(
|
mockOverlay = jasmine.createSpyObj(
|
||||||
"overlay",
|
"overlay",
|
||||||
[ "dismiss" ]
|
["dismiss"]
|
||||||
);
|
);
|
||||||
mockDeferred = jasmine.createSpyObj(
|
mockDeferred = jasmine.createSpyObj(
|
||||||
"deferred",
|
"deferred",
|
||||||
[ "resolve", "reject"]
|
["resolve", "reject"]
|
||||||
);
|
);
|
||||||
mockDeferred.promise = "mock promise";
|
mockDeferred.promise = "mock promise";
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("invokes the overlay service with the correct parameters when" +
|
it("invokes the overlay service with the correct parameters when" +
|
||||||
" a blocking dialog is requested", function() {
|
" a blocking dialog is requested", function () {
|
||||||
var dialogModel = {};
|
var dialogModel = {};
|
||||||
expect(dialogService.showBlockingMessage(dialogModel)).toBe(true);
|
expect(dialogService.showBlockingMessage(dialogModel)).toBe(true);
|
||||||
expect(mockOverlayService.createOverlay).toHaveBeenCalledWith(
|
expect(mockOverlayService.createOverlay).toHaveBeenCalledWith(
|
||||||
|
|||||||
@@ -38,13 +38,13 @@ define(
|
|||||||
overlayService;
|
overlayService;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockDocument = jasmine.createSpyObj("$document", [ "find" ]);
|
mockDocument = jasmine.createSpyObj("$document", ["find"]);
|
||||||
mockCompile = jasmine.createSpy("$compile");
|
mockCompile = jasmine.createSpy("$compile");
|
||||||
mockRootScope = jasmine.createSpyObj("$rootScope", [ "$new" ]);
|
mockRootScope = jasmine.createSpyObj("$rootScope", ["$new"]);
|
||||||
mockBody = jasmine.createSpyObj("body", [ "prepend" ]);
|
mockBody = jasmine.createSpyObj("body", ["prepend"]);
|
||||||
mockTemplate = jasmine.createSpy("template");
|
mockTemplate = jasmine.createSpy("template");
|
||||||
mockElement = jasmine.createSpyObj("element", [ "remove" ]);
|
mockElement = jasmine.createSpyObj("element", ["remove"]);
|
||||||
mockScope = jasmine.createSpyObj("scope", [ "$destroy" ]);
|
mockScope = jasmine.createSpyObj("scope", ["$destroy"]);
|
||||||
|
|
||||||
mockDocument.find.andReturn(mockBody);
|
mockDocument.find.andReturn(mockBody);
|
||||||
mockCompile.andReturn(mockTemplate);
|
mockCompile.andReturn(mockTemplate);
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ define([
|
|||||||
],
|
],
|
||||||
"constants": [
|
"constants": [
|
||||||
{
|
{
|
||||||
"key":"editModeBlacklist",
|
"key": "editModeBlacklist",
|
||||||
"value": ["copy", "follow", "window", "link", "locate"]
|
"value": ["copy", "follow", "window", "link", "locate"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -315,7 +315,7 @@ define([
|
|||||||
"transactionService"
|
"transactionService"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ define(
|
|||||||
CancelAction.prototype.perform = function () {
|
CancelAction.prototype.perform = function () {
|
||||||
var domainObject = this.domainObject;
|
var domainObject = this.domainObject;
|
||||||
|
|
||||||
function returnToBrowse () {
|
function returnToBrowse() {
|
||||||
var parent;
|
var parent;
|
||||||
|
|
||||||
//If the object existed already, navigate to refresh view
|
//If the object existed already, navigate to refresh view
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
EditAction.prototype.perform = function () {
|
EditAction.prototype.perform = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
function cancelEditing(){
|
function cancelEditing() {
|
||||||
self.domainObject.getCapability('editor').cancel();
|
self.domainObject.getCapability('editor').cancel();
|
||||||
self.navigationService.removeListener(cancelEditing);
|
self.navigationService.removeListener(cancelEditing);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,10 +57,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(
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ define(
|
|||||||
SaveAction.prototype.perform = function () {
|
SaveAction.prototype.perform = function () {
|
||||||
var domainObject = this.domainObject;
|
var domainObject = this.domainObject;
|
||||||
|
|
||||||
function resolveWith(object){
|
function resolveWith(object) {
|
||||||
return function () {
|
return function () {
|
||||||
return object;
|
return object;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ define(
|
|||||||
context
|
context
|
||||||
) {
|
) {
|
||||||
this.domainObject = (context || {}).domainObject;
|
this.domainObject = (context || {}).domainObject;
|
||||||
this.injectObjectService = function(){
|
this.injectObjectService = function () {
|
||||||
this.objectService = $injector.get("objectService");
|
this.objectService = $injector.get("objectService");
|
||||||
};
|
};
|
||||||
this.policyService = policyService;
|
this.policyService = policyService;
|
||||||
@@ -65,7 +65,7 @@ define(
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
SaveAsAction.prototype.getObjectService = function(){
|
SaveAsAction.prototype.getObjectService = function () {
|
||||||
// Lazily acquire object service (avoids cyclical dependency)
|
// Lazily acquire object service (avoids cyclical dependency)
|
||||||
if (!this.objectService) {
|
if (!this.objectService) {
|
||||||
this.injectObjectService();
|
this.injectObjectService();
|
||||||
@@ -73,7 +73,7 @@ define(
|
|||||||
return this.objectService;
|
return this.objectService;
|
||||||
};
|
};
|
||||||
|
|
||||||
function resolveWith(object){
|
function resolveWith(object) {
|
||||||
return function () {
|
return function () {
|
||||||
return object;
|
return object;
|
||||||
};
|
};
|
||||||
@@ -116,13 +116,13 @@ define(
|
|||||||
).then(wizard.populateObjectFromInput.bind(wizard));
|
).then(wizard.populateObjectFromInput.bind(wizard));
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchObject(objectId){
|
function fetchObject(objectId) {
|
||||||
return self.getObjectService().getObjects([objectId]).then(function(objects){
|
return self.getObjectService().getObjects([objectId]).then(function (objects) {
|
||||||
return objects[objectId];
|
return objects[objectId];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getParent(object){
|
function getParent(object) {
|
||||||
return fetchObject(object.getModel().location);
|
return fetchObject(object.getModel().location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,11 +52,11 @@ define(
|
|||||||
this.domainObject.getCapability('status').set('editing', true);
|
this.domainObject.getCapability('status').set('editing', true);
|
||||||
};
|
};
|
||||||
|
|
||||||
function isEditContextRoot (domainObject) {
|
function isEditContextRoot(domainObject) {
|
||||||
return domainObject.getCapability('status').get('editing');
|
return domainObject.getCapability('status').get('editing');
|
||||||
}
|
}
|
||||||
|
|
||||||
function isEditing (domainObject) {
|
function isEditing(domainObject) {
|
||||||
return isEditContextRoot(domainObject) ||
|
return isEditContextRoot(domainObject) ||
|
||||||
domainObject.hasCapability('context') &&
|
domainObject.hasCapability('context') &&
|
||||||
isEditing(domainObject.getCapability('context').getParent());
|
isEditing(domainObject.getCapability('context').getParent());
|
||||||
@@ -87,7 +87,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
EditorCapability.prototype.save = function () {
|
EditorCapability.prototype.save = function () {
|
||||||
var domainObject = this.domainObject;
|
var domainObject = this.domainObject;
|
||||||
return this.transactionService.commit().then(function() {
|
return this.transactionService.commit().then(function () {
|
||||||
domainObject.getCapability('status').set('editing', false);
|
domainObject.getCapability('status').set('editing', false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -101,7 +101,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
EditorCapability.prototype.cancel = function () {
|
EditorCapability.prototype.cancel = function () {
|
||||||
var domainObject = this.domainObject;
|
var domainObject = this.domainObject;
|
||||||
return this.transactionService.cancel().then(function(){
|
return this.transactionService.cancel().then(function () {
|
||||||
domainObject.getCapability("status").set("editing", false);
|
domainObject.getCapability("status").set("editing", false);
|
||||||
return domainObject;
|
return domainObject;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -60,14 +60,14 @@ define(
|
|||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
function onCommit() {
|
function onCommit() {
|
||||||
return self.persistenceCapability.persist().then(function(result) {
|
return self.persistenceCapability.persist().then(function (result) {
|
||||||
self.persistPending = false;
|
self.persistPending = false;
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCancel() {
|
function onCancel() {
|
||||||
return self.persistenceCapability.refresh().then(function(result) {
|
return self.persistenceCapability.refresh().then(function (result) {
|
||||||
self.persistPending = false;
|
self.persistPending = false;
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ define(
|
|||||||
|
|
||||||
$scope.$watch('domainObject', setViewForDomainObject);
|
$scope.$watch('domainObject', setViewForDomainObject);
|
||||||
|
|
||||||
$scope.doAction = function (action){
|
$scope.doAction = function (action) {
|
||||||
return $scope[action] && $scope[action]();
|
return $scope[action] && $scope[action]();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -74,8 +74,8 @@ define(
|
|||||||
var navigatedObject = this.scope.domainObject,
|
var navigatedObject = this.scope.domainObject,
|
||||||
policyMessage;
|
policyMessage;
|
||||||
|
|
||||||
this.policyService.allow("navigation", navigatedObject, undefined, function(message) {
|
this.policyService.allow("navigation", navigatedObject, undefined, function (message) {
|
||||||
policyMessage = message;
|
policyMessage = message;
|
||||||
});
|
});
|
||||||
|
|
||||||
return policyMessage;
|
return policyMessage;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ define(
|
|||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function ElementsController($scope) {
|
function ElementsController($scope) {
|
||||||
function filterBy(text){
|
function filterBy(text) {
|
||||||
if (typeof text === 'undefined') {
|
if (typeof text === 'undefined') {
|
||||||
return $scope.searchText;
|
return $scope.searchText;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ define(
|
|||||||
count = 0,
|
count = 0,
|
||||||
type, views;
|
type, views;
|
||||||
|
|
||||||
if (!domainObject){
|
if (!domainObject) {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ define(
|
|||||||
actionMetadata = action.getMetadata ? action.getMetadata() : {};
|
actionMetadata = action.getMetadata ? action.getMetadata() : {};
|
||||||
|
|
||||||
if (navigatedObject.hasCapability("editor") && navigatedObject.getCapability("editor").isEditContextRoot()) {
|
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;
|
return this.editModeBlacklist.indexOf(actionMetadata.key) === -1;
|
||||||
} else {
|
} else {
|
||||||
//Target is in the context menu
|
//Target is in the context menu
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ define(
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
EditNavigationPolicy.prototype.isDirty = function(domainObject) {
|
EditNavigationPolicy.prototype.isDirty = function (domainObject) {
|
||||||
var navigatedObject = domainObject,
|
var navigatedObject = domainObject,
|
||||||
editorCapability = navigatedObject &&
|
editorCapability = navigatedObject &&
|
||||||
navigatedObject.getCapability("editor");
|
navigatedObject.getCapability("editor");
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ define(
|
|||||||
// Ensure existing watches are released
|
// Ensure existing watches are released
|
||||||
this.destroy();
|
this.destroy();
|
||||||
|
|
||||||
function setEditing(){
|
function setEditing() {
|
||||||
scope.viewObjectTemplate = 'edit-object';
|
scope.viewObjectTemplate = 'edit-object';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,15 +124,15 @@ define(
|
|||||||
* editable then change the view and inspector regions
|
* editable then change the view and inspector regions
|
||||||
* object representation accordingly
|
* object representation accordingly
|
||||||
*/
|
*/
|
||||||
this.listenHandle = this.domainObject.getCapability('status').listen(function(statuses){
|
this.listenHandle = this.domainObject.getCapability('status').listen(function (statuses) {
|
||||||
if (statuses.indexOf('editing') !== -1){
|
if (statuses.indexOf('editing') !== -1) {
|
||||||
setEditing();
|
setEditing();
|
||||||
} else {
|
} else {
|
||||||
delete scope.viewObjectTemplate;
|
delete scope.viewObjectTemplate;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (representedObject.hasCapability('editor') && representedObject.getCapability('editor').isEditContextRoot()){
|
if (representedObject.hasCapability('editor') && representedObject.getCapability('editor').isEditContextRoot()) {
|
||||||
setEditing();
|
setEditing();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
/*global define*/
|
/*global define*/
|
||||||
define(
|
define(
|
||||||
[],
|
[],
|
||||||
function() {
|
function () {
|
||||||
/**
|
/**
|
||||||
* Implements an application-wide transaction state. Once a
|
* Implements an application-wide transaction state. Once a
|
||||||
* transaction is started, calls to
|
* transaction is started, calls to
|
||||||
@@ -103,7 +103,7 @@ define(
|
|||||||
this.$log.error("Error committing transaction.");
|
this.$log.error("Error committing transaction.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.$q.all(promises).then( function () {
|
return this.$q.all(promises).then(function () {
|
||||||
self.transaction = false;
|
self.transaction = false;
|
||||||
|
|
||||||
self.onCommits = [];
|
self.onCommits = [];
|
||||||
@@ -145,4 +145,4 @@ define(
|
|||||||
};
|
};
|
||||||
|
|
||||||
return TransactionService;
|
return TransactionService;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -44,15 +44,15 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockLocation = jasmine.createSpyObj(
|
mockLocation = jasmine.createSpyObj(
|
||||||
"$location",
|
"$location",
|
||||||
[ "path" ]
|
["path"]
|
||||||
);
|
);
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getCapability", "hasCapability" ]
|
["getCapability", "hasCapability"]
|
||||||
);
|
);
|
||||||
mockEditorCapability = jasmine.createSpyObj(
|
mockEditorCapability = jasmine.createSpyObj(
|
||||||
"editor",
|
"editor",
|
||||||
[ "save", "cancel" ]
|
["save", "cancel"]
|
||||||
);
|
);
|
||||||
mockUrlService = jasmine.createSpyObj(
|
mockUrlService = jasmine.createSpyObj(
|
||||||
"urlService",
|
"urlService",
|
||||||
|
|||||||
@@ -38,23 +38,23 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockLocation = jasmine.createSpyObj(
|
mockLocation = jasmine.createSpyObj(
|
||||||
"$location",
|
"$location",
|
||||||
[ "path" ]
|
["path"]
|
||||||
);
|
);
|
||||||
mockNavigationService = jasmine.createSpyObj(
|
mockNavigationService = jasmine.createSpyObj(
|
||||||
"navigationService",
|
"navigationService",
|
||||||
[ "setNavigation", "getNavigation", "addListener", "removeListener" ]
|
["setNavigation", "getNavigation", "addListener", "removeListener"]
|
||||||
);
|
);
|
||||||
mockLog = jasmine.createSpyObj(
|
mockLog = jasmine.createSpyObj(
|
||||||
"$log",
|
"$log",
|
||||||
[ "error", "warn", "info", "debug" ]
|
["error", "warn", "info", "debug"]
|
||||||
);
|
);
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getModel", "getCapability", "hasCapability", "useCapability" ]
|
["getId", "getModel", "getCapability", "hasCapability", "useCapability"]
|
||||||
);
|
);
|
||||||
mockType = jasmine.createSpyObj(
|
mockType = jasmine.createSpyObj(
|
||||||
"type",
|
"type",
|
||||||
[ "hasFeature" ]
|
["hasFeature"]
|
||||||
);
|
);
|
||||||
mockEditor = jasmine.createSpyObj(
|
mockEditor = jasmine.createSpyObj(
|
||||||
"editorCapability",
|
"editorCapability",
|
||||||
@@ -66,7 +66,7 @@ define(
|
|||||||
editor: mockEditor
|
editor: mockEditor
|
||||||
};
|
};
|
||||||
|
|
||||||
mockDomainObject.getCapability.andCallFake( function (name) {
|
mockDomainObject.getCapability.andCallFake(function (name) {
|
||||||
return capabilities[name];
|
return capabilities[name];
|
||||||
});
|
});
|
||||||
mockDomainObject.hasCapability.andReturn(true);
|
mockDomainObject.hasCapability.andReturn(true);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ define(
|
|||||||
|
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getCapability" ]
|
["getId", "getCapability"]
|
||||||
);
|
);
|
||||||
mockQ = { when: mockPromise };
|
mockQ = { when: mockPromise };
|
||||||
mockParent = {
|
mockParent = {
|
||||||
@@ -65,10 +65,10 @@ define(
|
|||||||
return capabilities[k].invoke(v);
|
return capabilities[k].invoke(v);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mockContext = jasmine.createSpyObj("context", [ "getParent" ]);
|
mockContext = jasmine.createSpyObj("context", ["getParent"]);
|
||||||
mockComposition = jasmine.createSpyObj("composition", [ "invoke", "add" ]);
|
mockComposition = jasmine.createSpyObj("composition", ["invoke", "add"]);
|
||||||
mockType = jasmine.createSpyObj("type", [ "hasFeature", "getKey" ]);
|
mockType = jasmine.createSpyObj("type", ["hasFeature", "getKey"]);
|
||||||
mockActionCapability = jasmine.createSpyObj("actionCapability", [ "getActions"]);
|
mockActionCapability = jasmine.createSpyObj("actionCapability", ["getActions"]);
|
||||||
mockEditAction = jasmine.createSpyObj("editAction", ["perform"]);
|
mockEditAction = jasmine.createSpyObj("editAction", ["perform"]);
|
||||||
|
|
||||||
mockDomainObject.getId.andReturn("test");
|
mockDomainObject.getId.andReturn("test");
|
||||||
@@ -86,7 +86,7 @@ define(
|
|||||||
type: mockType
|
type: mockType
|
||||||
};
|
};
|
||||||
model = {
|
model = {
|
||||||
composition: [ "a", "b", "c" ]
|
composition: ["a", "b", "c"]
|
||||||
};
|
};
|
||||||
|
|
||||||
actionContext = {
|
actionContext = {
|
||||||
|
|||||||
@@ -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')
|
||||||
},
|
},
|
||||||
mutation: jasmine.createSpy("mutation")
|
mutation: jasmine.createSpy("mutation")
|
||||||
@@ -46,11 +48,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 '};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -54,19 +54,19 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getCapability" ]
|
["getId", "getCapability"]
|
||||||
);
|
);
|
||||||
mockChildObject = jasmine.createSpyObj(
|
mockChildObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getCapability" ]
|
["getId", "getCapability"]
|
||||||
);
|
);
|
||||||
mockGrandchildObject = jasmine.createSpyObj(
|
mockGrandchildObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getCapability" ]
|
["getId", "getCapability"]
|
||||||
);
|
);
|
||||||
mockRootObject = jasmine.createSpyObj(
|
mockRootObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getCapability" ]
|
["getId", "getCapability"]
|
||||||
);
|
);
|
||||||
mockQ = { when: mockPromise };
|
mockQ = { when: mockPromise };
|
||||||
mockParent = {
|
mockParent = {
|
||||||
@@ -80,12 +80,12 @@ define(
|
|||||||
return capabilities[k].invoke(v);
|
return capabilities[k].invoke(v);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mockContext = jasmine.createSpyObj("context", [ "getParent" ]);
|
mockContext = jasmine.createSpyObj("context", ["getParent"]);
|
||||||
mockChildContext = jasmine.createSpyObj("context", [ "getParent" ]);
|
mockChildContext = jasmine.createSpyObj("context", ["getParent"]);
|
||||||
mockGrandchildContext = jasmine.createSpyObj("context", [ "getParent" ]);
|
mockGrandchildContext = jasmine.createSpyObj("context", ["getParent"]);
|
||||||
mockRootContext = jasmine.createSpyObj("context", [ "getParent" ]);
|
mockRootContext = jasmine.createSpyObj("context", ["getParent"]);
|
||||||
mockMutation = jasmine.createSpyObj("mutation", [ "invoke" ]);
|
mockMutation = jasmine.createSpyObj("mutation", ["invoke"]);
|
||||||
mockType = jasmine.createSpyObj("type", [ "hasFeature" ]);
|
mockType = jasmine.createSpyObj("type", ["hasFeature"]);
|
||||||
mockNavigationService = jasmine.createSpyObj(
|
mockNavigationService = jasmine.createSpyObj(
|
||||||
"navigationService",
|
"navigationService",
|
||||||
[
|
[
|
||||||
@@ -108,7 +108,7 @@ define(
|
|||||||
type: mockType
|
type: mockType
|
||||||
};
|
};
|
||||||
model = {
|
model = {
|
||||||
composition: [ "a", "test", "b" ]
|
composition: ["a", "test", "b"]
|
||||||
};
|
};
|
||||||
|
|
||||||
actionContext = { domainObject: mockDomainObject };
|
actionContext = { domainObject: mockDomainObject };
|
||||||
|
|||||||
@@ -52,11 +52,11 @@ define(
|
|||||||
);
|
);
|
||||||
mockEditorCapability = jasmine.createSpyObj(
|
mockEditorCapability = jasmine.createSpyObj(
|
||||||
"editor",
|
"editor",
|
||||||
[ "save", "cancel", "isEditContextRoot" ]
|
["save", "cancel", "isEditContextRoot"]
|
||||||
);
|
);
|
||||||
mockActionCapability = jasmine.createSpyObj(
|
mockActionCapability = jasmine.createSpyObj(
|
||||||
"actionCapability",
|
"actionCapability",
|
||||||
[ "perform"]
|
["perform"]
|
||||||
);
|
);
|
||||||
capabilities.editor = mockEditorCapability;
|
capabilities.editor = mockEditorCapability;
|
||||||
capabilities.action = mockActionCapability;
|
capabilities.action = mockActionCapability;
|
||||||
@@ -90,7 +90,7 @@ define(
|
|||||||
function () {
|
function () {
|
||||||
mockDomainObject.getModel.andReturn({persisted: undefined});
|
mockDomainObject.getModel.andReturn({persisted: undefined});
|
||||||
expect(SaveAction.appliesTo(actionContext)).toBe(false);
|
expect(SaveAction.appliesTo(actionContext)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses the editor capability to save the object",
|
it("uses the editor capability to save the object",
|
||||||
function () {
|
function () {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ define(
|
|||||||
capabilities = {},
|
capabilities = {},
|
||||||
action;
|
action;
|
||||||
|
|
||||||
function noop () {}
|
function noop() {}
|
||||||
|
|
||||||
function mockPromise(value) {
|
function mockPromise(value) {
|
||||||
return (value || {}).then ? value :
|
return (value || {}).then ? value :
|
||||||
@@ -49,7 +49,7 @@ define(
|
|||||||
catch: function (callback) {
|
catch: function (callback) {
|
||||||
return mockPromise(callback(value));
|
return mockPromise(callback(value));
|
||||||
}
|
}
|
||||||
} ;
|
} ;
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
@@ -78,7 +78,7 @@ define(
|
|||||||
|
|
||||||
mockEditorCapability = jasmine.createSpyObj(
|
mockEditorCapability = jasmine.createSpyObj(
|
||||||
"editor",
|
"editor",
|
||||||
[ "save", "cancel", "isEditContextRoot" ]
|
["save", "cancel", "isEditContextRoot"]
|
||||||
);
|
);
|
||||||
mockEditorCapability.cancel.andReturn(mockPromise(undefined));
|
mockEditorCapability.cancel.andReturn(mockPromise(undefined));
|
||||||
mockEditorCapability.save.andReturn(mockPromise(true));
|
mockEditorCapability.save.andReturn(mockPromise(true));
|
||||||
@@ -130,7 +130,7 @@ define(
|
|||||||
action.createWizard.andReturn({
|
action.createWizard.andReturn({
|
||||||
getFormStructure: noop,
|
getFormStructure: noop,
|
||||||
getInitialFormValue: noop,
|
getInitialFormValue: noop,
|
||||||
populateObjectFromInput: function() {
|
populateObjectFromInput: function () {
|
||||||
return mockDomainObject;
|
return mockDomainObject;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ define(
|
|||||||
status: mockStatusCapability
|
status: mockStatusCapability
|
||||||
};
|
};
|
||||||
|
|
||||||
mockDomainObject.hasCapability.andCallFake(function(name) {
|
mockDomainObject.hasCapability.andCallFake(function (name) {
|
||||||
return capabilities[name] !== undefined;
|
return capabilities[name] !== undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -126,8 +126,8 @@ define(
|
|||||||
expect(capability.inEditContext()).toBe(true);
|
expect(capability.inEditContext()).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("save", function() {
|
describe("save", function () {
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
capability.edit();
|
capability.edit();
|
||||||
capability.save();
|
capability.save();
|
||||||
});
|
});
|
||||||
@@ -139,8 +139,8 @@ define(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("cancel", function() {
|
describe("cancel", function () {
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
capability.edit();
|
capability.edit();
|
||||||
capability.cancel();
|
capability.cancel();
|
||||||
});
|
});
|
||||||
@@ -152,10 +152,10 @@ define(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("dirty", function() {
|
describe("dirty", function () {
|
||||||
var model = {};
|
var model = {};
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
mockDomainObject.getModel.andReturn(model);
|
mockDomainObject.getModel.andReturn(model);
|
||||||
capability.edit();
|
capability.edit();
|
||||||
capability.cancel();
|
capability.cancel();
|
||||||
|
|||||||
@@ -33,18 +33,18 @@ define(
|
|||||||
mockCapabilityService,
|
mockCapabilityService,
|
||||||
provider;
|
provider;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
mockQ = {};
|
mockQ = {};
|
||||||
mockTransactionService = {};
|
mockTransactionService = {};
|
||||||
mockCapabilityService = jasmine.createSpyObj("capabilityService", ["getCapabilities"]);
|
mockCapabilityService = jasmine.createSpyObj("capabilityService", ["getCapabilities"]);
|
||||||
mockCapabilityService.getCapabilities.andReturn({
|
mockCapabilityService.getCapabilities.andReturn({
|
||||||
persistence: function() {}
|
persistence: function () {}
|
||||||
});
|
});
|
||||||
|
|
||||||
provider = new TransactionCapabilityDecorator(mockQ, mockTransactionService, mockCapabilityService);
|
provider = new TransactionCapabilityDecorator(mockQ, mockTransactionService, mockCapabilityService);
|
||||||
|
|
||||||
});
|
});
|
||||||
it("decorates the persistence capability", function() {
|
it("decorates the persistence capability", function () {
|
||||||
var capabilities = provider.getCapabilities();
|
var capabilities = provider.getCapabilities();
|
||||||
expect(capabilities.persistence({}) instanceof TransactionalPersistenceCapability).toBe(true);
|
expect(capabilities.persistence({}) instanceof TransactionalPersistenceCapability).toBe(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ define(
|
|||||||
|
|
||||||
function fastPromise(val) {
|
function fastPromise(val) {
|
||||||
return {
|
return {
|
||||||
then: function(callback) {
|
then: function (callback) {
|
||||||
return callback(val);
|
return callback(val);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -42,7 +42,7 @@ define(
|
|||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
capability;
|
capability;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
mockQ = jasmine.createSpyObj("$q", ["when"]);
|
mockQ = jasmine.createSpyObj("$q", ["when"]);
|
||||||
mockQ.when.andCallFake(function (val) {
|
mockQ.when.andCallFake(function (val) {
|
||||||
return fastPromise(val);
|
return fastPromise(val);
|
||||||
@@ -61,14 +61,14 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("if no transaction is active, passes through to persistence" +
|
it("if no transaction is active, passes through to persistence" +
|
||||||
" provider", function() {
|
" provider", function () {
|
||||||
mockTransactionService.isActive.andReturn(false);
|
mockTransactionService.isActive.andReturn(false);
|
||||||
capability.persist();
|
capability.persist();
|
||||||
expect(mockPersistence.persist).toHaveBeenCalled();
|
expect(mockPersistence.persist).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if transaction is active, persist and cancel calls are" +
|
it("if transaction is active, persist and cancel calls are" +
|
||||||
" queued", function() {
|
" queued", function () {
|
||||||
mockTransactionService.isActive.andReturn(true);
|
mockTransactionService.isActive.andReturn(true);
|
||||||
capability.persist();
|
capability.persist();
|
||||||
expect(mockTransactionService.addToTransaction).toHaveBeenCalled();
|
expect(mockTransactionService.addToTransaction).toHaveBeenCalled();
|
||||||
@@ -78,7 +78,7 @@ define(
|
|||||||
expect(mockPersistence.refresh).toHaveBeenCalled();
|
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);
|
mockTransactionService.isActive.andReturn(true);
|
||||||
capability.persist();
|
capability.persist();
|
||||||
expect(mockTransactionService.addToTransaction).toHaveBeenCalled();
|
expect(mockTransactionService.addToTransaction).toHaveBeenCalled();
|
||||||
|
|||||||
@@ -52,15 +52,15 @@ define(
|
|||||||
);
|
);
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
"$scope",
|
"$scope",
|
||||||
[ "$on", "$watch" ]
|
["$on", "$watch"]
|
||||||
);
|
);
|
||||||
mockObject = jasmine.createSpyObj(
|
mockObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getModel", "getCapability", "hasCapability", "useCapability" ]
|
["getId", "getModel", "getCapability", "hasCapability", "useCapability"]
|
||||||
);
|
);
|
||||||
mockType = jasmine.createSpyObj(
|
mockType = jasmine.createSpyObj(
|
||||||
"type",
|
"type",
|
||||||
[ "hasFeature" ]
|
["hasFeature"]
|
||||||
);
|
);
|
||||||
mockStatusCapability = jasmine.createSpyObj('statusCapability',
|
mockStatusCapability = jasmine.createSpyObj('statusCapability',
|
||||||
["get"]
|
["get"]
|
||||||
@@ -99,8 +99,8 @@ define(
|
|||||||
expect(controller.getUnloadWarning()).toBeUndefined();
|
expect(controller.getUnloadWarning()).toBeUndefined();
|
||||||
|
|
||||||
// Override the policy service to prevent navigation
|
// Override the policy service to prevent navigation
|
||||||
mockPolicyService.allow.andCallFake(function(category, object, context, callback){
|
mockPolicyService.allow.andCallFake(function (category, object, context, callback) {
|
||||||
callback(errorMessage);
|
callback(errorMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Should have some warning message here now
|
// Should have some warning message here now
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ define(
|
|||||||
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
|
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
'domainObject',
|
'domainObject',
|
||||||
[ 'getId', 'getCapability' ]
|
['getId', 'getCapability']
|
||||||
);
|
);
|
||||||
mockContext = jasmine.createSpyObj(
|
mockContext = jasmine.createSpyObj(
|
||||||
'context',
|
'context',
|
||||||
[ 'getTrueRoot' ]
|
['getTrueRoot']
|
||||||
);
|
);
|
||||||
|
|
||||||
mockDomainObject.getId.andReturn('test-id');
|
mockDomainObject.getId.andReturn('test-id');
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ define(
|
|||||||
controller = new ElementsController(mockScope);
|
controller = new ElementsController(mockScope);
|
||||||
});
|
});
|
||||||
|
|
||||||
function getModel (model) {
|
function getModel(model) {
|
||||||
return function() {
|
return function () {
|
||||||
return model;
|
return model;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,10 +58,10 @@ define(
|
|||||||
mockEditAction = jasmine.createSpyObj('edit', ['getMetadata']);
|
mockEditAction = jasmine.createSpyObj('edit', ['getMetadata']);
|
||||||
mockPropertiesAction = jasmine.createSpyObj('edit', ['getMetadata']);
|
mockPropertiesAction = jasmine.createSpyObj('edit', ['getMetadata']);
|
||||||
|
|
||||||
mockDomainObject.getCapability.andCallFake(function(capability){
|
mockDomainObject.getCapability.andCallFake(function (capability) {
|
||||||
return capabilities[capability];
|
return capabilities[capability];
|
||||||
});
|
});
|
||||||
mockDomainObject.hasCapability.andCallFake(function(capability){
|
mockDomainObject.hasCapability.andCallFake(function (capability) {
|
||||||
return !!capabilities[capability];
|
return !!capabilities[capability];
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -88,42 +88,42 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("allows the edit action when there are editable views", function () {
|
it("allows the edit action when there are editable views", function () {
|
||||||
testViews = [ editableView ];
|
testViews = [editableView];
|
||||||
expect(policy.allow(mockEditAction, testContext)).toBe(true);
|
expect(policy.allow(mockEditAction, testContext)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows the edit properties action when there are no editable views", function () {
|
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);
|
expect(policy.allow(mockPropertiesAction, testContext)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("disallows the edit action when there are no editable views", function () {
|
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);
|
expect(policy.allow(mockEditAction, testContext)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("disallows the edit properties action when there are" +
|
it("disallows the edit properties action when there are" +
|
||||||
" editable views", function () {
|
" editable views", function () {
|
||||||
testViews = [ editableView ];
|
testViews = [editableView];
|
||||||
expect(policy.allow(mockPropertiesAction, testContext)).toBe(false);
|
expect(policy.allow(mockPropertiesAction, testContext)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("disallows the edit action when object is already being" +
|
it("disallows the edit action when object is already being" +
|
||||||
" edited", function () {
|
" edited", function () {
|
||||||
testViews = [ editableView ];
|
testViews = [editableView];
|
||||||
mockEditorCapability.isEditContextRoot.andReturn(true);
|
mockEditorCapability.isEditContextRoot.andReturn(true);
|
||||||
expect(policy.allow(mockEditAction, testContext)).toBe(false);
|
expect(policy.allow(mockEditAction, testContext)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows editing of panels in plot view", function () {
|
it("allows editing of panels in plot view", function () {
|
||||||
testViews = [ plotView ];
|
testViews = [plotView];
|
||||||
mockTypeCapability.getKey.andReturn('telemetry.panel');
|
mockTypeCapability.getKey.andReturn('telemetry.panel');
|
||||||
|
|
||||||
expect(policy.allow(mockEditAction, testContext)).toBe(true);
|
expect(policy.allow(mockEditAction, testContext)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("disallows editing of plot view when object not a panel type", function () {
|
it("disallows editing of plot view when object not a panel type", function () {
|
||||||
testViews = [ plotView ];
|
testViews = [plotView];
|
||||||
mockTypeCapability.getKey.andReturn('something.else');
|
mockTypeCapability.getKey.andReturn('something.else');
|
||||||
|
|
||||||
expect(policy.allow(mockEditAction, testContext)).toBe(false);
|
expect(policy.allow(mockEditAction, testContext)).toBe(false);
|
||||||
@@ -131,7 +131,7 @@ define(
|
|||||||
|
|
||||||
|
|
||||||
it("allows the edit properties outside of the 'view-control' category", function () {
|
it("allows the edit properties outside of the 'view-control' category", function () {
|
||||||
testViews = [ nonEditableView ];
|
testViews = [nonEditableView];
|
||||||
testContext.category = "something-else";
|
testContext.category = "something-else";
|
||||||
expect(policy.allow(mockPropertiesAction, testContext)).toBe(true);
|
expect(policy.allow(mockPropertiesAction, testContext)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -61,12 +61,12 @@ define(
|
|||||||
policy = new EditContextualActionPolicy(navigationService, editModeBlacklist, nonEditContextBlacklist);
|
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);
|
expect(policy.allow(mockAction, context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Allows "window" action when navigated object in edit mode,' +
|
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);
|
navigatedObject.hasCapability.andReturn(true);
|
||||||
mockEditorCapability.isEditContextRoot.andReturn(true);
|
mockEditorCapability.isEditContextRoot.andReturn(true);
|
||||||
metadata.key = "window";
|
metadata.key = "window";
|
||||||
@@ -75,7 +75,7 @@ define(
|
|||||||
|
|
||||||
it('Allows "remove" action when navigated object in edit mode,' +
|
it('Allows "remove" action when navigated object in edit mode,' +
|
||||||
' and selected object not editable, but its parent is.',
|
' and selected object not editable, but its parent is.',
|
||||||
function() {
|
function () {
|
||||||
var mockParent = jasmine.createSpyObj("parentObject", ["hasCapability"]),
|
var mockParent = jasmine.createSpyObj("parentObject", ["hasCapability"]),
|
||||||
mockContextCapability = jasmine.createSpyObj("contextCapability", ["getParent"]);
|
mockContextCapability = jasmine.createSpyObj("contextCapability", ["getParent"]);
|
||||||
|
|
||||||
@@ -93,10 +93,10 @@ define(
|
|||||||
metadata.key = "remove";
|
metadata.key = "remove";
|
||||||
|
|
||||||
expect(policy.allow(mockAction, context)).toBe(true);
|
expect(policy.allow(mockAction, context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Disallows "move" action when navigated object in edit mode,' +
|
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);
|
navigatedObject.hasCapability.andReturn(true);
|
||||||
mockEditorCapability.isEditContextRoot.andReturn(true);
|
mockEditorCapability.isEditContextRoot.andReturn(true);
|
||||||
mockEditorCapability.inEditContext.andReturn(false);
|
mockEditorCapability.inEditContext.andReturn(false);
|
||||||
@@ -105,7 +105,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Disallows copy action when navigated object and' +
|
it('Disallows copy action when navigated object and' +
|
||||||
' selected object in edit mode', function() {
|
' selected object in edit mode', function () {
|
||||||
navigatedObject.hasCapability.andReturn(true);
|
navigatedObject.hasCapability.andReturn(true);
|
||||||
mockDomainObject.hasCapability.andReturn(true);
|
mockDomainObject.hasCapability.andReturn(true);
|
||||||
mockEditorCapability.isEditContextRoot.andReturn(true);
|
mockEditorCapability.isEditContextRoot.andReturn(true);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ define(
|
|||||||
['hasCapability', 'getCapability']
|
['hasCapability', 'getCapability']
|
||||||
);
|
);
|
||||||
mockDomainObject.getCapability.andReturn({
|
mockDomainObject.getCapability.andReturn({
|
||||||
inEditContext: function () {
|
inEditContext: function () {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ define(
|
|||||||
mockDomainObject.getModel.andReturn({});
|
mockDomainObject.getModel.andReturn({});
|
||||||
mockDomainObject.hasCapability.andReturn(true);
|
mockDomainObject.hasCapability.andReturn(true);
|
||||||
mockDomainObject.useCapability.andReturn(true);
|
mockDomainObject.useCapability.andReturn(true);
|
||||||
mockDomainObject.getCapability.andCallFake(function(capability){
|
mockDomainObject.getCapability.andCallFake(function (capability) {
|
||||||
return mockCapabilities[capability];
|
return mockCapabilities[capability];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -34,13 +34,13 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
'$scope',
|
'$scope',
|
||||||
[ '$on', '$watch', '$watchCollection', "commit" ]
|
['$on', '$watch', '$watchCollection', "commit"]
|
||||||
);
|
);
|
||||||
mockElement = {};
|
mockElement = {};
|
||||||
testAttrs = { toolbar: 'testToolbar' };
|
testAttrs = { toolbar: 'testToolbar' };
|
||||||
mockScope.$parent = jasmine.createSpyObj(
|
mockScope.$parent = jasmine.createSpyObj(
|
||||||
'$parent',
|
'$parent',
|
||||||
[ '$watch', '$watchCollection' ]
|
['$watch', '$watchCollection']
|
||||||
);
|
);
|
||||||
mockUnwatch = jasmine.createSpy('unwatch');
|
mockUnwatch = jasmine.createSpy('unwatch');
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ define(
|
|||||||
|
|
||||||
// Provide a view which has a toolbar
|
// Provide a view which has a toolbar
|
||||||
representer.represent({
|
representer.represent({
|
||||||
toolbar: { sections: [ { items: [ { property: 'k' } ] } ] }
|
toolbar: { sections: [{ items: [{ property: 'k' }] }] }
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the selection
|
// Update the selection
|
||||||
@@ -120,7 +120,7 @@ define(
|
|||||||
|
|
||||||
// Provide a view which has a toolbar
|
// Provide a view which has a toolbar
|
||||||
representer.represent({
|
representer.represent({
|
||||||
toolbar: { sections: [ { items: [ { property: 'k' } ] } ] }
|
toolbar: { sections: [{ items: [{ property: 'k' }] }] }
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the selection
|
// Update the selection
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ define(
|
|||||||
|
|
||||||
it("provides properties from the original structure", function () {
|
it("provides properties from the original structure", function () {
|
||||||
expect(
|
expect(
|
||||||
new EditToolbar(testStructure, [ testABC ])
|
new EditToolbar(testStructure, [testABC])
|
||||||
.getStructure()
|
.getStructure()
|
||||||
.sections[0]
|
.sections[0]
|
||||||
.items[1]
|
.items[1]
|
||||||
@@ -87,7 +87,7 @@ define(
|
|||||||
// This is needed by mct-toolbar
|
// This is needed by mct-toolbar
|
||||||
it("adds keys to form structure", function () {
|
it("adds keys to form structure", function () {
|
||||||
expect(
|
expect(
|
||||||
new EditToolbar(testStructure, [ testABC ])
|
new EditToolbar(testStructure, [testABC])
|
||||||
.getStructure()
|
.getStructure()
|
||||||
.sections[0]
|
.sections[0]
|
||||||
.items[1]
|
.items[1]
|
||||||
@@ -97,20 +97,20 @@ define(
|
|||||||
|
|
||||||
it("marks empty sections as hidden", function () {
|
it("marks empty sections as hidden", function () {
|
||||||
// Verify that all sections are included when applicable...
|
// Verify that all sections are included when applicable...
|
||||||
toolbar.setSelection([ testABCXYZ ]);
|
toolbar.setSelection([testABCXYZ]);
|
||||||
expect(toolbar.getStructure().sections.map(getVisibility))
|
expect(toolbar.getStructure().sections.map(getVisibility))
|
||||||
.toEqual([ true, true, false ]);
|
.toEqual([true, true, false]);
|
||||||
|
|
||||||
// ...but omitted when only some are applicable
|
// ...but omitted when only some are applicable
|
||||||
toolbar.setSelection([ testABC ]);
|
toolbar.setSelection([testABC]);
|
||||||
expect(toolbar.getStructure().sections.map(getVisibility))
|
expect(toolbar.getStructure().sections.map(getVisibility))
|
||||||
.toEqual([ true, false, false ]);
|
.toEqual([true, false, false]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reads properties from selections", function () {
|
it("reads properties from selections", function () {
|
||||||
var structure, state;
|
var structure, state;
|
||||||
|
|
||||||
toolbar.setSelection([ testABC ]);
|
toolbar.setSelection([testABC]);
|
||||||
|
|
||||||
structure = toolbar.getStructure();
|
structure = toolbar.getStructure();
|
||||||
state = toolbar.getState();
|
state = toolbar.getState();
|
||||||
@@ -126,9 +126,11 @@ 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();
|
||||||
state = toolbar.getState();
|
state = toolbar.getState();
|
||||||
|
|
||||||
@@ -137,7 +139,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("sets properties on update", function () {
|
it("sets properties on update", function () {
|
||||||
toolbar.setSelection([ testABC ]);
|
toolbar.setSelection([testABC]);
|
||||||
toolbar.updateState(
|
toolbar.updateState(
|
||||||
toolbar.getStructure().sections[0].items[0].key,
|
toolbar.getStructure().sections[0].items[0].key,
|
||||||
"new value"
|
"new value"
|
||||||
@@ -151,7 +153,7 @@ define(
|
|||||||
|
|
||||||
testABC.a = jasmine.createSpy('a');
|
testABC.a = jasmine.createSpy('a');
|
||||||
|
|
||||||
toolbar.setSelection([ testABC ]);
|
toolbar.setSelection([testABC]);
|
||||||
structure = toolbar.getStructure();
|
structure = toolbar.getStructure();
|
||||||
|
|
||||||
toolbar.updateState(
|
toolbar.updateState(
|
||||||
@@ -165,7 +167,7 @@ define(
|
|||||||
it("provides a return value describing update status", function () {
|
it("provides a return value describing update status", function () {
|
||||||
// Should return true if actually updated, otherwise false
|
// Should return true if actually updated, otherwise false
|
||||||
var key;
|
var key;
|
||||||
toolbar.setSelection([ testABC ]);
|
toolbar.setSelection([testABC]);
|
||||||
key = toolbar.getStructure().sections[0].items[0].key;
|
key = toolbar.getStructure().sections[0].items[0].key;
|
||||||
expect(toolbar.updateState(key, testABC.a)).toBeFalsy();
|
expect(toolbar.updateState(key, testABC.a)).toBeFalsy();
|
||||||
expect(toolbar.updateState(key, "new value")).toBeTruthy();
|
expect(toolbar.updateState(key, "new value")).toBeTruthy();
|
||||||
@@ -173,35 +175,35 @@ define(
|
|||||||
|
|
||||||
it("removes inapplicable items", function () {
|
it("removes inapplicable items", function () {
|
||||||
// First, verify with all items
|
// First, verify with all items
|
||||||
toolbar.setSelection([ testABC ]);
|
toolbar.setSelection([testABC]);
|
||||||
expect(toolbar.getStructure().sections[0].items.map(getVisibility))
|
expect(toolbar.getStructure().sections[0].items.map(getVisibility))
|
||||||
.toEqual([ true, true, true ]);
|
.toEqual([true, true, true]);
|
||||||
// Then, try with some items omitted
|
// Then, try with some items omitted
|
||||||
toolbar.setSelection([ testABC, testAB ]);
|
toolbar.setSelection([testABC, testAB]);
|
||||||
expect(toolbar.getStructure().sections[0].items.map(getVisibility))
|
expect(toolbar.getStructure().sections[0].items.map(getVisibility))
|
||||||
.toEqual([ true, true, false ]);
|
.toEqual([true, true, false]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("removes inconsistent states", function () {
|
it("removes inconsistent states", function () {
|
||||||
// Only two of three values match among these selections
|
// 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))
|
expect(toolbar.getStructure().sections[0].items.map(getVisibility))
|
||||||
.toEqual([ false, true, true ]);
|
.toEqual([false, true, true]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows inclusive items", function () {
|
it("allows inclusive items", function () {
|
||||||
// One inclusive item is in the set, property 'x' of the
|
// One inclusive item is in the set, property 'x' of the
|
||||||
// second section; make sure items are pruned down
|
// second section; make sure items are pruned down
|
||||||
// when only some of the selection has x,y,z properties
|
// 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))
|
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 () {
|
it("removes inclusive items when there are no matches", function () {
|
||||||
toolbar.setSelection([ testABCYZ ]);
|
toolbar.setSelection([testABCYZ]);
|
||||||
expect(toolbar.getStructure().sections[1].items.map(getVisibility))
|
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 () {
|
it("adds click functions when a method is specified", function () {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ define(
|
|||||||
mockLog,
|
mockLog,
|
||||||
transactionService;
|
transactionService;
|
||||||
|
|
||||||
function fastPromise (val) {
|
function fastPromise(val) {
|
||||||
return {
|
return {
|
||||||
then: function (callback) {
|
then: function (callback) {
|
||||||
return fastPromise(callback(val));
|
return fastPromise(callback(val));
|
||||||
@@ -75,8 +75,8 @@ define(
|
|||||||
describe("commit", function () {
|
describe("commit", function () {
|
||||||
var onCommits;
|
var onCommits;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
onCommits = [0, 1, 2].map(function(val) {
|
onCommits = [0, 1, 2].map(function (val) {
|
||||||
return jasmine.createSpy("onCommit" + val);
|
return jasmine.createSpy("onCommit" + val);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ define(
|
|||||||
it("commit calls all queued commit functions", function () {
|
it("commit calls all queued commit functions", function () {
|
||||||
expect(transactionService.onCommits.length).toBe(3);
|
expect(transactionService.onCommits.length).toBe(3);
|
||||||
transactionService.commit();
|
transactionService.commit();
|
||||||
onCommits.forEach( function (spy) {
|
onCommits.forEach(function (spy) {
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -104,8 +104,8 @@ define(
|
|||||||
describe("cancel", function () {
|
describe("cancel", function () {
|
||||||
var onCancels;
|
var onCancels;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
onCancels = [0, 1, 2].map(function(val) {
|
onCancels = [0, 1, 2].map(function (val) {
|
||||||
return jasmine.createSpy("onCancel" + val);
|
return jasmine.createSpy("onCancel" + val);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ define(
|
|||||||
it("cancel calls all queued cancel functions", function () {
|
it("cancel calls all queued cancel functions", function () {
|
||||||
expect(transactionService.onCancels.length).toBe(3);
|
expect(transactionService.onCancels.length).toBe(3);
|
||||||
transactionService.cancel();
|
transactionService.cancel();
|
||||||
onCancels.forEach( function (spy) {
|
onCancels.forEach(function (spy) {
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ define(
|
|||||||
['../src/FormatProvider'],
|
['../src/FormatProvider'],
|
||||||
function (FormatProvider) {
|
function (FormatProvider) {
|
||||||
|
|
||||||
var KEYS = [ 'a', 'b', 'c' ];
|
var KEYS = ['a', 'b', 'c'];
|
||||||
|
|
||||||
describe("The FormatProvider", function () {
|
describe("The FormatProvider", function () {
|
||||||
var mockFormats,
|
var mockFormats,
|
||||||
@@ -35,12 +35,14 @@ define(
|
|||||||
mockFormatInstances = KEYS.map(function (k) {
|
mockFormatInstances = KEYS.map(function (k) {
|
||||||
return jasmine.createSpyObj(
|
return jasmine.createSpyObj(
|
||||||
'format-' + k,
|
'format-' + k,
|
||||||
[ 'parse', 'validate', 'format' ]
|
['parse', 'validate', 'format']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
// 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;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ define([
|
|||||||
{
|
{
|
||||||
"key": "mctTree",
|
"key": "mctTree",
|
||||||
"implementation": MCTTree,
|
"implementation": MCTTree,
|
||||||
"depends": [ '$parse', 'gestureService' ]
|
"depends": ['$parse', 'gestureService']
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"constants": [
|
"constants": [
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ define(
|
|||||||
function BannerController($scope, notificationService, dialogService) {
|
function BannerController($scope, notificationService, dialogService) {
|
||||||
$scope.active = notificationService.active;
|
$scope.active = notificationService.active;
|
||||||
|
|
||||||
$scope.action = function (action, $event){
|
$scope.action = function (action, $event) {
|
||||||
/*
|
/*
|
||||||
Prevents default 'maximize' behaviour when clicking on
|
Prevents default 'maximize' behaviour when clicking on
|
||||||
notification button
|
notification button
|
||||||
@@ -48,19 +48,19 @@ define(
|
|||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
return action();
|
return action();
|
||||||
};
|
};
|
||||||
$scope.dismiss = function(notification, $event) {
|
$scope.dismiss = function (notification, $event) {
|
||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
notification.dismissOrMinimize();
|
notification.dismissOrMinimize();
|
||||||
};
|
};
|
||||||
$scope.maximize = function(notification) {
|
$scope.maximize = function (notification) {
|
||||||
if (notification.model.severity !== "info"){
|
if (notification.model.severity !== "info") {
|
||||||
|
|
||||||
notification.model.cancel = function(){
|
notification.model.cancel = function () {
|
||||||
dialogService.dismiss();
|
dialogService.dismiss();
|
||||||
};
|
};
|
||||||
//If the notification is dismissed by the user, close
|
//If the notification is dismissed by the user, close
|
||||||
// the dialog.
|
// the dialog.
|
||||||
notification.onDismiss(function(){
|
notification.onDismiss(function () {
|
||||||
dialogService.dismiss();
|
dialogService.dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ define(
|
|||||||
* Get the current state of the toggle.
|
* Get the current state of the toggle.
|
||||||
* @return {boolean} true if active
|
* @return {boolean} true if active
|
||||||
*/
|
*/
|
||||||
ClickAwayController.prototype.isActive =function () {
|
ClickAwayController.prototype.isActive = function () {
|
||||||
return this.state;
|
return this.state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
[ 'moment' ],
|
['moment'],
|
||||||
function (moment) {
|
function (moment) {
|
||||||
|
|
||||||
var TIME_NAMES = {
|
var TIME_NAMES = {
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ define(
|
|||||||
// based on a new mouse event object.
|
// based on a new mouse event object.
|
||||||
function updatePosition(event) {
|
function updatePosition(event) {
|
||||||
// Get the current position, as an array
|
// Get the current position, as an array
|
||||||
var currentPosition = [ event.pageX, event.pageY ];
|
var currentPosition = [event.pageX, event.pageY];
|
||||||
|
|
||||||
// Track the initial position, if one hasn't been observed
|
// Track the initial position, if one hasn't been observed
|
||||||
initialPosition = initialPosition || currentPosition;
|
initialPosition = initialPosition || currentPosition;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ define(
|
|||||||
function link(scope, element, attrs, ctrl, transclude) {
|
function link(scope, element, attrs, ctrl, transclude) {
|
||||||
var div = $compile(TEMPLATE)(scope),
|
var div = $compile(TEMPLATE)(scope),
|
||||||
rect = element.parent()[0].getBoundingClientRect(),
|
rect = element.parent()[0].getBoundingClientRect(),
|
||||||
position = [ rect.left, rect.top ],
|
position = [rect.left, rect.top],
|
||||||
popup = popupService.display(div, position);
|
popup = popupService.display(div, position);
|
||||||
|
|
||||||
// TODO: Handle in CSS;
|
// TODO: Handle in CSS;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ define(
|
|||||||
},
|
},
|
||||||
// Grab the event when the user is done moving
|
// Grab the event when the user is done moving
|
||||||
// the splitter and pass it on
|
// the splitter and pass it on
|
||||||
endMove: function() {
|
endMove: function () {
|
||||||
mctSplitPane.toggleClass('resizing');
|
mctSplitPane.toggleClass('resizing');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ define(
|
|||||||
var $document = this.$document,
|
var $document = this.$document,
|
||||||
$window = this.$window,
|
$window = this.$window,
|
||||||
body = $document.find('body'),
|
body = $document.find('body'),
|
||||||
winDim = [ $window.innerWidth, $window.innerHeight ],
|
winDim = [$window.innerWidth, $window.innerHeight],
|
||||||
styles = { position: 'absolute' },
|
styles = { position: 'absolute' },
|
||||||
margin,
|
margin,
|
||||||
offset;
|
offset;
|
||||||
@@ -93,7 +93,7 @@ define(
|
|||||||
options.offsetX !== undefined ? options.offsetX : 0,
|
options.offsetX !== undefined ? options.offsetX : 0,
|
||||||
options.offsetY !== undefined ? options.offsetY : 0
|
options.offsetY !== undefined ? options.offsetY : 0
|
||||||
];
|
];
|
||||||
margin = [ options.marginX, options.marginY ].map(function (m, i) {
|
margin = [options.marginX, options.marginY].map(function (m, i) {
|
||||||
return m === undefined ? (winDim[i] / 2) : m;
|
return m === undefined ? (winDim[i] / 2) : m;
|
||||||
}).map(adjustNegatives);
|
}).map(adjustNegatives);
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ define([
|
|||||||
this.activeGestures = this.gestureService.attachGestures(
|
this.activeGestures = this.gestureService.attachGestures(
|
||||||
this.elements(),
|
this.elements(),
|
||||||
domainObject,
|
domainObject,
|
||||||
[ 'info', 'menu', 'drag' ]
|
['info', 'menu', 'drag']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ define(
|
|||||||
|
|
||||||
mockPlainDocument =
|
mockPlainDocument =
|
||||||
jasmine.createSpyObj("document", ["createElement"]);
|
jasmine.createSpyObj("document", ["createElement"]);
|
||||||
mockDocument = [ mockPlainDocument ];
|
mockDocument = [mockPlainDocument];
|
||||||
mockDocument.find = jasmine.createSpy("$document.find");
|
mockDocument.find = jasmine.createSpy("$document.find");
|
||||||
mockHead = jasmine.createSpyObj("head", ["append"]);
|
mockHead = jasmine.createSpyObj("head", ["append"]);
|
||||||
mockElement = jasmine.createSpyObj("link", ["setAttribute"]);
|
mockElement = jasmine.createSpyObj("link", ["setAttribute"]);
|
||||||
|
|||||||
@@ -35,11 +35,13 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockIndicator = jasmine.createSpyObj(
|
mockIndicator = jasmine.createSpyObj(
|
||||||
"indicator",
|
"indicator",
|
||||||
[ "getGlyph", "getText" ]
|
["getGlyph", "getText"]
|
||||||
);
|
);
|
||||||
|
|
||||||
testIndicatorA = {};
|
testIndicatorA = {};
|
||||||
testIndicatorB = function () { return mockIndicator; };
|
testIndicatorB = function () {
|
||||||
|
return mockIndicator;
|
||||||
|
};
|
||||||
testIndicatorC = { template: "someTemplate" };
|
testIndicatorC = { template: "someTemplate" };
|
||||||
|
|
||||||
testIndicators = [
|
testIndicators = [
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockDocument = jasmine.createSpyObj(
|
mockDocument = jasmine.createSpyObj(
|
||||||
"$document",
|
"$document",
|
||||||
[ "on", "off" ]
|
["on", "off"]
|
||||||
);
|
);
|
||||||
mockTimeout = jasmine.createSpy('timeout');
|
mockTimeout = jasmine.createSpy('timeout');
|
||||||
controller = new ClickAwayController(
|
controller = new ClickAwayController(
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
"$scope",
|
"$scope",
|
||||||
[ "$apply", "$watch", "$watchCollection" ]
|
["$apply", "$watch", "$watchCollection"]
|
||||||
);
|
);
|
||||||
mockScope.ngModel = {};
|
mockScope.ngModel = {};
|
||||||
mockScope.field = "testField";
|
mockScope.field = "testField";
|
||||||
|
|||||||
@@ -39,35 +39,35 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
"$scope",
|
"$scope",
|
||||||
[ "$watch" ]
|
["$watch"]
|
||||||
);
|
);
|
||||||
mockScope.ngModel = {};
|
mockScope.ngModel = {};
|
||||||
mockScope.ngModel.selectedObject = 'mock selected object';
|
mockScope.ngModel.selectedObject = 'mock selected object';
|
||||||
|
|
||||||
mockObjectService = jasmine.createSpyObj(
|
mockObjectService = jasmine.createSpyObj(
|
||||||
"objectService",
|
"objectService",
|
||||||
[ "getObjects" ]
|
["getObjects"]
|
||||||
);
|
);
|
||||||
mockPromise = jasmine.createSpyObj(
|
mockPromise = jasmine.createSpyObj(
|
||||||
"promise",
|
"promise",
|
||||||
[ "then" ]
|
["then"]
|
||||||
);
|
);
|
||||||
mockObjectService.getObjects.andReturn(mockPromise);
|
mockObjectService.getObjects.andReturn(mockPromise);
|
||||||
|
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"selectedObject",
|
"selectedObject",
|
||||||
[ "hasCapability", "getCapability", "useCapability", "getModel" ]
|
["hasCapability", "getCapability", "useCapability", "getModel"]
|
||||||
);
|
);
|
||||||
mockDomainObject.getModel.andReturn({location: 'somewhere'});
|
mockDomainObject.getModel.andReturn({location: 'somewhere'});
|
||||||
mockDomainObject.hasCapability.andReturn(true);
|
mockDomainObject.hasCapability.andReturn(true);
|
||||||
|
|
||||||
mockContextCapability = jasmine.createSpyObj(
|
mockContextCapability = jasmine.createSpyObj(
|
||||||
"context capability",
|
"context capability",
|
||||||
[ "getParent" ]
|
["getParent"]
|
||||||
);
|
);
|
||||||
mockLocationCapability = jasmine.createSpyObj(
|
mockLocationCapability = jasmine.createSpyObj(
|
||||||
"location capability",
|
"location capability",
|
||||||
[ "isLink" ]
|
["isLink"]
|
||||||
);
|
);
|
||||||
mockDomainObject.getCapability.andCallFake(function (param) {
|
mockDomainObject.getCapability.andCallFake(function (param) {
|
||||||
if (param === 'location') {
|
if (param === 'location') {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ define(
|
|||||||
function makeMockObject(id) {
|
function makeMockObject(id) {
|
||||||
var mockObject = jasmine.createSpyObj(
|
var mockObject = jasmine.createSpyObj(
|
||||||
'object-' + id,
|
'object-' + id,
|
||||||
[ 'getId' ]
|
['getId']
|
||||||
);
|
);
|
||||||
mockObject.getId.andReturn(id);
|
mockObject.getId.andReturn(id);
|
||||||
return mockObject;
|
return mockObject;
|
||||||
@@ -60,15 +60,15 @@ define(
|
|||||||
);
|
);
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
'domainObject',
|
'domainObject',
|
||||||
[ 'getCapability', 'hasCapability' ]
|
['getCapability', 'hasCapability']
|
||||||
);
|
);
|
||||||
mockType = jasmine.createSpyObj(
|
mockType = jasmine.createSpyObj(
|
||||||
'type',
|
'type',
|
||||||
[ 'instanceOf' ]
|
['instanceOf']
|
||||||
);
|
);
|
||||||
mockDomainObjects = {};
|
mockDomainObjects = {};
|
||||||
|
|
||||||
[ "ROOT", "abc", "def", "xyz" ].forEach(function (id) {
|
["ROOT", "abc", "def", "xyz"].forEach(function (id) {
|
||||||
mockDomainObjects[id] = makeMockObject(id);
|
mockDomainObjects[id] = makeMockObject(id);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("watches for changes in controlled property", function () {
|
it("watches for changes in controlled property", function () {
|
||||||
var testValue = [ "a", "b", 1, 2 ];
|
var testValue = ["a", "b", 1, 2];
|
||||||
// This test is sensitive to ordering of watch calls
|
// This test is sensitive to ordering of watch calls
|
||||||
expect(mockScope.$watchCollection.calls.length).toEqual(1);
|
expect(mockScope.$watchCollection.calls.length).toEqual(1);
|
||||||
// Make sure we're watching the correct object
|
// Make sure we're watching the correct object
|
||||||
@@ -131,7 +131,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("loads objects when the underlying list changes", function () {
|
it("loads objects when the underlying list changes", function () {
|
||||||
var testIds = [ "abc", "def", "xyz" ];
|
var testIds = ["abc", "def", "xyz"];
|
||||||
// This test is sensitive to ordering of watch calls
|
// This test is sensitive to ordering of watch calls
|
||||||
expect(mockScope.$watchCollection.calls.length).toEqual(1);
|
expect(mockScope.$watchCollection.calls.length).toEqual(1);
|
||||||
// Make sure we're watching the correct object
|
// Make sure we're watching the correct object
|
||||||
|
|||||||
@@ -56,16 +56,16 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
"$scope",
|
"$scope",
|
||||||
[ "$apply", "$watch", "$watchCollection" ]
|
["$apply", "$watch", "$watchCollection"]
|
||||||
);
|
);
|
||||||
mockFormatService = jasmine.createSpyObj(
|
mockFormatService = jasmine.createSpyObj(
|
||||||
"formatService",
|
"formatService",
|
||||||
[ "getFormat" ]
|
["getFormat"]
|
||||||
);
|
);
|
||||||
testDefaultFormat = 'utc';
|
testDefaultFormat = 'utc';
|
||||||
mockFormat = jasmine.createSpyObj(
|
mockFormat = jasmine.createSpyObj(
|
||||||
"format",
|
"format",
|
||||||
[ "validate", "format", "parse" ]
|
["validate", "format", "parse"]
|
||||||
);
|
);
|
||||||
|
|
||||||
mockFormatService.getFormat.andReturn(mockFormat);
|
mockFormatService.getFormat.andReturn(mockFormat);
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
@@ -44,7 +46,7 @@ define(
|
|||||||
mockTimeout = jasmine.createSpy("$timeout");
|
mockTimeout = jasmine.createSpy("$timeout");
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getCapability", "getModel", "useCapability" ]
|
["getId", "getCapability", "getModel", "useCapability"]
|
||||||
);
|
);
|
||||||
|
|
||||||
controller = new TreeNodeController(mockScope, mockTimeout);
|
controller = new TreeNodeController(mockScope, mockTimeout);
|
||||||
@@ -71,7 +73,7 @@ define(
|
|||||||
// This is needed to highlight the current selection
|
// This is needed to highlight the current selection
|
||||||
var mockContext = jasmine.createSpyObj(
|
var mockContext = jasmine.createSpyObj(
|
||||||
"context",
|
"context",
|
||||||
[ "getParent", "getPath", "getRoot" ]
|
["getParent", "getPath", "getRoot"]
|
||||||
),
|
),
|
||||||
obj = new TestObject("test-object", mockContext);
|
obj = new TestObject("test-object", mockContext);
|
||||||
|
|
||||||
@@ -92,11 +94,11 @@ define(
|
|||||||
it("expands a node if it is on the navigation path", function () {
|
it("expands a node if it is on the navigation path", function () {
|
||||||
var mockParentContext = jasmine.createSpyObj(
|
var mockParentContext = jasmine.createSpyObj(
|
||||||
"parentContext",
|
"parentContext",
|
||||||
[ "getParent", "getPath", "getRoot" ]
|
["getParent", "getPath", "getRoot"]
|
||||||
),
|
),
|
||||||
mockChildContext = jasmine.createSpyObj(
|
mockChildContext = jasmine.createSpyObj(
|
||||||
"childContext",
|
"childContext",
|
||||||
[ "getParent", "getPath", "getRoot" ]
|
["getParent", "getPath", "getRoot"]
|
||||||
),
|
),
|
||||||
parent = new TestObject("parent", mockParentContext),
|
parent = new TestObject("parent", mockParentContext),
|
||||||
child = new TestObject("child", mockChildContext);
|
child = new TestObject("child", mockChildContext);
|
||||||
@@ -128,11 +130,11 @@ define(
|
|||||||
it("does not expand a node if it is not on the navigation path", function () {
|
it("does not expand a node if it is not on the navigation path", function () {
|
||||||
var mockParentContext = jasmine.createSpyObj(
|
var mockParentContext = jasmine.createSpyObj(
|
||||||
"parentContext",
|
"parentContext",
|
||||||
[ "getParent", "getPath", "getRoot" ]
|
["getParent", "getPath", "getRoot"]
|
||||||
),
|
),
|
||||||
mockChildContext = jasmine.createSpyObj(
|
mockChildContext = jasmine.createSpyObj(
|
||||||
"childContext",
|
"childContext",
|
||||||
[ "getParent", "getPath", "getRoot" ]
|
["getParent", "getPath", "getRoot"]
|
||||||
),
|
),
|
||||||
parent = new TestObject("parent", mockParentContext),
|
parent = new TestObject("parent", mockParentContext),
|
||||||
child = new TestObject("child", mockChildContext);
|
child = new TestObject("child", mockChildContext);
|
||||||
@@ -161,11 +163,11 @@ define(
|
|||||||
it("does not expand a node if no context is available", function () {
|
it("does not expand a node if no context is available", function () {
|
||||||
var mockParentContext = jasmine.createSpyObj(
|
var mockParentContext = jasmine.createSpyObj(
|
||||||
"parentContext",
|
"parentContext",
|
||||||
[ "getParent", "getPath", "getRoot" ]
|
["getParent", "getPath", "getRoot"]
|
||||||
),
|
),
|
||||||
mockChildContext = jasmine.createSpyObj(
|
mockChildContext = jasmine.createSpyObj(
|
||||||
"childContext",
|
"childContext",
|
||||||
[ "getParent", "getPath", "getRoot" ]
|
["getParent", "getPath", "getRoot"]
|
||||||
),
|
),
|
||||||
parent = new TestObject("parent", mockParentContext),
|
parent = new TestObject("parent", mockParentContext),
|
||||||
child = new TestObject("child", undefined);
|
child = new TestObject("child", undefined);
|
||||||
|
|||||||
@@ -33,9 +33,11 @@ define(
|
|||||||
controller;
|
controller;
|
||||||
|
|
||||||
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);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ define(
|
|||||||
["../../src/directives/MCTClickElsewhere"],
|
["../../src/directives/MCTClickElsewhere"],
|
||||||
function (MCTClickElsewhere) {
|
function (MCTClickElsewhere) {
|
||||||
|
|
||||||
var JQLITE_METHODS = [ "on", "off", "find", "parent" ];
|
var JQLITE_METHODS = ["on", "off", "find", "parent"];
|
||||||
|
|
||||||
describe("The mct-click-elsewhere directive", function () {
|
describe("The mct-click-elsewhere directive", function () {
|
||||||
var mockDocument,
|
var mockDocument,
|
||||||
@@ -48,7 +48,7 @@ define(
|
|||||||
mockDocument =
|
mockDocument =
|
||||||
jasmine.createSpyObj("$document", JQLITE_METHODS);
|
jasmine.createSpyObj("$document", JQLITE_METHODS);
|
||||||
mockScope =
|
mockScope =
|
||||||
jasmine.createSpyObj("$scope", [ "$eval", "$apply", "$on" ]);
|
jasmine.createSpyObj("$scope", ["$eval", "$apply", "$on"]);
|
||||||
mockElement =
|
mockElement =
|
||||||
jasmine.createSpyObj("element", JQLITE_METHODS);
|
jasmine.createSpyObj("element", JQLITE_METHODS);
|
||||||
mockBody =
|
mockBody =
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ define(
|
|||||||
bundle: { path: "x", resources: "y" },
|
bundle: { path: "x", resources: "y" },
|
||||||
template: "<span>bar</span>",
|
template: "<span>bar</span>",
|
||||||
key: "xyz",
|
key: "xyz",
|
||||||
attributes: [ "someAttr", "someOtherAttr" ]
|
attributes: ["someAttr", "someOtherAttr"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
mctContainer;
|
mctContainer;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ define(
|
|||||||
["../../src/directives/MCTDrag"],
|
["../../src/directives/MCTDrag"],
|
||||||
function (MCTDrag) {
|
function (MCTDrag) {
|
||||||
|
|
||||||
var JQLITE_METHODS = [ "on", "off", "find" ];
|
var JQLITE_METHODS = ["on", "off", "find"];
|
||||||
|
|
||||||
describe("The mct-drag directive", function () {
|
describe("The mct-drag directive", function () {
|
||||||
var mockDocument,
|
var mockDocument,
|
||||||
@@ -46,7 +46,7 @@ define(
|
|||||||
mockDocument =
|
mockDocument =
|
||||||
jasmine.createSpyObj("$document", JQLITE_METHODS);
|
jasmine.createSpyObj("$document", JQLITE_METHODS);
|
||||||
mockScope =
|
mockScope =
|
||||||
jasmine.createSpyObj("$scope", [ "$eval", "$apply" ]);
|
jasmine.createSpyObj("$scope", ["$eval", "$apply"]);
|
||||||
mockElement =
|
mockElement =
|
||||||
jasmine.createSpyObj("element", JQLITE_METHODS);
|
jasmine.createSpyObj("element", JQLITE_METHODS);
|
||||||
mockBody =
|
mockBody =
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ define(
|
|||||||
["../../src/directives/MCTPopup"],
|
["../../src/directives/MCTPopup"],
|
||||||
function (MCTPopup) {
|
function (MCTPopup) {
|
||||||
|
|
||||||
var JQLITE_METHODS = [ "on", "off", "find", "parent", "css", "append" ];
|
var JQLITE_METHODS = ["on", "off", "find", "parent", "css", "append"];
|
||||||
|
|
||||||
describe("The mct-popup directive", function () {
|
describe("The mct-popup directive", function () {
|
||||||
var mockCompile,
|
var mockCompile,
|
||||||
@@ -48,7 +48,7 @@ define(
|
|||||||
mockPopup =
|
mockPopup =
|
||||||
jasmine.createSpyObj("popup", ["dismiss"]);
|
jasmine.createSpyObj("popup", ["dismiss"]);
|
||||||
mockScope =
|
mockScope =
|
||||||
jasmine.createSpyObj("$scope", [ "$eval", "$apply", "$on" ]);
|
jasmine.createSpyObj("$scope", ["$eval", "$apply", "$on"]);
|
||||||
mockElement =
|
mockElement =
|
||||||
jasmine.createSpyObj("element", JQLITE_METHODS);
|
jasmine.createSpyObj("element", JQLITE_METHODS);
|
||||||
mockBody =
|
mockBody =
|
||||||
@@ -98,7 +98,7 @@ define(
|
|||||||
it("displays as a popup", function () {
|
it("displays as a popup", function () {
|
||||||
expect(mockPopupService.display).toHaveBeenCalledWith(
|
expect(mockPopupService.display).toHaveBeenCalledWith(
|
||||||
mockNewElement,
|
mockNewElement,
|
||||||
[ testRect.left, testRect.top ]
|
[testRect.left, testRect.top]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -48,16 +48,16 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
'$scope',
|
'$scope',
|
||||||
[ '$on', '$watch' ]
|
['$on', '$watch']
|
||||||
);
|
);
|
||||||
mockElement = jasmine.createSpyObj(
|
mockElement = jasmine.createSpyObj(
|
||||||
'element',
|
'element',
|
||||||
[ 'addClass' ]
|
['addClass']
|
||||||
);
|
);
|
||||||
testAttrs = {};
|
testAttrs = {};
|
||||||
mockSplitPane = jasmine.createSpyObj(
|
mockSplitPane = jasmine.createSpyObj(
|
||||||
'mctSplitPane',
|
'mctSplitPane',
|
||||||
[ 'position', 'toggleClass', 'anchor' ]
|
['position', 'toggleClass', 'anchor']
|
||||||
);
|
);
|
||||||
|
|
||||||
mctSplitter.link(
|
mctSplitter.link(
|
||||||
@@ -92,7 +92,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("repositions during drag", function () {
|
it("repositions during drag", function () {
|
||||||
mockScope.splitter.move([ 10, 0 ]);
|
mockScope.splitter.move([10, 0]);
|
||||||
expect(mockSplitPane.position)
|
expect(mockSplitPane.position)
|
||||||
.toHaveBeenCalledWith(testPosition + 10);
|
.toHaveBeenCalledWith(testPosition + 10);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ define([
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockGestureService = jasmine.createSpyObj(
|
mockGestureService = jasmine.createSpyObj(
|
||||||
'gestureService',
|
'gestureService',
|
||||||
[ 'attachGestures' ]
|
['attachGestures']
|
||||||
);
|
);
|
||||||
mockParse = jasmine.createSpy('$parse');
|
mockParse = jasmine.createSpy('$parse');
|
||||||
mockExpr = jasmine.createSpy('expr');
|
mockExpr = jasmine.createSpy('expr');
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ define(
|
|||||||
popupService;
|
popupService;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockDocument = jasmine.createSpyObj('$document', [ 'find' ]);
|
mockDocument = jasmine.createSpyObj('$document', ['find']);
|
||||||
testWindow = { innerWidth: 1000, innerHeight: 800 };
|
testWindow = { innerWidth: 1000, innerHeight: 800 };
|
||||||
mockBody = jasmine.createSpyObj('body', [ 'append' ]);
|
mockBody = jasmine.createSpyObj('body', ['append']);
|
||||||
mockElement = jasmine.createSpyObj('element', [
|
mockElement = jasmine.createSpyObj('element', [
|
||||||
'css',
|
'css',
|
||||||
'remove'
|
'remove'
|
||||||
@@ -49,13 +49,13 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("adds elements to the body of the document", function () {
|
it("adds elements to the body of the document", function () {
|
||||||
popupService.display(mockElement, [ 0, 0 ]);
|
popupService.display(mockElement, [0, 0]);
|
||||||
expect(mockBody.append).toHaveBeenCalledWith(mockElement);
|
expect(mockBody.append).toHaveBeenCalledWith(mockElement);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when positioned in appropriate quadrants", function () {
|
describe("when positioned in appropriate quadrants", function () {
|
||||||
it("orients elements relative to the top-left", function () {
|
it("orients elements relative to the top-left", function () {
|
||||||
popupService.display(mockElement, [ 25, 50 ]);
|
popupService.display(mockElement, [25, 50]);
|
||||||
expect(mockElement.css).toHaveBeenCalledWith({
|
expect(mockElement.css).toHaveBeenCalledWith({
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
left: '25px',
|
left: '25px',
|
||||||
@@ -64,7 +64,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("orients elements relative to the top-right", function () {
|
it("orients elements relative to the top-right", function () {
|
||||||
popupService.display(mockElement, [ 800, 50 ]);
|
popupService.display(mockElement, [800, 50]);
|
||||||
expect(mockElement.css).toHaveBeenCalledWith({
|
expect(mockElement.css).toHaveBeenCalledWith({
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
right: '200px',
|
right: '200px',
|
||||||
@@ -73,7 +73,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("orients elements relative to the bottom-right", function () {
|
it("orients elements relative to the bottom-right", function () {
|
||||||
popupService.display(mockElement, [ 800, 650 ]);
|
popupService.display(mockElement, [800, 650]);
|
||||||
expect(mockElement.css).toHaveBeenCalledWith({
|
expect(mockElement.css).toHaveBeenCalledWith({
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
right: '200px',
|
right: '200px',
|
||||||
@@ -82,7 +82,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("orients elements relative to the bottom-left", function () {
|
it("orients elements relative to the bottom-left", function () {
|
||||||
popupService.display(mockElement, [ 120, 650 ]);
|
popupService.display(mockElement, [120, 650]);
|
||||||
expect(mockElement.css).toHaveBeenCalledWith({
|
expect(mockElement.css).toHaveBeenCalledWith({
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
left: '120px',
|
left: '120px',
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ define(
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockElement =
|
mockElement =
|
||||||
jasmine.createSpyObj('element', [ 'css', 'remove' ]);
|
jasmine.createSpyObj('element', ['css', 'remove']);
|
||||||
testStyles = { left: '12px', top: '14px' };
|
testStyles = { left: '12px', top: '14px' };
|
||||||
popup = new Popup(mockElement, testStyles);
|
popup = new Popup(mockElement, testStyles);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,15 +40,15 @@ define(
|
|||||||
// do the view search
|
// do the view search
|
||||||
mockLocation = jasmine.createSpyObj(
|
mockLocation = jasmine.createSpyObj(
|
||||||
"$location",
|
"$location",
|
||||||
[ "path", "search" ]
|
["path", "search"]
|
||||||
);
|
);
|
||||||
|
|
||||||
// The mockDomainObject is initialized as a
|
// The mockDomainObject is initialized as a
|
||||||
// spy object to ultimately be passed into the
|
// spy object to ultimately be passed into the
|
||||||
// urlService urlFor function
|
// urlService urlFor function
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getCapability", "getModel", "useCapability" ]
|
["getId", "getCapability", "getModel", "useCapability"]
|
||||||
);
|
);
|
||||||
mockContext = jasmine.createSpyObj('context', ['getPath']);
|
mockContext = jasmine.createSpyObj('context', ['getPath']);
|
||||||
testViews = [
|
testViews = [
|
||||||
|
|||||||
@@ -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,24 +46,24 @@ 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 () {
|
||||||
mockGestureService = jasmine.createSpyObj(
|
mockGestureService = jasmine.createSpyObj(
|
||||||
'gestureService',
|
'gestureService',
|
||||||
[ 'attachGestures' ]
|
['attachGestures']
|
||||||
);
|
);
|
||||||
|
|
||||||
mockGestureHandle = jasmine.createSpyObj('gestures', ['destroy']);
|
mockGestureHandle = jasmine.createSpyObj('gestures', ['destroy']);
|
||||||
@@ -99,24 +99,16 @@ define([
|
|||||||
var mockComposition;
|
var mockComposition;
|
||||||
|
|
||||||
function makeGenericCapabilities() {
|
function makeGenericCapabilities() {
|
||||||
var mockContext =
|
var mockStatus =
|
||||||
jasmine.createSpyObj('context', [ 'getPath' ]),
|
jasmine.createSpyObj('status', ['listen', 'list']);
|
||||||
mockType =
|
|
||||||
jasmine.createSpyObj('type', [ 'getGlyph' ]),
|
|
||||||
mockLocation =
|
|
||||||
jasmine.createSpyObj('location', [ 'isLink' ]),
|
|
||||||
mockMutation =
|
|
||||||
jasmine.createSpyObj('mutation', [ 'listen' ]),
|
|
||||||
mockStatus =
|
|
||||||
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 () {
|
||||||
@@ -231,7 +223,7 @@ define([
|
|||||||
calledBackInner = false;
|
calledBackInner = false;
|
||||||
|
|
||||||
newCapabilities.composition =
|
newCapabilities.composition =
|
||||||
jasmine.createSpyObj('composition', [ 'invoke' ]);
|
jasmine.createSpyObj('composition', ['invoke']);
|
||||||
newCapabilities.composition.invoke
|
newCapabilities.composition.invoke
|
||||||
.andReturn(Promise.resolve([mockGrandchild]));
|
.andReturn(Promise.resolve([mockGrandchild]));
|
||||||
mockComposition.push(mockNewChild);
|
mockComposition.push(mockNewChild);
|
||||||
@@ -274,7 +266,7 @@ define([
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
var mockStatus = mockComposition[1].getCapability('status');
|
var mockStatus = mockComposition[1].getCapability('status');
|
||||||
|
|
||||||
testStatuses = [ 'foo' ];
|
testStatuses = ['foo'];
|
||||||
|
|
||||||
mockStatus.list.andReturn(testStatuses);
|
mockStatus.list.andReturn(testStatuses);
|
||||||
mockStatus.listen.mostRecentCall.args[0](testStatuses);
|
mockStatus.listen.mostRecentCall.args[0](testStatuses);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ define({
|
|||||||
offsetX: 0,
|
offsetX: 0,
|
||||||
offsetY: -26
|
offsetY: -26
|
||||||
},
|
},
|
||||||
BUBBLE_MOBILE_POSITION: [ 0, -25 ],
|
BUBBLE_MOBILE_POSITION: [0, -25],
|
||||||
// Max width and margins allowed for bubbles;
|
// Max width and margins allowed for bubbles;
|
||||||
// defined in /platform/commonUI/general/res/sass/_constants.scss
|
// defined in /platform/commonUI/general/res/sass/_constants.scss
|
||||||
BUBBLE_MARGIN_LR: 10,
|
BUBBLE_MARGIN_LR: 10,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ define(
|
|||||||
// Record touch position, so bubble can be shown at latest
|
// Record touch position, so bubble can be shown at latest
|
||||||
// touch position, also offset by 22px to left (accounts for
|
// touch position, also offset by 22px to left (accounts for
|
||||||
// a finger-sized touch on the info button)
|
// a finger-sized touch on the info button)
|
||||||
touchPosition = [ event.clientX - 22, event.clientY ];
|
touchPosition = [event.clientX - 22, event.clientY];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hides the bubble and detaches the
|
// Hides the bubble and detaches the
|
||||||
@@ -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');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ define(
|
|||||||
InfoGesture.prototype.trackPosition = function (event) {
|
InfoGesture.prototype.trackPosition = function (event) {
|
||||||
// Record mouse position, so bubble can be shown at latest
|
// Record mouse position, so bubble can be shown at latest
|
||||||
// mouse position (not just where the mouse entered)
|
// mouse position (not just where the mouse entered)
|
||||||
this.mousePosition = [ event.clientX, event.clientY ];
|
this.mousePosition = [event.clientX, event.clientY];
|
||||||
};
|
};
|
||||||
|
|
||||||
InfoGesture.prototype.hideBubble = function () {
|
InfoGesture.prototype.hideBubble = function () {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user