mirror of
https://github.com/nasa/openmct.git
synced 2025-03-02 04:34:17 +00:00
[Windowing] urlService
Added the urlService to the unit tests for the cancel and save buttons also removed unused services. WTD 23.
This commit is contained in:
parent
6d28add055
commit
3a371483ab
platform/commonUI/edit
@ -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", "urlService", "navigationService" ],
|
"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": [ "$log", "$location", "urlService", "navigationService" ]
|
"depends": [ "$location", "urlService" ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"policies": [
|
"policies": [
|
||||||
|
@ -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($log, $location, urlService, navigationService, 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,7 @@ 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() {
|
||||||
var urlBrowse = $location.path(urlService.urlForNewTab(
|
var urlBrowse = $location.path(urlService.urlForLocation(
|
||||||
"browse",
|
"browse",
|
||||||
domainObject
|
domainObject
|
||||||
));
|
));
|
||||||
|
@ -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, urlService, navigationService, 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(urlService.urlForNewTab("browse", domainObject));
|
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)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user