Skip to content

Commit

Permalink
Merge branch 'feat/filter-ontologies-by-lang' into feature/show-ontol…
Browse files Browse the repository at this point in the history
…ogy-data-by-lang
  • Loading branch information
syphax-bouazzouni committed Mar 27, 2023
2 parents 2b479e6 + 849e1ad commit 94ca0b7
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/helpers/ontologies_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module OntologiesHelper

REST_URI = $REST_URL
API_KEY = $API_KEY
LANGUAGE_FILTERABLE_SECTIONS = ['classes', 'schemes', 'collections']



def additional_details
return "" if $ADDITIONAL_ONTOLOGY_DETAILS.nil? || $ADDITIONAL_ONTOLOGY_DETAILS[@ontology.acronym].nil?
Expand Down Expand Up @@ -393,6 +396,10 @@ def selected_section?(section_title)
current_section.eql?(section_title)
end

def allowed_to_show_language_filter?(section)
LANGUAGE_FILTERABLE_SECTIONS.include?(section)
end

def lazy_load_section(section_title, &block)
if current_section.eql?(section_title)
block.call
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Application } from "@hotwired/stimulus"
const application = Application.start()

// Configure Stimulus development experience
application.debug = true
application.debug = false
window.Stimulus = application


Expand Down
3 changes: 3 additions & 0 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ application.register("simple-tree", SimpleTreeController)
import SkosCollectionColorsController from "./skos_collection_colors_controller"
application.register("skos-collection-colors", SkosCollectionColorsController)

import TabChangeController from "./tab_change_controller"
application.register("tab-change", TabChangeController)

import TooltipController from "./tooltip_controller"
application.register("tooltip", TooltipController)

Expand Down
35 changes: 35 additions & 0 deletions app/javascript/controllers/tab_change_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Controller } from "@hotwired/stimulus"
import { showLoader } from "../mixins/showLoader";

export default class extends Controller {


static targets = ["sections"]


onClick(event) {

const anchorElement = event.target.closest('a');

// add active class to the clicked tab

if (anchorElement) {

showLoader(this.sectionsTarget);

anchorElement.classList.add('active');

// remove active class from the other tabs
const otherTabs = anchorElement.parentElement.parentElement.querySelectorAll('a');
otherTabs.forEach(tab => {
if (tab !== anchorElement) {
tab.classList.remove('active');
}
});

const href = anchorElement.getAttribute('href');
Turbo.visit(href);
}

}
}

0 comments on commit 94ca0b7

Please sign in to comment.