[Windowing] UrlService
UrlService added which takes in a mode (browse or edit), and also a domainObject. Returns the url path to that domainObject. WTD-16.
This commit is contained in:
@@ -78,6 +78,11 @@
|
|||||||
"key": "navigationService",
|
"key": "navigationService",
|
||||||
"implementation": "navigation/NavigationService.js"
|
"implementation": "navigation/NavigationService.js"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"key": "urlService",
|
||||||
|
"implementation": "services/UrlService.js",
|
||||||
|
"depends": [ "$location" ]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"key": "creationService",
|
"key": "creationService",
|
||||||
"implementation": "creation/CreationService.js",
|
"implementation": "creation/CreationService.js",
|
||||||
@@ -96,7 +101,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" ],
|
"depends": [ "urlService", "$window", "$route", "$location" ],
|
||||||
"group": "windowing",
|
"group": "windowing",
|
||||||
"glyph": "y"
|
"glyph": "y"
|
||||||
},
|
},
|
||||||
|
|||||||
59
platform/commonUI/browse/src/services/UrlService.js
Normal file
59
platform/commonUI/browse/src/services/UrlService.js
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT Web includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
/*global define,Promise*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module defining UrlService.
|
||||||
|
*/
|
||||||
|
define(
|
||||||
|
[],
|
||||||
|
function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The navigation service maintains the application's current
|
||||||
|
* navigation state, and allows listening for changes thereto.
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function UrlService($location) {
|
||||||
|
function urlFor(mode, domainObject) {
|
||||||
|
var context = domainObject &&
|
||||||
|
domainObject.getCapability('context'),
|
||||||
|
objectPath = context ? context.getPath() : [],
|
||||||
|
ids = objectPath.map(function (domainObject) {
|
||||||
|
return domainObject.getId();}),
|
||||||
|
viewPath = "?view=" + $location.search().view,
|
||||||
|
path = "index.html#/" + mode + "/" +
|
||||||
|
ids.slice(1).join("/") + viewPath;
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
|
||||||
|
urlFor: urlFor
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return UrlService;
|
||||||
|
}
|
||||||
|
);
|
||||||
@@ -37,9 +37,11 @@ define(
|
|||||||
* the user interface.)
|
* the user interface.)
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function NewTabAction($window, $route, $location, context) {
|
function NewTabAction(urlService, $window, $route, $location, context) {
|
||||||
|
// Returns the selected domain object
|
||||||
|
// when using the context menu or the top right button
|
||||||
|
// based on the context and the existance of the object
|
||||||
|
// It is set to object an returned
|
||||||
function getSelectedObject() {
|
function getSelectedObject() {
|
||||||
var object,
|
var object,
|
||||||
newParent;
|
newParent;
|
||||||
@@ -53,25 +55,13 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
// Performs the open in new tab function
|
||||||
* Open the object in a new tab
|
// By calling the url service, the mode needed
|
||||||
*/
|
// (browse) and the domainObject is passed in and
|
||||||
|
// the path is returned and opened in a new tab
|
||||||
perform: function () {
|
perform: function () {
|
||||||
var selectedDomainObject = getSelectedObject(),
|
window.open(urlService.urlFor("browse", getSelectedObject()),
|
||||||
mode = "browse",
|
"_blank");
|
||||||
context = selectedDomainObject &&
|
|
||||||
selectedDomainObject.getCapability('context'),
|
|
||||||
objectPath = context ? context.getPath() : [],
|
|
||||||
ids = objectPath.map(function (selectedDomainObject) {
|
|
||||||
return selectedDomainObject.getId();
|
|
||||||
}),
|
|
||||||
viewPath = "?view=" + $location.search().view,
|
|
||||||
partialPath = "index.html#/" + mode + "/" +
|
|
||||||
ids.slice(1).join("/") + viewPath;
|
|
||||||
|
|
||||||
window.open(partialPath, "_blank");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user