Skip to content

Commit

Permalink
Check all types of an entity to find one we have template for
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Sep 21, 2012
1 parent e28dcad commit e1f9980
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/Collection.js
Expand Up @@ -57,9 +57,10 @@ VIE.prototype.Collection = Backbone.Collection.extend({
throw new Error("No model given"); throw new Error("No model given");
} }


if (_.isString(model) && collection.isReference(model)) { if (_.isString(model)) {
model = { model = {
'@subject': model '@subject': model,
id: model
}; };
} }


Expand Down
16 changes: 12 additions & 4 deletions src/view/CollectionView.js
Expand Up @@ -57,12 +57,20 @@ VIE.prototype.view.Collection = Backbone.View.extend({
} }


var childType = entity.get('@type'); var childType = entity.get('@type');
var childTypeName;
if (_.isArray(childType)) { if (_.isArray(childType)) {
childType = childType[childType.length - 1]; _.each(childType, function (type) {
if (this.canAdd(type.id)) {
childTypeName = type.id;
}
}, this);
} else {
if (this.canAdd(childType.id)) {
childTypeName = childType.id;
}
} }
var childTypeName = childType.id;

if (!childTypeName) {
if (!this.canAdd(childTypeName)) {
return; return;
} }


Expand Down

0 comments on commit e1f9980

Please sign in to comment.