mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 21:27:52 +00:00
[API] Adapt composition capability
This commit is contained in:
parent
dd7d8d2642
commit
5b2c0e9aee
@ -26,14 +26,16 @@ define([
|
|||||||
'./directives/MCTView',
|
'./directives/MCTView',
|
||||||
'./services/Instantiate',
|
'./services/Instantiate',
|
||||||
'./capabilities/APICapabilityDecorator',
|
'./capabilities/APICapabilityDecorator',
|
||||||
'./policies/AdapterCompositionPolicy'
|
'./policies/AdapterCompositionPolicy',
|
||||||
|
'./runs/AlternateCompositionInitializer'
|
||||||
], function (
|
], function (
|
||||||
legacyRegistry,
|
legacyRegistry,
|
||||||
ActionDialogDecorator,
|
ActionDialogDecorator,
|
||||||
MCTView,
|
MCTView,
|
||||||
Instantiate,
|
Instantiate,
|
||||||
APICapabilityDecorator,
|
APICapabilityDecorator,
|
||||||
AdapterCompositionPolicy
|
AdapterCompositionPolicy,
|
||||||
|
AlternateCompositionInitializer
|
||||||
) {
|
) {
|
||||||
legacyRegistry.register('src/adapter', {
|
legacyRegistry.register('src/adapter', {
|
||||||
"extensions": {
|
"extensions": {
|
||||||
@ -82,6 +84,12 @@ define([
|
|||||||
depends: [ "openmct" ]
|
depends: [ "openmct" ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
runs: [
|
||||||
|
{
|
||||||
|
implementation: AlternateCompositionInitializer,
|
||||||
|
depends: ["openmct"]
|
||||||
|
}
|
||||||
|
],
|
||||||
licenses: [
|
licenses: [
|
||||||
{
|
{
|
||||||
"name": "almond",
|
"name": "almond",
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
define([
|
define([
|
||||||
'../../api/objects/object-utils'
|
'../../api/objects/object-utils'
|
||||||
], function (objectUtils) {
|
], function (objectUtils) {
|
||||||
|
|
||||||
function AlternateCompositionCapability($injector, domainObject) {
|
function AlternateCompositionCapability($injector, domainObject) {
|
||||||
this.domainObject = domainObject;
|
this.domainObject = domainObject;
|
||||||
this.getDependencies = function () {
|
this.getDependencies = function () {
|
||||||
@ -98,7 +97,9 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
AlternateCompositionCapability.appliesTo = function (model) {
|
AlternateCompositionCapability.appliesTo = function (model) {
|
||||||
return true;
|
// Will get replaced by a runs exception to properly
|
||||||
|
// bind to running openmct instance
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
return AlternateCompositionCapability;
|
return AlternateCompositionCapability;
|
||||||
|
36
src/adapter/runs/AlternateCompositionInitializer.js
Normal file
36
src/adapter/runs/AlternateCompositionInitializer.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT Web includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
define([
|
||||||
|
'../capabilities/AlternateCompositionCapability'
|
||||||
|
], function (AlternateCompositionCapability) {
|
||||||
|
// Present to work around the need for openmct to be used
|
||||||
|
// from AlternateCompositionCapability.appliesTo, even though it
|
||||||
|
// cannot be injected.
|
||||||
|
function AlternateCompositionInitializer(openmct) {
|
||||||
|
AlternateCompositionCapability.appliesTo = function (model) {
|
||||||
|
return !!openmct.composition.get(model);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return AlternateCompositionCapability;
|
||||||
|
});
|
@ -70,7 +70,7 @@ define([
|
|||||||
*/
|
*/
|
||||||
CompositionAPI.prototype.get = function (domainObject) {
|
CompositionAPI.prototype.get = function (domainObject) {
|
||||||
var provider = _.find(this.registry, function (p) {
|
var provider = _.find(this.registry, function (p) {
|
||||||
return p.appliesTo(object);
|
return p.appliesTo(domainObject);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
|
Loading…
Reference in New Issue
Block a user