Skip to content

Commit

Permalink
Merge branch 'development' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
SirineMhedhbi committed Nov 17, 2023
2 parents 2a14d85 + deaf94f commit 676d206
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 102 deletions.
6 changes: 3 additions & 3 deletions app/components/concept_details_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ def row_hash_properties(properties_set, ontology_acronym, &block)
display_in_multiple_languages([v].to_h)
end
end
end
end if values.is_a?(Array)

out << [
{ th: "<span title=#{url} data-controller='tooltip'>#{remove_owl_notation(key)}</span>".html_safe },
{ td: "<div class='d-flex flex-wrap'> #{"<p class='mx-1'>#{ajax_links.join('</p><p class="mx-1">')}"}</div>".html_safe }
{ td: "<div class='d-flex flex-wrap'> #{"<p class='mx-1'>#{ajax_links&.join('</p><p class="mx-1">')}"}</div>".html_safe }
]
end
out
Expand Down Expand Up @@ -153,7 +153,7 @@ def exclude_relation?(relation_to_check, ontology = nil)
end

excluded_relations.each do |relation|
return true if relation_to_check.include?(relation)
return true if relation_to_check.is_a?(Array) && relation_to_check.include?(relation)
end
return false
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
= header
%div.my-3
%div.raw-table
= render DropdownContainerComponent.new(title: 'Raw data', id: "accordion-#{@id}") do
- top_set, leftover_set, bottom_set = filter_properties(@top_keys, @bottom_keys, @exclude_keys, @concept_properties)
= render TableComponent.new(stripped: true) do |t|
- if @bottom_keys.present?
= render DropdownContainerComponent.new(title: 'Raw data', id: "accordion-#{@id}") do
- top_set, leftover_set, bottom_set = filter_properties(@top_keys, @bottom_keys, @exclude_keys, @concept_properties)
= render TableComponent.new(stripped: true) do |t|

- row_hash_properties(top_set, @acronym).each do |row|
- t.add_row(*row)
- row_hash_properties(top_set, @acronym).each do |row|
- t.add_row(*row)

- row_hash_properties(leftover_set, @acronym).each do |row|
- t.add_row(*row)
- row_hash_properties(leftover_set, @acronym).each do |row|
- t.add_row(*row)


- sections.each do |section|
- t.row do
= section
- sections.each do |section|
- t.row do
= section


- row_hash_properties(bottom_set, @acronym).each do |row|
- t.add_row(*row)
- row_hash_properties(bottom_set, @acronym).each do |row|
- t.add_row(*row)
1 change: 1 addition & 0 deletions app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def classes
end

def properties
@acronym = @ontology.acronym
if request.xhr?
return render 'ontologies/sections/properties', layout: false
else
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/properties_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class PropertiesController < ApplicationController
def show
@property = LinkedData::Client::HTTP.get("/ontologies/#{params[:acronym]}/properties/#{helpers.encode_param(params[:id])}")

@acronym = params[:acronym]
render partial: 'show'
end
end
1 change: 0 additions & 1 deletion app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

<!-- JavaScript -->
<%= javascript_include_tag "vendor" %>
<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.min.js" %>
<%= javascript_include_tag "//ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js" %>

<script>
Expand Down
1 change: 0 additions & 1 deletion app/views/layouts/appliance.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
= stylesheet_link_tag "application", media: "all"

= javascript_include_tag "vendor"
= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.min.js"
= javascript_include_tag "//ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"

%script
Expand Down
1 change: 0 additions & 1 deletion app/views/layouts/popup.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<%= stylesheet_link_tag "https://use.fontawesome.com/releases/v5.2.0/css/all.css", integrity: "sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ", crossorigin: "anonymous" %>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "vendor" %>
<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.min.js" %>
<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1/Chart.min.js" %>
<%= javascript_include_tag "//ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js" %>
<script>
Expand Down
92 changes: 8 additions & 84 deletions app/views/ontologies/sections/properties.html.haml
Original file line number Diff line number Diff line change
@@ -1,84 +1,8 @@
= turbo_frame_tag 'properties' do
%div.ont-properties{data:{controller: 'container-splitter'}}
%div#propTree{data:{'container-splitter-target': 'container'}}
%div#prop_contents.pl-3{data:{'container-splitter-target': 'container'}}

:plain
<script id="property-details" type="text/x-handlebars-template">
<table cellpadding="0" cellspacing="0" class="minimal concept_details" width="100%">
{{#if label}}
<tr>
<td class="label">
Labels
</td>
<td>
<p>
{{label}}&nbsp;
</p>
</td>
</tr>
{{/if}}
{{#if definition}}
<tr>
<td class="label">
Definitions
</td>
<td>
<p>
{{definition}}&nbsp;
</p>
</td>
</tr>
{{/if}}
<tr>
<td class="label">ID</td>
<td>
<p>
{{id}}&nbsp;
</p>
</td>
</tr>
{{#if parents}}
<tr>
<td class="label">Parent</td>
<td>
<p>
{{parents}}&nbsp;
</p>
</td>
</tr>
{{/if}}
</table>
</script>

:javascript
$(document).ready(function(){
jQuery(document).data().bp.ontPropertiesTab = {};

jQuery(document).data().bp.ontPropertiesTab.init = function() {
var source = jQuery("#property-details").html();
var propDetailsTemp = Handlebars.compile(source);

$("#propTree").NCBOPropertyTree({
ontology: "#{@ontology.acronym}",
ncboUIURL: jQuery(document).data().bp.config.ui_url,
width: "100%",
onInit: function() {
var ontPropTree = $("#propTree").data().NCBOPropertyTree;
var data = $("#propTree").find("a:first").data();
if (data) {
ontPropTree.selectClass(data.id);
data.id = decodeURIComponent(data.id);
jQuery("#prop_contents").html(propDetailsTemp(data));
}
}
}).on("afterSelect", function (e, classId, label, node) {
var data = node.data();
data.id = decodeURIComponent(data.id);
jQuery("#prop_contents").html(propDetailsTemp(data));
});
}

jQuery(document).data().bp.ontPropertiesTab.init();

})
= render TurboFrameComponent.new(id: "properties", data: {"turbo-frame-target": "frame"} ) do
%div.ont-properties{data: {controller: 'container-splitter turbo-frame', 'turbo-frame': {
'url-value': "/ontologies/#{@ontology.acronym}/properties/show"
}}}
%div#propTree{data: {'container-splitter-target': 'container', action: 'change->turbo-frame#updateFrame'}}
= render partial: 'properties/properties_tree'
%div#prop_contents.pl-3{data: {'container-splitter-target': 'container'}}
= render partial: 'properties/show'
25 changes: 25 additions & 0 deletions app/views/properties/_properties_tree.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
%div#propTree

:javascript
// TODO migrate this backend rendered component
$(document).ready(() => {
$('#propTree').NCBOPropertyTree({
ontology: '#{@ontology.acronym}',
ncboUIURL: '',
width: '100%',
onInit: function () {
let activeElem = $('#propTree a')[0]
if (activeElem) {
activeElem.click()
}
}
}).on('afterSelect', function (e, classId, label, node) {
e.target.dispatchEvent(new CustomEvent('change', {
bubbles: true,
detail: {
data: {id: decodeURIComponent(node.data().id)}
}
}))
})
})

14 changes: 14 additions & 0 deletions app/views/properties/_show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
= render TurboFrameComponent.new(id: 'property', data: {"turbo-frame-target": "frame"}) do
- if !@property
= render LoaderComponent.new
- else
= render ConceptDetailsComponent.new(id:'property-details', acronym: @acronym,
properties: OpenStruct.new(LinkedData::Client::Models::Property.properties_to_hash(@property).first),
top_keys: [],
bottom_keys: [],
exclude_keys: []) do |c|
- c.header(stripped: true) do |t|
- t.add_row({th: 'ID'}, {td: c.concept_properties[:id][:values]}) if c.concept_properties[:id][:values].present?
- t.add_row({th: 'Labels'}, {td: c.concept_properties[:prefLabel][:values]}) if c.concept_properties[:prefLabel][:values].present?
- t.add_row({th: 'Definitions'}, {td: c.concept_properties[:definition][:values]}) if c.concept_properties[:definition][:values].present?
- t.add_row({th: 'Parent'}, {td: c.concept_properties[:parents][:values]}) if c.concept_properties[:parents][:values].present?
1 change: 1 addition & 0 deletions config/bioportal_config_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

$SITE = 'Testportal'
$HOSTNAME = 'testportal'
$UI_HOSTNAME = 'localhost'
$UI_URL = "http://#{$UI_HOSTNAME}:3000"

Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@
match '/ontologies/:acronym/submissions/:id/edit_metadata' => 'submissions#edit_metadata', via: [:get, :post]
get '/ontologies_filter', to: 'ontologies#ontologies_filter'

get '/ontologies/:acronym/properties/show', to: 'properties#show'

# Analytics
get '/analytics/:action' => 'analytics#(?-mix:search_result_clicked|user_intention_surveys)'

Expand Down

0 comments on commit 676d206

Please sign in to comment.