estimancy/projestimate

View on GitHub
app/views/searches/results.html.erb

Summary

Maintainability
Test Coverage
<div class="tabs">
  <ul>
    <li><a href="#tabs-1"><%= I18n.t(:search_results) %></a></li>
  </ul>

  <div id="tabs-1">
    <% if @results.empty? %>
        <p><%= I18n.t(:no_results) %> <strong><%= params[:search] %></strong></p>
    <% else %>
              <% classes = @results.map { |i| i.class }.uniq %>
              <ul>
              <% classes.each do |cla| %>
                  <div id="accordion<%= cla.to_s %>" class="accordion">
                    <div class="accordion-group accordion-caret">
                      <div class="accordion-heading">
                        <%= render :partial => "searches/search_navigation", :locals => {:classes => classes} %>
                        <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion<%= cla.to_s %>" href="#collapse<%= cla.to_s %>">
                          <i class="fa fa-caret-down"></i>
                          <b><%= I18n.t("label_#{cla.to_s}") %> <%= "(#{ @result_count[cla]})"  %> </b>
                        </a>
                      </div>
                      <div id="collapse<%= cla.to_s %>" class="accordion-body in collapse">
                        <div class="accordion-inner">
                          <% if cla == Project %>
                            <% @results.each do |res| %>
                              <% if res.class == cla and can? :show_project, res %>
                                <li style="margin-left: 20px;"><%= display_link(res, params[:search]) %></li>
                                <li style="margin-left: 20px; font-style: italic; font-size: 10px;"><%= display_description(res, params[:search]) %></li>
                                <li style="margin-left: 20px; font-size: 10px;"><%= display_update(res, params[:search]) %></li>
                                <br>
                              <% end %>
                            <% end %>
                          <% else %>
                            <% @results.each do |res| %>
                              <% if res.class == cla %>
                                <li style="margin-left: 20px;"><%= display_link(res, params[:search]) %></li>
                                <li style="margin-left: 20px; font-style: italic; font-size: 10px;"><%= display_description(res, params[:search]) %></li>
                                <li style="margin-left: 20px; font-size: 10px;"><%= display_update(res, params[:search]) %></li>
                                <br>
                              <% end %>
                            <% end %>
                          <% end %>
                        </div>
                      </div>
                    </div>
                  </div>
              <% end %>
              </ul>
        </table>
    <% end %>
  </div>
</div>