[API] Adapt composition capability

This commit is contained in:
Victor Woeltjen 2016-09-30 15:47:54 -07:00
parent dd7d8d2642
commit 5b2c0e9aee
4 changed files with 50 additions and 5 deletions

View File

@ -26,14 +26,16 @@ define([
'./directives/MCTView',
'./services/Instantiate',
'./capabilities/APICapabilityDecorator',
'./policies/AdapterCompositionPolicy'
'./policies/AdapterCompositionPolicy',
'./runs/AlternateCompositionInitializer'
], function (
legacyRegistry,
ActionDialogDecorator,
MCTView,
Instantiate,
APICapabilityDecorator,
AdapterCompositionPolicy
AdapterCompositionPolicy,
AlternateCompositionInitializer
) {
legacyRegistry.register('src/adapter', {
"extensions": {
@ -82,6 +84,12 @@ define([
depends: [ "openmct" ]
}
],
runs: [
{
implementation: AlternateCompositionInitializer,
depends: ["openmct"]
}
],
licenses: [
{
"name": "almond",

View File

@ -26,7 +26,6 @@
define([
'../../api/objects/object-utils'
], function (objectUtils) {
function AlternateCompositionCapability($injector, domainObject) {
this.domainObject = domainObject;
this.getDependencies = function () {
@ -98,7 +97,9 @@ define([
};
AlternateCompositionCapability.appliesTo = function (model) {
return true;
// Will get replaced by a runs exception to properly
// bind to running openmct instance
return false;
};
return AlternateCompositionCapability;

View 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;
});

View File

@ -70,7 +70,7 @@ define([
*/
CompositionAPI.prototype.get = function (domainObject) {
var provider = _.find(this.registry, function (p) {
return p.appliesTo(object);
return p.appliesTo(domainObject);
});
if (!provider) {