mirror of
https://github.com/nasa/openmct.git
synced 2025-01-19 03:06:54 +00:00
[Views] Allow types to restrict views
Allow type definitions to restrict views; this specifically supports the restriction of autoflow tabular views to packets, and the omission of scrolling/plot views as applicable to packets. WTD-644.
This commit is contained in:
parent
3c37242fda
commit
22d2be8942
@ -81,15 +81,32 @@ define(
|
||||
return capabilities.map(hasCapability).reduce(and, true);
|
||||
}
|
||||
|
||||
// Check if a view and domain object type can be paired;
|
||||
// both can restrict the others they accept.
|
||||
function viewMatchesType(view, type) {
|
||||
var views = type && type.getDefinition().views,
|
||||
matches = true;
|
||||
|
||||
// View is restricted to a certain type
|
||||
if (view.type) {
|
||||
matches = matches && type && type.instanceOf(view.type);
|
||||
}
|
||||
|
||||
// Type wishes to restrict its specific views
|
||||
if (Array.isArray(views)) {
|
||||
matches = matches && (views.indexOf(view.key) > -1);
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
function getViews(domainObject) {
|
||||
var type = domainObject.useCapability("type");
|
||||
|
||||
// First, filter views by type (matched to domain object type.)
|
||||
// Second, filter by matching capabilities.
|
||||
return views.filter(function (view) {
|
||||
return (!view.type) || type.instanceOf(view.type);
|
||||
}).filter(function (view) {
|
||||
return capabilitiesMatch(
|
||||
return viewMatchesType(view, type) && capabilitiesMatch(
|
||||
domainObject,
|
||||
view.needs || [],
|
||||
view.delegation || false
|
||||
|
Loading…
Reference in New Issue
Block a user