af83/chouette-core

View on GitHub
app/views/time_tables/index.html.slim

Summary

Maintainability
Test Coverage
- breadcrumb :time_tables, @workbench, @referential

.page_content
  .container-fluid
    .row
      .col-lg-12
        = render 'filter'

    - if @time_tables.any?
      .row
        .col-lg-12
          = table_builder_2 @time_tables,
            [ \
              TableBuilderHelper::Column.new( \
                name: 'ID', \
                attribute: Proc.new { |n| n.get_objectid.short_id}, \
                sortable: false \
              ), \
              TableBuilderHelper::Column.new( \
                key: :color, \
                attribute: Proc.new { |tt| tt.color ? content_tag(:span, '', class: 'fa fa-circle', style: "color:#{tt.color}") : '-' }, \
              ), \
              TableBuilderHelper::Column.new( \
                key: :comment, \
                attribute: 'comment', \
                link_to: lambda do |time_table| \
                  workbench_referential_time_table_path(@workbench, @referential, time_table) \
                end \
              ), \
              TableBuilderHelper::Column.new( \
                key: :bounding_dates, \
                attribute: Proc.new { |tt| tt.object.bounding_dates.empty? ? '-' : t('bounding_dates', debut: l(tt.object.bounding_dates.min), end: l(tt.object.bounding_dates.max)) }, \
                sortable: false \
              ), \
              TableBuilderHelper::Column.new( \
                key: :vehicle_journeys_count, \
                name: Chouette::TimeTable.tmf('associated_vehicle_journeys'), \
                attribute: Proc.new{ |tt| tt.vehicle_journeys.count }, \
                sortable: false, \
                link_to: lambda do |time_table| \
                  workbench_referential_vehicle_journeys_path(@workbench, @referential, :'search[time_table_id]' => time_table.id) \
                end \
              ), \
              TableBuilderHelper::Column.new( \
                name: Chouette::TimeTable.tmf('day_types'), \
                attribute: Proc.new { |tt| (%w(monday tuesday wednesday thursday friday saturday sunday).collect{|d| tt.send(d) ? t("calendars.days.#{d}") : '' }).reject{|a| a.empty?}.join(', ').html_safe }, \
                sortable: false \
              ), \
              TableBuilderHelper::Column.new( \
                key: :calendar, \
                attribute: Proc.new { |tt| tt.calendar ? tt.calendar.try(:name) : '-' } \
              ), \
              TableBuilderHelper::Column.new( \
                key: :updated_at, \
                attribute: Proc.new { |tt| l(tt.updated_at) } \
              ) \
            ],
            cls: 'table has-search'

          = new_pagination @time_tables, 'pull-right'

    - unless @time_tables.any?
      .row.mt-xs
        .col-lg-12
          = replacement_msg t('time_tables.search_no_results')