Skip to content

Commit

Permalink
Merge branch 'fix/mappings-table-style' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Oct 31, 2024
2 parents 6603953 + af782e4 commit 8d7d3a0
Show file tree
Hide file tree
Showing 15 changed files with 234 additions and 195 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 23 additions & 1 deletion app/assets/stylesheets/mappings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -341,4 +363,4 @@ div#map_from_concept_details_table, div#map_to_concept_details_table {
padding: 10px;
outline: none;
margin-left: 0 !important;
}
}
54 changes: 53 additions & 1 deletion app/controllers/mappings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,56 @@ def valid_values?(values)
end
errors
end
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_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
14 changes: 7 additions & 7 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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')
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
1 change: 1 addition & 0 deletions app/helpers/collections_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module CollectionsHelper
include MultiLanguagesHelper


def get_collections(ontology, add_colors: false)
Expand Down
Loading

0 comments on commit 8d7d3a0

Please sign in to comment.