mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 23:53:49 +00:00
[Containment] Disallow composition in immutable objects
Disallow composition in objects which cannot be created, under the rationale that creatable objects must also be immutable. WTD-1098.
This commit is contained in:
30
platform/containment/src/CompositionMutabilityPolicy.js
Normal file
30
platform/containment/src/CompositionMutabilityPolicy.js
Normal file
@ -0,0 +1,30 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Disallow composition changes to objects which are not mutable.
|
||||
* @constructor
|
||||
*/
|
||||
function CompositionMutabilityPolicy() {
|
||||
return {
|
||||
/**
|
||||
* Is the type identified by the candidate allowed to
|
||||
* contain the type described by the context?
|
||||
* @param {Type} candidate the type of domain object
|
||||
*/
|
||||
allow: function (candidate) {
|
||||
// Equate creatability with mutability; that is, users
|
||||
// can only modify objects of types they can create, and
|
||||
// vice versa.
|
||||
return candidate.hasFeature('creation');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return CompositionMutabilityPolicy;
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user