[Windowing] urlService

urlService added to the edit action
bundle.json in addition to being
implemented, however 2nd time edit
bug still occurring. Also fixed urlService
test suite. WTD 23.
This commit is contained in:
Shivam Dave 2015-06-25 13:16:15 -07:00
parent fd6459394a
commit 6d28add055
7 changed files with 41 additions and 13 deletions

View File

@ -16,7 +16,7 @@
{
"key": "BrowseController",
"implementation": "BrowseController.js",
"depends": [ "$scope", "$route", "$location", "objectService", "navigationService", "urlService"]
"depends": [ "$scope", "$route", "$location", "objectService", "navigationService", "urlService" ]
},
{
"key": "BrowseObjectController",

View File

@ -9,7 +9,6 @@
"creation/LocatorController",
"navigation/NavigateAction",
"navigation/NavigationService",
"services/UrlService",
"windowing/FullscreenAction",
"windowing/NewTabAction",
"windowing/WindowTitler"

View File

@ -67,7 +67,7 @@
"implementation": "actions/SaveAction.js",
"name": "Save",
"description": "Save changes made to these objects.",
"depends": [ "$location" ],
"depends": [ "$location", "urlService", "navigationService" ],
"priority": "mandatory"
},
{
@ -76,7 +76,7 @@
"implementation": "actions/CancelAction.js",
"name": "Cancel",
"description": "Discard changes made to these objects.",
"depends": [ "$location" ]
"depends": [ "$log", "$location", "urlService", "navigationService" ]
}
],
"policies": [
@ -117,6 +117,13 @@
"templateUrl": "templates/topbar-edit.html"
}
],
"services": [
{
"key": "urlService",
"implementation": "../../general/src/services/UrlService.js",
"depends": [ "$location" ]
}
],
"representers": [
{
"implementation": "representers/EditRepresenter.js",

View File

@ -30,7 +30,7 @@ define(
* Edit Mode. Exits the editing user interface and invokes object
* capabilities to persist the changes that have been made.
*/
function CancelAction($location, context) {
function CancelAction($log, $location, urlService, navigationService, context) {
var domainObject = context.domainObject;
// Look up the object's "editor.completion" capability;
@ -50,7 +50,11 @@ define(
// Discard the current root view (which will be the editing
// UI, which will have been pushed atop the Browise UI.)
function returnToBrowse() {
$location.path("/browse");
var urlBrowse = $location.path(urlService.urlForNewTab(
"browse",
domainObject
));
$location.path(urlBrowse);
}
return {

View File

@ -31,7 +31,7 @@ define(
* Edit Mode. Exits the editing user interface and invokes object
* capabilities to persist the changes that have been made.
*/
function SaveAction($location, context) {
function SaveAction($location, urlService, navigationService, context) {
var domainObject = context.domainObject;
// Invoke any save behavior introduced by the editor capability;
@ -45,7 +45,7 @@ define(
// Discard the current root view (which will be the editing
// UI, which will have been pushed atop the Browise UI.)
function returnToBrowse() {
return $location.path("/browse");
return $location.path(urlService.urlForNewTab("browse", domainObject));
}
return {

View File

@ -51,8 +51,7 @@ define(
// into the service, followed by ids in the url
// joined by '/', and lastly the view path from
// the current location
path = "/" + mode + "/" +
ids.slice(1).join("/");
path = mode + "/" + ids.slice(1).join("/");
return path;
}
@ -61,11 +60,27 @@ define(
// includes the view and the index path
function urlForNewTab(mode, domainObject) {
var viewPath = "?view=" + $location.search().view,
newTabPath = "index.html#" +
urlForLocation(mode, domainObject) + viewPath;
newTabPath =
"index.html#" + urlForLocation(mode, domainObject) + viewPath;
return newTabPath;
}
function urlForEdit(mode, domainObject) {
var context = domainObject &&
domainObject.getCapability('context'),
objectPath = context ? context.getPath() : [],
ids = objectPath.map(function (domainObject) {
return domainObject.getId();
}),
// 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 = mode + "/";
return path;
}
return {
/**
* Returns the Url path for a specific domain object
@ -85,7 +100,9 @@ define(
* @param {DomainObject} value of the domain object
* to get the path of
*/
urlForLocation: urlForLocation
urlForLocation: urlForLocation,
urlForEdit: urlForEdit
};
}

View File

@ -13,5 +13,6 @@
"directives/MCTDrag",
"directives/MCTResize",
"directives/MCTScroll",
"services/UrlService",
"StyleSheetLoader"
]