mirror of
https://github.com/nasa/openmct.git
synced 2025-01-20 11:38:56 +00:00
Merge remote-tracking branch 'origin/open788' into open-master
This commit is contained in:
commit
6575291e3e
@ -9,12 +9,17 @@
|
||||
"controllers": [
|
||||
{
|
||||
"key": "EditController",
|
||||
"implementation": "EditController.js",
|
||||
"implementation": "controllers/EditController.js",
|
||||
"depends": [ "$scope", "navigationService" ]
|
||||
},
|
||||
{
|
||||
"key": "EditActionController",
|
||||
"implementation": "EditActionController.js",
|
||||
"implementation": "controllers/EditActionController.js",
|
||||
"depends": [ "$scope" ]
|
||||
},
|
||||
{
|
||||
"key": "EditPanesController",
|
||||
"implementation": "controllers/EditPanesController.js",
|
||||
"depends": [ "$scope" ]
|
||||
}
|
||||
],
|
||||
@ -72,7 +77,7 @@
|
||||
{
|
||||
"key": "edit-object",
|
||||
"templateUrl": "templates/edit-object.html",
|
||||
"uses": [ "view", "context" ]
|
||||
"uses": [ "view" ]
|
||||
},
|
||||
{
|
||||
"key": "edit-action-buttons",
|
||||
@ -92,7 +97,7 @@
|
||||
],
|
||||
"representers": [
|
||||
{
|
||||
"implementation": "EditRepresenter.js",
|
||||
"implementation": "representers/EditRepresenter.js",
|
||||
"depends": [ "$q", "$log" ]
|
||||
},
|
||||
{
|
||||
|
@ -18,10 +18,13 @@
|
||||
</div>
|
||||
<div class="splitter"></div>
|
||||
<div class='abs pane right edit-objects menus-to-left'>
|
||||
<div class='holder abs split-layout horizontal'>
|
||||
<div class='holder abs split-layout horizontal'
|
||||
ng-controller='EditPanesController as editPanes'>
|
||||
<div class="abs pane top accordion" ng-controller="ToggleController as toggle">
|
||||
<mct-container key="accordion" title="Library">
|
||||
<mct-representation key="'tree'" alias="foo1" mct-object="context.getRoot()">
|
||||
<mct-representation key="'tree'"
|
||||
alias="foo1"
|
||||
mct-object="editPanes.getRoot()">
|
||||
</mct-representation>
|
||||
</mct-container>
|
||||
</div>
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Module defining EditController. Created by vwoeltje on 11/14/14.
|
||||
*/
|
||||
define(
|
||||
["./objects/EditableDomainObject"],
|
||||
["../objects/EditableDomainObject"],
|
||||
function (EditableDomainObject) {
|
||||
"use strict";
|
||||
|
@ -0,0 +1,47 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Supports the Library and Elements panes in Edit mode.
|
||||
* @constructor
|
||||
*/
|
||||
function EditPanesController($scope) {
|
||||
var root;
|
||||
|
||||
// Update root object based on represented object
|
||||
function updateRoot(domainObject) {
|
||||
var context = domainObject &&
|
||||
domainObject.getCapability('context'),
|
||||
newRoot = context && context.getRoot(),
|
||||
oldId = root && root.getId(),
|
||||
newId = newRoot && newRoot.getId();
|
||||
|
||||
// Only update if this has actually changed,
|
||||
// to avoid excessive refreshing.
|
||||
if (oldId !== newId) {
|
||||
root = newRoot;
|
||||
}
|
||||
}
|
||||
|
||||
// Update root when represented object changes
|
||||
$scope.$watch('domainObject', updateRoot);
|
||||
|
||||
return {
|
||||
/**
|
||||
* Get the root-level domain object, as reported by the
|
||||
* represented domain object.
|
||||
* @returns {DomainObject} the root object
|
||||
*/
|
||||
getRoot: function () {
|
||||
return root;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return EditPanesController;
|
||||
}
|
||||
);
|
@ -1,7 +1,7 @@
|
||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||
|
||||
define(
|
||||
["../src/EditActionController"],
|
||||
["../../src/controllers/EditActionController"],
|
||||
function (EditActionController) {
|
||||
"use strict";
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||
|
||||
define(
|
||||
["../src/EditController"],
|
||||
["../../src/controllers/EditController"],
|
||||
function (EditController) {
|
||||
"use strict";
|
||||
|
@ -0,0 +1,94 @@
|
||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||
|
||||
define(
|
||||
["../../src/controllers/EditPanesController"],
|
||||
function (EditPanesController) {
|
||||
"use strict";
|
||||
|
||||
describe("The Edit Panes controller", function () {
|
||||
var mockScope,
|
||||
mockDomainObject,
|
||||
mockContext,
|
||||
controller;
|
||||
|
||||
beforeEach(function () {
|
||||
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
|
||||
mockDomainObject = jasmine.createSpyObj(
|
||||
'domainObject',
|
||||
[ 'getId', 'getCapability' ]
|
||||
);
|
||||
mockContext = jasmine.createSpyObj(
|
||||
'context',
|
||||
[ 'getRoot' ]
|
||||
);
|
||||
|
||||
mockDomainObject.getId.andReturn('test-id');
|
||||
mockDomainObject.getCapability.andReturn(mockContext);
|
||||
|
||||
// Return a new instance of the root object each time
|
||||
mockContext.getRoot.andCallFake(function () {
|
||||
var mockRoot = jasmine.createSpyObj('root', ['getId']);
|
||||
mockRoot.getId.andReturn('root-id');
|
||||
return mockRoot;
|
||||
});
|
||||
|
||||
|
||||
controller = new EditPanesController(mockScope);
|
||||
});
|
||||
|
||||
it("watches for the domain object in view", function () {
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||
"domainObject",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
it("exposes the root object found via the object's context capability", function () {
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
|
||||
// Verify that the correct capability was used
|
||||
expect(mockDomainObject.getCapability)
|
||||
.toHaveBeenCalledWith('context');
|
||||
|
||||
// Should have exposed the root from getRoot
|
||||
expect(controller.getRoot().getId()).toEqual('root-id');
|
||||
});
|
||||
|
||||
it("preserves the same root instance to avoid excessive refreshing", function () {
|
||||
var firstRoot;
|
||||
// Expose the domain object
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
firstRoot = controller.getRoot();
|
||||
// Update!
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
// Should still have the same object instance, to avoid
|
||||
// triggering the watch used by the template we're supporting
|
||||
expect(controller.getRoot()).toBe(firstRoot);
|
||||
});
|
||||
|
||||
// Complements the test above; the object pointed to should change
|
||||
// when the actual root has changed (detected by identifier)
|
||||
it("updates the root when it changes", function () {
|
||||
var firstRoot;
|
||||
// Expose the domain object
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
firstRoot = controller.getRoot();
|
||||
|
||||
// Change the exposed root
|
||||
mockContext.getRoot.andCallFake(function () {
|
||||
var mockRoot = jasmine.createSpyObj('root', ['getId']);
|
||||
mockRoot.getId.andReturn('other-root-id');
|
||||
return mockRoot;
|
||||
});
|
||||
|
||||
// Update!
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
|
||||
// Should still have the same object instance, to avoid
|
||||
// triggering the watch used by the template we're supporting
|
||||
expect(controller.getRoot()).not.toBe(firstRoot);
|
||||
expect(controller.getRoot().getId()).toEqual('other-root-id');
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
@ -1,7 +1,7 @@
|
||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||
|
||||
define(
|
||||
["../src/EditRepresenter"],
|
||||
["../../src/representers/EditRepresenter"],
|
||||
function (EditRepresenter) {
|
||||
"use strict";
|
||||
|
@ -1,7 +1,4 @@
|
||||
[
|
||||
"EditActionController",
|
||||
"EditController",
|
||||
"EditRepresenter",
|
||||
"actions/CancelAction",
|
||||
"actions/EditAction",
|
||||
"actions/PropertiesAction",
|
||||
@ -13,9 +10,13 @@
|
||||
"capabilities/EditableLookupCapability",
|
||||
"capabilities/EditablePersistenceCapability",
|
||||
"capabilities/EditorCapability",
|
||||
"controllers/EditActionController",
|
||||
"controllers/EditController",
|
||||
"controllers/EditPanesController",
|
||||
"objects/EditableDomainObject",
|
||||
"objects/EditableDomainObjectCache",
|
||||
"objects/EditableModelCache",
|
||||
"representers/EditRepresenter",
|
||||
"representers/EditToolbar",
|
||||
"representers/EditToolbarRepresenter"
|
||||
]
|
Loading…
Reference in New Issue
Block a user