mirror of
https://github.com/nasa/openmct.git
synced 2025-01-18 02:39:56 +00:00
[Edit Mode] #627 Fixed failing tests
Removed reference to defunct NavigationServiceDecorator Removed virtual panels from drop gesture
This commit is contained in:
parent
f192544be3
commit
7b5218c5ba
@ -248,6 +248,12 @@ define([
|
|||||||
"implementation": NavigationService
|
"implementation": NavigationService
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"services": [
|
||||||
|
{
|
||||||
|
"key": "navigationService",
|
||||||
|
"implementation": NavigationService
|
||||||
|
}
|
||||||
|
],
|
||||||
"policies": [
|
"policies": [
|
||||||
{
|
{
|
||||||
"implementation": CreationPolicy,
|
"implementation": CreationPolicy,
|
||||||
|
@ -256,7 +256,11 @@ define(
|
|||||||
it("after failed navigation event resets the selected tree" +
|
it("after failed navigation event resets the selected tree" +
|
||||||
" object", function () {
|
" object", function () {
|
||||||
mockScope.navigatedObject = mockDomainObject;
|
mockScope.navigatedObject = mockDomainObject;
|
||||||
mockNavigationService.setNavigation.andReturn(false);
|
mockWindow.confirm.andReturn(false);
|
||||||
|
mockPolicyService.allow.andCallFake(function(category, object, context, callback){
|
||||||
|
callback("unsaved changes");
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
//Simulate a change in selected tree object
|
//Simulate a change in selected tree object
|
||||||
mockScope.treeModel = {selectedObject: mockDomainObject};
|
mockScope.treeModel = {selectedObject: mockDomainObject};
|
||||||
|
@ -89,25 +89,25 @@ define(
|
|||||||
|
|
||||||
controller = new EditObjectController(
|
controller = new EditObjectController(
|
||||||
mockScope,
|
mockScope,
|
||||||
mockLocation
|
mockLocation,
|
||||||
|
mockPolicyService
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("exposes a warning message for unload", function () {
|
it("exposes a warning message for unload", function () {
|
||||||
var obj = mockObject,
|
var obj = mockObject,
|
||||||
mockEditor = jasmine.createSpyObj('editor', ['dirty']);
|
errorMessage = "Unsaved changes";
|
||||||
|
|
||||||
// Normally, should be undefined
|
// Normally, should be undefined
|
||||||
expect(controller.getUnloadWarning()).toBeUndefined();
|
expect(controller.getUnloadWarning()).toBeUndefined();
|
||||||
|
|
||||||
// Override the object's editor capability, make it look
|
// Override the policy service to prevent navigation
|
||||||
// like there are unsaved changes.
|
mockPolicyService.allow.andCallFake(function(category, object, context, callback){
|
||||||
mockCapabilities.editor = mockEditor;
|
callback(errorMessage);
|
||||||
mockEditor.dirty.andReturn(true);
|
});
|
||||||
mockStatusCapability.get.andReturn(true);
|
|
||||||
|
|
||||||
// Should have some warning message here now
|
// Should have some warning message here now
|
||||||
expect(controller.getUnloadWarning()).toEqual(jasmine.any(String));
|
expect(controller.getUnloadWarning()).toEqual(errorMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ define(
|
|||||||
mockScope,
|
mockScope,
|
||||||
testAttrs,
|
testAttrs,
|
||||||
mockEvent,
|
mockEvent,
|
||||||
mockNavigationService,
|
|
||||||
directive;
|
directive;
|
||||||
|
|
||||||
function fireListener(eventType, value) {
|
function fireListener(eventType, value) {
|
||||||
@ -47,8 +46,7 @@ define(
|
|||||||
mockScope = jasmine.createSpyObj("$scope", ['$eval', '$on']);
|
mockScope = jasmine.createSpyObj("$scope", ['$eval', '$on']);
|
||||||
testAttrs = { mctBeforeUnload: "someExpression" };
|
testAttrs = { mctBeforeUnload: "someExpression" };
|
||||||
mockEvent = jasmine.createSpyObj("event", ["preventDefault"]);
|
mockEvent = jasmine.createSpyObj("event", ["preventDefault"]);
|
||||||
mockNavigationService = jasmine.createSpyObj("navigationService", ["addListener", "removeListener"]);
|
directive = new MCTBeforeUnload(mockWindow);
|
||||||
directive = new MCTBeforeUnload(mockWindow, mockNavigationService);
|
|
||||||
directive.link(mockScope, {}, testAttrs);
|
directive.link(mockScope, {}, testAttrs);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -67,10 +65,6 @@ define(
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("listens for navigation changes", function () {
|
|
||||||
expect(mockNavigationService.addListener).toHaveBeenCalledWith(jasmine.any(Function), "before");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("listens for its scope's destroy event", function () {
|
it("listens for its scope's destroy event", function () {
|
||||||
expect(mockScope.$on).toHaveBeenCalledWith(
|
expect(mockScope.$on).toHaveBeenCalledWith(
|
||||||
"$destroy",
|
"$destroy",
|
||||||
@ -114,7 +108,6 @@ define(
|
|||||||
it("cleans up listeners when destroyed", function () {
|
it("cleans up listeners when destroyed", function () {
|
||||||
fireListener("$destroy", mockEvent);
|
fireListener("$destroy", mockEvent);
|
||||||
expect(mockWindow.onbeforeunload).toBeUndefined();
|
expect(mockWindow.onbeforeunload).toBeUndefined();
|
||||||
expect(mockNavigationService.removeListener).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,13 +80,6 @@ define(
|
|||||||
}).length > 0;
|
}).length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldCreateVirtualPanel(domainObject){
|
|
||||||
return domainObject.useCapability('view').filter(function (view){
|
|
||||||
return (view.key === 'plot' || view.key === 'scrolling')
|
|
||||||
&& domainObject.getModel().type !== 'telemetry.panel';
|
|
||||||
}).length > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function dragOver(e) {
|
function dragOver(e) {
|
||||||
//Refresh domain object on each dragOver to catch external
|
//Refresh domain object on each dragOver to catch external
|
||||||
// updates to the model
|
// updates to the model
|
||||||
@ -111,9 +104,7 @@ define(
|
|||||||
key: 'compose',
|
key: 'compose',
|
||||||
selectedObject: selectedObject
|
selectedObject: selectedObject
|
||||||
})[0];
|
})[0];
|
||||||
//TODO: Fix this. Define an action for creating new
|
if (action) {
|
||||||
// virtual panel
|
|
||||||
if (action || shouldCreateVirtualPanel(domainObject, selectedObject)) {
|
|
||||||
event.dataTransfer.dropEffect = 'move';
|
event.dataTransfer.dropEffect = 'move';
|
||||||
|
|
||||||
// Indicate that we will accept the drag
|
// Indicate that we will accept the drag
|
||||||
@ -123,51 +114,15 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createVirtualPanel(base, selectedObject){
|
|
||||||
|
|
||||||
var typeKey = 'telemetry.panel',
|
|
||||||
type = typeService.getType(typeKey),
|
|
||||||
model = type.getInitialModel(),
|
|
||||||
newPanel;
|
|
||||||
|
|
||||||
model.type = typeKey;
|
|
||||||
newPanel = new EditableDomainObject(instantiate(model), $q);
|
|
||||||
if (!canCompose(newPanel, selectedObject)) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
[base.getId(), selectedObject.getId()].forEach(function(id){
|
|
||||||
newPanel.getCapability('composition').add(id);
|
|
||||||
});
|
|
||||||
|
|
||||||
newPanel.getCapability('location')
|
|
||||||
.setPrimaryLocation(base.getCapability('location')
|
|
||||||
.getContextualLocation());
|
|
||||||
|
|
||||||
newPanel.setOriginalObject(base);
|
|
||||||
return newPanel;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function drop(e) {
|
function drop(e) {
|
||||||
var event = (e || {}).originalEvent || e,
|
var event = (e || {}).originalEvent || e,
|
||||||
id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE),
|
id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE),
|
||||||
domainObjectType = editableDomainObject.getModel().type,
|
domainObjectType = editableDomainObject.getModel().type;
|
||||||
selectedObject = dndService.getData(
|
|
||||||
GestureConstants.MCT_EXTENDED_DRAG_TYPE
|
|
||||||
);
|
|
||||||
|
|
||||||
// Handle the drop; add the dropped identifier to the
|
// Handle the drop; add the dropped identifier to the
|
||||||
// destination domain object's composition, and persist
|
// destination domain object's composition, and persist
|
||||||
// the change.
|
// the change.
|
||||||
if (id) {
|
if (id) {
|
||||||
if (shouldCreateVirtualPanel(domainObject, selectedObject)){
|
|
||||||
editableDomainObject = createVirtualPanel(domainObject, selectedObject);
|
|
||||||
if (editableDomainObject) {
|
|
||||||
editableDomainObject.getCapability('action').perform('edit');
|
|
||||||
broadcastDrop(id, event);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$q.when(action && action.perform()).then(function (result) {
|
$q.when(action && action.perform()).then(function (result) {
|
||||||
//Don't go into edit mode for folders
|
//Don't go into edit mode for folders
|
||||||
if (domainObjectType!=='folder') {
|
if (domainObjectType!=='folder') {
|
||||||
@ -177,8 +132,6 @@ define(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Alert user if drag and drop is not allowed
|
|
||||||
}
|
|
||||||
|
|
||||||
// We can only handle drops if we have access to actions...
|
// We can only handle drops if we have access to actions...
|
||||||
if (actionCapability) {
|
if (actionCapability) {
|
||||||
|
Loading…
Reference in New Issue
Block a user