afimb/chouette2

View on GitHub
app/views/shared/_header.erb

Summary

Maintainability
Test Coverage
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar version"><%= "#{ENV['prefix_application_version'].strip} " if ENV['prefix_application_version'].present? %><%= Chouette::Application::VERSION %></span>
      </button>
      <%= link_to referentials_path, :class =>"navbar-brand" do %>
        <%= image_tag("logo_chouette.png") %>
      <% end %>
      <p class="navbar-text"><span class="brand_name">CHOUETTE</span><span class="version">
        <%= "#{ENV['prefix_application_version'].strip} " if ENV['prefix_application_version'].present? %>
        <%= Chouette::Application::VERSION %></span>
      </p>
    </div>
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <% if selected_referential? %>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" title="<%= @referential.name %>"><%= truncate @referential.name, :length => 15 %><b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li><%= link_to t("layouts.navbar.return_to_referentials"), referentials_path %></li>
            <li class="divider"></li>
            <li role="presentation" class="dropdown-header"><%= t("layouts.navbar.select_referential") %></li>
            <% current_organisation.referentials.each do |referential| %>
            <li>
              <%= link_to referential.name, referential_path(referential) %>
            </li>
            <% end %>
          </ul>
        </li>
        <li class="dropdown datas">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= t("layouts.navbar.referential_datas") %><b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li><%= link_to t("layouts.navbar.return_to_dashboard"), referential_path(@referential) %></li>
            <li class="divider"></li>
            <li role="presentation" class="dropdown-header"><%= t("layouts.navbar.select_referential_datas") %></li>
            <li><%= link_to referential_networks_path(@referential) do  %>
              <span class="badge pull-right"><%= @referential.networks.size %></span><%= Referential.human_attribute_name("networks") %>
              <% end %>
            </li>
            <li><%= link_to referential_companies_path(@referential) do  %>
              <span class="badge pull-right"><%= @referential.companies.size %></span><%= Referential.human_attribute_name("companies") %>
              <% end %>
            </li>
            <li><%= link_to referential_group_of_lines_path(@referential) do %>
               <span class="badge pull-right"><%= @referential.group_of_lines.size %></span><%= Referential.human_attribute_name("group_of_lines") %>
              <% end %>
            </li>
            <li><%= link_to referential_lines_path(@referential) do %>
               <span class="badge pull-right"><%= @referential.lines.size %></span><%= Referential.human_attribute_name("lines") %>
              <% end %>
            </li>
            <li><%= link_to referential_stop_areas_path(@referential) do %>
               <span class="badge pull-right"><%= @referential.stop_areas.size %></span><%= Referential.human_attribute_name("stop_areas") %>
              <% end %>
            </li>
            <li><%= link_to referential_connection_links_path(@referential) do %>
               <span class="badge pull-right"><%= @referential.connection_links.size %></span><%= Referential.human_attribute_name("connection_links") %>
              <% end %>
            </li>
            <li><%= link_to referential_time_tables_path(@referential) do %>
               <span class="badge pull-right"><%= @referential.time_tables.size %></span><%= Referential.human_attribute_name("time_tables") %>
              <% end %>
            </li>
            <li><%= link_to referential_route_sections_path(@referential) do %>
               <span class="badge pull-right"><%= @referential.route_sections.size %></span><%= Referential.human_attribute_name("route_sections") %>
              <% end %>
            </li>
            <li><%= link_to referential_timebands_path(@referential) do %>
                <span class="badge pull-right"><%= @referential.timebands.size %></span><%= Referential.human_attribute_name("timebands") %>
              <% end %>
            </li>
          </ul>
        </li>
        <% if policy(:application).write? %>
          <li><%= link_to Referential.human_attribute_name("imports"), referential_imports_path(@referential) %></li>
          <li><%= link_to Referential.human_attribute_name("exports"), referential_exports_path(@referential) %></li>
        <% end %>
        <li><%= link_to Referential.human_attribute_name("compliance_checks"), referential_compliance_checks_path(@referential) %></li>
        <% end %>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li class="dropdown languages">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">
            <%= image_tag("language_engine/#{selected_language}_flag.png", { :'data-locale' => "#{selected_language}" } ) %><b class='caret'></b>
          </a>
          <ul class="dropdown-menu">
            <li><%= link_to_language :fr, { :class => language_class( :fr ) } %></li>
            <li><%= link_to_language :en, { :class => language_class( :en  ) } %></li>
          </ul>
        </li>
        <li><%= link_to t('layouts.help'), help_path, :class =>("current" if help_page?), :target => "chouette_help" %></li>
        <% if user_signed_in?  %>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle user_admin" data-toggle="dropdown"><span class="gravatar"><%= user_gravatar_image_tag(current_user, 16) %></span><%= truncate(current_user.name, :length => 20) %> <b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li><%= link_to t('layouts.user.profile'), edit_user_registration_path %></li>
            <li><%= link_to t('layouts.user.sign_out'), destroy_user_session_path, :method => :delete %></li>
            <li class="divider"></li>
            <li><%= tab_link_to Organisation.model_name.human, organisation_path %></li>
          </ul>
        </li>
        <% end %>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>