Skip to content

Commit

Permalink
breakout ancestors/descendants into their own partials, updating desc…
Browse files Browse the repository at this point in the history
…endants i18n key
  • Loading branch information
mejackreed committed Oct 20, 2016
1 parent bb31179 commit 54f5f29
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 28 deletions.
8 changes: 8 additions & 0 deletions app/views/relation/_ancestors.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<b><%= t('geoblacklight.relations.ancestor') %></b>
<% @relations.ancestors['docs'].each do |ancestor| %>
<li>
<%= link_to solr_document_path(ancestor['layer_slug_s']) do %>
<span class='geoblacklight geoblacklight-relations-ancestor'></span> <%= ancestor['dc_title_s'] %>
<% end %>
</li>
<% end %>
15 changes: 15 additions & 0 deletions app/views/relation/_descendants.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<b><%= t('geoblacklight.relations.descendant', count: @relations.descendants['numFound']) %></b>
<% @relations.descendants['docs'][0..2].each do |descendant| %>
<li>
<%= link_to solr_document_path(descendant['layer_slug_s']) do %>
<span class='geoblacklight geoblacklight-relations-descendant'></span> <%= descendant['dc_title_s'] %>
<% end %>
</li>
<% end %>
<% unless (@relations.descendants['numFound'].to_i <= 3) %>
<li>
<%= link_to search_catalog_path({f: {"#{Settings.FIELDS.SOURCE}" => [@relations.search_id]}}) do %>
<%= t('geoblacklight.relations.browse_all', count: @relations.descendants['numFound']) %>
<% end %>
</li>
<% end %>
29 changes: 2 additions & 27 deletions app/views/relation/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,8 @@
</div>
<div class="panel-body">
<ul class="nav">
<% unless (@relations.ancestors['numFound'].to_i == 0) %>
<b><%= t('geoblacklight.relations.ancestor') %></b>
<% @relations.ancestors['docs'].each do |ancestor| %>
<li>
<%= link_to solr_document_path(ancestor['layer_slug_s']) do %>
<span class='geoblacklight geoblacklight-relations-ancestor'></span> <%= ancestor['dc_title_s'] %>
<% end %>
</li>
<% end %>
<% end %>
<% unless (@relations.descendants['numFound'].to_i == 0) %>
<b><%= t('geoblacklight.relations.descendant') %>(<%= @relations.descendants['numFound'] %>)</b>
<% @relations.descendants['docs'][0..2].each do |descendant| %>
<li>
<%= link_to solr_document_path(descendant['layer_slug_s']) do %>
<span class='geoblacklight geoblacklight-relations-descendant'></span> <%= descendant['dc_title_s'] %>
<% end %>
</li>
<% end %>
<% unless (@relations.descendants['numFound'].to_i <= 3) %>
<li>
<%= link_to search_catalog_path({f: {"#{Settings.FIELDS.SOURCE}" => [@relations.search_id]}}) do %>
<%= t('geoblacklight.relations.browse_all', count:@relations.descendants['numFound']) %>
<% end %>
</li>
<% end %>
<% end %>
<%= render 'ancestors' unless @relations.ancestors['numFound'].to_i == 0 %>
<%= render 'descendants' unless @relations.descendants['numFound'].to_i == 0 %>
</ul>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions app/views/relation/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
json.ancestors@relations.ancestors
json.descendants @relations.descendants
json.current_doc @relations.search_id
2 changes: 1 addition & 1 deletion config/locales/geoblacklight.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ en:
data_dictionary: 'Documentation'
relations:
ancestor: 'Source Datasets'
descendant: 'Derived Datasets'
descendant: 'Derived Datasets (%{count})'
browse_all: "Browse all %{count} records..."
title: 'Data Relations'

0 comments on commit 54f5f29

Please sign in to comment.