From 894c41f9345c7cdb81dd57b8e694693fd9cd3e70 Mon Sep 17 00:00:00 2001 From: Syphax Date: Wed, 20 Nov 2024 15:19:36 +0100 Subject: [PATCH] add a custom topnav search input placeholder --- app/helpers/auto_complete_helper.rb | 6 +++--- app/views/layouts/_topnav.html.haml | 2 +- config/locales/en.yml | 1 + config/locales/fr.yml | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/helpers/auto_complete_helper.rb b/app/helpers/auto_complete_helper.rb index 69dd123af..d18168c39 100644 --- a/app/helpers/auto_complete_helper.rb +++ b/app/helpers/auto_complete_helper.rb @@ -4,9 +4,9 @@ def ontologies_autocomplete render OntologySearchInputComponent.new end - def ontologies_content_autocomplete(id: '', name: '', search: '', ontologies: [], types: [], search_icon_type: 'home') + def ontologies_content_autocomplete(id: '', name: '', placeholder: nil, search: '', ontologies: [], types: [], search_icon_type: 'home') render SearchInputComponent.new(id: id, name: name, ajax_url: "#{ajax_search_ontologies_content_path}?ontologies=#{ontologies.join(',')}&types=#{types.join(',')}&search=#{search}", - item_base_url: "", id_key: 'id', placeholder: t("ontologies.ontology_search_prompt"), + item_base_url: "", id_key: 'id', placeholder: placeholder || t("ontologies.ontology_search_prompt"), use_cache: false, search_icon_type: search_icon_type, actions_links: { search_ontology_content: "/search?query=o", browse_all_ontologies: "/ontologies?search=o" }) do |s| s.template do @@ -23,4 +23,4 @@ def ontology_content_autocomplete(search: '', ontologies: [], types: []) ontologies_content_autocomplete(ontologies: ontologies, types: types, search: "#{search}") end -end \ No newline at end of file +end diff --git a/app/views/layouts/_topnav.html.haml b/app/views/layouts/_topnav.html.haml index e3382bd25..e200b7c16 100644 --- a/app/views/layouts/_topnav.html.haml +++ b/app/views/layouts/_topnav.html.haml @@ -22,7 +22,7 @@ %input - else .nav-search-container - = ontologies_content_autocomplete(search_icon_type: 'nav') + = ontologies_content_autocomplete(search_icon_type: 'nav', placeholder: t('ontologies.ontology_search_topnav')) - if session[:user].nil? %a.nav-a{:href => "/login"}= t('layout.header.login') diff --git a/config/locales/en.yml b/config/locales/en.yml index a68931c7c..97b6b5126 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1174,6 +1174,7 @@ en: outside: outside relation_with_other_ontologies: Relation with other semantic resources either in %{inside} or %{outside} ontology_search_prompt: 'Search a semantic resource or a term (e.g., Environmental impact)' + ontology_search_topnav: 'Search...' views: Views create_new_view: Create new view expand_all: Expand All diff --git a/config/locales/fr.yml b/config/locales/fr.yml index cc9b4689e..9c9a9079b 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1198,6 +1198,7 @@ fr: outside: extérieur relation_with_other_ontologies: Relation avec d'autres ontologies soit à l'intérieur soit à l'extérieur ontology_search_prompt: 'Rechercher une ontologie ou un terme (par exemple, hauteur de plante)' + ontology_search_topnav: 'Rechercher...' views: Vues create_new_view: Créer une nouvelle vue expand_all: Tout déplier