Skip to content

Commit

Permalink
tmp 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilelkihal committed Mar 24, 2023
1 parent ed80f0b commit 8873539
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 24 deletions.
34 changes: 34 additions & 0 deletions app/assets/stylesheets/browse.scss
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,40 @@ a{
cursor: pointer;
}

.browse-ontology-title-bar{
display: flex;
align-items: center;
}
.browse-ontology-deprecated{
background-color: #EB433521;
color: #EB4335;
padding: 10px;
font-size: 14px;
border-radius: 8px;
margin-left: 15px;
font-weight: 500;
}
.browse-ontology-view{
background-color: var(--light-color);
color: var(--primary-color);
padding: 10px;
font-size: 14px;
border-radius: 8px;
margin-left: 15px;
font-weight: 500;
}

.browse-switch-filter{
display:flex;
align-items: center;
justify-content: space-between;
margin-bottom: 20px;
}
.browse-switch-filter p{
font-size: 16px;
color: #666666;
}



/* Toggle switch css */
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/theme-variables.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,28 @@
--primary-color: #31B404;
--hover-color: #40C811;
--secondary-color: #ffc107;
--light-color: #F5FCF3;
}
<% when "stageportal" %>
:root{
--primary-color: #76A7CC;
--hover-color: #6B96B7;
--secondary-color: #ffc107;
--light-color: #F1F6FA;
}
<% when "bioportal" %>
:root{
--primary-color: #76A7CC;
--hover-color: #6B96B7;
--secondary-color: #ffc107;
--light-color: #F1F6FA;
}
<% when "ontoportal" %>
:root{
--primary-color: #6E98A2;
--hover-color: #7BABB6;
--secondary-color: #ffc107;
--light-color: #F0F5F6;
}
<%# Here to add a new theme ... %>
<% end %>
Expand Down
16 changes: 11 additions & 5 deletions app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def index
### ----------------------------------- FILTERS --------------------------------------------------

@languages = submission_metadata.select { |x| x["@id"]["naturalLanguage"] }.first["enforcedValues"].map do |id, name|
{ "id" => "http://lexvo.org/id/iso639-3/#{id}", "name" => name, "acronym" => id.split('/').last }
{ "id" => id, "name" => name, "acronym" => id.split('/').last }
end

@formalityLevel = submission_metadata.select { |x| x["@id"]["hasFormalityLevel"] }.first["enforcedValues"].map do |id, name|
Expand All @@ -175,7 +175,7 @@ def index

filtered_ontologies = format_filter(filtered_ontologies, params[:format]) unless params[:format].nil?
filtered_ontologies = sort_by_filter(filtered_ontologies, params[:sort_by]) unless params[:sort_by].nil?

filtered_ontologies = filter_ontologies_by(filtered_ontologies, :categories)
filtered_ontologies = filter_ontologies_by(filtered_ontologies, :groups)
filtered_ontologies = filter_ontologies_by(filtered_ontologies, :naturalLanguage)
Expand Down Expand Up @@ -313,7 +313,7 @@ def ontologies_filter
### ----------------------------------- FILTERS --------------------------------------------------

@languages = submission_metadata.select { |x| x["@id"]["naturalLanguage"] }.first["enforcedValues"].map do |id, name|
{ "id" => "http://lexvo.org/id/iso639-3/#{id}", "name" => name, "acronym" => id.split('/').last }
{ "id" => id, "name" => name, "acronym" => id.split('/').last }
end

@formalityLevel = submission_metadata.select { |x| x["@id"]["hasFormalityLevel"] }.first["enforcedValues"].map do |id, name|
Expand Down Expand Up @@ -790,10 +790,16 @@ def filtered_ontologies(ontologies_table, checks, object_name)
filtered_table = []
ontologies_table.each do |ontology|
checks.each do |check|
ontology[object_name].each do |ontology_group|
if check.eql?(ontology_group)
if (ontology[object_name].instance_of? String) || (ontology[object_name].nil?)
if check.eql?(ontology[object_name])
filtered_table << ontology unless filtered_table.include? ontology
end
else
ontology[object_name].each do |ontology_group|
if check.eql?(ontology_group)
filtered_table << ontology unless filtered_table.include? ontology
end
end
end
end
end
Expand Down
54 changes: 39 additions & 15 deletions app/javascript/controllers/browse_filters_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,48 @@ export default class extends Controller {
}

dispatchFilterEvent(event){
let checks = this.#getSelectedChecks().map( x => x.name)
let filter = this.element.id.split("_")[0]

if(event.target.name === "format"){
if(event.target.value === ''){
checks = []
} else {
let checks;
let filter;

switch (event.target.name) {
case "format":
if(event.target.value === ''){
checks = []
} else {
checks = [event.target.value]
}
filter = "format"
break;
case "search":
checks = [event.target.value]
}
filter = "format"
} else if (event.target.name === "search"){
checks = [event.target.value]
filter = "search"
} else if (event.target.name == "Sort_by"){
checks = [event.target.value]
filter = "sort_by"
filter = "search"
break;
case "Sort_by":
checks = [event.target.value]
filter = "sort_by"
break;
case "views":
if (event.target.checked){
checks = ['show']
} else {
checks = []
}
filter = "views"
break;
case "retired":
if (event.target.checked){
checks = ['show']
} else {
checks = []
}
filter = "retired"
break;
default:
checks = this.#getSelectedChecks().map( x => x.name)
filter = this.element.id.split("_")[0]
}


let data = {
[filter]: checks,
}
Expand Down
13 changes: 11 additions & 2 deletions app/views/ontologies/_ontologies.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@
- @ontologies.each do |ontology|
.browse-ontology-container
.browse-ontology-description
%a.browse-ontology-title{:href => "/ontologies/#{ontology[:acronym]}"}
= ontology[:name]+" ("+ontology[:acronym]+")"
.browse-ontology-title-bar
%a.browse-ontology-title{:href => "/ontologies/#{ontology[:acronym]}"}
= ontology[:name]+" ("+ontology[:acronym]+")"
- deprecated = false
- view = false
- if deprecated
.browse-ontology-deprecated
deprecated
- if view
.browse-ontology-view
view
%p.browse-desc-text
= ontology[:description]
- unless ontology[:fairScore].nil? || ontology[:acronym] == 'AGROVOC'
Expand Down
13 changes: 11 additions & 2 deletions app/views/ontologies/browse.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,19 @@
%br
%br/
.browse-sub-container
.browse-first-row
.browse-first-row{data:{controller: "browse-filters", action: "change->browse-filters#dispatchFilterEvent changed->history#updateURL changed->turbo-frame#updateFrame"}}
%p.browse-filters-title Filters
%hr#browse-sub-title-line/

.browse-switch-filter
%p Show ontology views
%label.switch
%input{:type => "checkbox", name: "views"}/
%span.slider
.browse-switch-filter
%p Show retired ontologies
%label.switch
%input{:type => "checkbox", name: "retired"}/
%span.slider

- @filters.each do |key, values|
.browse-filter{data:{controller: "show-filter-count browse-filters", action: "change->show-filter-count#updateCount change->browse-filters#dispatchFilterEvent changed->history#updateURL changed->turbo-frame#updateFrame"}, id: "#{key}_filter_container" }
Expand Down

0 comments on commit 8873539

Please sign in to comment.