publiclab/plots2

View on GitHub
app/views/grids/_wikis.html.erb

Summary

Maintainability
Test Coverage
<div class="inline-wiki-container">
<div style="max-height:500px;overflow:auto;">
<table class="table inline-grid <%= type %>-grid <%= className %> <%= className %>-<%= randomSeed %>">
  <tr>
    <th>Title</th>
    <th>Updated</th>
    <th>Version</th>
    <th>Views</th>
    <th>Likes<th>
  </tr>
  <% nodes.each do |wiki| %>
    <tr>
      <td style="width:40%">
        <% if wiki.has_tag("pin:#{tagname}") %><i rel="tooltip" title="This item was pinned with the tag 'pin:<%= tagname %>'." class="fa fa-thumb-tack"></i> <% end %>
        <i class="fa fa-file"></i> 
        <a href="<%= wiki.path %>"><%= wiki.latest.title %></a>
      </td>
      <td><%= distance_of_time_in_words(Time.at(wiki.latest.created_at), Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' }) %> <%= raw t('wiki._wikis.by') %> 
      <a href="/profile/<%= wiki.latest.author.name %>"><%= wiki.latest.author.name %></a></td>
      <td><%= wiki.revisions.length %></td>
      <td><%= number_with_delimiter(wiki.views) %></td>
      <td><%= number_with_delimiter(wiki.cached_likes) %></td>
    </tr>
  <% end %>
</table>
</div>
<%= will_paginate @wikis, :renderer => BootstrapPagination::Rails if @paginated %>

<%= render partial: 'grids/embedButton' , locals: {className: className, randomSeed: randomSeed, type: type, tagname: tagname, thumbnails: false} %>

<script>
(function(){
  $(".<%= className %>-<%= randomSeed %> .show-all a").click(function() {
    $(".<%= className %>-<%= randomSeed %> tr.hide").toggleClass("hide");
  });
  setupGridSorters(".<%= className %>-<%= randomSeed %>");
})()
</script>

<style>
  th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #fff;
}
</style>
</div>