Skip to content

Commit

Permalink
Fix: the new summary page bugs (#371)
Browse files Browse the repository at this point in the history
* update language field component to have a better display of not valid ISO links

* fix the error page image not displaying the good color

* fix turbo frame error text extraction from the new errors pages

* fix summary links section display to use link component

* catch remaining  cases when @concept is nil in the ontology viewer

* fix ontology subscribe button  error message not showing

* show a better  error message when no classes found

* fix the concept  dates list view to use the correct alert component

* add '.svg' to the LinkText components icons

* fix new ontology form error not displaying when acronym is already used

* fix concept details, inSchemes and In Collection chips with no margin

* not show narrower row in concept details
  • Loading branch information
syphax-bouazzouni authored Oct 31, 2023
1 parent c83d5e0 commit 1e8ae5b
Show file tree
Hide file tree
Showing 27 changed files with 56 additions and 48 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/components/regular_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
}

.primary-button-icon path {
fill: white;
fill: white !important;
}


Expand Down
3 changes: 0 additions & 3 deletions app/assets/stylesheets/ontologies.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
$ont-metadata-bg-color: #e2ebf0;
$widget-table-border-color: #EFEFEF;

svg path {
fill: var(--primary-color);
}

.ontologies.show .gutter {
background-repeat: no-repeat;
Expand Down
5 changes: 5 additions & 0 deletions app/assets/stylesheets/ontology_viewer.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.ontology-viewer{
svg path {
fill: var(--primary-color);
}
}
.ontologies-tabs-container {
& > .tabs-container {
justify-content: center;
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/summary.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@


.disabled-icon svg path {
fill: rgba(0, 0, 0, 0.1);
fill: rgba(0, 0, 0, 0.1) !important;
}

.normal_text {
Expand Down
2 changes: 1 addition & 1 deletion app/components/external_link_text_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
class ExternalLinkTextComponent < LinkTextComponent

def initialize(text:)
super(text: text, icon: 'icons/external-link')
super(text: text, icon: 'icons/external-link.svg')
end
end
2 changes: 1 addition & 1 deletion app/components/internal_link_text_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

class InternalLinkTextComponent < LinkTextComponent
def initialize(text:)
super(text: text, icon: 'icons/internal-link')
super(text: text, icon: 'icons/internal-link.svg')
end
end
8 changes: 2 additions & 6 deletions app/components/language_field_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ def initialize(value:, label: nil)
end

def lang_code
if @lang_code
@lang_code = 'gb' if @lang_code.eql?('en')
@lang_code
else
@value
end
@lang_code = 'gb' if @lang_code.eql?('en')
@lang_code
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
%div.ml-1
= @label
- else
= render ChipButtonComponent.new(text: @value)
= render ChipButtonComponent.new(text: @value ? @value.split('/').last : 'NO-LANG')
3 changes: 2 additions & 1 deletion app/components/link_field_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

class LinkFieldComponent < ViewComponent::Base

def initialize(value:)
def initialize(value:, raw: false)
super
@value = value
@raw = raw
end


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- if internal_link?
= render ChipButtonComponent.new(url: @value.to_s.sub("data.", ""), text: @value.to_s.split("/").last, type: "clickable")
= render ChipButtonComponent.new(url: @value.to_s.sub("data.", ""), text: @raw ? @value : @value.to_s.split("/").last, type: "clickable")
- elsif @value.to_s =~ /\A#{URI::regexp(%w[http https])}\z/
= render ChipButtonComponent.new(url: @value.to_s, text: @value.to_s, type: "clickable")
- else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ export default class extends Controller {
type: "POST",
url: url,
dataType: "json",
success: () => {
success: (data) => {
// Change subbed value on a element
this.#hideSpinner()

if(!data.updated_sub){
this.#showError()
return
}

let linkElement = $(this.element);
this.isSubbedValue = !isSubbed

Expand Down
2 changes: 1 addition & 1 deletion app/components/popup_link_text_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class PopupLinkTextComponent < LinkTextComponent

def initialize(text:)
super(text: text, icon: 'icons/popup-link')
super(text: text, icon: 'icons/popup-link.svg')
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@

- c.error do
%div.text-wrap
= render AlertMessageComponent.new(id: "#{@id}_view_alert") do
= render Display::AlertComponent.new(type:'info') do
= error
3 changes: 2 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ def get_class(params)
@roots = @ontology.explore.roots(concept_schemes: params[:concept_schemes])
if @roots.nil? || @roots.empty?
LOG.add :debug, "Missing @roots for #{@ontology.acronym}"
@concept = @ontology.explore.classes.collection.first.explore.self(full: true)
classes = @ontology.explore.classes.collection
@concept = classes.first.explore.self(full: true) if classes.first
return
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def classes

@current_purl = @concept.purl if $PURL_ENABLED

unless @concept.id == 'bp_fake_root'
unless @concept.nil? || @concept.id == 'bp_fake_root'
@notes = @concept.explore.notes
end

Expand Down
9 changes: 3 additions & 6 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,9 @@ def help_tooltip(content, html_attribs = {}, icon = 'fas fa-question-circle', cs
end

def error_message_text
return @errors if @errors.is_a?(String)
@errors = @errors[:error] if @errors && @errors[:error]
if @errors.is_a?(String)
@errors
else
"Errors in fields #{@errors.keys.join(', ')}"
end
"Errors in fields #{@errors.keys.join(', ')}"
end

def error_message_alert
Expand Down Expand Up @@ -485,7 +482,7 @@ def subscribed_to_ontology?(ontology_acronym, user)
return false if user.subscription.nil? or user.subscription.empty?
user.subscription.each do |sub|
#sub = {ontology: ontology_acronym, notification_type: "NOTES"}
sub_ont_acronym = sub[:ontology].split('/').last # make sure we get the acronym, even if it's a full URI
sub_ont_acronym = sub[:ontology] ? sub[:ontology].split('/').last : nil # make sure we get the acronym, even if it's a full URI
return true if sub_ont_acronym == ontology_acronym
end
return false
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/concepts_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def exclude_relation?(relation_to_check, ontology = nil)
end

def get_concept_id(params, concept, root)
return nil if concept.nil?

if concept_id_param_exist?(params)
concept.nil? ? '' : concept.id
elsif !root.children.first.nil?
Expand Down
1 change: 1 addition & 0 deletions app/helpers/inputs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def input_label(label, name)
end

def attribute_error(attr)
return '' if @errors.is_a?(String)
return '' unless @errors && @errors[attr.to_sym]

errors = @errors[attr.to_sym]
Expand Down
1 change: 0 additions & 1 deletion app/helpers/mappings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def translation?(relation_array)
false
end
else
LOG.add :error, "Warning: Mapping relation is not an array"
false
end
end
Expand Down
16 changes: 8 additions & 8 deletions app/views/concepts/_details.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@


= render ConceptDetailsComponent.new(id:'concept-details', acronym: @ontology.acronym,
properties: @concept.properties,
top_keys: %w[description comment],
bottom_keys: %w[disjoint subclass is_a has_part],
exclude_keys: schemes_keys + label_xl_set + ['inScheme']) do |c|
properties: @concept.properties,
top_keys: %w[description comment],
bottom_keys: %w[disjoint subclass is_a has_part],
exclude_keys: schemes_keys + label_xl_set + ['inScheme', 'narrower']) do |c|

- c.header(stripped: true) do |t|
- t.add_row({th: t('ontology_details.concept.id')}, {td:@concept.id})
Expand Down Expand Up @@ -36,15 +36,15 @@
- unless @concept.memberOf.nil? || @concept.memberOf.empty?
- t.add_row({th: t('ontology_details.concept.member_of')}) do |h|
- h.td do
%div.my-1
- @concept.memberOf.each do |v|
- @concept.memberOf.each do |v|
%span.m-1
= raw get_link_for_collection_ajax(v, @ontology.acronym, '_blank')

- unless @concept.inScheme.nil? || @concept.inScheme.empty?
- t.add_row({th: t('ontology_details.concept.in_schemes')}) do |h|
- h.td do
%div.my-1
- @concept.inScheme.each do |v|
- @concept.inScheme.each do |v|
%span.m-1
= raw get_link_for_scheme_ajax(v, @ontology.acronym, '_blank')

- t.add_row({th: t('ontology_details.concept.type')} , {td: @concept.type})
Expand Down
2 changes: 1 addition & 1 deletion app/views/concepts/_show.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= render TurboFrameComponent.new(id: 'concept_show', data: {controller:'labels-ajax-container', 'action': 'turbo:before-fetch-request->labels-ajax-container#abortAll', 'labels-ajax-container-label-ajax-outlet': '#concept_show a[data-controller="label-ajax"]'}) do
- if @concept.id.eql?("bp_fake_root")
%div{:style => "padding: 100px 0; font-size: larger; font-weight: bold; text-align: center;"}
= render Display::AlertComponent.new do
Use the "Jump To" to find a class and display details, visualization, notes, and mappings
- else
= render TabsContainerComponent.new(type:'outline') do |c|
Expand Down
4 changes: 2 additions & 2 deletions app/views/errors/internal_server_error.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.d-flex.align-items-center.flex-column.position-relative
.d-flex.align-items-center.flex-column.position-relative.error-page
= inline_svg("errors/agroportal.svg")
.position-absolute.text-center{style: "top: 425px; font-size: 30px; font-weight: 800; color: #263238;"}
%h1.position-absolute.text-center{style: "top: 425px; font-size: 30px; font-weight: 800; color: #263238;"}
%div
We're sorry but something has gone wrong.
%div
Expand Down
4 changes: 2 additions & 2 deletions app/views/errors/not_found.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.d-flex.align-items-center.flex-column.position-relative
.d-flex.align-items-center.flex-column.position-relative.error-page
= inline_svg("errors/agroportal.svg")
.position-absolute{style: "top: 442px; font-size: 30px; font-weight: 800; color: #263238;"}
%h1.position-absolute{style: "top: 442px; font-size: 30px; font-weight: 800; color: #263238;"}
= @error_message || "Page not found"
.buttons.d-flex.justify-content-center.mt-3
%div{style: "width: 216px;"}
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_ontology_viewer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


= render :partial =>'layouts/header'
%div#bd.bg-white
%div#bd.bg-white.ontology-viewer
:javascript
// Javascript History HTML5 API
if ( typeof JSON === 'undefined' ) {
Expand Down
5 changes: 4 additions & 1 deletion app/views/ontologies/sections/_metadata.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
= 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)

= properties_dropdown('link','Links','Metadata properties that highlight the links enabling access to datasets, downloading semantic resources, etc', @links_properties)
= properties_dropdown('link','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)


= properties_dropdown('projects_section','Projects and usage information','Details pertaining to the utilization of the ontology.', nil) do |c|
- c.row do
Expand Down
2 changes: 1 addition & 1 deletion app/views/ontologies/sections/_widgets.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
%code uri
put the complete URI of the class (e.g.,
= succeed ")" do
%a.external.free{:href => @ontology.explore.classes["collection"].first.id, :rel => "nofollow", :title => "/visualize/39478/Common_Neoplasm"}
%a.external.free{:href => @ontology.explore.classes["collection"].first&.id, :rel => "nofollow", :title => "/visualize/39478/Common_Neoplasm"}
= @ontology.explore.classes["collection"].first.id
%li
%code shortid
Expand Down
8 changes: 4 additions & 4 deletions app/views/ontologies/sections/visualize.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
= render TurboFrameComponent.new(id: "classes", data: {"turbo-frame-target": "frame"} ) do
- unless @error
- unless @error || @concept.nil?
- @title = "#{@ontology.name} - #{@concept.prefLabel}"
- @new_term_request_ontologies
- @enable_ontolobridge = !$NEW_TERM_REQUEST_ONTOLOGIES.nil? && $NEW_TERM_REQUEST_ONTOLOGIES.include?(@ontology.acronym)
Expand All @@ -14,9 +14,9 @@
%input{:name => "search[ontologies][]", :type => "hidden", :value => @ontology.acronym}/
= hidden_field :search, :search_type, :value=>"contains"
= hidden_field :search, :keyword, :value=>"",:id=>"search_keyword"
- else # found an error
= "<div id=\"error\"><h2>#{@error}</h2></div>"

- else
= render Display::AlertComponent.new(type: 'danger') do
= @concept.nil? ? 'No class/concept found' : @error
:javascript
$(document).ready(function() {
const ontology_acronym = "#{@ontology.acronym}"
Expand Down

0 comments on commit 1e8ae5b

Please sign in to comment.