diff --git a/Gemfile.lock b/Gemfile.lock
index 3bb8c68812..73328d8412 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -160,7 +160,7 @@ GEM
ed25519 (1.3.0)
erubi (1.13.0)
erubis (2.7.0)
- excon (1.0.0)
+ excon (0.112.0)
execjs (2.10.0)
faraday (2.0.1)
faraday-net_http (~> 2.0)
diff --git a/app/assets/stylesheets/mappings.scss b/app/assets/stylesheets/mappings.scss
index 89a7ebffbe..dea483b61b 100644
--- a/app/assets/stylesheets/mappings.scss
+++ b/app/assets/stylesheets/mappings.scss
@@ -320,6 +320,28 @@ div#map_from_concept_details_table, div#map_to_concept_details_table {
#concept_mappings_table {
width: 100%;
+ word-break: break-word;
+ font-size: 13px;
+}
+.mappings-table-mapping-to{
+ width: 45%;
+}
+.mappings-table-mapping-to .chip-button-component-container{
+ text-wrap: wrap !important;
+}
+.mappings-table-mapping-to a{
+ background-color: unset;
+ line-height: unset;
+ padding: unset;
+ font-weight: unset;
+ font-size: unset;
+}
+.mappings-table-icon{
+ width: 18px;
+ height: 18px;
+}
+.mappings-table-icon path{
+ fill: var(--gray-color);
}
.summary-mappings-tab-table {
@@ -341,4 +363,4 @@ div#map_from_concept_details_table, div#map_to_concept_details_table {
padding: 10px;
outline: none;
margin-left: 0 !important;
-}
\ No newline at end of file
+}
diff --git a/app/controllers/mappings_controller.rb b/app/controllers/mappings_controller.rb
index b1bcfc8c32..df582acb4e 100644
--- a/app/controllers/mappings_controller.rb
+++ b/app/controllers/mappings_controller.rb
@@ -342,4 +342,56 @@ def valid_values?(values)
end
errors
end
-end
\ No newline at end of file
+
+ def set_mapping_target(concept_to_id:, ontology_to:, mapping_type: )
+ case mapping_type
+ when 'interportal'
+ @map_to_interportal, @map_to_interportal_ontology = ontology_to.match(%r{(.*)/ontologies/(.*)}).to_a[1..]
+ @map_to_interportal_class = concept_to_id
+ when 'external'
+ @map_to_external_ontology = ontology_to
+ @map_to_external_class = concept_to_id
+ else
+ @map_to_bioportal_ontology_id = ontology_to
+ @map_to_bioportal_full_id = concept_to_id
+ end
+ end
+
+ def get_mappings_target_params
+ mapping_type = Array(params[:mapping_type]).first
+ external = true
+ case mapping_type
+ when 'interportal'
+ ontology_to = "#{params[:map_to_interportal]}/ontologies/#{params[:map_to_interportal_ontology]}"
+ concept_to_id = params[:map_to_interportal_class]
+ when 'external'
+ ontology_to = params[:map_to_external_ontology]
+ concept_to_id = params[:map_to_external_class]
+ else
+ ontology_to = params[:map_to_bioportal_ontology_id]
+ concept_to_id = params[:map_to_bioportal_full_id]
+ external = false
+ end
+ [ontology_to, concept_to_id, external]
+ end
+
+ def get_mappings_target
+ ontology_to, concept_to_id, external_mapping = get_mappings_target_params
+ target = ''
+ if external_mapping
+ target_ontology = ontology_to
+ target = concept_to_id
+ else
+ if helpers.link?(ontology_to)
+ target_ontology = LinkedData::Client::Models::Ontology.find(ontology_to)
+ else
+ target_ontology = LinkedData::Client::Models::Ontology.find_by_acronym(ontology_to).first
+ end
+ if target_ontology
+ target = target_ontology.explore.single_class(concept_to_id).id
+ target_ontology = target_ontology.id
+ end
+ end
+ [target_ontology, target, external_mapping]
+ end
+end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 490072b4bd..5816730466 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -26,13 +26,13 @@ def show
redirect_to projects_path
return
end
-
+
@project = projects.first
@ontologies_used = []
onts_used = @project.ontologyUsed
onts_used.each do |ont_used|
ont = LinkedData::Client::Models::Ontology.find(ont_used)
- unless ont.nil?
+ unless ont.nil? || ont.errors
@ontologies_used << Hash["name", ont.name, "acronym", ont.acronym]
end
end
@@ -62,7 +62,7 @@ def edit
@project = projects.first
@user_select_list = LinkedData::Client::Models::User.all.map {|u| [u.username, u.id]}
@user_select_list.sort! {|a,b| a[1].downcase <=> b[1].downcase}
- @usedOntologies = @project.ontologyUsed || []
+ @usedOntologies = @project.ontologyUsed&.map{|o| o.split('/').last}
@ontologies = LinkedData::Client::Models::Ontology.all
end
@@ -76,7 +76,7 @@ def create
@project = LinkedData::Client::Models::Project.new(values: project_params)
@project_saved = @project.save
-
+
# Project successfully created.
if response_success?(@project_saved)
flash[:notice] = t('projects.project_successfully_created')
@@ -160,10 +160,10 @@ def destroy
def project_params
p = params.require(:project).permit(:name, :acronym, :institution, :contacts, { creator:[] }, :homePage,
:description, { ontologyUsed:[] })
-
+
p[:creator]&.reject!(&:blank?)
- p[:ontologyUsed]&.reject!(&:blank?)
- p.to_h
+ p[:ontologyUsed] ||= []
+ p = p.to_h
end
def flash_error(msg)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 3f69732afd..acf5335c1c 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -107,14 +107,14 @@ def error_message_alert
end
def onts_for_select(include_views: false)
- ontologies ||= LinkedData::Client::Models::Ontology.all({include: "acronym,name", include_views: include_views})
+ ontologies ||= LinkedData::Client::Models::Ontology.all({include: "acronym,name,viewOf", include_views: include_views})
onts_for_select = [['', '']]
ontologies.each do |ont|
next if ( ont.acronym.nil? or ont.acronym.empty? )
acronym = ont.acronym
name = ont.name
abbreviation = acronym.empty? ? "" : "(#{acronym})"
- ont_label = "#{name.strip} #{abbreviation}"
+ ont_label = "#{name.strip} #{abbreviation}#{ont.viewOf ? ' [view]' : ''}"
onts_for_select << [ont_label, acronym]
end
onts_for_select.sort! { |a,b| a[0].downcase <=> b[0].downcase }
diff --git a/app/helpers/collections_helper.rb b/app/helpers/collections_helper.rb
index b366a1401c..9a80d24111 100644
--- a/app/helpers/collections_helper.rb
+++ b/app/helpers/collections_helper.rb
@@ -1,4 +1,5 @@
module CollectionsHelper
+ include MultiLanguagesHelper
def get_collections(ontology, add_colors: false)
diff --git a/app/helpers/mappings_helper.rb b/app/helpers/mappings_helper.rb
index bfe583a41b..1096744e58 100644
--- a/app/helpers/mappings_helper.rb
+++ b/app/helpers/mappings_helper.rb
@@ -2,43 +2,85 @@ module MappingsHelper
# Used to replace the full URI by the prefixed URI
RELATIONSHIP_PREFIX = {
- "http://www.w3.org/2004/02/skos/core#" => "skos:",
- "http://www.w3.org/2000/01/rdf-schema#" => "rdfs:",
- "http://www.w3.org/2002/07/owl#" => "owl:",
- "http://www.w3.org/1999/02/22-rdf-syntax-ns#" => "rdf:",
- "http://purl.org/linguistics/gold/" => "gold:",
- "http://lemon-model.net/lemon#" => "lemon:"
+ 'http://www.w3.org/2004/02/skos/core#' => 'skos:',
+ 'http://www.w3.org/2000/01/rdf-schema#' => 'rdfs:',
+ 'http://www.w3.org/2002/07/owl#' => 'owl:',
+ 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' => 'rdf:',
+ 'http://purl.org/linguistics/gold/' => 'gold:',
+ 'http://lemon-model.net/lemon#' => 'lemon:'
}
INTERPORTAL_HASH = $INTERPORTAL_HASH
-
- # a little method that returns true if the URIs array contain a gold:translation or gold:freeTranslation
- def translation?(relation_array)
- if relation_array.kind_of?(Array)
- relation_array.map!(&:downcase)
- if relation_array.include? "http://purl.org/linguistics/gold/translation"
- true
- elsif relation_array.include? "http://purl.org/linguistics/gold/freetranslation"
- true
- else
- false
+ def mapping_links(mapping, concept)
+ target_concept = mapping.classes.select do |c|
+ c.id != concept.id && c.links['ontology'] != concept.links['ontology']
+ end.first
+ target_concept ||= mapping.classes.last
+ process = mapping.process || {}
+
+ if inter_portal_mapping?(target_concept)
+ cls_link = ajax_to_inter_portal_cls(target_concept)
+ ont_name = target_concept.links['ontology']
+ ont_link = link_to ont_name, get_inter_portal_ui_link(ont_name, process['name']), target: '_blank'
+ source_tooltip = 'Internal-portal'
+ elsif internal_mapping?(target_concept)
+ begin
+ ont = target_concept.explore.ontology
+ ont_name = ont.acronym
+ ont_link = link_to ont_name, ontology_path(ont_name), 'data-turbo-frame': '_top'
+ rescue
+ ont_name = target_concept.links['ontology'] || target_concept.id
+ ont_link = ont_name
end
+ cls_link = raw(get_link_for_cls_ajax(target_concept.id, ont_name, '_top'))
+ source_tooltip = 'Internal'
else
- false
+ cls_label = ExternalLinkTextComponent.new(text: target_concept.links['self']).call
+ cls_link = raw("#{cls_label}")
+ ont_name = target_concept.links['ontology']
+ ont_link = link_to ExternalLinkTextComponent.new(text: ont_name).call, target_concept.links['ontology'],
+ target: '_blank'
+ source_tooltip = 'External'
end
+
+ [cls_link, ont_link, source_tooltip]
+ end
+
+ def mapping_prefixed_relations(mapping)
+ process = mapping.process || {}
+ Array(process[:relation]).each { |relation| get_prefixed_uri(relation) }
+ end
+
+ def mapping_type_tooltip(map)
+ relations = mapping_prefixed_relations(map)
+ process = map.process || {}
+ type = if map.source.to_s.include? 'SKOS'
+ 'SKOS'
+ else
+ map.source
+ end
+ types_description = {
+ 'CUI' => 'Created between 2 concepts that have the same CUI (Concept Unique Identifiers)',
+ 'LOOM' => 'Lexical mappings created between 2 concepts with very similar labels (preferred name)',
+ 'REST' => 'A mapping added by a user using the REST API (or the UI, which is calling the API to create it)',
+ 'SAME_URI' => 'Created between 2 concepts with the same URI.',
+ 'SKOS' => 'Mappings based on SKOS relationships, (e.g. skos:exactMatch or skos:closeMatch)'
+ }
+ type_tooltip = "#{map.source} #{relations.join(', ')} : #{types_description[type]} #{process[:source_name]}".strip
+ [type, type_tooltip]
end
# a little method that returns the uri with a prefix : http://purl.org/linguistics/gold/translation become gold:translation
def get_prefixed_uri(uri)
RELATIONSHIP_PREFIX.each { |k, v| uri.sub!(k, v) }
- return uri
+ uri
end
# method to get (using http) prefLabel for interportal classes
# Using bp_ajax_controller.ajax_process_interportal_cls will try to resolve class labels.
def ajax_to_inter_portal_cls(cls)
- inter_portal_acronym = get_inter_portal_acronym(cls.links["ui"])
+ inter_portal_acronym = get_inter_portal_acronym(cls.links['ui'])
href_cls = " href='#{cls.links["ui"]}' "
if inter_portal_acronym
data_cls = " data-cls='#{cls.links["self"]}?apikey=' "
@@ -52,7 +94,7 @@ def ajax_to_inter_portal_cls(cls)
def ajax_to_internal_cls(cls)
link_to("#{cls.id}".html_safe,
- ontology_path(cls.explore.ontology.acronym, p: 'classes', conceptid: cls.id), target: "_blank")
+ ontology_path(cls.explore.ontology.acronym, p: 'classes', conceptid: cls.id), target: '_blank')
end
# to get the apikey from the interportal instance of the interportal class.
@@ -60,7 +102,7 @@ def ajax_to_internal_cls(cls)
def get_inter_portal_acronym(class_ui_url)
if !INTERPORTAL_HASH.nil?
INTERPORTAL_HASH.each do |key, value|
- if class_ui_url.start_with?(value["ui"])
+ if class_ui_url.start_with?(value['ui'])
return key
else
return nil
@@ -71,11 +113,11 @@ def get_inter_portal_acronym(class_ui_url)
# method to extract the prefLabel from the external class URI
def get_label_for_external_cls(class_uri)
- if class_uri.include? "#"
- prefLabel = class_uri.split("#")[-1]
- else
- prefLabel = class_uri.split("/")[-1]
- end
+ prefLabel = if class_uri.include? '#'
+ class_uri.split('#')[-1]
+ else
+ class_uri.split('/')[-1]
+ end
return prefLabel
end
@@ -86,11 +128,11 @@ def ajax_to_external_cls(cls)
# Replace the inter_portal mapping ontology URI (that link to the API) by the link to the ontology in the UI
def get_inter_portal_ui_link(uri, process_name)
process_name = '' if process_name.nil?
- interportal_acronym = process_name.split(" ")[2]
+ interportal_acronym = process_name.split(' ')[2]
if interportal_acronym.nil? || interportal_acronym.empty?
uri
else
- uri.sub!(INTERPORTAL_HASH[interportal_acronym]["api"], INTERPORTAL_HASH[interportal_acronym]["ui"])
+ uri.sub!(INTERPORTAL_HASH[interportal_acronym]['api'], INTERPORTAL_HASH[interportal_acronym]['ui'])
end
end
@@ -99,66 +141,14 @@ def internal_mapping?(cls)
end
def inter_portal_mapping?(cls)
- !internal_mapping?(cls) && cls.links.has_key?("ui")
- end
-
- def get_mappings_target_params
- mapping_type = Array(params[:mapping_type]).first
- external = true
- case mapping_type
- when 'interportal'
- ontology_to = "#{params[:map_to_interportal]}/ontologies/#{params[:map_to_interportal_ontology]}"
- concept_to_id = params[:map_to_interportal_class]
- when 'external'
- ontology_to = params[:map_to_external_ontology]
- concept_to_id = params[:map_to_external_class]
- else
- ontology_to = params[:map_to_bioportal_ontology_id]
- concept_to_id = params[:map_to_bioportal_full_id]
- external = false
- end
- [ontology_to, concept_to_id, external]
- end
-
- def set_mapping_target(concept_to_id:, ontology_to:, mapping_type: )
- case mapping_type
- when 'interportal'
- @map_to_interportal, @map_to_interportal_ontology = ontology_to.match(%r{(.*)/ontologies/(.*)}).to_a[1..]
- @map_to_interportal_class = concept_to_id
- when 'external'
- @map_to_external_ontology = ontology_to
- @map_to_external_class = concept_to_id
- else
- @map_to_bioportal_ontology_id = ontology_to
- @map_to_bioportal_full_id = concept_to_id
- end
- end
-
- def get_mappings_target
- ontology_to, concept_to_id, external_mapping = get_mappings_target_params
- target = ''
- if external_mapping
- target_ontology = ontology_to
- target = concept_to_id
- else
- if helpers.link?(ontology_to)
- target_ontology = LinkedData::Client::Models::Ontology.find(ontology_to)
- else
- target_ontology = LinkedData::Client::Models::Ontology.find_by_acronym(ontology_to).first
- end
- if target_ontology
- target = target_ontology.explore.single_class(concept_to_id).id
- target_ontology = target_ontology.id
- end
- end
- [target_ontology, target, external_mapping]
+ !internal_mapping?(cls) && cls.links.has_key?('ui')
end
def type?(type)
@mapping_type.nil? && type.eql?('internal') || @mapping_type.eql?(type)
end
- def concept_mappings_loader(ontology_acronym: ,concept_id: )
+ def concept_mappings_loader(ontology_acronym:, concept_id:)
content_tag(:span, id: 'mapping_count') do
concat(content_tag(:div, class: 'concepts-mapping-count ml-1 mr-1') do
render(TurboFrameComponent.new(
@@ -173,21 +163,23 @@ def concept_mappings_loader(ontology_acronym: ,concept_id: )
end
def client_filled_modal
- link_to_modal "", ""
+ link_to_modal '', ''
end
def mappings_bubble_view_legend
content_tag(:div, class: 'mappings-bubble-view-legend') do
- mappings_legend_section(t('mappings.bubble_view_legend.bubble_size'), t('mappings.bubble_view_legend.bubble_size_desc'), 'mappings-bubble-size-legend') +
+ mappings_legend_section(t('mappings.bubble_view_legend.bubble_size'),
+ t('mappings.bubble_view_legend.bubble_size_desc'), 'mappings-bubble-size-legend') +
mappings_legend_section(
- t('mappings.bubble_view_legend.color_degree'),t('mappings.bubble_view_legend.color_degree_desc'),'mappings-bubble-color-legend') +
+ t('mappings.bubble_view_legend.color_degree'), t('mappings.bubble_view_legend.color_degree_desc'), 'mappings-bubble-color-legend') +
content_tag(:div, class: 'content-container') do
content_tag(:div, class: 'bubble-view-legend-item') do
content_tag(:div, class: 'title') do
- content_tag(:div, t('mappings.bubble_view_legend.yellow_bubble'), class: 'd-inline') + content_tag(:span, t('mappings.bubble_view_legend.selected_bubble'))
+ content_tag(:div, t('mappings.bubble_view_legend.yellow_bubble'),
+ class: 'd-inline') + content_tag(:span, t('mappings.bubble_view_legend.selected_bubble'))
end +
- content_tag(:div, class: "mappings-bubble-size-legend d-flex justify-content-center") do
- content_tag(:div, '', class: "bubble yellow")
+ content_tag(:div, class: 'mappings-bubble-size-legend d-flex justify-content-center') do
+ content_tag(:div, '', class: 'bubble yellow')
end
end
end
@@ -209,7 +201,7 @@ def mappings_legend_section(title_text, description_text, css_class)
def mappings_legend(css_class)
content_tag(:div, class: css_class) do
content_tag(:div, t('mappings.bubble_view_legend.less_mappings'), class: 'mappings-legend-text') +
- (1..6).map { |i| content_tag(:div, "", class: "bubble bubble#{i}") }.join.html_safe +
+ (1..6).map { |i| content_tag(:div, '', class: "bubble bubble#{i}") }.join.html_safe +
content_tag(:div, t('mappings.bubble_view_legend.more_mappings'), class: 'mappings-legend-text')
end
end
diff --git a/app/views/mappings/_concept_mappings.html.haml b/app/views/mappings/_concept_mappings.html.haml
index c71fe9066b..99448352fd 100644
--- a/app/views/mappings/_concept_mappings.html.haml
+++ b/app/views/mappings/_concept_mappings.html.haml
@@ -2,17 +2,18 @@
= "#{@mappings.size}"
= turbo_frame_tag @type.eql?('modal') ? 'application_modal_content' : 'concept_mappings' do
- %div{:style => "padding: 1%; width: 98%"}
+ %div.p-1
- if session[:user].nil?
= link_to "Create New Mapping", "/login?redirect=/ontologies/#{@ontology.acronym}/?p=classes&t=mappings&conceptid=#{escape(@concept.id)}", :method => :get, :class => "btn btn-default mb-3"
- else
- = link_to_modal("Create New Mapping",
- new_mapping_path(ontology_from: "#{@ontology.id}", conceptid_from: "#{@concept.id}"),
- id: "new_mapping_btn",
- role: "button",
- class: "btn btn-default mb-3",
- data: { show_modal_title_value: "Create a new mapping for #{@concept.prefLabel}" },
- )
+ %div{style: 'width: 225px; margin: 0 0 10px 0;'}
+ = link_to_modal("Create New Mapping",
+ new_mapping_path(ontology_from: "#{@ontology.id}", conceptid_from: "#{@concept.id}"),
+ id: "new_mapping_btn",
+ role: "button",
+ class: "secondary-button regular-button slim",
+ data: { show_modal_title_value: "Create a new mapping for #{@concept.prefLabel}" },
+ )
#mapping_details
- = render :partial => '/mappings/mapping_table'
\ No newline at end of file
+ = render :partial => '/mappings/mapping_table'
diff --git a/app/views/mappings/_mapping_table.html.haml b/app/views/mappings/_mapping_table.html.haml
index 1d91b3b5bb..20efcd92d5 100644
--- a/app/views/mappings/_mapping_table.html.haml
+++ b/app/views/mappings/_mapping_table.html.haml
@@ -1,16 +1,14 @@
= check_box_tag "delete_mappings_permission", @delete_mapping_permission, @delete_mapping_permission, style: "display: none;"
%div#concept_mappings_tables_div
= render_alerts_container(MappingsController)
- %table#concept_mappings_table.table-content-stripped.table-content{width: "100%", style:'word-break: break-word'}
+ %table#concept_mappings_table.table-content-stripped.table-content.table-mini
%thead
%tr
%th= t("mappings.mapping_table.mapping_to")
- %th{width: "30%"}= t("mappings.count.ontology")
- %th= t("mappings.mapping_table.relations")
- %th= t("mappings.mapping_table.source")
+ %th= t("mappings.count.ontology")
%th= t("mappings.mapping_table.type")
- - if current_user_admin?
- %th{:class => 'delete_mappings_column'}= t("mappings.mapping_table.actions")
+ - if current_user_admin? && !@mappings.all? { |obj| !obj.source.eql?('REST') }
+ %th{:class => 'delete_mappings_column'}
%tbody#concept_mappings_table_content
- @mappings.each do |map|
= render partial: 'mappings/show_line' , locals: {map: map, concept: @concept}
@@ -19,4 +17,4 @@
:javascript
jQuery(document).ready(function(){
ajax_process_init();
- })
\ No newline at end of file
+ })
diff --git a/app/views/mappings/_show_line.html.haml b/app/views/mappings/_show_line.html.haml
index bbfab2b78e..255fd42610 100644
--- a/app/views/mappings/_show_line.html.haml
+++ b/app/views/mappings/_show_line.html.haml
@@ -1,56 +1,23 @@
-- process = map.process || {}
-- source = "#{map.source} #{process[:source_name]}"
-- relations = process[:relation]&.each { |relation| get_prefixed_uri(relation)}
+- type, type_tooltip = mapping_type_tooltip(map)
+- cls_link, ont_link, source_tooltip = mapping_links(map, concept)
- map_id = map.id.to_s.split("/").last
-- target_concept = map.classes.select {|target_concept| target_concept.id != concept.id && target_concept.links['ontology'] != concept.links['ontology']}.first || map.classes.last
-- if inter_portal_mapping?(target_concept)
- - cls_link = ajax_to_inter_portal_cls(target_concept)
- - ont_name = target_concept.links['ontology']
- - ont_acronym = ont_name
- - ont_link = link_to ont_acronym , get_inter_portal_ui_link(target_concept.links['ontology'], process["name"]), target: '_blank'
- - type = 'Inter-portal'
-- elsif internal_mapping?(target_concept)
- - begin
- - ont = target_concept.explore.ontology
- - ont_name = ont.acronym
- - ont_link = link_to ont_name, ontology_path(ont_name), 'data-turbo-frame':'_top'
- - rescue
- - ont_name = target_concept.links['ontology'] || target_concept.id
- - ont_link = ont_name
- - cls_link = raw(get_link_for_cls_ajax(target_concept.id, ont_name, '_top'))
- - type = 'Internal'
-- else
- - cls_label = get_label_for_external_cls(target_concept.links["self"])
- - cls_link = raw("#{cls_label}")
- - ont_name = target_concept.links['ontology']
- - ont_link = link_to ont_name, target_concept.links['ontology'], target: "_blank"
- - type = 'External'
-
%tr.human{:id => map_id}
- %td
+ %td.mappings-table-mapping-to
= cls_link
- %td
+ %td.mappings-table-mapping-to
= ont_link
%td
- - relations&.each do |r|
- = r
- %br/
- %td
- #{source}
- - if !process.nil?
- - if translation?(process["relation"])
- %img{:src => asset_path('sifr/english_language_flag.png'), :style => "padding: 5px", :align => "right", :title => "Traduction"}
- %td
- = type
+ = render ChipButtonComponent.new(class: 'chip_button_small mr-1', text: type, tooltip:"#{source_tooltip} mapping of type #{type_tooltip}")
+
- if current_user_admin?
%td{:class => 'delete_mappings_column'}
- if map.id && !map.id.empty? && session[:user] && (session[:user].id.to_i == map.creator || session[:user].admin?) && map.source.eql?('REST')
%div.d-flex
- = link_to_modal(t("mappings.show_line.edit_modal"),
+ = link_to_modal(nil,
mapping_path(map_id, {conceptid_from: @concept.id}),
- role: "button",
- class: "btn btn-link",
+ class: 'btn btn-link p-0 mr-1',
data: { show_modal_title_value: t("mappings.show_line.edit_mapping", preflabel: @concept.prefLabel)},
- )
- = button_to t("mappings.show_line.delete_button"), CGI.unescape(mapping_path(map.id)), method: :delete, class:'btn btn-link', form: {data: { turbo: true, turbo_confirm: t("mappings.show_line.turbo_confirm"), turbo_frame: '_top'}}
\ No newline at end of file
+ ) do
+ = inline_svg_tag "edit.svg", width: '16px', height: '16px'
+ = button_to inline_svg_tag('icons/delete.svg', width: '16px', heigth: '16px'), CGI.unescape(mapping_path(map.id)), class: 'btn btn-link p-0', method: :delete, form: {data: { turbo: true, turbo_confirm: t("mappings.show_line.turbo_confirm"), turbo_frame: '_top'}}
diff --git a/app/views/ontologies/ontologies_selector/ontologies_selector_results.html.haml b/app/views/ontologies/ontologies_selector/ontologies_selector_results.html.haml
index 2aeafa23df..9bd25a770a 100644
--- a/app/views/ontologies/ontologies_selector/ontologies_selector_results.html.haml
+++ b/app/views/ontologies/ontologies_selector/ontologies_selector_results.html.haml
@@ -2,7 +2,7 @@
.ontologies-selector-results
.horizontal-line
.results-number
- = t("ontologies.showing_ontologies_size", ontologies_size: @ontologies.length, analytics_size: @total_ontologies_number)
+ = t("ontologies.showing_ontologies_size", ontologies_size: @ontologies.length, analytics_size: @total_ontologies_number, portals: portal_name)
%span.select-all{'data-action': 'click->ontologies-selector#selectall'}
= t('ontologies_selector.select_all')
.ontologies
diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml
index cd3eea4235..55bdb61edc 100644
--- a/app/views/projects/_form.html.haml
+++ b/app/views/projects/_form.html.haml
@@ -53,5 +53,5 @@
%div#ontology_picker_project{style: "padding-top: 2em;"}
- selected_ontologies = @project.ontologyUsed && @project.ontologyUsed.map {|id| id.split('/').last } || []
- locals = { sel_text: t('projects.form.select_ontologies'), selected_ontologies: selected_ontologies, form_object: :project, form_attribute: "ontologyUsed" }
- = ontologies_selector(id:'projects_page_ontologies_selector' ,name: 'ontologies')
+ = ontologies_selector(id:'projects_page_ontologies_selector' ,name: 'project[ontologyUsed][]', selected: @usedOntologies)
diff --git a/test/helpers/application_test_helpers.rb b/test/helpers/application_test_helpers.rb
index 975c220eac..28530711f7 100644
--- a/test/helpers/application_test_helpers.rb
+++ b/test/helpers/application_test_helpers.rb
@@ -16,17 +16,27 @@ module Users
def sign_in_as(username)
user = fixtures(:users)[username]
logged_in_user = LinkedData::Client::Models::User.authenticate(user.username, user.password)
- if logged_in_user && !logged_in_user.errors
- logged_in_user = create_user(user)
- end
+ logged_in_user = create_user(user) if logged_in_user && !logged_in_user.errors
logged_in_user
end
def create_user(user, admin: false)
- admin_user = LinkedData::Client::Models::User.authenticate('admin', 'password') if admin
+ admin_user = LinkedData::Client::Models::User.authenticate('admin', 'password')
existent_user = LinkedData::Client::Models::User.find_by_username(user.username).first
- existent_user.delete if existent_user
+ conn = Faraday.new(url: LinkedData::Client.settings.rest_url) do |faraday|
+ faraday.request :url_encoded
+ faraday.response :logger
+ faraday.adapter Faraday.default_adapter
+ faraday.headers = {
+ "Accept" => "application/json",
+ "Authorization" => "apikey token=#{admin_user.apikey}",
+ "User-Agent" => "NCBO API Ruby Client v0.1.0"
+ }
+
+ end
+
+ conn.delete("/users/#{user.username}") if existent_user
values = user.to_h
values[:role] = ["ADMINISTRATOR"] if admin
@@ -34,17 +44,6 @@ def create_user(user, admin: false)
if admin
# Overwrite the normal ".save" to accept creating admin user
- conn = Faraday.new(url: LinkedData::Client.settings.rest_url) do |faraday|
- faraday.request :url_encoded
- faraday.response :logger
- faraday.adapter Faraday.default_adapter
- faraday.headers = {
- "Accept" => "application/json",
- "Authorization" => "apikey token=#{admin_user.apikey}",
- "User-Agent" => "NCBO API Ruby Client v0.1.0"
- }
-
- end
conn.post(existent_user.class.collection_path, existent_user.to_hash.to_json, 'Content-Type' => 'application/json')
else
existent_user.save
@@ -61,7 +60,22 @@ def delete_users(users = LinkedData::Client::Models::User.all)
end
def delete_user(user)
- LinkedData::Client::Models::User.find_by_username(user.username).first&.delete
+ admin_user = LinkedData::Client::Models::User.authenticate('admin', 'password')
+ existent_user = LinkedData::Client::Models::User.find_by_username(user.username).first
+
+ conn = Faraday.new(url: LinkedData::Client.settings.rest_url) do |faraday|
+ faraday.request :url_encoded
+ faraday.response :logger
+ faraday.adapter Faraday.default_adapter
+ faraday.headers = {
+ "Accept" => "application/json",
+ "Authorization" => "apikey token=#{admin_user.apikey}",
+ "User-Agent" => "NCBO API Ruby Client v0.1.0"
+ }
+
+ end
+
+ conn.delete("/users/#{user.username}") if existent_user
end
end
@@ -133,4 +147,4 @@ def delete_agents(agents = LinkedData::Client::Models::Agent.all)
Array(agents).each { |g| g.delete }
end
end
-end
\ No newline at end of file
+end
diff --git a/test/system/login_flows_test.rb b/test/system/login_flows_test.rb
index d6ff0deb49..8bed283d20 100644
--- a/test/system/login_flows_test.rb
+++ b/test/system/login_flows_test.rb
@@ -22,8 +22,6 @@ class LoginFlowsTest < ApplicationSystemTestCase
new_user = @user_john
delete_user(new_user)
- LinkedData::Client::Models::User.find_by_username(new_user.username).first&.delete
-
fill_in 'user_firstName', with: new_user.firstName
fill_in 'user_lastName', with: new_user.lastName
fill_in 'user_username', with: new_user.username
diff --git a/test/system/submission_flows_test.rb b/test/system/submission_flows_test.rb
index 6045308d04..a0c06a4f47 100644
--- a/test/system/submission_flows_test.rb
+++ b/test/system/submission_flows_test.rb
@@ -46,7 +46,6 @@ class SubmissionFlowsTest < ApplicationSystemTestCase
assert_text cat.acronym.titleize
end
-
assert_text @new_submission.URI
assert_text @new_submission.description
assert_text @new_submission.pullLocation
@@ -103,7 +102,6 @@ class SubmissionFlowsTest < ApplicationSystemTestCase
click_on "Licensing"
submission_licensing_edit_fill(ontology_2, submission_2)
-
# Persons and organizations tab
click_on "Persons and organizations"
submission_agent_edit_fill(submission_2)
@@ -148,7 +146,10 @@ class SubmissionFlowsTest < ApplicationSystemTestCase
assert_text submission_2.URI
assert_text submission_2.versionIRI
+
+ wait_for '.submission-status'
assert_selector '.submission-status', text: submission_2.version
+
assert_selector ".flag-icon-fr" # todo fix this
submission_2.identifier.each do |id|
assert_text id
@@ -258,7 +259,6 @@ class SubmissionFlowsTest < ApplicationSystemTestCase
assert_text "rdfs"
assert_text "dct"
-
open_dropdown "#configuration"
submission_2.keyClasses.each do |key|
@@ -341,10 +341,8 @@ class SubmissionFlowsTest < ApplicationSystemTestCase
sleep 0.5
click_button 'Back'
-
fill_ontology(ontology_2, submission_2, add_submission: true)
-
assert_selector 'h2', text: 'Ontology submitted successfully!'
click_on current_url.gsub("/ontologies/success/#{existent_ontology.acronym}", '') + ontology_path(existent_ontology.acronym)
@@ -362,7 +360,6 @@ class SubmissionFlowsTest < ApplicationSystemTestCase
assert_text submission_2.description
assert_text submission_2.pullLocation
-
# check
assert_selector '.fas.fa-key' if submission_2.status.eql?('private')
@@ -380,7 +377,6 @@ class SubmissionFlowsTest < ApplicationSystemTestCase
assert_text group.name
end
-
open_dropdown "#dates"
assert_date submission_2.modificationDate
assert_date existent_submission.released
@@ -483,7 +479,6 @@ def submission_agent_edit_fill(submission)
list_inputs "#submissioncontact_from_group_input", "submission[contact]", submission.contact
-
agent1 = fixtures(:agents)[:agent1]
agent2 = fixtures(:agents)[:agent2]
@@ -624,7 +619,6 @@ def fill_ontology(new_ontology, new_submission, add_submission: false)
list_checks new_ontology.hasDomain.map(&:acronym), @categories.map(&:acronym)
list_checks new_ontology.group.map(&:acronym), @groups.map(&:acronym)
-
click_button 'Next'
# Page 2
@@ -644,9 +638,9 @@ def fill_ontology(new_ontology, new_submission, add_submission: false)
# Page 3
if add_submission
- date_picker_fill_in 'submission[modificationDate]', new_submission.modificationDate
+ date_picker_fill_in 'submission[modificationDate]', new_submission.modificationDate
else
- date_picker_fill_in 'submission[released]', new_submission.released
+ date_picker_fill_in 'submission[released]', new_submission.released
end
list_inputs "#submissioncontact_from_group_input", "submission[contact]", new_submission.contact