lib/dato/local/items_repo.rb in dato-0.4.2 vs lib/dato/local/items_repo.rb in dato-0.4.3
- old
+ new
@@ -132,9 +132,16 @@
item_types.each do |item_type|
method = item_type_methods[item_type]
if !item_type.singleton && item_type.sortable
@collections_by_type[method].sort_by!(&:position)
+ elsif item_type.ordering_field
+ @collections_by_type[method].sort_by! do |item|
+ item.send(item_type.ordering_field.api_key)
+ end
+ if item_type.ordering_direction == 'desc'
+ @collections_by_type[method].reverse!
+ end
end
end
end
def build_singletons_by_type!