diff options
| -rw-r--r-- | app/controllers/referentials_controller.rb | 6 | ||||
| -rw-r--r-- | app/helpers/newapplication_helper.rb | 8 | ||||
| -rw-r--r-- | app/views/referentials/show.html.slim | 4 | 
3 files changed, 10 insertions, 8 deletions
| diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 5ff296659..9a9e9b151 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -81,7 +81,7 @@ class ReferentialsController < BreadcrumbController    end    def lines_collection -    @q = resource.lines.search(params[:q]) +    @q = resource.lines.includes(:company, :network).search(params[:q])      if sort_column && sort_direction        @reflines ||= @@ -115,8 +115,10 @@ class ReferentialsController < BreadcrumbController    private    def sort_column -    resource.lines.include?(params[:sort]) ? params[:sort] : 'name' +    sortable_columns = Chouette::Line.column_names + ['networks.name', 'companies.name'] +    params[:sort] if sortable_columns.include?(params[:sort])    end +    def sort_direction      %w[asc desc].include?(params[:direction]) ?  params[:direction] : 'asc'    end diff --git a/app/helpers/newapplication_helper.rb b/app/helpers/newapplication_helper.rb index dc16166e1..c4ea0a200 100644 --- a/app/helpers/newapplication_helper.rb +++ b/app/helpers/newapplication_helper.rb @@ -16,11 +16,11 @@ module NewapplicationHelper          end          columns.map do |k, v| -          if k.is_a? Symbol +          # if k.is_a? Symbol              hcont << content_tag(:th, sortable_columns(collection, k)) -          else -            hcont << content_tag(:th, k) -          end +          # else +          #   hcont << content_tag(:th, k) +          # end          end          hcont << content_tag(:th, '') if actions.any? diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim index 5c267769a..f12f47aa4 100644 --- a/app/views/referentials/show.html.slim +++ b/app/views/referentials/show.html.slim @@ -52,8 +52,8 @@              :name => 'name',              :deactivated => Proc.new{|n| n.deactivated? ? t('false') : t('true')},              :transport_mode => 'transport_mode', -            :network => Proc.new { |n| n.try(:network).try(:name) }, -            :company => Proc.new { |n| n.try(:company).try(:name) } }, +            'networks.name' => Proc.new { |n| n.try(:network).try(:name) }, +            'companies.name' => Proc.new { |n| n.try(:company).try(:name) } },              [:show],              [],              'table has-filter has-search' | 
