mirror of
https://github.com/nasa/openmct.git
synced 2025-05-09 12:03:21 +00:00
[Actions] Restrict mutating actions
Restrict actions which cause mutation of domain objects to types of domain objects which can be created. (This does not include Packet or Telemetry Point, WTD-723.)
This commit is contained in:
parent
5c34382933
commit
4c42d4de28
@ -57,7 +57,11 @@ define(
|
|||||||
* will be performed; should contain a `domainObject` property
|
* will be performed; should contain a `domainObject` property
|
||||||
*/
|
*/
|
||||||
EditAction.appliesTo = function (context) {
|
EditAction.appliesTo = function (context) {
|
||||||
return (context || {}).domainObject !== undefined;
|
var domainObject = (context || {}).domainObject,
|
||||||
|
type = domainObject && domainObject.getCapability('type');
|
||||||
|
|
||||||
|
// Only allow creatable types to be edited
|
||||||
|
return type && type.hasFeature('creation');
|
||||||
};
|
};
|
||||||
|
|
||||||
return EditAction;
|
return EditAction;
|
||||||
|
@ -70,9 +70,14 @@ define(
|
|||||||
* context.
|
* context.
|
||||||
*/
|
*/
|
||||||
PropertiesAction.appliesTo = function (context) {
|
PropertiesAction.appliesTo = function (context) {
|
||||||
return (context || {}).domainObject &&
|
var domainObject = (context || {}).domainObject,
|
||||||
(context || {}).domainObject.hasCapability("type") &&
|
type = domainObject && domainObject.getCapability('type'),
|
||||||
(context || {}).domainObject.hasCapability("persistence");
|
creatable = type && type.hasFeature('creation');
|
||||||
|
|
||||||
|
// Only allow creatable types to be edited
|
||||||
|
return domainObject &&
|
||||||
|
domainObject.hasCapability("persistence") &&
|
||||||
|
creatable;
|
||||||
};
|
};
|
||||||
|
|
||||||
return PropertiesAction;
|
return PropertiesAction;
|
||||||
|
@ -80,9 +80,14 @@ define(
|
|||||||
RemoveAction.appliesTo = function (context) {
|
RemoveAction.appliesTo = function (context) {
|
||||||
var object = (context || {}).domainObject,
|
var object = (context || {}).domainObject,
|
||||||
contextCapability = object && object.getCapability("context"),
|
contextCapability = object && object.getCapability("context"),
|
||||||
parent = contextCapability && contextCapability.getParent();
|
parent = contextCapability && contextCapability.getParent(),
|
||||||
|
parentType = parent.getCapability('type'),
|
||||||
|
parentCreatable = parentType && parentType.hasFeature('creation');
|
||||||
|
|
||||||
|
// Only creatable types should be modifiable
|
||||||
return parent !== undefined &&
|
return parent !== undefined &&
|
||||||
Array.isArray(parent.getModel().composition);
|
Array.isArray(parent.getModel().composition) &&
|
||||||
|
parentCreatable;
|
||||||
};
|
};
|
||||||
|
|
||||||
return RemoveAction;
|
return RemoveAction;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user