From 6d28add055e6aaf6c4562c16e587b2253e117135 Mon Sep 17 00:00:00 2001 From: Shivam Dave Date: Thu, 25 Jun 2015 13:16:15 -0700 Subject: [PATCH] [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. --- platform/commonUI/browse/bundle.json | 2 +- platform/commonUI/browse/test/suite.json | 1 - platform/commonUI/edit/bundle.json | 11 ++++++-- .../commonUI/edit/src/actions/CancelAction.js | 8 ++++-- .../commonUI/edit/src/actions/SaveAction.js | 4 +-- .../general/src/services/UrlService.js | 27 +++++++++++++++---- platform/commonUI/general/test/suite.json | 1 + 7 files changed, 41 insertions(+), 13 deletions(-) diff --git a/platform/commonUI/browse/bundle.json b/platform/commonUI/browse/bundle.json index f776a45b9c..30bae3cf00 100644 --- a/platform/commonUI/browse/bundle.json +++ b/platform/commonUI/browse/bundle.json @@ -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", diff --git a/platform/commonUI/browse/test/suite.json b/platform/commonUI/browse/test/suite.json index 810b75d673..6cc41900e1 100644 --- a/platform/commonUI/browse/test/suite.json +++ b/platform/commonUI/browse/test/suite.json @@ -9,7 +9,6 @@ "creation/LocatorController", "navigation/NavigateAction", "navigation/NavigationService", - "services/UrlService", "windowing/FullscreenAction", "windowing/NewTabAction", "windowing/WindowTitler" diff --git a/platform/commonUI/edit/bundle.json b/platform/commonUI/edit/bundle.json index fbfd44b42a..b512065c77 100644 --- a/platform/commonUI/edit/bundle.json +++ b/platform/commonUI/edit/bundle.json @@ -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", diff --git a/platform/commonUI/edit/src/actions/CancelAction.js b/platform/commonUI/edit/src/actions/CancelAction.js index fce556ba48..799c837679 100644 --- a/platform/commonUI/edit/src/actions/CancelAction.js +++ b/platform/commonUI/edit/src/actions/CancelAction.js @@ -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 { diff --git a/platform/commonUI/edit/src/actions/SaveAction.js b/platform/commonUI/edit/src/actions/SaveAction.js index 301fced802..036eeb9f56 100644 --- a/platform/commonUI/edit/src/actions/SaveAction.js +++ b/platform/commonUI/edit/src/actions/SaveAction.js @@ -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 { diff --git a/platform/commonUI/general/src/services/UrlService.js b/platform/commonUI/general/src/services/UrlService.js index b4c145c5dc..df5e4178df 100644 --- a/platform/commonUI/general/src/services/UrlService.js +++ b/platform/commonUI/general/src/services/UrlService.js @@ -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 }; } diff --git a/platform/commonUI/general/test/suite.json b/platform/commonUI/general/test/suite.json index e8c9674b44..37fc4c4b78 100644 --- a/platform/commonUI/general/test/suite.json +++ b/platform/commonUI/general/test/suite.json @@ -13,5 +13,6 @@ "directives/MCTDrag", "directives/MCTResize", "directives/MCTScroll", + "services/UrlService", "StyleSheetLoader" ] \ No newline at end of file