With adaptModel.findDescendants, if you wanted to do something like get all available, mandatory components for a contentObject, you could do this:
Adapt.findById('co-05').findDescendants('components').where({'_isAvailable': true, '_isOptional': false});
However, following #1616 this function is deprecated in favour of findDescendantModels - but as this function returns an Array rather than a Backbone Collection it's necessary to do the following to achieve the same result:
_.filter(Adapt.findById('co-05').findDescendantModels('components'), function(comp) {
return comp.get('_isAvailable') === true && comp.get('_isOptional') === false;
});
Which is obviously quite a bit wordier compared to the original.
I think it would therefore be useful to amend findDescendantModels to have an optional 2nd parameter filterBy that would give us similar functionality to the original version.
With
adaptModel.findDescendants, if you wanted to do something like get all available, mandatory components for a contentObject, you could do this:However, following #1616 this function is deprecated in favour of
findDescendantModels- but as this function returns an Array rather than a Backbone Collection it's necessary to do the following to achieve the same result:Which is obviously quite a bit wordier compared to the original.
I think it would therefore be useful to amend
findDescendantModelsto have an optional 2nd parameterfilterBythat would give us similar functionality to the original version.