af83/chouette-core

View on GitHub
app/views/dashboards/_dashboard.html.slim

Summary

Maintainability
Test Coverage
- @dashboard.current_user.workbenches.with_active_workgroup.each do |workbench|
  .row
    - if @dashboard.current_user.workbenches.many?
      .col-lg-12
        h2 = workbench.workgroup.name
    .col-sm-6.col-xs-12
      - unless @dashboard.current_user.workbenches.many?
        .panel.panel-default
          .panel-heading
            h3.panel-title.with_actions
              div
                = link_to t('dashboards.workbench_output.title', name: workbench.name), workbench_output_path(workbench)
                span.badge.ml-xs = workbench.output.referentials.count if workbench.output.referentials.present?

              div
                = link_to '', workbench_output_path(workbench), class: ' fa fa-chevron-right pull-right', title: t('workbenches.index.offers.see')

          - if workbench.output.referentials.present?
            .list-group
              - workbench.output.referentials.limit(5).each do |referential|
                = link_to referential.name, workbench_referential_path(workbench, referential), class: 'list-group-item'
          - else
            .panel-body
              em.small.text-muted = t('dashboards.workbench_output.none')

      .panel.panel-default
        .panel-heading
          h3.panel-title.with_actions
            div
              - if @dashboard.current_user.workbenches.many?
                = link_to t('dashboards.workbench.title', name: workbench.name), workbench_path(workbench)
              - else
                = link_to Workbench.model_name.human.capitalize, workbench_path(workbench)
              span.badge.ml-xs = workbench.all_referentials.uniq.count if workbench.all_referentials.present?

            div
              = link_to '', workbench_path(workbench), class: ' fa fa-chevron-right pull-right', title: t('workbenches.index.offers.see')

        - if workbench.all_referentials.present?
          .list-group
            - workbench.all_referentials.order(created_at: :desc).limit(5).each do |referential|
              = link_to referential.name, workbench_referential_path(workbench, referential), class: 'list-group-item'
        - else
          .panel-body
            em.small.text-muted = t('workbenches.index.offers.no_content')

      - if (imports = workbench.imports.workbench).present?
        .panel.panel-default
          .panel-heading
            h3.panel-title.with_actions
              div
                = link_to I18n.t("activerecord.models.import", count: imports.size), workbench_imports_path(workbench)
                span.badge.ml-xs = imports.count if imports.present?
              div
                = link_to '', workbench_imports_path(workbench), class: ' fa fa-chevron-right pull-right'
          .list-group
            - imports.order("updated_at desc").limit(5).each do |import|
              = link_to import.name, workbench_import_path(workbench, import), class: 'list-group-item'

    .col-sm-6.col-xs-12
      .panel.panel-default
        .panel-heading
          h3.panel-title
            = t('dashboards.stop_area_referentials.title')
        .list-group
          = link_to Chouette::StopArea.model_name.human.pluralize.capitalize, workbench_stop_area_referential_stop_areas_path(workbench), class: 'list-group-item'

      .panel.panel-default
        .panel-heading
          h3.panel-title
            = t('dashboards.line_referentials.title')
        .list-group
            = link_to Chouette::Line.model_name.human.pluralize.capitalize, workbench_line_referential_lines_path(workbench), class: 'list-group-item'
            = link_to Chouette::Company.model_name.human.pluralize.capitalize, workbench_line_referential_companies_path(workbench), class: 'list-group-item'
            = link_to Chouette::Network.model_name.human.pluralize(I18n.locale).capitalize, workbench_line_referential_networks_path(workbench), class: 'list-group-item'

      - if workbench.workgroup.owner == current_organisation
        .panel.panel-default
          .panel-heading
            h3.panel-title.with_actions
              div
                = link_to I18n.t("dashboards.aggregates.title", count: workbench.workgroup.aggregates.size), workgroup_output_path(workbench.workgroup)
                span.badge.ml-xs = workbench.workgroup.aggregates.count if workbench.workgroup.aggregates.present?
              div
                = link_to '', workgroup_output_path(workbench.workgroup), class: ' fa fa-chevron-right pull-right'

          - if workbench.workgroup.aggregates.present?
            .list-group
              - workbench.workgroup.aggregates.order("created_at desc").limit(5).each do |aggregate|
                = link_to t("aggregates.show.title", name: aggregate.name.capitalize).html_safe, workgroup_aggregate_path(aggregate.workgroup, aggregate), class: 'list-group-item'
          - else
            .panel-body
              em.small.text-muted = t('dashboards.aggregates.none')