<% show_component_switch = false component_switch_value = false component_map = {"resource" => "archival_object", "digital_object" => "digital_object_component"} if @search_data && @search_data[:criteria].has_key?("type[]") types = @search_data[:criteria]["type[]"] if types.length === 1 if component_map.keys.include?(types[0]) show_component_switch = true component_switch_value = false parent_type = types[0] end elsif types.length === 2 intersection = component_map.keys & types if intersection.length === 1 show_component_switch = true component_switch_value = true parent_type = intersection[0] end end end %> <% if show_component_switch %>
<%= check_box_tag "component_switch_checkbox", component_switch_value, component_switch_value, :onclick => "location.href = $('#component_switch_link').attr('href');" %> <%= link_to I18n.t("search_results.component_switch"), params_for_search("type" => component_switch_value ? parent_type : [parent_type, component_map[parent_type]]), :id => "component_switch_link" %>
<% end %>