Composition policy takes child instance
The composition policy now takes a child instance instead of the child type, as in all cases we have access to the child object. This allows new-style objects to be contained by old-style objects. Updated all composition policies to use standardized argument names instead of `context` and `candidate`; this makes it easier to understand. Updated AddActionProvider to hardcode the object types supported.
This commit is contained in:
@@ -34,13 +34,14 @@ define(
|
||||
function LayoutCompositionPolicy() {
|
||||
}
|
||||
|
||||
LayoutCompositionPolicy.prototype.allow = function (candidate, context) {
|
||||
var isFolderInLayout =
|
||||
candidate &&
|
||||
context &&
|
||||
candidate.instanceOf('layout') &&
|
||||
context.instanceOf('folder');
|
||||
return !isFolderInLayout;
|
||||
LayoutCompositionPolicy.prototype.allow = function (parentType, child) {
|
||||
if (parentType.instanceOf('layout') &&
|
||||
child.getCapability('type').instanceOf('folder')) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
return LayoutCompositionPolicy;
|
||||
|
||||
Reference in New Issue
Block a user