Skip to content

Commit

Permalink
Merge branch 'development' into feature/federate-search-page
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni authored Oct 4, 2024
2 parents 3d2a63c + 5ade600 commit 22eeca9
Show file tree
Hide file tree
Showing 28 changed files with 173 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
.description
= render TextAreaFieldComponent.new(value: @taxonomy.description)
.ontologies-cards
- @taxonomy.ontologies.each do |ontology|
- @taxonomy.ontologies.each_with_index do |ontology, index|
- if index>10
= render ChipButtonComponent.new(url: "/ontologies?#{@taxonomy.id.split('/')[-2]}=#{@taxonomy.acronym}", text: "...", tooltip:"See all ontologies ...", type: "clickable")
- break
= render ChipButtonComponent.new(url: "/ontologies/#{ontology.split('/').last}", text: ontology.split('/').last, tooltip: @ontologies_names[ontology], type: "clickable")

- if @taxonomy.children
.taxonomy-children-reveal{'data-action': "click->reveal-component#toggle", 'data-id': reveal_id}
.text
Expand Down
8 changes: 2 additions & 6 deletions app/components/tab_item_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@ def page_name
end

def call
if title && !title.empty?
link_to(title, @path, id: "#{item_id}_tab", class: "#{active_class} tab-link", 'data-json-link': @json_link)
else
link_to(@path, id: "#{item_id}_tab", class: "#{active_class} tab-link", 'data-json-link': @json_link) do
content
end
link_to(@path, id: "#{item_id}_tab", class: "#{active_class} tab-link", 'data-json-link': @json_link) do
(title && !title.empty?) ? title.html_safe : content
end
end

Expand Down
5 changes: 4 additions & 1 deletion app/controllers/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ def index
end

def show
redirect_to(ontology_path(id: params[:ontology_id], p: 'collections', collectionid: params[:id], lang: request_lang)) and return unless turbo_frame_request?

redirect_to(ontology_path(id: params[:ontology], p: 'collections', collectionid: params[:id], lang: request_lang)) and return unless turbo_frame_request?

@collection = get_request_collection

render partial: "collections/show"
end

def show_label
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/instances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def show

redirect_to(ontology_path(id: params[:ontology], p: 'instances', instanceid: params[:id] || params[:instanceid], lang: request_lang)) and return unless turbo_frame_request?

render partial: 'instances/details', layout: nil
render partial: 'show'
end

private
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ def instances
def schemes
@schemes = get_schemes(@ontology)
scheme_id = params[:schemeid] || @submission_latest.URI || nil
@scheme = get_scheme(@ontology, scheme_id) if scheme_id
@scheme = scheme_id ? get_scheme(@ontology, scheme_id) : @schemes.first


render partial: 'ontologies/sections/schemes', layout: 'ontology_viewer'
end
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/schemes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ def index
end

def show
redirect_to(ontology_path(id: params[:ontology_id], p: 'schemes', schemeid: params[:id],lang: request_lang)) and return unless turbo_frame_request?
redirect_to(ontology_path(id: params[:ontology], p: 'schemes', schemeid: params[:id],lang: request_lang)) and return unless turbo_frame_request?

@scheme = get_request_scheme

render partial: "schemes/show"
end

def show_label
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/collections_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module CollectionsHelper
def get_collections(ontology, add_colors: false)
collections = ontology.explore.collections(language: request_lang)
generate_collections_colors(collections) if add_colors
collections
collections.sort_by{ |x| x.prefLabel }
end

def get_collection(ontology, collection_uri)
Expand Down
11 changes: 10 additions & 1 deletion app/helpers/components_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
module ComponentsHelper
include TermsReuses

def chips_component(id: , name: , label: , value: , checked: false , tooltip: nil, disabled: false, &block)
def tab_item_component(container_tabs:, title:, path:, selected: false, json_link: "", &content)
container_tabs.item(title: title.html_safe, path: path, selected: selected, json_link: json_link)
container_tabs.item_content { capture(&content) }
end

def alert_component(message, type: "info")
render Display::AlertComponent.new(type: type, message: message)
end

def chips_component(id: , name: , label: , value: , checked: false , tooltip: nil, disabled: false, &block)
content_tag(:div, data: { controller: 'tooltip' }, title: tooltip) do
check_input(id: id, name: name, value: value, label: label, checked: checked, disabled: disabled, &block)
end
Expand Down
45 changes: 45 additions & 0 deletions app/helpers/ontologies_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,51 @@ def language_selector_hidden_tag(section)
data: { controller: "language-change", 'language-change-section-value': section, action: "change->language-change#dispatchLangChangeEvent" }
end

def ontology_object_json_link(ontology_acronym, object_type, id)
"#{rest_url}/ontologies/#{ontology_acronym}/#{object_type}/#{escape(id)}?display=all&apikey=#{get_apikey}"
end

def render_permalink_link
content_tag(:div, class: 'mx-1') do
link_to("#classPermalinkModal", class: "class-permalink nav-link", title: t('concepts.permanent_link_class'), aria: { label: t('concepts.permanent_link_class') }, data: { toggle: "modal", current_purl: @current_purl }) do
content_tag(:i, '', class: "fas fa-link", aria: { hidden: "true" })
end
end
end

def render_concepts_json_button(link)
content_tag(:div, class: 'concepts_json_button') do
render RoundedButtonComponent.new(link: link, target: '_blank')
end
end


def ontology_object_details_component(frame_id: , ontology_id:, objects_title:, object:, &block)
render TurboFrameComponent.new(id: frame_id, data: {"turbo-frame-target": "frame"}) do
return if !object.present?
return alert_component(object.errors.join) if object.errors

ontology_object_tabs_component(ontology_id: ontology_id, objects_title: objects_title, object_id: object["@id"]) do |tabs|
tab_item_component(container_tabs: tabs, title: t('concepts.details'), path: '#details', selected: true) do
capture(&block)
end
end
end
end

def ontology_object_tabs_component(ontology_id:, objects_title:, object_id:, &block)
resource_url = ontology_object_json_link(ontology_id, objects_title, object_id)
render TabsContainerComponent.new(type: 'outline') do |c|
concat(c.pinned_right do
content_tag(:div, '', 'data-concepts-json-target': 'button') do
concat(render_permalink_link) if $PURL_ENABLED
concat(render_concepts_json_button(resource_url))
end
end)

capture(c, &block)
end
end


def display_complex_text(definitions)
Expand Down
2 changes: 1 addition & 1 deletion app/views/annotator/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
= render(ChipsComponent.new(name: 'exclude_synonyms', label: t('annotator.exclude_synonyms'), checked: params[:exclude_synonyms]))

.select-ontologies
= ontologies_selector(id:'annotator_page_ontologies', label: 'Select ontologies' ,name: 'ontologies[]', selected: params[:ontologies]&.split(','))
= ontologies_selector(id:'annotator_page_ontologies', label: t('annotator.select_ontologies') ,name: 'ontologies[]', selected: params[:ontologies]&.split(','))
= show_advanced_options_button(text: t('show_advanced_options'), init: @advanced_options_open)
= hide_advanced_options_button(text: t('hide_advanced_options'), init: @advanced_options_open)
.more-advanced-options{'data-reveal-component-target': 'item', class: "#{@advanced_options_open ? '' : 'd-none'}"}
Expand Down
13 changes: 0 additions & 13 deletions app/views/collections/_collection.html.haml

This file was deleted.

14 changes: 14 additions & 0 deletions app/views/collections/_show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
= ontology_object_details_component(frame_id: "collection", ontology_id: @ontology.acronym, objects_title: "collections", object: @collection) do
= render ConceptDetailsComponent.new(id:'collection-label', acronym: @ontology.acronym, concept_id: @collection.id,
properties: @collection.properties,
top_keys: %w[created modified comment note],
bottom_keys: [],
exclude_keys: %w[member]) do |c|
- c.header(stripped: true) do |t|
- t.add_row({th: t("collections.id")}, {td: link_to_with_actions(@collection["@id"], acronym: @ontology.acronym)})
- t.add_row({th: t("collections.preferred_name")}, {td: display_in_multiple_languages(get_collection_label(@collection))})
- t.add_row({th: t("collections.members_count")}) do |r|
- r.td do
= link_to @collection["memberCount"], "/ontologies/" + @ontology.acronym + "/?p=classes&sub_menu=list&concept_collections=" + @collection["@id"], 'data-turbo-frame':'_top'
- t.add_row({th: t("collections.type")}, {td: @collection["@type"]})

1 change: 0 additions & 1 deletion app/views/collections/show.html.haml

This file was deleted.

57 changes: 13 additions & 44 deletions app/views/concepts/_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,32 @@
= t('concepts.use_jump_to')
- else
%div{'data-controller': 'concepts-json', 'data-action': 'click->concepts-json#update'}
= render TabsContainerComponent.new(type:'outline') do |c|
- c.pinned_right do
- if $PURL_ENABLED
%div.mx-1
= link_to("#classPermalinkModal", class: "class-permalink nav-link", title: t('concepts.permanent_link_class'), aria: {label: t('concepts.permanent_link_class')}, data: {toggle: "modal", current_purl: "#{@current_purl}"}) do
%i{class: "fas fa-link", aria: {hidden: "true"}}
%div{'data-concepts-json-target': 'button'}
.concepts_json_button
= render RoundedButtonComponent.new(link: "#{@ontology.id}/classes/#{escape(@concept.id)}?display=all&apikey=#{get_apikey}", target:'_blank')
= ontology_object_tabs_component(ontology_id: @ontology.acronym, objects_title: "classes", object_id: @concept.id) do |c|
- apikey = "apikey=#{get_apikey}"
- baseClassUrl = "#{@ontology.id}/classes/#{escape(@concept.id)}"
- c.item(title: t('concepts.details'), path: '#details', selected: true, json_link: "#{baseClassUrl}?#{apikey}&display=all")

- unless skos?
- c.item(id: 'instances', path: '#instances', json_link: "#{baseClassUrl}/instances?#{apikey}") do
= t('concepts.instances')
(
%span#concept_instances_sorted_list_count
)

- c.item(title: t('concepts.visualization'), path: '#visualization')

- c.item(id: 'notes', path: '#notes', json_link: "#{baseClassUrl}/notes?#{apikey}") do
= t('concepts.notes')
%span#note_count_wrapper
(
%span#note_count= @notes.length
)
- c.item(id: 'mappings', path: '#mappings', json_link: "#{baseClassUrl}/mappings?#{apikey}") do
.d-flex
#{t('concepts.mappings')}
(
= concept_mappings_loader(ontology_acronym: @ontology.acronym, concept_id: @concept.id)
)

- if @enable_ontolobridge
- c.item(title: t('concepts.new_term_requests'), path: '#request_term')

- c.item_content do
- tab_item_component(container_tabs: c, title: t('concepts.details'), path: '#details', selected: true, json_link: "#{baseClassUrl}?#{apikey}&display=all") do
= render :partial =>'/concepts/details'

- unless skos?
- c.item_content do
- count_span = content_tag(:span, "#{t('concepts.instances')} (#{content_tag(:span, "", id: 'concept_instances_sorted_list_count')})".html_safe)
- tab_item_component(container_tabs: c, title: count_span, path: '#instances', json_link: "#{baseClassUrl}/instances?#{apikey}") do
= render :partial =>'instances/instances' , locals: {id: "class-instances-data-table"}
- c.item_content do


- tab_item_component(container_tabs: c, title: t('concepts.visualization'), path: '#visualization') do
= render :partial =>'/concepts/biomixer'

- c.item_content do

- count_span = content_tag(:span, "#{t('concepts.notes')} (#{content_tag(:span, @notes.length, id: 'note_count')})".html_safe)
- tab_item_component(container_tabs: c, title: count_span, path: '#notes', json_link: "#{baseClassUrl}/notes?#{apikey}") do
= render :partial =>'/notes/list'

- c.item_content do

- count_span = content_tag(:span, "#{t('concepts.mappings')} (#{content_tag(:span, concept_mappings_loader(ontology_acronym: @ontology.acronym, concept_id: @concept.id))})".html_safe, class: "d-flex")
- tab_item_component(container_tabs: c, title: count_span, path: '#mappings', json_link: "#{baseClassUrl}/mappings?#{apikey}") do
= render TurboFrameComponent.new(id:'concept_mappings',
src:"/ajax/mappings/get_concept_table?ontologyid=#{@ontology.acronym}&conceptid=#{CGI.escape(@concept.id)}")

- if @enable_ontolobridge
- c.item_content do
= render :partial =>'/concepts/request_term'

:javascript
jQuery(document).ready(function(){
Expand Down
2 changes: 1 addition & 1 deletion app/views/home/cookies.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
%div
= link_button_component(id:'accept-cookie-selector', value: t('cookies_modal.accept_button'), href: cookies_path(cookies: true), size: "slim", variant: 'primary')
%div.cookie-privacy-link
= link_to t('cookies_modal.privacy_link'), $FOOTER_LINKS.dig(:sections, :agreements, :privacy_policy)
= link_to t('cookies_modal.privacy_link'), "#{$FOOTER_LINKS.dig(:sections, :agreements, :privacy_policy)}#{t('cookies_modal.privacy_policy_anchor')}"
27 changes: 0 additions & 27 deletions app/views/instances/_details.html.haml

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/instances/_instances.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

- if params[:p].eql?('instances')
%div#prop_contents{data: {'container-splitter-target': 'container'}}
= render partial: 'instances/details'
= render partial: 'instances/show'



22 changes: 22 additions & 0 deletions app/views/instances/_show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
= ontology_object_details_component(frame_id: params['modal'].eql?('true') ? modal_frame_id : "instance_show", ontology_id: @ontology.acronym, objects_title: "instances", object: @instance) do
= render ConceptDetailsComponent.new(id: 'instance-details', acronym: @ontology.acronym, concept_id: @instance["@id"]) do |c|
- c.header(stripped: true) do |t|
- t.add_row({ th: t("instances.id") }, { td: link_to_with_actions(@instance["@id"], acronym: @ontology.acronym) })

- label = @instance['label'] || @instance['prefLabel']
- t.add_row({ th: t('instances.label') }, { td: label.join(', ').html_safe }) unless label.blank?

- types = @instance.types.reject { |x| x['NamedIndividual'] }
- unless types.empty?
- t.add_row({ th: t('instances.type') }) do |r|
- r.td do
= types.map { |cls| link_to_class(@ontology.acronym, cls) }.join(', ').html_safe

- filter_properties = %w[http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/2000/01/rdf-schema#label http://www.w3.org/2004/02/skos/core#prefLabel]
- properties = @instance[:properties].to_h.reject { |k, _| filter_properties.include?(k.to_s) }
- properties.each do |prop, values|
- if values.present?
- t.add_row({ th: link_to_property(prop, @ontology.acronym) }, { td: values.map { |value| instance_property_value(value, @ontology.acronym) }.join(', ').html_safe })



4 changes: 3 additions & 1 deletion app/views/layouts/_footer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
%h2
= t("layout.footer."+key.to_s)
%div

- section_links.each do |section , link|
%a{:href => link, :target => "_blank"}
- anchor = I18n.t("layout.footer.#{section}_anchor", default: "")
%a{:href => "#{link}#{anchor}", :target => "_blank"}
= t("layout.footer."+section.to_s)


Expand Down
18 changes: 8 additions & 10 deletions app/views/ontologies/sections/_collections.html.haml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
= render TurboFrameComponent.new(id: "collections", data: {"turbo-frame-target": "frame"} ) do
- if no_collections?
= no_collections_alert
- else
%div.ont-collections{data:{controller: 'container-splitter'}}
%div#collectionsTree.card.sidebar{data:{'container-splitter-target': 'container'}}
%div.ont-collections{data:{controller: 'container-splitter'}}
%div#collectionsTree.card.sidebar{data:{'container-splitter-target': 'container'}}
- if no_collections?
= no_collections_alert
- else
= tree_container_component(id: "collections_sorted_list_view-page-1",
placeholder: t('ontologies.sections.collections_search_placeholder', acronym: @ontology.acronym),
frame_url: "/ontologies/#{@ontology.acronym}/collections",
tree_url: "/ontologies/#{@ontology.acronym}/collections?#{request.original_url.split('?')[1]}")

%div#collection_contents{data:{'container-splitter-target': 'container'}}
= render TurboFrameComponent.new(id: 'collection') do
- if @collection
= render partial: 'collections/collection', locals: {collection: @collection}
%div#collection_contents{data:{'container-splitter-target': 'container'}}
= render TurboFrameComponent.new(id: 'collection') do
= render partial: 'collections/show'


2 changes: 1 addition & 1 deletion app/views/ontologies/sections/_schemes.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

%div#scheme_contents{data:{'container-splitter-target': 'container'}}
= render TurboFrameComponent.new(id:'scheme') do
= render partial: 'schemes/scheme', locals: {scheme: @scheme}
= render partial: 'schemes/show'



Loading

0 comments on commit 22eeca9

Please sign in to comment.