From 50c5f215885b20277f0a7592fccec3154f348a0c Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Mon, 8 May 2023 00:44:36 +0200 Subject: [PATCH 1/5] extract EditSubmissionAttributeButton component --- ...t_submission_attribute_button_component.rb | 24 +++++++++++++++++++ .../_attribute_inline_editable.html.haml | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 app/components/edit_submission_attribute_button_component.rb diff --git a/app/components/edit_submission_attribute_button_component.rb b/app/components/edit_submission_attribute_button_component.rb new file mode 100644 index 000000000..a4ef5bbc7 --- /dev/null +++ b/app/components/edit_submission_attribute_button_component.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class EditSubmissionAttributeButtonComponent < ViewComponent::Base + include ActionView::Helpers::TagHelper + + def initialize(acronym: , submission_id:, attribute:, inline: false) + @acronym = acronym + @submission_id = submission_id + @attribute = attribute + + if inline + @link = "ontologies_metadata_curator/#{@acronym}/submissions/#{@submission_id}?properties=#{@attribute}&inline_save=true" + else + @link = "/ontologies/#{@acronym}/submissions/#{@submission_id}/edit?properties=#{@attribute}" + end + end + + def call + link_to @link, data: {turbo: true}, class: "btn btn-sm btn-light" do + content + end + end + +end diff --git a/app/views/ontologies_metadata_curator/_attribute_inline_editable.html.haml b/app/views/ontologies_metadata_curator/_attribute_inline_editable.html.haml index b2fdeedcb..7358a35e0 100644 --- a/app/views/ontologies_metadata_curator/_attribute_inline_editable.html.haml +++ b/app/views/ontologies_metadata_curator/_attribute_inline_editable.html.haml @@ -20,5 +20,5 @@ %div - %a.btn.btn-sm.btn-light{href: "ontologies_metadata_curator/#{ontology.acronym}/submissions/#{submission_id}?properties=#{attribute}&inline_save=true", data: {turbo: true}} - %i.far.fa-edit + = render EditSubmissionAttributeButtonComponent.new(acronym: ontology.acronym, submission_id: submission_id, attribute: attribute, inline: true) do + %i.far.fa-edit \ No newline at end of file From d6d39e1bda7bb4259ac46af062f7d2251c2251fc Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Mon, 8 May 2023 00:46:48 +0200 Subject: [PATCH 2/5] in ontology viewer show in an information text if no language defined --- app/helpers/ontologies_helper.rb | 13 ++++++++++++- app/views/layouts/_ontology_viewer.html.haml | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/helpers/ontologies_helper.rb b/app/helpers/ontologies_helper.rb index b180fcc4e..7a26747b1 100644 --- a/app/helpers/ontologies_helper.rb +++ b/app/helpers/ontologies_helper.rb @@ -447,7 +447,18 @@ def sections_to_show def language_selector_tag(name) - select_tag name, languages_options, class: 'custom-select', disabled: !ontology_data_section?, data: {'ontology-viewer-tabs-target': 'languageSelector'} + languages = languages_options + + if languages.empty? + content_tag(:div ,data: {'ontology-viewer-tabs-target': 'languageSelector'}, style: "visibility: #{ontology_data_section? ? 'visible' : 'hidden'} ; margin-bottom: -1px;") do + render EditSubmissionAttributeButtonComponent.new(acronym: @ontology.acronym, submission_id: @submission_latest.submissionId, attribute: :naturalLanguage) do + concat "Enable multilingual display " + concat content_tag(:i , "", class: "fas fa-lg fa-question-circle") + end + end + else + select_tag name, languages_options, class: 'custom-select', disabled: !ontology_data_section?, style: "visibility: #{ontology_data_section? ? 'visible' : 'hidden'}; margin-bottom: -10px;", data: {'ontology-viewer-tabs-target': 'languageSelector'} + end end def language_selector_hidden_tag(section) diff --git a/app/views/layouts/_ontology_viewer.html.haml b/app/views/layouts/_ontology_viewer.html.haml index 2fbcd8e9c..d2ad4caea 100644 --- a/app/views/layouts/_ontology_viewer.html.haml +++ b/app/views/layouts/_ontology_viewer.html.haml @@ -49,7 +49,7 @@ %div.col - sections = sections_to_show %div.card - %div.card-header{style: 'padding-bottom: 3px'} + %div.card-header %div{style: "display: flex; justify-content: space-between;"} %ul.nav.nav-tabs.card-header-tabs{id: "navbar-ontology", role: "tablist"} - sections.each do |section| From 7463fe87c3655e240ff6e822b6808afe61fdc9ba Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Mon, 8 May 2023 00:48:05 +0200 Subject: [PATCH 3/5] in ontology viewer hide the language selector if no language defined --- .../controllers/ontology_viewer_tabs_controller.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/javascript/controllers/ontology_viewer_tabs_controller.js b/app/javascript/controllers/ontology_viewer_tabs_controller.js index a36cf7de6..f8cb2a310 100644 --- a/app/javascript/controllers/ontology_viewer_tabs_controller.js +++ b/app/javascript/controllers/ontology_viewer_tabs_controller.js @@ -31,8 +31,8 @@ export default class extends Controller { } #updateURL(event){ - const page = jQuery(event.target).attr("data-bp-ont-page"); - const page_name = jQuery(event.target).attr("data-bp-ont-page-name"); + const page = event.target.getAttribute("data-bp-ont-page"); + const page_name = event.target.getAttribute("data-bp-ont-page-name"); (new HistoryService()).pushState({p: page}, page_name + " | " + jQuery(document).data().bp.ont_viewer.org_site, "?p=" + page); @@ -42,8 +42,10 @@ export default class extends Controller { #disableLanguageSelector(selectedSection){ if (this.languageSectionsValue.includes(selectedSection)){ this.languageSelectorTarget.removeAttribute("disabled") + this.languageSelectorTarget.style.visibility = 'visible' } else{ this.languageSelectorTarget.setAttribute("disabled", true) + this.languageSelectorTarget.style.visibility = 'hidden' } } From f809e1bedcf98f04233d1966fc826f5f90788f5f Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Mon, 8 May 2023 00:48:47 +0200 Subject: [PATCH 4/5] fix the submission edit page to show the selected attributes in the URL --- app/views/submissions/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/submissions/_form.html.haml b/app/views/submissions/_form.html.haml index c98657349..75f859318 100644 --- a/app/views/submissions/_form.html.haml +++ b/app/views/submissions/_form.html.haml @@ -44,7 +44,7 @@ - unless @filters_disabled %div.w-75.mt-3 - if @submission.id - = render MetadataSelectorComponent.new(label: 'Filter properties to show', values: submission_editable_properties , selected: nil, inline: true) + = render MetadataSelectorComponent.new(label: 'Filter properties to show', values: submission_editable_properties , selected: @selected_attributes, inline: true) %div = render SwitchInputComponent.new(id:"filter-required-only", name: "required-only", label: "Required only", checked: @required_only) From 7ebf5cc897f39dc001df767d6b35065ee0fa399c Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Mon, 8 May 2023 00:50:09 +0200 Subject: [PATCH 5/5] fix summary page submissions table to not show the loader in the bottom --- app/views/ontologies/sections/_metadata.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/ontologies/sections/_metadata.html.haml b/app/views/ontologies/sections/_metadata.html.haml index 46c942e61..f8711102a 100644 --- a/app/views/ontologies/sections/_metadata.html.haml +++ b/app/views/ontologies/sections/_metadata.html.haml @@ -68,7 +68,7 @@ - unless (@submission_latest.nil? || (@submission_latest.respond_to?(:status) && @submission_latest.status == 404)) = link_to(edit_ontology_submission_path(@ontology.acronym, @submission_latest.submissionId), "aria-label": "Edit latest submission", title: "Edit latest submission") do %i.fas.fa-user-edit{"aria-hidden": "true", style: "margin-left: 0.5rem;"} - = render TurboFrameComponent.new(id: 'ontology_submissions', src: ontology_submissions_path(@ontology.acronym)) + = render TurboFrameComponent.new(id: 'ontology_submissions', src: ontology_submissions_path(@ontology.acronym), target: '_top') -# Views pane (don't show if the ontology is a view - we don't allow views of views).