Skip to content

Commit

Permalink
Merge branch 'master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Nov 1, 2023
2 parents 8027115 + 3930a4a commit 1758941
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 81 deletions.
27 changes: 14 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/ontoportal-lirmm/ontologies_api_ruby_client.git
revision: f49cd49aee437c98221521f7763ecb8386855e17
revision: 169afb7c1002f9db2b3276af36d552575cc80ba2
branch: development
specs:
ontologies_api_client (2.2.0)
Expand Down Expand Up @@ -109,7 +109,7 @@ GEM
sassc-rails (>= 2.0.0)
brakeman (5.4.1)
builder (3.2.4)
capistrano (3.17.3)
capistrano (3.18.0)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
Expand Down Expand Up @@ -143,7 +143,7 @@ GEM
addressable
cube-ruby (0.0.3)
daemons (1.4.1)
dalli (3.2.5)
dalli (3.2.6)
date (3.3.3)
debug (1.8.0)
irb (>= 1.5.0)
Expand Down Expand Up @@ -175,7 +175,8 @@ GEM
flamegraph (0.9.5)
globalid (1.2.1)
activesupport (>= 6.1)
graphql (2.1.0)
graphql (2.1.3)
racc (~> 1.4)
graphql-client (0.18.0)
activesupport (>= 3.0)
graphql
Expand Down Expand Up @@ -215,7 +216,7 @@ GEM
activesupport (>= 3.0)
nokogiri (>= 1.6)
io-console (0.6.0)
irb (1.8.1)
irb (1.8.3)
rdoc
reline (>= 0.3.8)
iso-639 (0.3.6)
Expand All @@ -239,7 +240,7 @@ GEM
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.21.3)
loofah (2.21.4)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
lookbook (1.5.5)
Expand All @@ -266,7 +267,7 @@ GEM
method_source (1.0.0)
mime-types (3.5.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2023.0808)
mime-types-data (3.2023.1003)
mini_mime (1.1.5)
minitest (5.20.0)
msgpack (1.7.2)
Expand All @@ -279,7 +280,7 @@ GEM
time
net-http (0.3.2)
uri
net-imap (0.3.7)
net-imap (0.4.1)
date
net-protocol
net-pop (0.1.2)
Expand Down Expand Up @@ -333,7 +334,7 @@ GEM
omniauth (~> 2.0)
open_uri_redirections (0.2.1)
parallel (1.23.0)
parser (3.2.2.3)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
popper_js (1.16.1)
Expand Down Expand Up @@ -430,7 +431,7 @@ GEM
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
Expand Down Expand Up @@ -477,7 +478,7 @@ GEM
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
stackprof (0.2.25)
stimulus-rails (1.2.2)
stimulus-rails (1.3.0)
railties (>= 6.0.0)
temple (0.10.2)
terminal-table (3.0.2)
Expand All @@ -493,7 +494,7 @@ GEM
time (0.2.2)
date
timeout (0.4.0)
turbo-rails (1.4.0)
turbo-rails (1.5.0)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
Expand All @@ -507,7 +508,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (2.4.2)
unicode-display_width (2.5.0)
uri (0.12.2)
version_gem (1.1.3)
view_component (2.82.0)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concepts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def show
display = params[:callback].eql?('load') ? {full: true} : {display: "prefLabel"}
@concept = @ontology.explore.single_class(display, params[:id])
concept_not_found(params[:id]) if @concept.nil?
@schemes = params[:concept_schemes].split(',')
@schemes = params[:concept_schemes]&.split(',')
show_ajax_request # process an ajax call
else
# Get the latest 'ready' submission, or fallback to any latest submission
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def feedback
unless params[:question].nil? || params[:question].empty?
@tags << "Question"
end
unless params[:ontology_submissions_request].nil? || params[:bug].empty?
unless params[:ontology_submissions_request].nil? || params[:ontology_submissions_request].empty?
@tags << "Ontology submissions request"
end

Expand Down
58 changes: 24 additions & 34 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ def draw_note_tree_leaves(notes,level,output,key)
end
end

def draw_tree(root, id = nil, concept_schemes = [])
def draw_tree(root, acronym, id = nil, concept_schemes = nil)
id = root.children.first.id if id.nil?

# TODO: handle tree view for obsolete classes, e.g. 'http://purl.obolibrary.org/obo/GO_0030400'
raw build_tree(root, '', id, concept_schemes: concept_schemes)
raw build_tree(root, '', id, acronym, concept_schemes: concept_schemes)
end

def build_tree(node, string, id, concept_schemes: [])
def build_tree(node, string, id, acronym, concept_schemes: nil)

return string if node.children.nil? || node.children.empty?

Expand All @@ -203,16 +203,16 @@ def build_tree(node, string, id, concept_schemes: [])
# This fake root will be present at the root of "flat" ontologies, we need to keep the id intact

if child.id.eql?('bp_fake_root')
string << tree_link_to_concept(child: child, ontology_acronym: '',
active_style: active_style, node: node)
string << tree_link_to_concept(child: child, ontology_acronym: acronym,
active_style: active_style, node: node, skos: !concept_schemes.nil?)
else
string << tree_link_to_concept(child: child, ontology_acronym: child.explore.ontology.acronym,
active_style: active_style, node: node)
string << tree_link_to_concept(child: child, ontology_acronym: acronym,
active_style: active_style, node: node, skos: !concept_schemes.nil?)
if child.hasChildren && !child.expanded?
string << tree_link_to_children(child: child, concept_schemes: concept_schemes)
string << tree_link_to_children(child: child, acronym: acronym, concept_schemes: concept_schemes)
elsif child.expanded?
string << '<ul>'
build_tree(child, string, id, concept_schemes: concept_schemes)
build_tree(child, string, id, acronym, concept_schemes: concept_schemes)
string << '</ul>'
end
string << '</li>'
Expand All @@ -221,45 +221,35 @@ def build_tree(node, string, id, concept_schemes: [])
string
end

def tree_link_to_concept(child:, ontology_acronym:, active_style:, node: nil)
def tree_link_to_concept(child:, ontology_acronym:, active_style:, node: nil, skos: false)
language = request_lang
li_id = child.id.eql?('bp_fake_root') ? 'bp_fake_root' : short_uuid
open = child.expanded? ? "class='open'" : ''
icons = child.relation_icon(node)
muted_style = child.isInActiveScheme&.empty? ? 'text-muted' : ''
muted_style = skos && Array(child.isInActiveScheme).empty? ? 'text-muted' : nil
muted_title = muted_style && !child.obsolete? ? "title='is not in a scheme'" : nil
href = ontology_acronym.blank? ? '#' : "/ontologies/#{child.explore.ontology.acronym}/concepts/?id=#{CGI.escape(child.id)}&language=#{language}"

if child.prefLabel.nil?
prefLabelHTML = child.id.split('/').last
else
prefLabelLang, prefLabelHTML = select_language_label(child.prefLabel)
prefLabelLang = prefLabelLang.to_s.upcase
tooltip = prefLabelLang.eql?("@NONE") ? "" : "data-controller='tooltip' data-tooltip-position-value='right' title='#{prefLabelLang}'";
end

link = <<-EOS
<a id='#{child.id}'
data-conceptid='#{child.id}'
data-turbo=true data-turbo-frame='concept_show' href='#{href}'
data-collections-value='#{child.memberOf || []}'
data-active-collections-value='#{child.isInActiveCollection || []}'
data-skos-collection-colors-target='collection'
class='#{muted_style} #{active_style}'
#{tooltip}
>
#{ prefLabelHTML }
<a id='#{child.id}' data-conceptid='#{child.id}'
data-turbo=true data-turbo-frame='concept_show' href='#{href}'
data-collections-value='#{child.memberOf || []}'
data-active-collections-value='#{child.isInActiveCollection || []}'
data-skos-collection-colors-target='collection'
class='#{muted_style} #{active_style}' #{muted_title}>
#{child.prefLabel ? child.prefLabel({ use_html: true }) : child.id}
</a>
EOS

"<li #{open} id='#{li_id}'>#{link} #{icons}"
end

def tree_link_to_children(child:, concept_schemes: [])

def tree_link_to_children(child:, acronym: ,concept_schemes: nil)
language = request_lang
li_id = child.id.eql?('bp_fake_root') ? 'bp_fake_root' : short_uuid
concept_schemes = concept_schemes.map{|x| CGI.escape(x)}.join(',')
link = "<a id='#{child.id}' href='/ajax_concepts/#{child.explore.ontology.acronym}/?conceptid=#{CGI.escape(child.id)}&concept_schemes=#{concept_schemes}&callback=children&language=#{language}'>ajax_class</a>"
concept_schemes = "&concept_schemes=#{concept_schemes.map{|x| CGI.escape(x)}.join(',')}" if concept_schemes

link = "<a id='#{child.id}' href='/ajax_concepts/#{acronym}/?conceptid=#{CGI.escape(child.id)}#{concept_schemes}&callback=children&language=#{language}'>ajax_class</a>"
"<ul class='ajax'><li id='#{li_id}'>#{link}</li></ul>"
end

Expand Down
31 changes: 16 additions & 15 deletions app/services/issue_creator_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
class IssueCreatorService < ApplicationService
class QueryError < StandardError; end


def initialize(params)
@title = params[:content][:title]
@body = params[:content][:body]
@repo = Rails.configuration.change_request.dig(:ontologies, params[:ont_acronym].to_sym, :repository)
end

def call

findRepoQuery = GitHub::Client.parse <<-'GRAPHQL'
query ($owner: String!, $name: String!) {
repository(owner: $owner, name: $name) {
Expand All @@ -19,23 +21,22 @@ def call
GRAPHQL

createIssueMutation = GitHub::Client.parse <<-'GRAPHQL'
mutation ($repositoryId: ID!, $title: String!, $body: String) {
createIssue(input: {repositoryId: $repositoryId, title: $title, body: $body}) {
issue {
bodyText,
createdAt,
id,
number,
repository {
nameWithOwner
},
title,
url
}
mutation ($repositoryId: ID!, $title: String!, $body: String) {
createIssue(input: {repositoryId: $repositoryId, title: $title, body: $body}) {
issue {
bodyText,
createdAt,
id,
number,
repository {
nameWithOwner
},
title,
url
}
}
GRAPHQL

}
GRAPHQL
data = query(findRepoQuery, variables: { owner: repo_owner, name: repo_name })
data = query(createIssueMutation, variables: { repositoryId: data.repository.id, title: @title, body: @body })
data.to_h.dig('createIssue', 'issue')
Expand Down
4 changes: 2 additions & 2 deletions app/views/concepts/_child_nodes.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- output =""
- for child in @children
- output << tree_link_to_concept(child: child, ontology_acronym: child.explore.ontology.acronym, active_style: '', node: @concept)
- output << tree_link_to_concept(child: child, ontology_acronym: @ontology.acronym, active_style: '', node: @concept, skos: [email protected]?)
- if child.hasChildren
- output << tree_link_to_children(child: child, concept_schemes: @schemes)
- output << tree_link_to_children(child: child, acronym: @ontology.acronym, concept_schemes: @schemes)
- output << "</li>"
= raw output
2 changes: 1 addition & 1 deletion app/views/ontologies/_treeview.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
action: 'clicked->history#updateURL'}}
%li.root
%ul
= draw_tree(@root, @concept.id, (params[:concept_schemes] || '').split(','))
= draw_tree(@root, params[:ontology], @concept.id, params[:concept_schemes]&.split(','))


14 changes: 10 additions & 4 deletions app/views/ontologies/concepts_browsers/_concepts_tree.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
data: {action: 'changed->skos-collection-colors#updateCollectionTags' ,
'chosen-enable-colors-value': 'true'}}
-# Class tree
%div#sd_content.py-3{style: 'overflow-y: scroll; height: 60vh;'}
= render TurboFrameComponent.new(id: 'concepts_tree_view',
src: "/ajax/classes/treeview?ontology=#{@ontology.acronym}&conceptid=#{escape(@concept.id)}&concept_schemes=#{params[:concept_schemes]}&auto_click=false&language=#{request_lang}",
data: {'turbo-frame-target': 'frame'})
%div#sd_content.card.p-1.py-3{style: 'overflow-y: scroll; height: 60vh;'}
- if skos? && @roots&.empty?
%div.text-wrap
= render AlertMessageComponent.new do
Missing roots for #{@ontology.acronym} (skos:topConceptOf)
- else
- concept_schemes = skos? ? "&concept_schemes=#{params[:concept_schemes]}" : ''
= render TurboFrameComponent.new(id: 'concepts_tree_view',
src: "/ajax/classes/treeview?ontology=#{@ontology.acronym}&conceptid=#{escape(@concept.id)}#{concept_schemes}&auto_click=false",
data: {'turbo-frame-target': 'frame'})
14 changes: 4 additions & 10 deletions vendor/assets/javascripts/jquery.simple.tree.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,8 @@ $.fn.simpleTree = function(opt){
.bind('selectstart', function() {
return false;
}).click(function(){
$('.active',TREE).attr('class','text');
if(this.className=='text')
{
this.className='active';
}
$('.active',TREE).removeClass('active');
this.classList.add('active');
if(typeof TREE.option.afterClick == 'function')
{
TREE.option.afterClick($(this).parent());
Expand All @@ -177,11 +174,8 @@ $.fn.simpleTree = function(opt){
// added by Erik Dohmen (2BinBusiness.nl) to make context menu actions
// available
}).bind("contextmenu",function(){
$('.active',TREE).attr('class','text');
if(this.className=='text')
{
this.className='active';
}
$('.active',TREE).removeClass('active');
this.classList.add('active');
if(typeof TREE.option.afterContextMenu == 'function')
{
TREE.option.afterContextMenu($(this).parent());
Expand Down

0 comments on commit 1758941

Please sign in to comment.