mirror of
https://github.com/nasa/openmct.git
synced 2025-05-09 03:53:19 +00:00
Disallow composition for domain object types which will not have a composition property; WTD-1221.
28 lines
734 B
JavaScript
28 lines
734 B
JavaScript
/*global define*/
|
|
|
|
define(
|
|
[],
|
|
function () {
|
|
"use strict";
|
|
|
|
/**
|
|
* Policy allowing composition only for domain object types which
|
|
* have a composition property.
|
|
*/
|
|
function CompositionModelPolicy() {
|
|
return {
|
|
/**
|
|
* Is the type identified by the candidate allowed to
|
|
* contain the type described by the context?
|
|
*/
|
|
allow: function (candidate, context) {
|
|
return Array.isArray(
|
|
(candidate.getInitialModel() || {}).composition
|
|
);
|
|
}
|
|
};
|
|
}
|
|
|
|
return CompositionModelPolicy;
|
|
}
|
|
); |