Display the entries and sub-titles count

This commit is contained in:
Alex Ling 2020-12-29 04:33:55 +00:00
parent 93c21ea659
commit 2559f65f35
3 changed files with 14 additions and 4 deletions

View File

@ -108,8 +108,18 @@ class Title
ary.reverse ary.reverse
end end
def size # Returns a string the describes the content of the title
@entries.size + @title_ids.size # e.g., - 3 titles and 1 entry
# - 4 entries
# - 1 title
def content_label
ary = [] of String
tsize = titles.size
esize = entries.size
ary << "#{tsize} #{tsize > 1 ? "titles" : "title"}" if tsize > 0
ary << "#{esize} #{esize > 1 ? "entries" : "entry"}" if esize > 0
ary.join " and "
end end
def get_entry(eid) def get_entry(eid)

View File

@ -76,7 +76,7 @@
<% end %> <% end %>
<% if item.is_a? Title %> <% if item.is_a? Title %>
<% if grouped_count == 1 %> <% if grouped_count == 1 %>
<p class="uk-text-meta"><%= item.size %> entries</p> <p class="uk-text-meta"><%= item.content_label %></p>
<% else %> <% else %>
<p class="uk-text-meta"><%= grouped_count %> new entries</p> <p class="uk-text-meta"><%= grouped_count %> new entries</p>
<% end %> <% end %>

View File

@ -32,7 +32,7 @@
<%- end -%> <%- end -%>
<li class="uk-disabled"><a><%= title.display_name %></a></li> <li class="uk-disabled"><a><%= title.display_name %></a></li>
</ul> </ul>
<p class="uk-text-meta"><%= title.size %> entries found</p> <p class="uk-text-meta"><%= title.content_label %> found</p>
<div class="uk-grid-small" uk-grid> <div class="uk-grid-small" uk-grid>
<div class="uk-margin-bottom uk-width-3-4@s"> <div class="uk-margin-bottom uk-width-3-4@s">
<form class="uk-search uk-search-default"> <form class="uk-search uk-search-default">