Skip to content

Commit

Permalink
Merge pull request #239 from ontoportal-lirmm/feature/show-ontology-d…
Browse files Browse the repository at this point in the history
…ata-by-lang

Feature: Show ontology data by one language - part 3
  • Loading branch information
syphax-bouazzouni committed Sep 5, 2023
1 parent d0ce42a commit 8e8ce1a
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 8 deletions.
24 changes: 24 additions & 0 deletions app/components/edit_submission_attribute_button_component.rb
Original file line number Diff line number Diff line change
@@ -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
13 changes: 12 additions & 1 deletion app/helpers/ontologies_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions app/javascript/controllers/ontology_viewer_tabs_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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'
}
}

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 @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion app/views/ontologies/sections/_metadata.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/views/submissions/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 8e8ce1a

Please sign in to comment.