-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add rtl functionality to search results
- Loading branch information
1 parent
f8c58f3
commit 84cba4f
Showing
3 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class RTLIndexPresenter < ::Blacklight::IndexPresenter | ||
def label(field_or_string_or_proc, opts = {}) | ||
config = Blacklight::Configuration::NullField.new | ||
value = case field_or_string_or_proc | ||
when Symbol | ||
config = field_config(field_or_string_or_proc) | ||
value_from_symbol(field_or_string_or_proc) | ||
when Proc | ||
field_or_string_or_proc.call(@document, opts) | ||
when String | ||
field_or_string_or_proc | ||
end | ||
value ||= @document.id | ||
label_value(value, config) | ||
end | ||
|
||
private | ||
|
||
def value_from_symbol(field) | ||
default_title_field = @configuration.index.title_field | ||
preferred_title_field = @configuration.index.preferred_title_field | ||
|
||
if field.to_s == default_title_field && @document.key?(preferred_title_field) | ||
@document[preferred_title_field] | ||
else | ||
@document[field] | ||
end | ||
end | ||
|
||
def label_value(value, config) | ||
if value.is_a?(Array) && value.count > 1 | ||
value.collect { |v| field_values(config, value: v) } | ||
else | ||
field_values(config, value: value) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<%# header bar for doc items in index view -%> | ||
<div class="documentHeader row"> | ||
<%# main title container for doc partial view | ||
How many bootstrap columns need to be reserved | ||
for bookmarks control depends on size. | ||
-%> | ||
<% document_actions = capture do %> | ||
<% # bookmark functions for items/docs -%> | ||
<%= render_index_doc_actions document, wrapping_class: "index-document-functions col-sm-3 col-lg-2" %> | ||
<% end %> | ||
<h3 class="index_title document-title-heading <%= document_actions.present? ? "col-sm-9 col-lg-10" : "col-md-12" %>"> | ||
<div class="row"> | ||
</div> | ||
<% if counter = document_counter_with_offset(document_counter) %> | ||
<span style="" class="document-counter col-sm-1"> | ||
<%= t('blacklight.search.documents.counter', counter: counter) %> | ||
</span> | ||
<% end %> | ||
<div class="col-sm-11"> | ||
<% field = index_presenter(document).label(document_show_link_field(document)) %> | ||
<% if field.length == 1 || !field.is_a?(Array) %> | ||
<% valdir = Array(field).first.dir %> | ||
<span style="display: block;" dir="<%= valdir %>"> | ||
<%= link_to_document document, document_show_link_field(document), counter: counter %> | ||
</span> | ||
<% else %> | ||
<% valdirs = [] %> | ||
<% field.each do |value| %> | ||
<% valdirs << value.dir %> | ||
<% end %> | ||
<% field.each do |value| %> | ||
<span style="display: block;" dir="<%= valdirs[field.index(value)] %>"> | ||
<%= link_to value, '/' %> | ||
</span> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
</h3> | ||
<%= document_actions %> | ||
</div> |