Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add agent tooltip in summary page #404

Merged
merged 14 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/assets/images/icons/organization.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/images/icons/person.svg
Bilelkihal marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions app/assets/stylesheets/agent_tooltip.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.agent-container{
display: flex;
align-items: center;
margin: 10px;
}
.agent-circle{
width: 70px;
height: 70px;
background-color: var(--light-color);
display: flex;
justify-content: center;
align-items: center;
border-radius: 35px;
margin-right: 12px;
}
.agent-name{
font-size: 18px;
font-weight: 600;
margin-bottom: 3px;
}
.agent-dependency{
font-size: 16px;
font-weight: 400;
color: #767676;
margin-bottom: 3px;
}
.agent-type-icon path{
fill: var(--primary-color)
}
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
/* Bootstrap and Font Awesome */
@import "bootstrap";
@import "bootstrap_overrides";
@import "agent_tooltip";

<% if (ui_theme = $UI_THEME.to_s.parameterize).present? && File.exists?(Rails.root.join('app', 'assets', 'stylesheets', 'themes', ui_theme)) %>
@import "themes/<%= ui_theme %>/main";
Expand Down
54 changes: 43 additions & 11 deletions app/helpers/agent_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,6 @@ def display_identifiers(identifiers, link: true)
end.join(', ')
end

def display_agent(agent, link: true)
Bilelkihal marked this conversation as resolved.
Show resolved Hide resolved
return agent if agent.is_a?(String)

out = agent.name.to_s
identifiers = display_identifiers(agent.identifiers, link: link)
out = "#{out} ( #{identifiers} )" unless identifiers.empty?
affiliations = Array(agent.affiliations).map { |a| display_agent(a, link: link) }.join(', ')
out = "#{out} (affiliations: #{affiliations})" unless affiliations.empty?
out
end

def agent_field_name(name, name_prefix = '')
name_prefix&.empty? ? name : "#{name_prefix}[#{name}]"
end
Expand Down Expand Up @@ -166,4 +155,47 @@ def agent_usage_error_display(error)
details.values.join(', ').html_safe
end.join('. ').html_safe
end

def display_agent(agent, link: true)
Bilelkihal marked this conversation as resolved.
Show resolved Hide resolved
return agent if agent.is_a?(String)

out = agent.name.to_s
identifiers = display_identifiers(agent.identifiers, link: link)
out = "#{out} ( #{identifiers} )" unless identifiers.empty?
affiliations = Array(agent.affiliations).map { |a| display_agent(a, link: link) }.join(', ')
out = "#{out} (affiliations: #{affiliations})" unless affiliations.empty?
out
end

def agent_tooltip(agent)
name = agent.name
email = agent.email
type = agent.agentType
identifiers = display_identifiers(agent.identifiers, link: false)
affiliations = Array(agent.affiliations).map { |a| display_agent(a, link: false) }.join(', ')
person_icon = inline_svg_tag 'icons/person.svg' , class: 'agent-type-icon'
organization_icon = inline_svg_tag 'icons/organization.svg', class: 'agent-type-icon'
agent_icon = type == "organization" ? organization_icon : person_icon
tooltip_html = generate_tooltip_html(agent_icon, name, email, identifiers, affiliations)
return tooltip_html
end

def generate_tooltip_html(agent_icon, name, email = nil, identifiers = nil, affiliations = nil)
Bilelkihal marked this conversation as resolved.
Show resolved Hide resolved
content_tag(:div, class: 'agent-container') do
content_tag(:div, agent_icon, class: 'agent-circle') +
content_tag(:div) do
content_tag(:div, name, class: 'agent-name') +
content_tag(:div, email || '', class: 'agent-dependency') +
content_tag(:div, identifiers || '', class: 'agent-dependency') +
content_tag(:div, affiliations || '', class: 'agent-dependency')
end
end
end

def agent_chip_component(agent)
render ChipButtonComponent.new(type: "static",'data-controller':' tooltip', title: agent_tooltip(agent) , class: 'text-truncate', style: 'max-width: 280px; display:block; line-height: unset') do
agent.name.to_s
end
end

end
6 changes: 2 additions & 4 deletions app/views/ontologies/sections/_metadata.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@

= properties_dropdown('person_and_organization','Persons and organizations','', @agents_properties) do |values|
= horizontal_list_container(values) do |v|
= render ChipButtonComponent.new(type: "static",'data-controller':' tooltip', title: '', class: 'text-truncate', style: 'max-width: 280px; display:block; line-height: unset') do
= display_agent(v, link: false)


= agent_chip_component(v)

= properties_dropdown('link','Other links','Metadata properties that highlight the links enabling access to datasets, downloading semantic resources, etc', @links_properties) do |values|
= horizontal_list_container(values) do |v|
= render LinkFieldComponent.new(value: v, raw: true)
Expand Down
Loading