mirror of
https://github.com/nasa/openmct.git
synced 2025-06-01 07:00:49 +00:00
Merge branch 'open277' into open199
This commit is contained in:
commit
9a42cb4f7e
@ -39,6 +39,7 @@
|
||||
class="mobile-hide"
|
||||
key="'label'"
|
||||
mct-object="domainObject"
|
||||
parameters="{suppressMenuOnEdit: true}"
|
||||
ng-click="treeNode.select()"
|
||||
>
|
||||
</mct-representation>
|
||||
|
@ -27,7 +27,8 @@
|
||||
{
|
||||
"key": "menu",
|
||||
"implementation": "gestures/ContextMenuGesture.js",
|
||||
"depends": ["$timeout", "agentService"]
|
||||
"depends": ["$timeout", "$parse", "agentService",
|
||||
"navigationService"]
|
||||
}
|
||||
],
|
||||
"components": [
|
||||
@ -66,8 +67,7 @@
|
||||
"$document",
|
||||
"$rootScope",
|
||||
"popupService",
|
||||
"agentService",
|
||||
"navigationService"
|
||||
"agentService"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -55,14 +55,12 @@ define(
|
||||
$rootScope,
|
||||
popupService,
|
||||
agentService,
|
||||
navigationService,
|
||||
actionContext
|
||||
) {
|
||||
this.$compile = $compile;
|
||||
this.agentService = agentService;
|
||||
this.actionContext = actionContext;
|
||||
this.popupService = popupService;
|
||||
this.navigationService = navigationService;
|
||||
this.getDocument = function () { return $document; };
|
||||
this.getRootScope = function () { return $rootScope; };
|
||||
}
|
||||
@ -84,10 +82,6 @@ define(
|
||||
menu,
|
||||
popup;
|
||||
|
||||
if (this.navigationService.getNavigation() && this.navigationService.getNavigation().hasCapability('editor')){
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove the context menu
|
||||
function dismiss() {
|
||||
if (popup) {
|
||||
|
@ -41,16 +41,32 @@ define(
|
||||
* in the context menu will be performed
|
||||
* @implements {Gesture}
|
||||
*/
|
||||
function ContextMenuGesture($timeout, agentService, element, domainObject) {
|
||||
function ContextMenuGesture($timeout, $parse, agentService, navigationService, element, domainObject) {
|
||||
var isPressing,
|
||||
longTouchTime = 500;
|
||||
longTouchTime = 500,
|
||||
parameters = element && element.attr('parameters') && $parse(element.attr('parameters'))()
|
||||
|
||||
function suppressMenu(){
|
||||
return parameters
|
||||
&& parameters.suppressMenuOnEdit
|
||||
&& navigationService.getNavigation()
|
||||
&& navigationService.getNavigation().hasCapability('editor');
|
||||
}
|
||||
|
||||
function showMenu(event) {
|
||||
domainObject.getCapability('action').perform({
|
||||
key: 'menu',
|
||||
domainObject: domainObject,
|
||||
event: event
|
||||
});
|
||||
/**
|
||||
* Some menu items should have the context menu action
|
||||
* suppressed (eg. the navigation menu on the left)
|
||||
*/
|
||||
if (suppressMenu()){
|
||||
return;
|
||||
} else {
|
||||
domainObject.getCapability('action').perform({
|
||||
key: 'menu',
|
||||
domainObject: domainObject,
|
||||
event: event
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// When context menu event occurs, show object actions instead
|
||||
|
@ -47,8 +47,6 @@ define(
|
||||
mockScope,
|
||||
mockElement,
|
||||
mockDomainObject,
|
||||
mockNavigatedObject,
|
||||
mockNavigationService,
|
||||
mockEvent,
|
||||
mockPopup,
|
||||
mockActionContext,
|
||||
@ -69,11 +67,9 @@ define(
|
||||
]);
|
||||
mockRootScope = jasmine.createSpyObj("$rootScope", ["$new"]);
|
||||
mockAgentService = jasmine.createSpyObj("agentService", ["isMobile"]);
|
||||
mockNavigationService = jasmine.createSpyObj("navigationService", ["getNavigation"]);
|
||||
mockScope = jasmine.createSpyObj("scope", ["$destroy"]);
|
||||
mockElement = jasmine.createSpyObj("element", JQLITE_FUNCTIONS);
|
||||
mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS);
|
||||
mockNavigatedObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS);
|
||||
mockEvent = jasmine.createSpyObj("event", ["preventDefault", "stopPropagation"]);
|
||||
mockEvent.pageX = 123;
|
||||
mockEvent.pageY = 321;
|
||||
@ -83,7 +79,6 @@ define(
|
||||
mockDocument.find.andReturn(mockBody);
|
||||
mockRootScope.$new.andReturn(mockScope);
|
||||
mockPopupService.display.andReturn(mockPopup);
|
||||
mockNavigationService.getNavigation.andReturn(mockNavigatedObject);
|
||||
|
||||
mockActionContext = {key: 'menu', domainObject: mockDomainObject, event: mockEvent};
|
||||
|
||||
@ -93,7 +88,6 @@ define(
|
||||
mockRootScope,
|
||||
mockPopupService,
|
||||
mockAgentService,
|
||||
mockNavigationService,
|
||||
mockActionContext
|
||||
);
|
||||
});
|
||||
@ -188,15 +182,6 @@ define(
|
||||
expect(mockBody.off).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is not active when in edit mode", function () {
|
||||
mockNavigatedObject.hasCapability.andReturn(true);
|
||||
|
||||
// Show the menu
|
||||
action.perform();
|
||||
|
||||
expect(mockPopupService.display).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps a menu when menu is clicked on mobile", function () {
|
||||
mockAgentService.isMobile.andReturn(true);
|
||||
action = new ContextMenuAction(
|
||||
@ -205,7 +190,6 @@ define(
|
||||
mockRootScope,
|
||||
mockPopupService,
|
||||
mockAgentService,
|
||||
mockNavigationService,
|
||||
mockActionContext
|
||||
);
|
||||
action.perform();
|
||||
|
@ -30,14 +30,16 @@ define(
|
||||
function (ContextMenuGesture) {
|
||||
"use strict";
|
||||
|
||||
var JQLITE_FUNCTIONS = [ "on", "off", "find", "append", "remove" ],
|
||||
var JQLITE_FUNCTIONS = [ "on", "off", "find", "append", "remove", "attr" ],
|
||||
DOMAIN_OBJECT_METHODS = [ "getId", "getModel", "getCapability", "hasCapability", "useCapability"];
|
||||
|
||||
|
||||
describe("The 'context menu' gesture", function () {
|
||||
var mockTimeout,
|
||||
mockParse,
|
||||
mockElement,
|
||||
mockAgentService,
|
||||
mockNavigationService,
|
||||
mockDomainObject,
|
||||
mockEvent,
|
||||
mockTouchEvent,
|
||||
@ -51,6 +53,7 @@ define(
|
||||
|
||||
beforeEach(function () {
|
||||
mockTimeout = jasmine.createSpy("$timeout");
|
||||
mockParse = jasmine.createSpy("$parse");
|
||||
mockElement = jasmine.createSpyObj("element", JQLITE_FUNCTIONS);
|
||||
mockAgentService = jasmine.createSpyObj("agentService", ["isMobile"]);
|
||||
mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS);
|
||||
@ -69,8 +72,7 @@ define(
|
||||
mockContextMenuAction.perform.andReturn(jasmine.any(Function));
|
||||
mockAgentService.isMobile.andReturn(false);
|
||||
|
||||
|
||||
gesture = new ContextMenuGesture(mockTimeout, mockAgentService, mockElement, mockDomainObject);
|
||||
gesture = new ContextMenuGesture(mockTimeout, mockParse, mockAgentService, mockNavigationService, mockElement, mockDomainObject);
|
||||
|
||||
// Capture the contextmenu callback
|
||||
fireGesture = mockElement.on.mostRecentCall.args[1];
|
||||
@ -106,7 +108,7 @@ define(
|
||||
mockAgentService.isMobile.andReturn(true);
|
||||
|
||||
// Then create new (mobile) gesture
|
||||
gesture = new ContextMenuGesture(mockTimeout, mockAgentService, mockElement, mockDomainObject);
|
||||
gesture = new ContextMenuGesture(mockTimeout, mockParse, mockAgentService, mockNavigationService, mockElement, mockDomainObject);
|
||||
|
||||
// Set calls for the touchstart and touchend gestures
|
||||
fireTouchStartGesture = mockElement.on.calls[1].args[1];
|
||||
|
Loading…
x
Reference in New Issue
Block a user