Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge to master: Release 3.0.2 - Fix some bugs related to the federation release #887

Merged
merged 6 commits into from
Dec 12, 2024
Merged
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ API_KEY=

UI_THEME=ontoportal

TWITTER_NEWS=

BIOMIXER_URL=
BIOMIXER_APIKEY=

Expand Down
9 changes: 9 additions & 0 deletions app/controllers/admin/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,20 @@ def ontologies_filter
end
end.flatten

unless request_portals.empty?
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
Expand Down Expand Up @@ -583,4 +586,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
9 changes: 9 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/helpers/fair_score_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/instances_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 8 additions & 4 deletions app/views/admin/categories/_category.html.haml
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -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'}}
18 changes: 9 additions & 9 deletions app/views/home/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions config/bioportal_config_env.rb.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading