@@ -16,7 +16,7 @@
|
|||||||
{
|
{
|
||||||
"key": "BrowseController",
|
"key": "BrowseController",
|
||||||
"implementation": "BrowseController.js",
|
"implementation": "BrowseController.js",
|
||||||
"depends": [ "$scope", "$route", "$location", "objectService", "navigationService", "urlService"]
|
"depends": [ "$scope", "$route", "$location", "objectService", "navigationService", "urlService" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "BrowseObjectController",
|
"key": "BrowseObjectController",
|
||||||
@@ -77,12 +77,7 @@
|
|||||||
{
|
{
|
||||||
"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",
|
||||||
|
|||||||
@@ -55,10 +55,11 @@ define(
|
|||||||
$route.current = priorRoute;
|
$route.current = priorRoute;
|
||||||
unlisten();
|
unlisten();
|
||||||
});
|
});
|
||||||
// urlService.urlFor used to adjust current
|
// urlService.urlForLocation used to adjust current
|
||||||
// path to new, addressed, path based on
|
// path to new, addressed, path based on
|
||||||
// domainObject
|
// domainObject
|
||||||
$location.path(urlService.urlFor("browse", domainObject));
|
$location.path(urlService.urlForLocation("browse", domainObject));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback for updating the in-scope reference to the object
|
// Callback for updating the in-scope reference to the object
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ define(
|
|||||||
// (browse) and the domainObject is passed in and
|
// (browse) and the domainObject is passed in and
|
||||||
// the path is returned and opened in a new tab
|
// the path is returned and opened in a new tab
|
||||||
perform: function () {
|
perform: function () {
|
||||||
$window.open(urlService.urlFor("browse", getSelectedObject()),
|
$window.open(urlService.urlForNewTab("browse", getSelectedObject()),
|
||||||
"_blank");
|
"_blank");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ define(
|
|||||||
);
|
);
|
||||||
mockUrlService = jasmine.createSpyObj(
|
mockUrlService = jasmine.createSpyObj(
|
||||||
"urlService",
|
"urlService",
|
||||||
["urlFor"]
|
["urlForLocation"]
|
||||||
);
|
);
|
||||||
mockObjectService = jasmine.createSpyObj(
|
mockObjectService = jasmine.createSpyObj(
|
||||||
"objectService",
|
"objectService",
|
||||||
@@ -225,7 +225,7 @@ define(
|
|||||||
// location.path to be called with the urlService's
|
// location.path to be called with the urlService's
|
||||||
// urlFor function with the next domainObject and mode
|
// urlFor function with the next domainObject and mode
|
||||||
expect(mockLocation.path).toHaveBeenCalledWith(
|
expect(mockLocation.path).toHaveBeenCalledWith(
|
||||||
mockUrlService.urlFor(mockMode, mockNextObject)
|
mockUrlService.urlForLocation(mockMode, mockNextObject)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Exercise the Angular workaround
|
// Exercise the Angular workaround
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
"creation/LocatorController",
|
"creation/LocatorController",
|
||||||
"navigation/NavigateAction",
|
"navigation/NavigateAction",
|
||||||
"navigation/NavigationService",
|
"navigation/NavigationService",
|
||||||
"services/UrlService",
|
|
||||||
"windowing/FullscreenAction",
|
"windowing/FullscreenAction",
|
||||||
"windowing/NewTabAction",
|
"windowing/NewTabAction",
|
||||||
"windowing/WindowTitler"
|
"windowing/WindowTitler"
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ define(
|
|||||||
|
|
||||||
// Mocks the urlService used to make the new tab's url from a
|
// Mocks the urlService used to make the new tab's url from a
|
||||||
// domainObject and mode
|
// domainObject and mode
|
||||||
mockUrlService = jasmine.createSpyObj("urlService", ["urlFor"]);
|
mockUrlService = jasmine.createSpyObj("urlService", ["urlForNewTab"]);
|
||||||
|
|
||||||
// Action done using the current context or mockContextCurrent
|
// Action done using the current context or mockContextCurrent
|
||||||
actionCurrent = new NewTabAction(mockUrlService, mockWindow,
|
actionCurrent = new NewTabAction(mockUrlService, mockWindow,
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
"implementation": "actions/SaveAction.js",
|
"implementation": "actions/SaveAction.js",
|
||||||
"name": "Save",
|
"name": "Save",
|
||||||
"description": "Save changes made to these objects.",
|
"description": "Save changes made to these objects.",
|
||||||
"depends": [ "$location" ],
|
"depends": [ "$location", "urlService" ],
|
||||||
"priority": "mandatory"
|
"priority": "mandatory"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
"implementation": "actions/CancelAction.js",
|
"implementation": "actions/CancelAction.js",
|
||||||
"name": "Cancel",
|
"name": "Cancel",
|
||||||
"description": "Discard changes made to these objects.",
|
"description": "Discard changes made to these objects.",
|
||||||
"depends": [ "$location" ]
|
"depends": [ "$location", "urlService" ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"policies": [
|
"policies": [
|
||||||
@@ -116,7 +116,7 @@
|
|||||||
"key": "topbar-edit",
|
"key": "topbar-edit",
|
||||||
"templateUrl": "templates/topbar-edit.html"
|
"templateUrl": "templates/topbar-edit.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"representers": [
|
"representers": [
|
||||||
{
|
{
|
||||||
"implementation": "representers/EditRepresenter.js",
|
"implementation": "representers/EditRepresenter.js",
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ define(
|
|||||||
* Edit Mode. Exits the editing user interface and invokes object
|
* Edit Mode. Exits the editing user interface and invokes object
|
||||||
* capabilities to persist the changes that have been made.
|
* capabilities to persist the changes that have been made.
|
||||||
*/
|
*/
|
||||||
function CancelAction($location, context) {
|
function CancelAction($location, urlService, context) {
|
||||||
var domainObject = context.domainObject;
|
var domainObject = context.domainObject;
|
||||||
|
|
||||||
// Look up the object's "editor.completion" capability;
|
// Look up the object's "editor.completion" capability;
|
||||||
@@ -50,7 +50,10 @@ define(
|
|||||||
// Discard the current root view (which will be the editing
|
// Discard the current root view (which will be the editing
|
||||||
// UI, which will have been pushed atop the Browise UI.)
|
// UI, which will have been pushed atop the Browise UI.)
|
||||||
function returnToBrowse() {
|
function returnToBrowse() {
|
||||||
$location.path("/browse");
|
$location.path($location.path(urlService.urlForLocation(
|
||||||
|
"browse",
|
||||||
|
domainObject
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ define(
|
|||||||
* Edit Mode. Exits the editing user interface and invokes object
|
* Edit Mode. Exits the editing user interface and invokes object
|
||||||
* capabilities to persist the changes that have been made.
|
* capabilities to persist the changes that have been made.
|
||||||
*/
|
*/
|
||||||
function SaveAction($location, context) {
|
function SaveAction($location, urlService, context) {
|
||||||
var domainObject = context.domainObject;
|
var domainObject = context.domainObject;
|
||||||
|
|
||||||
// Invoke any save behavior introduced by the editor capability;
|
// Invoke any save behavior introduced by the editor capability;
|
||||||
@@ -45,7 +45,10 @@ define(
|
|||||||
// Discard the current root view (which will be the editing
|
// Discard the current root view (which will be the editing
|
||||||
// UI, which will have been pushed atop the Browise UI.)
|
// UI, which will have been pushed atop the Browise UI.)
|
||||||
function returnToBrowse() {
|
function returnToBrowse() {
|
||||||
return $location.path("/browse");
|
return $location.path(urlService.urlForLocation(
|
||||||
|
"browse",
|
||||||
|
domainObject
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ define(
|
|||||||
var mockLocation,
|
var mockLocation,
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
mockEditorCapability,
|
mockEditorCapability,
|
||||||
|
mockUrlService,
|
||||||
actionContext,
|
actionContext,
|
||||||
action;
|
action;
|
||||||
|
|
||||||
@@ -54,7 +55,10 @@ define(
|
|||||||
"editor",
|
"editor",
|
||||||
[ "save", "cancel" ]
|
[ "save", "cancel" ]
|
||||||
);
|
);
|
||||||
|
mockUrlService = jasmine.createSpyObj(
|
||||||
|
"urlService",
|
||||||
|
["urlForLocation"]
|
||||||
|
);
|
||||||
|
|
||||||
actionContext = {
|
actionContext = {
|
||||||
domainObject: mockDomainObject
|
domainObject: mockDomainObject
|
||||||
@@ -64,7 +68,7 @@ define(
|
|||||||
mockDomainObject.getCapability.andReturn(mockEditorCapability);
|
mockDomainObject.getCapability.andReturn(mockEditorCapability);
|
||||||
mockEditorCapability.cancel.andReturn(mockPromise(true));
|
mockEditorCapability.cancel.andReturn(mockPromise(true));
|
||||||
|
|
||||||
action = new CancelAction(mockLocation, actionContext);
|
action = new CancelAction(mockLocation, mockUrlService, actionContext);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -91,7 +95,9 @@ define(
|
|||||||
|
|
||||||
it("returns to browse when performed", function () {
|
it("returns to browse when performed", function () {
|
||||||
action.perform();
|
action.perform();
|
||||||
expect(mockLocation.path).toHaveBeenCalledWith("/browse");
|
expect(mockLocation.path).toHaveBeenCalledWith(
|
||||||
|
mockUrlService.urlForLocation("browse", mockDomainObject)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ define(
|
|||||||
var mockLocation,
|
var mockLocation,
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
mockEditorCapability,
|
mockEditorCapability,
|
||||||
|
mockUrlService,
|
||||||
actionContext,
|
actionContext,
|
||||||
action;
|
action;
|
||||||
|
|
||||||
@@ -54,6 +55,10 @@ define(
|
|||||||
"editor",
|
"editor",
|
||||||
[ "save", "cancel" ]
|
[ "save", "cancel" ]
|
||||||
);
|
);
|
||||||
|
mockUrlService = jasmine.createSpyObj(
|
||||||
|
"urlService",
|
||||||
|
["urlForLocation"]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
actionContext = {
|
actionContext = {
|
||||||
@@ -64,7 +69,7 @@ define(
|
|||||||
mockDomainObject.getCapability.andReturn(mockEditorCapability);
|
mockDomainObject.getCapability.andReturn(mockEditorCapability);
|
||||||
mockEditorCapability.save.andReturn(mockPromise(true));
|
mockEditorCapability.save.andReturn(mockPromise(true));
|
||||||
|
|
||||||
action = new SaveAction(mockLocation, actionContext);
|
action = new SaveAction(mockLocation, mockUrlService, actionContext);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -91,7 +96,9 @@ define(
|
|||||||
|
|
||||||
it("returns to browse when performed", function () {
|
it("returns to browse when performed", function () {
|
||||||
action.perform();
|
action.perform();
|
||||||
expect(mockLocation.path).toHaveBeenCalledWith("/browse");
|
expect(mockLocation.path).toHaveBeenCalledWith(
|
||||||
|
mockUrlService.urlForLocation("browse", mockDomainObject)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,13 @@
|
|||||||
"description": "General UI elements, meant to be reused across modes",
|
"description": "General UI elements, meant to be reused across modes",
|
||||||
"resources": "res",
|
"resources": "res",
|
||||||
"extensions": {
|
"extensions": {
|
||||||
|
"services": [
|
||||||
|
{
|
||||||
|
"key": "urlService",
|
||||||
|
"implementation": "/services/UrlService.js",
|
||||||
|
"depends": [ "$location" ]
|
||||||
|
}
|
||||||
|
],
|
||||||
"runs": [
|
"runs": [
|
||||||
{
|
{
|
||||||
"implementation": "StyleSheetLoader.js",
|
"implementation": "StyleSheetLoader.js",
|
||||||
|
|||||||
@@ -39,34 +39,52 @@ define(
|
|||||||
// is returned. The view is defaulted to
|
// is returned. The view is defaulted to
|
||||||
// the current location's (current object's)
|
// the current location's (current object's)
|
||||||
// view set.
|
// view set.
|
||||||
function urlFor(mode, domainObject) {
|
function urlForLocation(mode, domainObject) {
|
||||||
var context = domainObject &&
|
var context = domainObject &&
|
||||||
domainObject.getCapability('context'),
|
domainObject.getCapability('context'),
|
||||||
objectPath = context ? context.getPath() : [],
|
objectPath = context ? context.getPath() : [],
|
||||||
ids = objectPath.map(function (domainObject) {
|
ids = objectPath.map(function (domainObject) {
|
||||||
return domainObject.getId();
|
return domainObject.getId();
|
||||||
}),
|
}),
|
||||||
viewPath = "?view=" + $location.search().view,
|
|
||||||
// Parses the path together. Starts with the
|
// Parses the path together. Starts with the
|
||||||
// default index.html file, then the mode passed
|
// default index.html file, then the mode passed
|
||||||
// into the service, followed by ids in the url
|
// into the service, followed by ids in the url
|
||||||
// joined by '/', and lastly the view path from
|
// joined by '/', and lastly the view path from
|
||||||
// the current location
|
// the current location
|
||||||
path = "index.html#/" + mode + "/" +
|
path = mode + "/" + ids.slice(1).join("/");
|
||||||
ids.slice(1).join("/") + viewPath;
|
|
||||||
|
|
||||||
return path;
|
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 {
|
return {
|
||||||
/**
|
/**
|
||||||
* Returns the Url path for a specific domain object
|
* 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
|
* @param {value} value of the browse or edit mode
|
||||||
* for the path
|
* for the path
|
||||||
* @param {DomainObject} value of the domain object
|
* @param {DomainObject} value of the domain object
|
||||||
* to get the path of
|
* 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
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +31,11 @@ define(
|
|||||||
|
|
||||||
describe("The url service", function () {
|
describe("The url service", function () {
|
||||||
var urlService,
|
var urlService,
|
||||||
mockLocation;
|
mockLocation,
|
||||||
|
mockDomainObject,
|
||||||
|
mockContext,
|
||||||
|
mockMode,
|
||||||
|
testViews;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
// Creates a mockLocation, used to
|
// Creates a mockLocation, used to
|
||||||
@@ -41,24 +45,20 @@ define(
|
|||||||
[ "path", "search" ]
|
[ "path", "search" ]
|
||||||
);
|
);
|
||||||
|
|
||||||
urlService = new UrlService(mockLocation);
|
// The mockDomainObject is initialized as a
|
||||||
});
|
|
||||||
|
|
||||||
it("get url for a domainObject and mode", function () {
|
|
||||||
// The mockDomainObject is initialized as a
|
|
||||||
// spy object to ultimately be passed into the
|
// spy object to ultimately be passed into the
|
||||||
// urlService urlFor function
|
// urlService urlFor function
|
||||||
var mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getCapability", "getModel", "useCapability" ]
|
[ "getId", "getCapability", "getModel", "useCapability" ]
|
||||||
),
|
);
|
||||||
mockContext = jasmine.createSpyObj('context', ['getPath']),
|
mockContext = jasmine.createSpyObj('context', ['getPath']);
|
||||||
testViews = [
|
testViews = [
|
||||||
{ key: 'abc' },
|
{ key: 'abc' },
|
||||||
{ key: 'def', someKey: 'some value' },
|
{ key: 'def', someKey: 'some value' },
|
||||||
{ key: 'xyz' }
|
{ key: 'xyz' }
|
||||||
],
|
];
|
||||||
mockMode = "browse";
|
mockMode = "browse";
|
||||||
|
|
||||||
// The mockContext is set a path
|
// The mockContext is set a path
|
||||||
// for the mockDomainObject
|
// for the mockDomainObject
|
||||||
@@ -81,8 +81,17 @@ define(
|
|||||||
// Uses the mockLocation to get the current
|
// Uses the mockLocation to get the current
|
||||||
// "mock" website's view
|
// "mock" website's view
|
||||||
mockLocation.search.andReturn({ view: 'def' });
|
mockLocation.search.andReturn({ view: 'def' });
|
||||||
urlService.urlFor(mockMode, mockDomainObject);
|
|
||||||
|
urlService = new UrlService(mockLocation);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("get url for a location using domainObject and mode", function () {
|
||||||
|
urlService.urlForLocation(mockMode, mockDomainObject);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("get url for a new tab using domainObject and mode", function () {
|
||||||
|
urlService.urlForNewTab(mockMode, mockDomainObject);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -13,5 +13,6 @@
|
|||||||
"directives/MCTDrag",
|
"directives/MCTDrag",
|
||||||
"directives/MCTResize",
|
"directives/MCTResize",
|
||||||
"directives/MCTScroll",
|
"directives/MCTScroll",
|
||||||
|
"services/UrlService",
|
||||||
"StyleSheetLoader"
|
"StyleSheetLoader"
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user