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
|
||||
}
|
||||
],
|
||||
"services": [
|
||||
{
|
||||
"key": "navigationService",
|
||||
"implementation": NavigationService
|
||||
}
|
||||
],
|
||||
"policies": [
|
||||
{
|
||||
"implementation": CreationPolicy,
|
||||
|
@ -256,7 +256,11 @@ define(
|
||||
it("after failed navigation event resets the selected tree" +
|
||||
" object", function () {
|
||||
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
|
||||
mockScope.treeModel = {selectedObject: mockDomainObject};
|
||||
|
@ -89,25 +89,25 @@ define(
|
||||
|
||||
controller = new EditObjectController(
|
||||
mockScope,
|
||||
mockLocation
|
||||
mockLocation,
|
||||
mockPolicyService
|
||||
);
|
||||
});
|
||||
|
||||
it("exposes a warning message for unload", function () {
|
||||
var obj = mockObject,
|
||||
mockEditor = jasmine.createSpyObj('editor', ['dirty']);
|
||||
errorMessage = "Unsaved changes";
|
||||
|
||||
// Normally, should be undefined
|
||||
expect(controller.getUnloadWarning()).toBeUndefined();
|
||||
|
||||
// Override the object's editor capability, make it look
|
||||
// like there are unsaved changes.
|
||||
mockCapabilities.editor = mockEditor;
|
||||
mockEditor.dirty.andReturn(true);
|
||||
mockStatusCapability.get.andReturn(true);
|
||||
// Override the policy service to prevent navigation
|
||||
mockPolicyService.allow.andCallFake(function(category, object, context, callback){
|
||||
callback(errorMessage);
|
||||
});
|
||||
|
||||
// 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,
|
||||
testAttrs,
|
||||
mockEvent,
|
||||
mockNavigationService,
|
||||
directive;
|
||||
|
||||
function fireListener(eventType, value) {
|
||||
@ -47,8 +46,7 @@ define(
|
||||
mockScope = jasmine.createSpyObj("$scope", ['$eval', '$on']);
|
||||
testAttrs = { mctBeforeUnload: "someExpression" };
|
||||
mockEvent = jasmine.createSpyObj("event", ["preventDefault"]);
|
||||
mockNavigationService = jasmine.createSpyObj("navigationService", ["addListener", "removeListener"]);
|
||||
directive = new MCTBeforeUnload(mockWindow, mockNavigationService);
|
||||
directive = new MCTBeforeUnload(mockWindow);
|
||||
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 () {
|
||||
expect(mockScope.$on).toHaveBeenCalledWith(
|
||||
"$destroy",
|
||||
@ -114,10 +108,9 @@ define(
|
||||
it("cleans up listeners when destroyed", function () {
|
||||
fireListener("$destroy", mockEvent);
|
||||
expect(mockWindow.onbeforeunload).toBeUndefined();
|
||||
expect(mockNavigationService.removeListener).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
@ -80,13 +80,6 @@ define(
|
||||
}).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) {
|
||||
//Refresh domain object on each dragOver to catch external
|
||||
// updates to the model
|
||||
@ -111,9 +104,7 @@ define(
|
||||
key: 'compose',
|
||||
selectedObject: selectedObject
|
||||
})[0];
|
||||
//TODO: Fix this. Define an action for creating new
|
||||
// virtual panel
|
||||
if (action || shouldCreateVirtualPanel(domainObject, selectedObject)) {
|
||||
if (action) {
|
||||
event.dataTransfer.dropEffect = 'move';
|
||||
|
||||
// Indicate that we will accept the drag
|
||||
@ -123,61 +114,23 @@ 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) {
|
||||
var event = (e || {}).originalEvent || e,
|
||||
id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE),
|
||||
domainObjectType = editableDomainObject.getModel().type,
|
||||
selectedObject = dndService.getData(
|
||||
GestureConstants.MCT_EXTENDED_DRAG_TYPE
|
||||
);
|
||||
|
||||
domainObjectType = editableDomainObject.getModel().type;
|
||||
|
||||
// Handle the drop; add the dropped identifier to the
|
||||
// destination domain object's composition, and persist
|
||||
// the change.
|
||||
if (id) {
|
||||
if (shouldCreateVirtualPanel(domainObject, selectedObject)){
|
||||
editableDomainObject = createVirtualPanel(domainObject, selectedObject);
|
||||
if (editableDomainObject) {
|
||||
$q.when(action && action.perform()).then(function (result) {
|
||||
//Don't go into edit mode for folders
|
||||
if (domainObjectType!=='folder') {
|
||||
editableDomainObject.getCapability('action').perform('edit');
|
||||
broadcastDrop(id, event);
|
||||
}
|
||||
} else {
|
||||
$q.when(action && action.perform()).then(function (result) {
|
||||
//Don't go into edit mode for folders
|
||||
if (domainObjectType!=='folder') {
|
||||
editableDomainObject.getCapability('action').perform('edit');
|
||||
}
|
||||
broadcastDrop(id, event);
|
||||
});
|
||||
}
|
||||
broadcastDrop(id, event);
|
||||
});
|
||||
}
|
||||
// TODO: Alert user if drag and drop is not allowed
|
||||
}
|
||||
|
||||
// We can only handle drops if we have access to actions...
|
||||
|
Loading…
Reference in New Issue
Block a user