Skip to content

Commit

Permalink
509 need safe nav in ubiq view (#512)
Browse files Browse the repository at this point in the history
* add safe nav for 'array_of_hash'

* handle odd case in which nil field ends up in view
  • Loading branch information
cziaarm authored Jan 19, 2024
1 parent c4fa452 commit 522206b
Showing 1 changed file with 50 additions and 48 deletions.
98 changes: 50 additions & 48 deletions app/views/shared/ubiquity/search_display/_show_array_hash.html.erb
Original file line number Diff line number Diff line change
@@ -1,59 +1,61 @@
<% array_size = (array_of_hash&.size <= 5 ? array_of_hash.size - 1 : 4) %>
<% array_of_hash.each_with_index do |hash, index| %>
<% if index <= 4 %>
<span itemprop='<%= "#{attr_name}" %>'>
<% last_name = hash["#{attr_name}_family_name"] || '' %>
<% first_name = hash["#{attr_name}_given_name"] || '' %>
<% organizational_creator = hash["#{attr_name}_organization_name"] %>
<% last_name << ',' if last_name && display_comma?(hash.keys, ["#{attr_name}_family_name", "#{attr_name}_given_name"]) %>
<% document.creator_search.each do |creator| %>
<span>
<% if creator == organizational_creator %>
<%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(organizational_creator)}), class: 'creator-search-results' do %>
<%= organizational_creator %>
<%= remove_last_semicolon(array_size, index) %>
<% if index != array_size %>
&nbsp;
<% end %>
<%= '…' if index == array_size && array_of_hash.size > 5 %>
<% end %>
<% end %>
<% if last_name %>
<% if creator == "#{last_name} " + first_name ||
creator + first_name == "#{last_name} " + first_name %>
<%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(last_name + (" #{first_name}" if first_name)) }), class: 'creator-search-results' do %>
<%= last_name %>
<%= first_name if first_name %>
<% if array_of_hash.present? %>
<% array_size = (array_of_hash&.size <= 5 ? array_of_hash.size - 1 : 4) %>
<% array_of_hash.each_with_index do |hash, index| %>
<% if index <= 4 %>
<span itemprop='<%= "#{attr_name}" %>'>
<% last_name = hash["#{attr_name}_family_name"] || '' %>
<% first_name = hash["#{attr_name}_given_name"] || '' %>
<% organizational_creator = hash["#{attr_name}_organization_name"] %>
<% last_name << ',' if last_name && display_comma?(hash.keys, ["#{attr_name}_family_name", "#{attr_name}_given_name"]) %>
<% document.creator_search.each do |creator| %>
<span>
<% if creator == organizational_creator %>
<%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(organizational_creator)}), class: 'creator-search-results' do %>
<%= organizational_creator %>
<%= remove_last_semicolon(array_size, index) %>
<% if index != array_size %>
&nbsp;
<% end %>
<%= '…' if index == array_size && array_of_hash.size > 5 %>
<% end %>
<% end %>
<% if creator == last_name %>
<%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(last_name) }), class: 'creator-search-results' do %>
<%= last_name %>
<%= remove_last_semicolon(array_size, index) %>
<% if index != array_size %>
&nbsp;
<% end %>
<%= '…' if index == array_size && array_of_hash.size > 5 %>
<% if last_name %>
<% if creator == "#{last_name} " + first_name ||
creator + first_name == "#{last_name} " + first_name %>
<%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(last_name + (" #{first_name}" if first_name)) }), class: 'creator-search-results' do %>
<%= last_name %>
<%= first_name if first_name %>
<%= remove_last_semicolon(array_size, index) %>
<% if index != array_size %>
&nbsp;
<% end %>
<%= '…' if index == array_size && array_of_hash.size > 5 %>
<% end %>
<% end %>
<% end %>
<% if creator == first_name %>
<%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(first_name) }), class: 'creator-search-results' do %>
<%= first_name %>
<%= remove_last_semicolon(array_size, index) %>
<% if index != array_size %>
&nbsp;
<% end %>
<%= '…' if index == array_size && array_of_hash.size > 5 %>
<% if creator == last_name %>
<%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(last_name) }), class: 'creator-search-results' do %>
<%= last_name %>
<%= remove_last_semicolon(array_size, index) %>
<% if index != array_size %>
&nbsp;
<% end %>
<%= '…' if index == array_size && array_of_hash.size > 5 %>
<% end %>
<% end %>
<% end %>
<% end %>
</span>
<% end %>
</span>
<% if creator == first_name %>
<%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(first_name) }), class: 'creator-search-results' do %>
<%= first_name %>
<%= remove_last_semicolon(array_size, index) %>
<% if index != array_size %>
&nbsp;
<% end %>
<%= '…' if index == array_size && array_of_hash.size > 5 %>
<% end %>
<% end %>
<% end %>
</span>
<% end %>
</span>
<% end %>
<% end %>
<% end %>

0 comments on commit 522206b

Please sign in to comment.