mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 17:57:04 +00:00
[LinkService] Reorder/refactor validation
Reoder validation to consider the composition capability first; refactor to express as a single expression to clarify validation logic (explicitly say 'and' instead of implying it with control flow.) Based on feedback from nasa/openmctweb#98
This commit is contained in:
parent
3310016264
commit
c17269ba8b
@ -39,20 +39,17 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
LinkService.prototype.validate = function (object, parentCandidate) {
|
LinkService.prototype.validate = function (object, parentCandidate) {
|
||||||
if (!parentCandidate || !parentCandidate.getId) {
|
var objectId = object.getId();
|
||||||
return false;
|
return !!parentCandidate &&
|
||||||
}
|
!!parentCandidate.getId &&
|
||||||
if (parentCandidate.getId() === object.getId()) {
|
parentCandidate.getId() !== objectId &&
|
||||||
return false;
|
parentCandidate.hasCapability("composition") &&
|
||||||
}
|
parentCandidate.getModel().composition.indexOf(objectId) === -1 &&
|
||||||
if ((parentCandidate.getModel().composition || []).indexOf(object.getId()) !== -1) {
|
this.policyService.allow(
|
||||||
return false;
|
"composition",
|
||||||
}
|
parentCandidate.getCapability('type'),
|
||||||
return this.policyService.allow(
|
object.getCapability('type')
|
||||||
"composition",
|
);
|
||||||
parentCandidate.getCapability('type'),
|
|
||||||
object.getCapability('type')
|
|
||||||
) && parentCandidate.hasCapability('composition');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
LinkService.prototype.perform = function (object, parentObject) {
|
LinkService.prototype.perform = function (object, parentObject) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user