app/controllers/puffer/tree_base.rb in puffer-0.0.29 vs app/controllers/puffer/tree_base.rb in puffer-0.0.30

- old
+ new

@@ -5,12 +5,12 @@ helper :puffer_tree define_fieldset :tree, :fallbacks => :index def index - return super if params[:search] - @records = resource.collection_scope.includes(resource.includes) + return super if puffer_filters.any? + @records = resource.collection_scope if session[:expanded].present? @records = @records.where(["depth in (0, 1) or parent_id in (#{session[:expanded].join(', ')})"]).arrange else @records = @records.with_depth([0, 1]).arrange end @@ -32,18 +32,18 @@ def expand @parent = resource.member session[:expanded] ||= [] session[:expanded].push params[:id] if @parent session[:expanded].uniq! - @records = @parent.self_and_descendants.where(:parent_id => [@parent.parent_id] + session[:expanded]).includes(resource.includes).arrange + @records = resource.model.to_adapter.filter(@parent.self_and_descendants.where(:parent_id => [@parent.parent_id] + session[:expanded]), tree_fields).arrange render 'toggle' end def collapse @parent = resource.member session[:expanded] ||= [] session[:expanded].delete params[:id] - @records = resource.collection_scope.where(:id => [@parent.id]).includes(resource.includes).arrange + @records = resource.model.to_adapter.filter(resource.collection_scope.where(:id => [@parent.id]), tree_fields).arrange render 'toggle' end end end