team-umlaut/umlaut

View on GitHub
app/views/resolve/_search_inside.html.erb

Summary

Maintainability
Test Coverage
<div class="umlaut-section search_inside">
  <%
  search_providers = search_inside  
  # We don't show this block until ALL possible search inside tools
  # have been found. Too hard to deal with AJAX update of a DIV
  # that has a text input box in it otherwise. 
  # TODO: Make this a helper function!?
  if (search_providers.length > 0 and (not service_type_in_progress?('search_inside'))) %>
    <div class="section_heading">
      <%= content_tag :h3, t('umlaut.display_sections.search_inside.search_inside_this_x', :x => @user_request.referent.container_type_of_thing.try(:downcase)) %>      
    </div>
    <div class="umlaut_section_content">
      <%= content_tag("form", :target => "_blank", :action => url_for(:controller=>'link_router', :action=>'index'), :class => "form-inline") do %>

        <div class="search-inside-source form-group">
            <%=t 'umlaut.display_sections.search_inside.via' %>        
            <% if search_providers.length > 1 %>
              <%= select_tag("id", options_for_select(search_providers.collect {|st| [st.view_data[:display_text], st.id]}), 
                              :class =>"form-control id") %>
            <% else %>
                <input type="hidden" name="id" value="<%= search_providers[0].id %>">
                <%= search_providers[0].view_data[:display_text] %>
            <% end %>
        </div>

        <div class="search-inside-query form-group">
            <div class='input-group'>
              <input name="query" type="text" class="form-control" /> 
              <span class="input-group-btn">
                <input value="<%=t 'umlaut.display_sections.search_inside.action_label' %>" type="submit" class="btn btn-default input-group-add-on">
              </span>
            </div>
        </div>     
      <% end %>
    </div>
  <% elsif (@user_request.referent.format == 'book' && service_type_in_progress?('search_inside')) %>
    <%# don't show the spinner unless it's identified as a book, otherwise too likely to be a false promise %>
    <%= render(:partial => "background_progress", :locals => {:svc_type => "search_inside", 
      :progress_message => "#{t 'umlaut.display_sections.search_inside.progress_message'} #{@user_request.referent.container_type_of_thing}" }) %>
  <% end %>

</div>