mirror of
https://github.com/nasa/openmct.git
synced 2025-06-20 08:03:49 +00:00
Merge remote-tracking branch 'origin/open788' into open-master
This commit is contained in:
@ -9,12 +9,17 @@
|
|||||||
"controllers": [
|
"controllers": [
|
||||||
{
|
{
|
||||||
"key": "EditController",
|
"key": "EditController",
|
||||||
"implementation": "EditController.js",
|
"implementation": "controllers/EditController.js",
|
||||||
"depends": [ "$scope", "navigationService" ]
|
"depends": [ "$scope", "navigationService" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "EditActionController",
|
"key": "EditActionController",
|
||||||
"implementation": "EditActionController.js",
|
"implementation": "controllers/EditActionController.js",
|
||||||
|
"depends": [ "$scope" ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "EditPanesController",
|
||||||
|
"implementation": "controllers/EditPanesController.js",
|
||||||
"depends": [ "$scope" ]
|
"depends": [ "$scope" ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -72,7 +77,7 @@
|
|||||||
{
|
{
|
||||||
"key": "edit-object",
|
"key": "edit-object",
|
||||||
"templateUrl": "templates/edit-object.html",
|
"templateUrl": "templates/edit-object.html",
|
||||||
"uses": [ "view", "context" ]
|
"uses": [ "view" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "edit-action-buttons",
|
"key": "edit-action-buttons",
|
||||||
@ -92,7 +97,7 @@
|
|||||||
],
|
],
|
||||||
"representers": [
|
"representers": [
|
||||||
{
|
{
|
||||||
"implementation": "EditRepresenter.js",
|
"implementation": "representers/EditRepresenter.js",
|
||||||
"depends": [ "$q", "$log" ]
|
"depends": [ "$q", "$log" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -18,10 +18,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="splitter"></div>
|
<div class="splitter"></div>
|
||||||
<div class='abs pane right edit-objects menus-to-left'>
|
<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">
|
<div class="abs pane top accordion" ng-controller="ToggleController as toggle">
|
||||||
<mct-container key="accordion" title="Library">
|
<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-representation>
|
||||||
</mct-container>
|
</mct-container>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Module defining EditController. Created by vwoeltje on 11/14/14.
|
* Module defining EditController. Created by vwoeltje on 11/14/14.
|
||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
["./objects/EditableDomainObject"],
|
["../objects/EditableDomainObject"],
|
||||||
function (EditableDomainObject) {
|
function (EditableDomainObject) {
|
||||||
"use strict";
|
"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*/
|
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
["../src/EditActionController"],
|
["../../src/controllers/EditActionController"],
|
||||||
function (EditActionController) {
|
function (EditActionController) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
["../src/EditController"],
|
["../../src/controllers/EditController"],
|
||||||
function (EditController) {
|
function (EditController) {
|
||||||
"use strict";
|
"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*/
|
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
["../src/EditRepresenter"],
|
["../../src/representers/EditRepresenter"],
|
||||||
function (EditRepresenter) {
|
function (EditRepresenter) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
@ -1,7 +1,4 @@
|
|||||||
[
|
[
|
||||||
"EditActionController",
|
|
||||||
"EditController",
|
|
||||||
"EditRepresenter",
|
|
||||||
"actions/CancelAction",
|
"actions/CancelAction",
|
||||||
"actions/EditAction",
|
"actions/EditAction",
|
||||||
"actions/PropertiesAction",
|
"actions/PropertiesAction",
|
||||||
@ -13,9 +10,13 @@
|
|||||||
"capabilities/EditableLookupCapability",
|
"capabilities/EditableLookupCapability",
|
||||||
"capabilities/EditablePersistenceCapability",
|
"capabilities/EditablePersistenceCapability",
|
||||||
"capabilities/EditorCapability",
|
"capabilities/EditorCapability",
|
||||||
|
"controllers/EditActionController",
|
||||||
|
"controllers/EditController",
|
||||||
|
"controllers/EditPanesController",
|
||||||
"objects/EditableDomainObject",
|
"objects/EditableDomainObject",
|
||||||
"objects/EditableDomainObjectCache",
|
"objects/EditableDomainObjectCache",
|
||||||
"objects/EditableModelCache",
|
"objects/EditableModelCache",
|
||||||
|
"representers/EditRepresenter",
|
||||||
"representers/EditToolbar",
|
"representers/EditToolbar",
|
||||||
"representers/EditToolbarRepresenter"
|
"representers/EditToolbarRepresenter"
|
||||||
]
|
]
|
Reference in New Issue
Block a user