[Windowing] URL Fix

The URL malformation was caused by the same
function returning the view and index path for
both the newtab window and the browse controller
window. As a result, the BrowseController now only
uses a path that excludes the view and index paths,
like before the UrlService was added. Another,
separate function uses this url for the location
and includes the view and index paths for new
tabs, in order to maintain the current view. WTD 23.
This commit is contained in:
Shivam Dave 2015-06-25 09:47:58 -07:00
parent 9ac6abe78f
commit ca6f44f7b6
3 changed files with 29 additions and 9 deletions

View File

@ -55,10 +55,11 @@ define(
$route.current = priorRoute;
unlisten();
});
// urlService.urlFor used to adjust current
// urlService.urlForLocation used to adjust current
// path to new, addressed, path based on
// domainObject
$location.path(urlService.urlFor("browse", domainObject));
$location.path(urlService.urlForLocation("browse", domainObject));
}
// Callback for updating the in-scope reference to the object

View File

@ -39,34 +39,53 @@ define(
// is returned. The view is defaulted to
// the current location's (current object's)
// view set.
function urlFor(mode, domainObject) {
function urlForLocation(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,
// Parses the path together. Starts with the
// default index.html file, then the mode passed
// into the service, followed by ids in the url
// joined by '/', and lastly the view path from
// the current location
path = "index.html#/" + mode + "/" +
ids.slice(1).join("/") + viewPath;
path = "/" + mode + "/" +
ids.slice(1).join("/");
return path;
}
// Uses the Url for the current location
// from the urlForLocation function and
// includes the view and the index path
function urlForNewTab(mode, domainObject) {
var viewPath = "?view=" + $location.search().view,
newTabPath = "index.html#" +
urlForLocation(mode, domainObject) + viewPath;
return newTabPath;
}
return {
/**
* Returns the Url path for a specific domain object
* without the index.html path and the view path
* @param {value} value of the browse or edit mode
* for the path
* @param {DomainObject} value of the domain object
* to get the path of
*/
urlFor: urlFor
urlForNewTab: urlForNewTab,
/**
* Returns the Url path for a specific domain object
* including the index.html path and the view path
* allowing a new tab to hold the correct characteristics
* @param {value} value of the browse or edit mode
* for the path
* @param {DomainObject} value of the domain object
* to get the path of
*/
urlForLocation: urlForLocation
};
}

View File

@ -56,7 +56,7 @@ define(
// (browse) and the domainObject is passed in and
// the path is returned and opened in a new tab
perform: function () {
$window.open(urlService.urlFor("browse", getSelectedObject()),
$window.open(urlService.urlForNewTab("browse", getSelectedObject()),
"_blank");
}
};