mirror of
https://github.com/nasa/openmct.git
synced 2025-01-11 23:42:41 +00:00
[Edit] Add policy to restrict views in Edit mode
Add policy to disallow views in Edit mode which have been explicitly flagged as non-editable, WTD-1062.
This commit is contained in:
parent
ccf2ccc4c6
commit
facf350648
36
platform/commonUI/edit/src/policies/EditableViewPolicy.js
Normal file
36
platform/commonUI/edit/src/policies/EditableViewPolicy.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*global define*/
|
||||||
|
|
||||||
|
define(
|
||||||
|
[],
|
||||||
|
function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Policy controlling which views should be visible in Edit mode.
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function EditableViewPolicy() {
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
* Check whether or not a given action is allowed by this
|
||||||
|
* policy.
|
||||||
|
* @param {Action} action the action
|
||||||
|
* @param domainObject the domain object which will be viewed
|
||||||
|
* @returns {boolean} true if not disallowed
|
||||||
|
*/
|
||||||
|
allow: function (view, domainObject) {
|
||||||
|
// If a view is flagged as non-editable, only allow it
|
||||||
|
// while we're not in Edit mode.
|
||||||
|
if ((view || {}).editable === false) {
|
||||||
|
return !domainObject.hasCapability('editor');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Like all policies, allow by default.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return EditableViewPolicy;
|
||||||
|
}
|
||||||
|
);
|
Loading…
Reference in New Issue
Block a user