Skip to content

Commit

Permalink
use explicit methods keys word extrapolation
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jan 31, 2025
1 parent 5f9bf07 commit 3cebf52
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
3 changes: 3 additions & 0 deletions app/components/display/search_result_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def mappings_button
t.loader do
render LoaderComponent.new(small: true)
end
t.error do
"-1"
end
end + content_tag(:div, 'mappings', class: 'ml-1')
end
end
Expand Down
12 changes: 9 additions & 3 deletions app/helpers/internationalisation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ module InternationalisationHelper
# Implement logic to make the term 'ontology' configurable throughout the portal,
# allowing it to be replaced with the variable $RESOURCE_TERM
def self.t(*args)
return I18n.t(*args) unless $RESOURCE_TERM
key, options = args
options ||= {}

return I18n.t(key, **options) unless $RESOURCE_TERM

begin
original_translation = I18n.t(*args)
key, options = args
options ||= {}
original_translation = I18n.t(key, **options)
downcase_translation = original_translation.downcase
rescue StandardError => e
binding.pry
return e.message
end

Expand All @@ -32,7 +38,7 @@ def self.t(*args)
replacement = resources if downcase_translation.include?(plural_term)
original_translation.gsub(plural_term, replacement)
else
I18n.t(*args)
I18n.t(key, **options)
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/helpers/turbo_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def alert_success(id: nil, &block)
alert(id: id, type:'success', &block)
end
def prepend(id, options = {}, &block)
turbo_stream.prepend(id, options, &block)
turbo_stream.prepend(id, **options, &block)
end
def replace(id, options = {}, &block)
turbo_stream.replace(id, options, &block)
turbo_stream.replace(id, **options, &block)
end

def remove(id)
Expand All @@ -38,4 +38,4 @@ def render_alerts_container(controller_class = nil)
render AlertsContainerComponent.new(id: id)
end

end
end
8 changes: 4 additions & 4 deletions app/views/search/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@
- descendants = result[:descendants]
- reuses = result[:reuses]
- result[:root][:number] = number
= render Display::SearchResultComponent.new(result[:root]) do |c|
- descendants.each { |d| c.subresult(d.merge(is_sub_component: true))}
= render Display::SearchResultComponent.new(**result[:root]) do |c|
- descendants.each { |d| c.subresult(**d.merge(is_sub_component: true))}
- reuses.each do |r|
- number = number + 1
- c.reuse(r[:root].merge(is_sub_component: true, number: number)) do |b|
- r[:descendants].each { |dd| b.subresult(dd.merge(is_sub_component: true))}
- c.reuse(**r[:root].merge(is_sub_component: true, number: number)) do |b|
- r[:descendants].each { |dd| b.subresult(**dd.merge(is_sub_component: true))}

- if @search_results.empty? && !@search_query.empty?
= empty_state

0 comments on commit 3cebf52

Please sign in to comment.