Merge branch 'open401'
This commit is contained in:
@@ -92,6 +92,13 @@ define([
|
|||||||
"reloadOnSearch": false
|
"reloadOnSearch": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"constants": [
|
||||||
|
{
|
||||||
|
"key": "DEFAULT_PATH",
|
||||||
|
"value": "mine",
|
||||||
|
"priority": "fallback"
|
||||||
|
}
|
||||||
|
],
|
||||||
"controllers": [
|
"controllers": [
|
||||||
{
|
{
|
||||||
"key": "BrowseController",
|
"key": "BrowseController",
|
||||||
@@ -103,7 +110,8 @@ define([
|
|||||||
"$q",
|
"$q",
|
||||||
"objectService",
|
"objectService",
|
||||||
"navigationService",
|
"navigationService",
|
||||||
"urlService"
|
"urlService",
|
||||||
|
"DEFAULT_PATH"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var ROOT_ID = "ROOT",
|
var ROOT_ID = "ROOT",
|
||||||
DEFAULT_PATH = "mine",
|
|
||||||
CONFIRM_MSG = "Unsaved changes will be lost if you leave this page.";
|
CONFIRM_MSG = "Unsaved changes will be lost if you leave this page.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,9 +46,18 @@ define(
|
|||||||
* @memberof platform/commonUI/browse
|
* @memberof platform/commonUI/browse
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function BrowseController($scope, $route, $location, $q, objectService, navigationService, urlService) {
|
function BrowseController(
|
||||||
|
$scope,
|
||||||
|
$route,
|
||||||
|
$location,
|
||||||
|
$q,
|
||||||
|
objectService,
|
||||||
|
navigationService,
|
||||||
|
urlService,
|
||||||
|
defaultPath
|
||||||
|
) {
|
||||||
var path = [ROOT_ID].concat(
|
var path = [ROOT_ID].concat(
|
||||||
($route.current.params.ids || DEFAULT_PATH).split("/")
|
($route.current.params.ids || defaultPath).split("/")
|
||||||
);
|
);
|
||||||
|
|
||||||
function isDirty(){
|
function isDirty(){
|
||||||
@@ -143,6 +151,12 @@ define(
|
|||||||
} else {
|
} else {
|
||||||
doNavigate(nextObject, index + 1);
|
doNavigate(nextObject, index + 1);
|
||||||
}
|
}
|
||||||
|
} else if (index === 1 && c.length > 0) {
|
||||||
|
// Roots are in a top-level container that we don't
|
||||||
|
// want to be selected, so if we couldn't find an
|
||||||
|
// object at the path we wanted, at least select
|
||||||
|
// one of its children.
|
||||||
|
navigateTo(c[c.length - 1]);
|
||||||
} else {
|
} else {
|
||||||
// Couldn't find the next element of the path
|
// Couldn't find the next element of the path
|
||||||
// so navigate to the last path object we did find
|
// so navigate to the last path object we did find
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ define(
|
|||||||
mockUrlService,
|
mockUrlService,
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
mockNextObject,
|
mockNextObject,
|
||||||
|
testDefaultRoot,
|
||||||
controller;
|
controller;
|
||||||
|
|
||||||
function mockPromise(value) {
|
function mockPromise(value) {
|
||||||
@@ -50,7 +51,21 @@ define(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function instantiateController() {
|
||||||
|
controller = new BrowseController(
|
||||||
|
mockScope,
|
||||||
|
mockRoute,
|
||||||
|
mockLocation,
|
||||||
|
mockObjectService,
|
||||||
|
mockNavigationService,
|
||||||
|
mockUrlService,
|
||||||
|
testDefaultRoot
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
testDefaultRoot = "some-root-level-domain-object";
|
||||||
|
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
"$scope",
|
"$scope",
|
||||||
[ "$on", "$watch" ]
|
[ "$on", "$watch" ]
|
||||||
@@ -101,41 +116,28 @@ define(
|
|||||||
]));
|
]));
|
||||||
mockNextObject.useCapability.andReturn(undefined);
|
mockNextObject.useCapability.andReturn(undefined);
|
||||||
mockNextObject.getId.andReturn("next");
|
mockNextObject.getId.andReturn("next");
|
||||||
mockDomainObject.getId.andReturn("mine");
|
mockDomainObject.getId.andReturn(testDefaultRoot);
|
||||||
|
|
||||||
controller = new BrowseController(
|
instantiateController();
|
||||||
mockScope,
|
|
||||||
mockRoute,
|
|
||||||
mockLocation,
|
|
||||||
mockObjectService,
|
|
||||||
mockNavigationService,
|
|
||||||
mockUrlService
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses composition to set the navigated object, if there is none", function () {
|
it("uses composition to set the navigated object, if there is none", function () {
|
||||||
controller = new BrowseController(
|
instantiateController();
|
||||||
mockScope,
|
expect(mockNavigationService.setNavigation)
|
||||||
mockRoute,
|
.toHaveBeenCalledWith(mockDomainObject);
|
||||||
mockLocation,
|
});
|
||||||
mockObjectService,
|
|
||||||
mockNavigationService,
|
it("navigates to a root-level object, even when default path is not found", function () {
|
||||||
mockUrlService
|
mockDomainObject.getId
|
||||||
);
|
.andReturn("something-other-than-the-" + testDefaultRoot);
|
||||||
|
instantiateController();
|
||||||
expect(mockNavigationService.setNavigation)
|
expect(mockNavigationService.setNavigation)
|
||||||
.toHaveBeenCalledWith(mockDomainObject);
|
.toHaveBeenCalledWith(mockDomainObject);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not try to override navigation", function () {
|
it("does not try to override navigation", function () {
|
||||||
mockNavigationService.getNavigation.andReturn(mockDomainObject);
|
mockNavigationService.getNavigation.andReturn(mockDomainObject);
|
||||||
controller = new BrowseController(
|
instantiateController();
|
||||||
mockScope,
|
|
||||||
mockRoute,
|
|
||||||
mockLocation,
|
|
||||||
mockObjectService,
|
|
||||||
mockNavigationService,
|
|
||||||
mockUrlService
|
|
||||||
);
|
|
||||||
expect(mockScope.navigatedObject).toBe(mockDomainObject);
|
expect(mockScope.navigatedObject).toBe(mockDomainObject);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -162,14 +164,8 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("uses route parameters to choose initially-navigated object", function () {
|
it("uses route parameters to choose initially-navigated object", function () {
|
||||||
mockRoute.current.params.ids = "mine/next";
|
mockRoute.current.params.ids = testDefaultRoot + "/next";
|
||||||
controller = new BrowseController(
|
instantiateController();
|
||||||
mockScope,
|
|
||||||
mockRoute,
|
|
||||||
mockLocation,
|
|
||||||
mockObjectService,
|
|
||||||
mockNavigationService
|
|
||||||
);
|
|
||||||
expect(mockScope.navigatedObject).toBe(mockNextObject);
|
expect(mockScope.navigatedObject).toBe(mockNextObject);
|
||||||
expect(mockNavigationService.setNavigation)
|
expect(mockNavigationService.setNavigation)
|
||||||
.toHaveBeenCalledWith(mockNextObject);
|
.toHaveBeenCalledWith(mockNextObject);
|
||||||
@@ -179,14 +175,8 @@ define(
|
|||||||
// Idea here is that if we get a bad path of IDs,
|
// Idea here is that if we get a bad path of IDs,
|
||||||
// browse controller should traverse down it until
|
// browse controller should traverse down it until
|
||||||
// it hits an invalid ID.
|
// it hits an invalid ID.
|
||||||
mockRoute.current.params.ids = "mine/junk";
|
mockRoute.current.params.ids = testDefaultRoot + "/junk";
|
||||||
controller = new BrowseController(
|
instantiateController();
|
||||||
mockScope,
|
|
||||||
mockRoute,
|
|
||||||
mockLocation,
|
|
||||||
mockObjectService,
|
|
||||||
mockNavigationService
|
|
||||||
);
|
|
||||||
expect(mockScope.navigatedObject).toBe(mockDomainObject);
|
expect(mockScope.navigatedObject).toBe(mockDomainObject);
|
||||||
expect(mockNavigationService.setNavigation)
|
expect(mockNavigationService.setNavigation)
|
||||||
.toHaveBeenCalledWith(mockDomainObject);
|
.toHaveBeenCalledWith(mockDomainObject);
|
||||||
@@ -196,14 +186,8 @@ define(
|
|||||||
// Idea here is that if we get a path which passes
|
// Idea here is that if we get a path which passes
|
||||||
// through an object without a composition, browse controller
|
// through an object without a composition, browse controller
|
||||||
// should stop at it since remaining IDs cannot be loaded.
|
// should stop at it since remaining IDs cannot be loaded.
|
||||||
mockRoute.current.params.ids = "mine/next/junk";
|
mockRoute.current.params.ids = testDefaultRoot + "/next/junk";
|
||||||
controller = new BrowseController(
|
instantiateController();
|
||||||
mockScope,
|
|
||||||
mockRoute,
|
|
||||||
mockLocation,
|
|
||||||
mockObjectService,
|
|
||||||
mockNavigationService
|
|
||||||
);
|
|
||||||
expect(mockScope.navigatedObject).toBe(mockNextObject);
|
expect(mockScope.navigatedObject).toBe(mockNextObject);
|
||||||
expect(mockNavigationService.setNavigation)
|
expect(mockNavigationService.setNavigation)
|
||||||
.toHaveBeenCalledWith(mockNextObject);
|
.toHaveBeenCalledWith(mockNextObject);
|
||||||
|
|||||||
Reference in New Issue
Block a user