af83/chouette-core

View on GitHub
app/views/referentials/show.html.slim

Summary

Maintainability
Test Coverage
- breadcrumb :referential, @workbench, @referential
- page_header_content_for @referential
- javascript_additional_packs 'referential_overview/index'

.page_content
  .container-fluid
    .row
      .col-lg-6.col-md-6.col-sm-12.col-xs-12
        - attributes = {}
        - attributes[@referential.human_attribute_name(:status)] = referential_state(@referential) unless @referential.in_referential_suite?
        - attributes[@referential.human_attribute_name(:validity_period)] = (@referential.validity_period.present? ? t('validity_range', debut: l(@referential.try(:validity_period).try(:begin)), end: l(@referential.try(:validity_period).try(:end))) : '-')
        - attributes[@referential.human_attribute_name(:workbench)] = @referential.workbench&.name if @referential.workbench
        - unless @referential.in_referential_suite?
          - attributes[@referential.human_attribute_name(:merged_at)] = @referential.merged_at ? l(@referential.merged_at) : '-'
          - attributes[@referential.human_attribute_name(:urgent)] = boolean_icon(@referential.contains_urgent_offer?)
        - if @referential.created_from
          - attributes[@referential.human_attribute_name(:created_from)] = link_to(@referential.created_from.name, [@workbench, @referential.created_from])
        = definition_list t('metadatas'), attributes

    - unless @referential.ready?
      - if operation = @referential.last_operation
        .jumbotron.operation
            = operation_status(operation.status)
            span= "#{operation.class.ts}"
            span= (operation.try(:name) || operation.created_at.l(format: :short))

    - else
      .row
        .col-lg-12
          = render 'filters'
      - if @reflines.any?
        .row
          .col-lg-12
            / ID Codif, nom court, nom de la ligne, réseau, mode, transporteur principal, actions = [show, edit_notes]
            = table_builder_2 @reflines,
              [ \
                TableBuilderHelper::Column.new( \
                  name: t('id_codif'), \
                  attribute: Proc.new { |n| n.get_objectid.short_id }, \
                  sortable: false \
                ), \
                TableBuilderHelper::Column.new( \
                  key: :number, \
                  attribute: 'number' \
                ), \
                TableBuilderHelper::Column.new( \
                  key: :name, \
                  attribute: 'name', \
                  link_to: lambda do |line| \
                    workbench_referential_line_path(@workbench, @referential, line) \
                  end \
                ), \
                TableBuilderHelper::Column.new( \
                  key: :status, \
                  attribute: Proc.new { |n| line_status(n) } \
                ), \
                TableBuilderHelper::Column.new( \
                  key: :transport_mode, \
                  attribute: Proc.new { |n| n.transport_mode ? t("enumerize.transport_mode.#{n.transport_mode}") : '' }, \
                ), \
                TableBuilderHelper::Column.new( \
                  key: 'network', \
                  attribute: Proc.new { |n| n.try(:network).try(:name) } \
                ), \
                TableBuilderHelper::Column.new( \
                  key: 'company', \
                  attribute: Proc.new { |n| n&.company&.name || "-" } \
                ) \
              ],
              cls: 'table has-filter has-search',
              action: :index

            = new_pagination @reflines, 'pull-right'

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


      = referential_overview(resource) if @referential.service_counts.any?