From 0c9adacad094c6897a86373b1980161fe56d0a80 Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Thu, 5 Dec 2024 15:59:41 +0100 Subject: [PATCH 1/6] check FAIRNESS_DISABLED variable when it's string --- app/helpers/fair_score_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/fair_score_helper.rb b/app/helpers/fair_score_helper.rb index ef5b81e2d..b5daf0b3a 100644 --- a/app/helpers/fair_score_helper.rb +++ b/app/helpers/fair_score_helper.rb @@ -5,7 +5,7 @@ def user_apikey end def fairness_service_enabled? - !$FAIRNESS_DISABLED + $FAIRNESS_DISABLED == 'false' || !$FAIRNESS_DISABLED end def get_fairness_service_url(apikey = user_apikey) From 00c804b3a0b937838bfbb1f36c25f06c1fe6ab4d Mon Sep 17 00:00:00 2001 From: MUH <58882014+muhammedBkf@users.noreply.github.com> Date: Mon, 9 Dec 2024 20:08:46 +0100 Subject: [PATCH 2/6] Update `link_to_property` to include `propertyid` in the URL parameters of instances subtab (#878) --- app/helpers/instances_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/instances_helper.rb b/app/helpers/instances_helper.rb index 79e5b1758..18a4dddd2 100644 --- a/app/helpers/instances_helper.rb +++ b/app/helpers/instances_helper.rb @@ -52,7 +52,7 @@ def link_to_class(ontology_acronym, conceptid) def link_to_property(property, ontology_acronym) link_to extract_label_from(property), - ontology_path(ontology_acronym, p: 'properties'), + ontology_path(ontology_acronym, p: 'properties', propertyid: property), { target: '_blank'} end From 6d3f0fa96070bf1fc60d958b6881cb62b09347a8 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Mon, 9 Dec 2024 20:13:54 +0100 Subject: [PATCH 3/6] Fix: display only root categories coming from federation portals in browse page (#877) --- app/controllers/ontologies_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/ontologies_controller.rb b/app/controllers/ontologies_controller.rb index 9d5f26777..92a807fe7 100644 --- a/app/controllers/ontologies_controller.rb +++ b/app/controllers/ontologies_controller.rb @@ -60,11 +60,12 @@ def ontologies_filter end end.flatten - unless request_portals.empty? + unless request_portals.length == 1 streams += [ replace('categories_refresh_for_federation') do key = "categories" objects, checked_values, _ = @filters[key.to_sym] + objects = keep_only_root_categories(objects) helpers.browse_filter_section_body(checked_values: checked_values, key: key, objects: objects, counts: @count_objects[key.to_sym]) @@ -583,4 +584,9 @@ def search_first_instance_id return !results.blank? ? results.first[:name] : nil end + def keep_only_root_categories(categories) + categories.select do |category| + category.id.start_with?(rest_url) || category.parentCategory.blank? + end + end end From c2fa08b045ab12687be3cd9805ee9a0f49cc19af Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Tue, 10 Dec 2024 22:58:00 +0100 Subject: [PATCH 4/6] Feature: add option to enable or disable twitter section (#880) * enable and disable twitter news in home page * make the block as an empty white space --- .env.sample | 2 ++ app/views/home/index.html.haml | 18 +++++++++--------- config/bioportal_config_env.rb.sample | 3 +++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.env.sample b/.env.sample index 6a8e41d24..d63ef287a 100644 --- a/.env.sample +++ b/.env.sample @@ -10,6 +10,8 @@ API_KEY= UI_THEME=ontoportal +TWITTER_NEWS= + BIOMIXER_URL= BIOMIXER_APIKEY= diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 43fc5ff02..b99138af6 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -165,15 +165,15 @@ %a{:href => "/landscape#fairness_assessment"} %div.home-fair-details %p= t('home.fair_details') - - .home-sub-section-right - %h4= t('home.twitter_news') - %hr.home-section-line - .home-card.home-twitter-news - %a.twitter-timeline{"data-height" => "360", :href => "https://twitter.com/lagroportal?ref_src=twsrc%5Etfw"} - .home-twitter-loader - = render LoaderComponent.new(type: 'pulsing') - %script{:async => "", :charset => "utf-8", :src => "https://platform.twitter.com/widgets.js"} + - if !$TWITTER_NEWS.blank? + .home-sub-section-right + %h4= t('home.twitter_news') + %hr.home-section-line + .home-card.home-twitter-news + %a.twitter-timeline{"data-height" => "360", :href => $TWITTER_NEWS} + .home-twitter-loader + = render LoaderComponent.new(type: 'pulsing') + %script{:async => "", :charset => "utf-8", :src => "https://platform.twitter.com/widgets.js"} - if slices_enabled? .home-section diff --git a/config/bioportal_config_env.rb.sample b/config/bioportal_config_env.rb.sample index 8d6c4b52e..80091a5a5 100644 --- a/config/bioportal_config_env.rb.sample +++ b/config/bioportal_config_env.rb.sample @@ -8,6 +8,9 @@ $ORG_URL = ENV['ORG_URL'] # Site name (required) $SITE = ENV['SITE'] +# Twitter section +$TWITTER_NEWS = ENV["TWITTER_NEWS"] + # Full string for site, EX: "NCBO BioPortal", do not modify $ORG_SITE = $ORG.nil? || $ORG.empty? ? $SITE : "#{$ORG} #{$SITE}" From 1576f20c13c15002464661b1af05885ae19048dc Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Tue, 10 Dec 2024 23:02:40 +0100 Subject: [PATCH 5/6] Fix: Prevent delete category if still used as parent category (#876) * prevent delete category if still used as parent category * internationalize can't delete category, used as parent category message * extract prevent delete category parent to a helper * rename is_parent? to category_is_parent? --------- Co-authored-by: Syphax --- app/controllers/admin/categories_controller.rb | 9 +++++++++ app/helpers/application_helper.rb | 9 +++++++++ app/views/admin/categories/_category.html.haml | 12 ++++++++---- config/locales/en.yml | 1 + config/locales/fr.yml | 1 + 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/categories_controller.rb b/app/controllers/admin/categories_controller.rb index 1e3ba2ed8..f704248c6 100644 --- a/app/controllers/admin/categories_controller.rb +++ b/app/controllers/admin/categories_controller.rb @@ -11,6 +11,15 @@ class Admin::CategoriesController < ApplicationController def index @categories = _categories + + @parents_list = Hash.new { |hash, key| hash[key] = [] } + @categories.each do |category| + category.parentCategory.each do |parent| + @parents_list[parent] << category.acronym + end + end + + end def new diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c41d1734f..6f66044aa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -451,4 +451,13 @@ def categories_select(id: nil, name: nil, selected: 'None') render Input::SelectComponent.new(id: id, name: name, value: categories_for_select, selected: selected, multiple: true) end + def category_is_parent?(parents_list, category) + is_parent = parents_list.keys.include?(category.id) + parent_error_message = t('admin.categories.category_used_parent') + parents_list[category.id].each do |c| + parent_error_message = "#{parent_error_message} #{c}" + end + [is_parent,parent_error_message] + end + end diff --git a/app/views/admin/categories/_category.html.haml b/app/views/admin/categories/_category.html.haml index 649149ed1..0e812309f 100644 --- a/app/views/admin/categories/_category.html.haml +++ b/app/views/admin/categories/_category.html.haml @@ -1,5 +1,6 @@ %tr.human{:id => category.id.split('/').last} - - count = category.ontologies&.size || 0 + - count = category.ontologies&.size || 0 + - is_parent, parent_error_message = category_is_parent?(@parents_list, category) %td %div{style: 'width: 250px'} %div.text-truncate{title: category.name} @@ -18,8 +19,11 @@ = link_to_modal(nil, edit_admin_category_path(category.id.split('/').last), data: {show_modal_title_value: category.name}) do = t('admin.categories.edit_button') %span - - if count.zero? - = button_to t('admin.categories.delete'), CGI.unescape(admin_category_path(category.id.split('/').last)), method: :delete, class: 'btn btn-link', form: {data: { turbo: true, turbo_confirm: t('admin.categories.turbo_confirm'), turbo_frame: '_top'}} - - else + - if !count.zero? %span{data: { controller: 'tooltip' }, title: t('admin.categories.info_error_delete')} = link_to t('admin.categories.delete'), "", class: 'btn btn-link disabled' + - elsif is_parent + %span{data: { controller: 'tooltip' }, title: parent_error_message} + = link_to t('admin.categories.delete'), "", class: 'btn btn-link disabled' + - else + = button_to t('admin.categories.delete'), CGI.unescape(admin_category_path(category.id.split('/').last)), method: :delete, class: 'btn btn-link', form: {data: { turbo: true, turbo_confirm: t('admin.categories.turbo_confirm'), turbo_frame: '_top'}} diff --git a/config/locales/en.yml b/config/locales/en.yml index 8bcd055c9..188ee057d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -193,6 +193,7 @@ en: problem_of_updating: Problem updating the category - %{message} category_deleted_successfully: Category successfully deleted in %{time}s problem_of_deleting: Problem deleting the category - %{message} + category_used_parent: "Can't delete category, used as a parent category for:" edit_button: "Edit" delete: Delete info_error_delete: Can't delete this category because still used diff --git a/config/locales/fr.yml b/config/locales/fr.yml index d471829cf..8f16f56b3 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -199,6 +199,7 @@ fr: problem_of_updating: Problème lors de la mise à jour de la catégorie - %{message} category_deleted_successfully: Catégorie supprimée avec succès en %{time}s problem_of_deleting: Problème lors de la suppression de la catégorie - %{message} + category_used_parent: "Impossible de supprimer la catégorie, utilisée comme catégorie parente pour:" edit_button: Éditer delete: Supprimer info_error_delete: Impossible de supprimer cette catégorie car elle est encore utilisée From 6fb4988ac947f5663d038941d0774d9d9c960c3b Mon Sep 17 00:00:00 2001 From: Syphax Date: Wed, 11 Dec 2024 04:09:32 +0100 Subject: [PATCH 6/6] update browse page categories_refresh_for_federation condition to work to reset to not federated mod --- app/controllers/ontologies_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/ontologies_controller.rb b/app/controllers/ontologies_controller.rb index 92a807fe7..f47a16500 100644 --- a/app/controllers/ontologies_controller.rb +++ b/app/controllers/ontologies_controller.rb @@ -60,18 +60,20 @@ def ontologies_filter end end.flatten - unless request_portals.length == 1 + if federated_request? streams += [ replace('categories_refresh_for_federation') do - key = "categories" + key = 'categories' objects, checked_values, _ = @filters[key.to_sym] objects = keep_only_root_categories(objects) + helpers.browse_filter_section_body(checked_values: checked_values, key: key, objects: objects, counts: @count_objects[key.to_sym]) end ] end + else streams = [replace("ontologies_list_view-page-#{@page.page}", partial: 'ontologies/browser/ontologies')] end