[Windowing] Selected Object

Uses the context to get the selected object
or the navigated object. This allows contextual
menu new tab access from the tree. WTD-16.
This commit is contained in:
Shivam Dave 2015-06-23 13:32:09 -07:00
parent e55cd88d38
commit 29efb5cf3b
2 changed files with 24 additions and 15 deletions

View File

@ -96,7 +96,7 @@
"implementation": "windowing/NewTabAction.js", "implementation": "windowing/NewTabAction.js",
"description": "Open this object in a new tab", "description": "Open this object in a new tab",
"category": ["view-control", "contextual"], "category": ["view-control", "contextual"],
"depends": [ "$window", "$route", "$location", "navigationService" ], "depends": [ "$window", "$route", "$location" ],
"group": "windowing", "group": "windowing",
"glyph": "y" "glyph": "y"
}, },

View File

@ -29,7 +29,7 @@ define(
function () { function () {
"use strict"; "use strict";
var ROOT_ID = "ROOT", var ROOT_ID = "ROOT",
DEFAULT_PATH = "mine"; DEFAULT_PATH = "/mine";
/** /**
* The new tab action allows a domain object to be opened * The new tab action allows a domain object to be opened
* into a new browser tab. (Currently this is a stub, present * into a new browser tab. (Currently this is a stub, present
@ -37,10 +37,19 @@ define(
* the user interface.) * the user interface.)
* @constructor * @constructor
*/ */
function NewTabAction($window, $route, $location, navigationService) { function NewTabAction($window, $route, $location, context) {
function getNavigatedObject() {
var navigatedObject = navigationService.getNavigation();
return navigatedObject; function getSelectedObject() {
var object,
newParent;
if (context.selectedObject) {
newParent = context.domainObject;
object = context.selectedObject;
} else {
object = context.domainObject;
}
return object;
} }
return { return {
@ -48,19 +57,19 @@ define(
* Open the object in a new tab * Open the object in a new tab
*/ */
perform: function () { perform: function () {
var genPath = [ROOT_ID].concat(($route.current.params.ids || DEFAULT_PATH)),
selectedDomainObject = getSelectedObject(),
var currentDomainObject = getNavigatedObject(), context = selectedDomainObject &&
context = currentDomainObject && selectedDomainObject.getCapability('context'),
currentDomainObject.getCapability('context'),
objectPath = context ? context.getPath() : [], objectPath = context ? context.getPath() : [],
ids = objectPath.map(function (currentDomainObject) { ids = objectPath.map(function (selectedDomainObject) {
return currentDomainObject.getId(); return selectedDomainObject.getId();
}), }),
viewKey = $location.search().view, viewKey = $location.search().view,
partialPath = "index.html#/browse/" + ids.slice(1).join("/") + "?view=" + viewKey; partialPath = "index.html#/browse/" + ids.slice(1).join("/") +
"?view=" + viewKey;
window.alert(partialPath); window.open(partialPath, "_blank");
} }
}; };
} }