Skip to content

Commit

Permalink
Fix citations render in browse noemnclature
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Dec 28, 2024
1 parent 6eedc8e commit 3f1bac0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 14 additions & 8 deletions app/helpers/sources_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ def sources_autocomplete_tag(source, term)
if source.respond_to?(:in_project) && !source.in_project.nil?
s += ' ' + tag.span('in', class: [:feedback, 'feedback-primary', 'feedback-thin'])
c = source.use_count
s += ' ' + ( c > 0 ? tag.span("#{c.to_s} #{'citations'.pluralize(c)}".html_safe, class: [:feedback, 'feedback-secondary', 'feedback-thin']) : '' )
s += ' ' + ( c > 0 ? tag.span("#{c} #{'citations'.pluralize(c)}".html_safe, class: [:feedback, 'feedback-secondary', 'feedback-thin']) : '' )
s += ' ' + tag.span('doc/pdf', class: [:feedback, 'feedback-success', 'feedback-thin']) if source.documentation.where(project_id: sessions_current_project_id).any?
elsif source.is_in_project?(sessions_current_project_id)
s += ' ' + tag.span('in', class: [:feedback, 'feedback-primary', 'feedback-thin'])
c = source.citations.where(project_id: sessions_current_project_id).count
s += ' ' + ( c > 0 ? tag.span("#{c.to_s} #{'citations'.pluralize(c)}".html_safe, class: [:feedback, 'feedback-secondary', 'feedback-thin']) : '' )
s += ' ' + ( c > 0 ? tag.span("#{c} #{'citations'.pluralize(c)}".html_safe, class: [:feedback, 'feedback-secondary', 'feedback-thin']) : '' )
s += ' ' + tag.span('doc/pdf', class: [:feedback, 'feedback-success', 'feedback-thin']) if source.documentation.where(project_id: sessions_current_project_id).any?
else
s += ' ' + tag.span('out', class: [:feedback, 'feedback-warning', 'feedback-thin'])
Expand All @@ -50,7 +50,7 @@ def source_author_year_label(source)
when 'Source::Human'
source.cached
when 'Source::Bibtex'
source.author_year.present? ? source.author_year : not_provided
(source.author_year.presence || not_provided)
else
not_provided
end
Expand All @@ -62,7 +62,7 @@ def source_author_year_tag(source)
when 'Source::Human'
source.cached
when 'Source::Bibtex'
source.author_year.present? ? source.author_year : not_provided
(source.author_year.presence || not_provided)
else
tag.span(not_provided, class: [:feedback, 'feedback-thin', 'feedback-warning'])
end
Expand Down Expand Up @@ -163,10 +163,16 @@ def source_in_other_project_tag(object)

def source_nomenclature_tag(source, topics)
t = [tag.span(source_tag(source))]
t.push [':', topic_list_tag(topics).html_safe] if !topics.blank?
t.push radial_annotator(source)
t.push radial_navigation_tag(source)
t.flatten.compact.join(' ').html_safe
t.push [':', topic_list_tag(topics).html_safe] if topics.present?

content_tag(:div,
t.flatten.compact.join(' ').html_safe +
content_tag(:div,
content_tag(:div,
radial_annotator(source) +
radial_navigation_tag(source), class: 'flex-row gap-small'
), class: 'd-inline-block margin-small-left')
)
end


Expand Down
2 changes: 1 addition & 1 deletion app/views/tasks/nomenclature/browse/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<%= content_tag(:h3, 'References')-%>
<ul class="citations">
<% @data.sources.each do |s| -%>
<%= content_tag(:li, source_nomenclature_tag(s, @data.topics_for_source(s)), class: 'horizontal-left-content gap-small') -%>
<%= content_tag(:li, source_nomenclature_tag(s, @data.topics_for_source(s))) -%>
<% end %>
</ul>
<% end %>
Expand Down

0 comments on commit 3f1bac0

Please sign in to comment.