Skip to content

Commit

Permalink
Merge branch 'master' into feature/ecoportal/aling-to-agroportal-3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Dec 12, 2024
2 parents 5e1c0c8 + 80fc27d commit ae57555
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 8 deletions.
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
6 changes: 4 additions & 2 deletions app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -454,5 +454,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
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'}}
2 changes: 1 addition & 1 deletion app/views/home/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,4 @@
}
function submitRecommender(){
document.getElementById("recommender_submit").click()
}
}
2 changes: 1 addition & 1 deletion app/views/visits/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
%tbody
- count = 0
- @analytics.onts.each do |visits|
- ont = @ontologies_hash[visits[:ont].to_s]
- ont = @ontologies_hash[visits[:ont].to_s.split('/').last]
- next if ont.nil?
- count += 1
%tr
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 @@ -194,6 +194,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 @@ -200,6 +200,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

0 comments on commit ae57555

Please sign in to comment.