[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",
"description": "Open this object in a new tab",
"category": ["view-control", "contextual"],
"depends": [ "$window", "$route", "$location", "navigationService" ],
"depends": [ "$window", "$route", "$location" ],
"group": "windowing",
"glyph": "y"
},

View File

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