From bb80b2175ce92a50d7764dc4b26528088e9a79ab Mon Sep 17 00:00:00 2001 From: Sarah Hale Date: Thu, 2 Jul 2015 09:36:19 -0700 Subject: [PATCH] [Browse] Gesture calling action The context menu gesture (attempts) to call the context menu action. The menu arrow still fails to call. #33. --- platform/commonUI/browse/bundle.json | 2 +- .../browse/src/MenuArrowController.js | 31 +++++++++++-------- .../src/actions/ContextMenuAction.js | 7 +++-- .../src/gestures/ContextMenuGesture.js | 6 ++-- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/platform/commonUI/browse/bundle.json b/platform/commonUI/browse/bundle.json index 20ccbbe5ad..1869e0d8f9 100644 --- a/platform/commonUI/browse/bundle.json +++ b/platform/commonUI/browse/bundle.json @@ -36,7 +36,7 @@ { "key": "MenuArrowController", "implementation": "MenuArrowController", - "depends": [ "$scope", "$route", "objectService" ] + "depends": [ "$scope" ] } ], "controls": [ diff --git a/platform/commonUI/browse/src/MenuArrowController.js b/platform/commonUI/browse/src/MenuArrowController.js index 0623b62400..7eae522810 100644 --- a/platform/commonUI/browse/src/MenuArrowController.js +++ b/platform/commonUI/browse/src/MenuArrowController.js @@ -38,25 +38,30 @@ define( * menu. * @constructor */ - function MenuArrowController($scope, $route, domainObject) { + function MenuArrowController($scope) { + var domainObject = $scope.domainObject, + context; function showMenu(event) { - console.log('showMenu() called'); - //console.log('editor? ', $scope.domainObject.hasCapability('editor')); /* - if (true || $scope.domainObject.hasCapability('editor')) { - $scope.$emit('contextmenu', event); - } + console.log('showMenu() called'); + + console.log('$scope ', $scope); + console.log('$scope.domainObject ', $scope.domainObject); + console.log('domainObject ', domainObject); + console.log('event ', event); */ - //console.log('domainObject ', domainObject); - //console.log('$scope.domainObject ', $scope.domainObject); - console.log('event ', event); - - //$scope.domainObject.getCapability('action').perform({key: 'contextMenu', event: event}); - domainObject.getCapability('action').perform({key: 'contextMenu', event: event}); + context = {key: 'contextMenu', event: event, domainObject: domainObject}; + domainObject.getCapability('action').perform(context); } - + + // attempt to set the domain object + $scope.$watch('domainObject', function (c) { + domainObject = c; + console.log('watcher called'); + }); + return { showMenu: showMenu }; diff --git a/platform/representation/src/actions/ContextMenuAction.js b/platform/representation/src/actions/ContextMenuAction.js index ba929bb170..42764af0d7 100644 --- a/platform/representation/src/actions/ContextMenuAction.js +++ b/platform/representation/src/actions/ContextMenuAction.js @@ -52,8 +52,11 @@ define( */ function ContextMenuAction($compile, $document, $window, $rootScope, element, domainObject, event) { //var turnOffMenu; + + /* console.log('in ContextMenuAction'); console.log('contextMenuAction event ', event); + */ //function showMenu(event) { var winDim = [$window.innerWidth, $window.innerHeight], @@ -93,12 +96,12 @@ define( "context-menu-holder": true }; - console.log("ContextMenuAction scope ", scope); + //console.log("ContextMenuAction scope ", scope); // Create the context menu menu = $compile(MENU_TEMPLATE)(scope); - console.log("ContextMenuAction menu ", menu); + //console.log("ContextMenuAction menu ", menu); // Add the menu to the body body.append(menu); diff --git a/platform/representation/src/gestures/ContextMenuGesture.js b/platform/representation/src/gestures/ContextMenuGesture.js index 4b182d00b3..2cd7ea3afb 100644 --- a/platform/representation/src/gestures/ContextMenuGesture.js +++ b/platform/representation/src/gestures/ContextMenuGesture.js @@ -45,13 +45,15 @@ define( // When context menu event occurs, show object actions instead element.on('contextmenu', function (event) { + /* console.log('in ContextMenuGesture'); + console.log('event ', event); console.log('domainObject ', domainObject); console.log('domainObject action', domainObject.getCapability('action')); console.log('domainObject actions', domainObject.getCapability('action').getActions('contextMenu')); + */ - - actionContext = {key: 'contextMenu', /*element: element,*/ domainObject: domainObject, event: event}; + actionContext = {key: 'contextMenu', domainObject: domainObject, event: event}; stop = domainObject.getCapability('action').perform(actionContext); });