diff --git a/app/views/shared/ubiquity/search_display/_show_array_hash.html.erb b/app/views/shared/ubiquity/search_display/_show_array_hash.html.erb index 1e03d190..c117c492 100644 --- a/app/views/shared/ubiquity/search_display/_show_array_hash.html.erb +++ b/app/views/shared/ubiquity/search_display/_show_array_hash.html.erb @@ -1,29 +1,17 @@ -<% 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 %> - - <% 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| %> - - <% 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 %> -   - <% 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 %> + + <% 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| %> + + <% 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 %>   @@ -31,29 +19,43 @@ <%= '…' 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 %> -   - <% 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 %> +   + <% 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 %> -   - <% 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 %> +   + <% end %> + <%= '…' if index == array_size && array_of_hash.size > 5 %> + <% end %> <% end %> - <% 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 %> +   + <% end %> + <%= '…' if index == array_size && array_of_hash.size > 5 %> + <% end %> + <% end %> + <% end %> + + <% end %> + + <% end %> <% end %> <% end %>