<div class="row">
  <div class="col-md-12">
    <a class="btn record-selector dropdown btn-primary glyphicon glyphicon-chevron-down" href="#" data-toggle="dropdown"></a>
    <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
      <% @repository.snapshots.last.best_records(@metric).each do |document| %>
        <%= record_selector_entry(@documents[i], document) %>
      <% end %>
    </ul>
    <a class="btn record-selector dropdown btn-default glyphicon glyphicon-search" href="<%= "#search-modal-#{i}" %>" data-toggle="modal"></a>
    <div class="modal fade" id="<%= "search-modal-#{i}" %>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title">Record Search</h4>
          </div>
          <div class="modal-body">
            <div class="row">
              <div class="col-md-12">
                <input id="<%= "record-search-input-#{i}" %>" class="form-control" type="text" placeholder="Search..."></input>
              </div>
            </div>
            <div class="row">
              <div id="<%= "record-search-results-#{i}" %>" class="col-md-12" data-document="<%= @documents[i][:id] %>">
                <!-- The list class is used to make List.js working -->
                <table data-provides="rowlink" class="table metric record-results">
                  <thead>
                    <tr>
                      <th class="name">Name</th>
                      <th class="score">Score</th>
                    </tr>
                  </thead>
                  <tbody class="list">
                    <tr>
                      <td class="name"></td>
                      <td class="score"></td>
                    </tr>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          </div>
        </div> <!-- /.modal-content -->
      </div> <!-- /.modal-dialog -->
    </div> <!-- /.modal -->
  </div>
</div>
<div class="row">
  <div class="col-md-12">
    <table class="metric record-info table table-bordered">
      <tr>
        <th>ID</th>
        <td><%= @documents[i].record[:id] %></td>
      </tr>
      <tr>
        <th>Name</th>
        <td><%= @documents[i].record[:name] %></td>
      </tr>
      <tr>
        <th>Score</th>
        <td><%= @documents[i].send(@metric)[:score] %></td>
      </tr>
    </table>
  </div>
</div>

Add partial to encapsulate record selection
Add partial to encapsulate record selection

The record selectors have been separated into its own partial. More and
more view files become redundant, but this seems a necessary process in
this refactoring.

Signed-off-by: Konrad Reiche <4ff0213f56e2082fcd8c882d04c546881c579ce4@gmail.com>
