Compare commits

...

2 Commits

Author SHA1 Message Date
efb4ab5bba [Views] Update view API usage in adapter 2016-12-22 09:31:38 -08:00
41eb92d18a [Views] Update ViewProvider API
Expect contexts, not simple objects, for view api. #1307

See https://github.com/nasa/openmct/issues/1126#issuecomment-248127507
for rationale.
2016-12-20 15:33:16 -08:00
3 changed files with 13 additions and 9 deletions

View File

@ -29,8 +29,9 @@ define([], function () {
}
var domainObject = legacyObject.useCapability('adapter');
var providers = openmct.mainViews.get(domainObject);
$scope.view = providers[0] && providers[0].view(domainObject);
var context = { item: domainObject };
var providers = openmct.mainViews.get(context);
$scope.view = providers[0] && providers[0].view(context);
}
$scope.$watch('domainObject', refresh);

View File

@ -31,7 +31,8 @@ define([], function () {
) {
if (view.key === 'adapted-view') {
var domainObject = legacyObject.useCapability('adapter');
return this.openmct.mainViews.get(domainObject).length > 0;
var context = { item: domainObject };
return this.openmct.mainViews.get(context).length > 0;
}
return true;
};

View File

@ -34,13 +34,14 @@ define([], function () {
/**
* @private for platform-internal use
* @param {*} item the object to be viewed
* @param {module:openmct.Context} context the view's context,
* which includes the item being viewed
* @returns {module:openmct.ViewProvider[]} any providers
* which can provide views of this object
*/
ViewRegistry.prototype.get = function (item) {
ViewRegistry.prototype.get = function (context) {
return this.providers.filter(function (provider) {
return provider.canView(item);
return provider.canView(context);
});
};
@ -105,8 +106,8 @@ define([], function () {
*
* @method canView
* @memberof module:openmct.ViewProvider#
* @param {module:openmct.DomainObject} domainObject the domain object
* to be viewed
* @param {module:openmct.Context} context the view's context,
* which includes the item being viewed
* @returns {boolean} true if this domain object can be viewed using
* this provider
*/
@ -122,7 +123,8 @@ define([], function () {
*
* @method view
* @memberof module:openmct.ViewProvider#
* @param {*} object the object to be viewed
* @param {module:openmct.Context} context the view's context,
* which includes the item being viewed
* @returns {module:openmct.View} a view of this domain object
*/