Skip to content

Commit

Permalink
last tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilelkihal committed Mar 27, 2023
1 parent 7e424cc commit c04b47c
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 43 deletions.
119 changes: 105 additions & 14 deletions app/assets/stylesheets/browse.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,44 @@
margin: unset;
}


a{
text-decoration: none !important;
}
.browse-center{
display: flex;
justify-content: center;
margin: 50px 0;
}
.browse-title{
font-size: 18px;
font-size: 22px;
font-weight: 700;
}

.browse-submit-new-ontology-and-you-are-admin-container{
display: flex;
margin-bottom: 20px;

}
.browse-you-are-admin{
display: flex;
flex-direction: column;
align-items: center;
border: 1px solid #DFDFDF;
border-radius: 5px;
padding: 20px;
margin-left: 180px
}
.browse-you-are-admin h3{
font-size: 20px;
font-weight: 600;

}
.browse-you-are-admin div{
display: flex;

align-items: center;

}
.browse-you-are-admin div p{
margin-left: 20px;
}
.browse-upload-ontology-button{
margin: 20px 0;
display: flex;
Expand Down Expand Up @@ -67,6 +92,7 @@ a{

.browse-sub-container{
display: flex;
margin-top: 90px;
}
.browse-first-row{
width: 300px;
Expand Down Expand Up @@ -132,7 +158,7 @@ a{
.browse-ontology-cards{
display: grid;
grid-template-columns: 113px 113px;
grid-template-rows: 78px 78px;
grid-template-rows: min-content;
grid-column-gap: 15px;
grid-row-gap: 15px;
direction: rtl;
Expand Down Expand Up @@ -167,6 +193,7 @@ a{
font-weight: 600;
font-size: 16px;
}

.browse-search-bar{
display: flex;

Expand All @@ -175,7 +202,7 @@ a{
border: none;
border-radius: 14px;
width: 100%;
box-shadow: rgba(100, 100, 111, 0.1) 0px 7px 29px 0px;
box-shadow: rgba(100, 100, 111, 0.08) 0px 7px 29px 0px;
padding: 20px 20px;
margin-bottom: 20px;
font-size: 16px;
Expand Down Expand Up @@ -272,6 +299,7 @@ a{
font-size: 14px;
border-radius: 8px;
margin-left: 15px;
margin-right: 15px;
font-weight: 500;
}
.browse-ontology-view{
Expand All @@ -281,6 +309,7 @@ a{
font-size: 14px;
border-radius: 8px;
margin-left: 15px;
margin-right: 15px;
font-weight: 500;
}

Expand All @@ -297,12 +326,6 @@ a{



/* Toggle switch css */
.switch {
position: relative;
display: inline-block;
width: 40px;
height: 20px;
.browse-ontology-title-bar{
display: flex;
align-items: center;
Expand Down Expand Up @@ -338,4 +361,72 @@ a{
.browse-second-row{
width: 68vw;
}
}
.browse-search-bar input{
width: 94vw;
}
.browse-search-bar .browse-format-filter{
margin-left: 50%
}
.browse-search-bar .browse-sort-by-filter{
margin-left:65%
}

}
@media only screen and (max-width: 1005px) {
.browse-sub-container{
display: block;
}
.browse-second-row{
width: 94vw;
}
.browse-first-row{
width: 94vw;
}
.browse-search-bar input{
position: static ;
margin-bottom: 1vw;
}
.browse-search-bar .browse-format-filter{
margin-left: 0;
position: static;
border-radius: 14px;
width:46.5vw;
box-shadow: rgba(100, 100, 111, 0.1) 0px 7px 29px 0px;
margin-right: 1vw;
}
.browse-search-bar .browse-sort-by-filter{
margin-left: 0;
position: static;
border-radius: 14px;
width:46vw;
box-shadow: rgba(100, 100, 111, 0.1) 0px 7px 29px 0px;
}

.browse-sub-container{
margin-top: 20px;
}
.browse-center{
margin-left: 20px;
}
}

@media only screen and (max-width: 893px){
.browse-ontology-container{
display: block;
}
.browse-ontology-description{
width: 100%;
}
.browse-ontology-cards{
direction:ltr;
margin-top: 20px;
}
.browse-ontology-deprecated{
margin-right: 0;
}
.browse-ontology-view{
margin-right: 0;
}

}

22 changes: 20 additions & 2 deletions app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def ontologies_filter

@ontologies << o
end

@ontologies.sort! { |a, b| b[:popularity] <=> a[:popularity] }


Expand Down Expand Up @@ -474,6 +474,7 @@ def apply_ontology_filters(ontologies, categories, groups)
filtered_ontologies = filter_ontologies_by(filtered_ontologies, :naturalLanguage)
filtered_ontologies = filter_ontologies_by(filtered_ontologies, :hasFormalityLevel)
filtered_ontologies = filter_ontologies_by(filtered_ontologies, :isOfType)
filtered_ontologies = filter_ontologies_by(filtered_ontologies, :missingStatus)

filtered_ontologies
end
Expand All @@ -490,6 +491,22 @@ def ontology_filters_init(categories, groups)
@isOfType = submission_metadata.select { |x| x["@id"]["isOfType"] }.first["enforcedValues"].map do |id, name|
{ "id" => id, "name" => name, "acronym" => name.camelize(:lower) }
end

@missingStatus = [
{"id" => "RDF", "name" => "RDF", "acronym" => "RDF"},
{"id" => "ABSOLETE", "name" => "ABSOLETE", "acronym" => "ABSOLETE"},
{"id" => "METRICS", "name" => "METRICS", "acronym" => "METRICS"},
{"id" => "RDF_LABELS", "name" => "RDF LABELS", "acronym" => "RDFLABELS"},
{"id" => "UPLOADED", "name" => "UPLOADED", "acronym" => "UPLOADED"},
{"id" => "INDEXED_PROPERTIES", "name" => "INDEXED PROPERTIES", "acronym" => "INDEXED_PROPERTIES"},
{"id" => "ANNOTATOR", "name" => "ANNOTATOR", "acronym" => "ANNOTATOR"},
{"id" => "DIFF", "name" => "DIFF", "acronym" => "DIFF"}
]

#@missingStatus = submission_metadata.select { |x| x["@id"]["submissionStatus"] }.first["enforcedValues"].map do |id, name|
# { "id" => id, "name" => name, "acronym" => name.camelize(:lower) }
#end

@show_views = params[:show_views]&.eql?('true')
@show_retired = params[:show_retired]&.eql?('true')
@selected_format = params[:format]
Expand All @@ -500,7 +517,8 @@ def ontology_filters_init(categories, groups)
groups: object_filter(groups, :groups),
naturalLanguage: object_filter(@languages, :naturalLanguage),
hasFormalityLevel: object_filter(@formalityLevel, :hasFormalityLevel),
isOfType: object_filter(@isOfType, :isOfType)
isOfType: object_filter(@isOfType, :isOfType),
missingStatus: object_filter(@missingStatus, :missingStatus)
}
end

Expand Down
7 changes: 6 additions & 1 deletion app/views/ontologies/_ontologies.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


= turbo_frame_tag "search-results" do
%p.browse-desc-text{:style => "margin-bottom: 15px;"}
= "Showing "+ @ontologies.length.to_s
Expand All @@ -14,8 +16,11 @@
- if ontology[:viewOfOnt]
.browse-ontology-view
view

%p.browse-desc-text
= ontology[:description]


- unless ontology[:fairScore].nil? || ontology[:acronym] == 'AGROVOC'
.browse-fair
%p.browse-fair-title
Expand Down Expand Up @@ -53,4 +58,4 @@
%p.browse-card-number
= ontology[:note_count]
%p.browse-card-text
notes
notes
62 changes: 36 additions & 26 deletions app/views/ontologies/browse.html.haml
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@


.browse-center
.browse-container
%h2.browse-title Browse
%hr#browse-title-line/
- if session[:user].nil?
%a.browse-upload-ontology-button{:href => "/login?redirect=/ontologies/new"}
%svg{:fill => "none", :height => "14", :viewbox => "0 0 15 14", :width => "15", :xmlns => "http://www.w3.org/2000/svg"}
%path{:d => "M3.46242 4.17686L6.91776 0.23682C6.98312 0.162278 7.06302 0.102677 7.15225 0.0618794C7.24149 0.0210821 7.33808 0 7.43576 0C7.53344 0 7.63003 0.0210821 7.71927 0.0618794C7.80851 0.102677 7.8884 0.162278 7.95377 0.23682L11.4092 4.17686C11.533 4.31795 11.5971 4.50373 11.5874 4.69334C11.5777 4.88295 11.4951 5.06086 11.3577 5.18792C11.2204 5.31498 11.0395 5.38079 10.8548 5.37087C10.6702 5.36095 10.497 5.27612 10.3732 5.13503L8.13286 2.58055V10.4116C8.13286 10.6015 8.05942 10.7836 7.92869 10.9178C7.79796 11.0521 7.62065 11.1275 7.43576 11.1275C7.25088 11.1275 7.07357 11.0521 6.94284 10.9178C6.8121 10.7836 6.73866 10.6015 6.73866 10.4116V2.58058L4.49846 5.13512C4.43719 5.20498 4.36313 5.26177 4.28049 5.30223C4.19785 5.3427 4.10826 5.36605 4.01684 5.37096C3.92541 5.37587 3.83394 5.36223 3.74764 5.33084C3.66135 5.29944 3.58192 5.2509 3.51389 5.18798C3.44586 5.12506 3.39057 5.04899 3.35117 4.96413C3.31176 4.87926 3.28902 4.78726 3.28425 4.69337C3.27947 4.59948 3.29274 4.50554 3.32331 4.41692C3.35388 4.32829 3.40115 4.24672 3.46242 4.17686ZM14.1744 12.488H0.697103C0.51222 12.488 0.334909 12.5635 0.204177 12.6977C0.0734445 12.832 0 13.0141 0 13.2039C0 13.3938 0.0734445 13.5759 0.204177 13.7101C0.334909 13.8444 0.51222 13.9198 0.697103 13.9198H14.1744C14.3593 13.9198 14.5366 13.8444 14.6673 13.7101C14.7981 13.5759 14.8715 13.3938 14.8715 13.2039C14.8715 13.0141 14.7981 12.832 14.6673 12.6977C14.5366 12.5635 14.3593 12.488 14.1744 12.488Z", :fill => "#31B404"}
Submit new ontology
- else
%a.browse-upload-ontology-button{:href => "/ontologies/new"}
%svg{:fill => "none", :height => "14", :viewbox => "0 0 15 14", :width => "15", :xmlns => "http://www.w3.org/2000/svg"}
%path{:d => "M3.46242 4.17686L6.91776 0.23682C6.98312 0.162278 7.06302 0.102677 7.15225 0.0618794C7.24149 0.0210821 7.33808 0 7.43576 0C7.53344 0 7.63003 0.0210821 7.71927 0.0618794C7.80851 0.102677 7.8884 0.162278 7.95377 0.23682L11.4092 4.17686C11.533 4.31795 11.5971 4.50373 11.5874 4.69334C11.5777 4.88295 11.4951 5.06086 11.3577 5.18792C11.2204 5.31498 11.0395 5.38079 10.8548 5.37087C10.6702 5.36095 10.497 5.27612 10.3732 5.13503L8.13286 2.58055V10.4116C8.13286 10.6015 8.05942 10.7836 7.92869 10.9178C7.79796 11.0521 7.62065 11.1275 7.43576 11.1275C7.25088 11.1275 7.07357 11.0521 6.94284 10.9178C6.8121 10.7836 6.73866 10.6015 6.73866 10.4116V2.58058L4.49846 5.13512C4.43719 5.20498 4.36313 5.26177 4.28049 5.30223C4.19785 5.3427 4.10826 5.36605 4.01684 5.37096C3.92541 5.37587 3.83394 5.36223 3.74764 5.33084C3.66135 5.29944 3.58192 5.2509 3.51389 5.18798C3.44586 5.12506 3.39057 5.04899 3.35117 4.96413C3.31176 4.87926 3.28902 4.78726 3.28425 4.69337C3.27947 4.59948 3.29274 4.50554 3.32331 4.41692C3.35388 4.32829 3.40115 4.24672 3.46242 4.17686ZM14.1744 12.488H0.697103C0.51222 12.488 0.334909 12.5635 0.204177 12.6977C0.0734445 12.832 0 13.0141 0 13.2039C0 13.3938 0.0734445 13.5759 0.204177 13.7101C0.334909 13.8444 0.51222 13.9198 0.697103 13.9198H14.1744C14.3593 13.9198 14.5366 13.8444 14.6673 13.7101C14.7981 13.5759 14.8715 13.3938 14.8715 13.2039C14.8715 13.0141 14.7981 12.832 14.6673 12.6977C14.5366 12.5635 14.3593 12.488 14.1744 12.488Z", :fill => "#31B404"}
Submit new ontology
.browse-submit-new-ontology-and-you-are-admin-container
- if session[:user].nil?
%a.browse-upload-ontology-button{:href => "/login?redirect=/ontologies/new"}
%svg{:fill => "none", :height => "14", :viewbox => "0 0 15 14", :width => "15", :xmlns => "http://www.w3.org/2000/svg"}
%path{:d => "M3.46242 4.17686L6.91776 0.23682C6.98312 0.162278 7.06302 0.102677 7.15225 0.0618794C7.24149 0.0210821 7.33808 0 7.43576 0C7.53344 0 7.63003 0.0210821 7.71927 0.0618794C7.80851 0.102677 7.8884 0.162278 7.95377 0.23682L11.4092 4.17686C11.533 4.31795 11.5971 4.50373 11.5874 4.69334C11.5777 4.88295 11.4951 5.06086 11.3577 5.18792C11.2204 5.31498 11.0395 5.38079 10.8548 5.37087C10.6702 5.36095 10.497 5.27612 10.3732 5.13503L8.13286 2.58055V10.4116C8.13286 10.6015 8.05942 10.7836 7.92869 10.9178C7.79796 11.0521 7.62065 11.1275 7.43576 11.1275C7.25088 11.1275 7.07357 11.0521 6.94284 10.9178C6.8121 10.7836 6.73866 10.6015 6.73866 10.4116V2.58058L4.49846 5.13512C4.43719 5.20498 4.36313 5.26177 4.28049 5.30223C4.19785 5.3427 4.10826 5.36605 4.01684 5.37096C3.92541 5.37587 3.83394 5.36223 3.74764 5.33084C3.66135 5.29944 3.58192 5.2509 3.51389 5.18798C3.44586 5.12506 3.39057 5.04899 3.35117 4.96413C3.31176 4.87926 3.28902 4.78726 3.28425 4.69337C3.27947 4.59948 3.29274 4.50554 3.32331 4.41692C3.35388 4.32829 3.40115 4.24672 3.46242 4.17686ZM14.1744 12.488H0.697103C0.51222 12.488 0.334909 12.5635 0.204177 12.6977C0.0734445 12.832 0 13.0141 0 13.2039C0 13.3938 0.0734445 13.5759 0.204177 13.7101C0.334909 13.8444 0.51222 13.9198 0.697103 13.9198H14.1744C14.3593 13.9198 14.5366 13.8444 14.6673 13.7101C14.7981 13.5759 14.8715 13.3938 14.8715 13.2039C14.8715 13.0141 14.7981 12.832 14.6673 12.6977C14.5366 12.5635 14.3593 12.488 14.1744 12.488Z", :fill => "#31B404"}
Submit new ontology
- else
%a.browse-upload-ontology-button{:href => "/ontologies/new"}
%svg{:fill => "none", :height => "14", :viewbox => "0 0 15 14", :width => "15", :xmlns => "http://www.w3.org/2000/svg"}
%path{:d => "M3.46242 4.17686L6.91776 0.23682C6.98312 0.162278 7.06302 0.102677 7.15225 0.0618794C7.24149 0.0210821 7.33808 0 7.43576 0C7.53344 0 7.63003 0.0210821 7.71927 0.0618794C7.80851 0.102677 7.8884 0.162278 7.95377 0.23682L11.4092 4.17686C11.533 4.31795 11.5971 4.50373 11.5874 4.69334C11.5777 4.88295 11.4951 5.06086 11.3577 5.18792C11.2204 5.31498 11.0395 5.38079 10.8548 5.37087C10.6702 5.36095 10.497 5.27612 10.3732 5.13503L8.13286 2.58055V10.4116C8.13286 10.6015 8.05942 10.7836 7.92869 10.9178C7.79796 11.0521 7.62065 11.1275 7.43576 11.1275C7.25088 11.1275 7.07357 11.0521 6.94284 10.9178C6.8121 10.7836 6.73866 10.6015 6.73866 10.4116V2.58058L4.49846 5.13512C4.43719 5.20498 4.36313 5.26177 4.28049 5.30223C4.19785 5.3427 4.10826 5.36605 4.01684 5.37096C3.92541 5.37587 3.83394 5.36223 3.74764 5.33084C3.66135 5.29944 3.58192 5.2509 3.51389 5.18798C3.44586 5.12506 3.39057 5.04899 3.35117 4.96413C3.31176 4.87926 3.28902 4.78726 3.28425 4.69337C3.27947 4.59948 3.29274 4.50554 3.32331 4.41692C3.35388 4.32829 3.40115 4.24672 3.46242 4.17686ZM14.1744 12.488H0.697103C0.51222 12.488 0.334909 12.5635 0.204177 12.6977C0.0734445 12.832 0 13.0141 0 13.2039C0 13.3938 0.0734445 13.5759 0.204177 13.7101C0.334909 13.8444 0.51222 13.9198 0.697103 13.9198H14.1744C14.3593 13.9198 14.5366 13.8444 14.6673 13.7101C14.7981 13.5759 14.8715 13.3938 14.8715 13.2039C14.8715 13.0141 14.7981 12.832 14.6673 12.6977C14.5366 12.5635 14.3593 12.488 14.1744 12.488Z", :fill => "#31B404"}
Submit new ontology
- if session[:user]&.admin?
.browse-you-are-admin
%h3 Welcome admin
%div
%svg{:fill => "none", :height => "11", :viewbox => "0 0 11 11", :width => "11", :xmlns => "http://www.w3.org/2000/svg"}
%circle{:cx => "5.5", :cy => "5.5", :fill => "#145FF4", :r => "5.5"}
%p This coloring indicates admin-only features

%div{data: { controller: "turbo-frame history browse-filters" , "turbo-frame-url-value": "/ontologies_filter", action: "change->browse-filters#dispatchFilterEvent changed->history#updateURL changed->turbo-frame#updateFrame"}}
.browse-search-bar
.browse-search-container
Expand All @@ -31,10 +42,7 @@
%option{:value => "Upload date"} Upload date
%option{:value => "Release date"} Release date
%option{:value => "FAIR"} FAIR
%br
%br
%br
%br/

.browse-sub-container
.browse-first-row{data:{controller: "browse-filters", action: "change->browse-filters#dispatchFilterEvent changed->history#updateURL changed->turbo-frame#updateFrame"}}
%p.browse-filters-title Filters
Expand All @@ -45,18 +53,20 @@
Show retired ontologies

- @filters.each do |key, values|
.browse-filter{data:{controller: "show-filter-count browse-filters", action: "change->show-filter-count#updateCount change->browse-filters#dispatchFilterEvent"}, id: "#{key}_filter_container" }
.browse-filter-title-bar{"data-target" => "#browse-#{key}-filter", "data-toggle" => "collapse"}
%p
#{key.to_s.underscore.humanize.capitalize}
%span.badge.badge-secondary{"data-show-filter-count-target":"countSpan", style: "#{values[2] && values[2].positive? ? '' : 'display: none;'}"}
= values[2]
%img{:src => "#{asset_path("arrow-down.svg")}"}/
.collapse{id: "browse-#{key}-filter", class: "#{values[2].positive? ? 'show': ''}"}
.browse-filter-checks-container
- values.first.each do |object|
%div
= render ChipsComponent.new(name: object["acronym"], value: object["name"] || object["id"], checked: values[1]&.include?(object["id"]))
- if session[:user]&.admin? || key != :missingStatus
.browse-filter{data:{controller: "show-filter-count browse-filters", action: "change->show-filter-count#updateCount change->browse-filters#dispatchFilterEvent"}, id: "#{key}_filter_container", style: "#{"border-color: #145FF4;" if key == :missingStatus}"}
.browse-filter-title-bar{"data-target" => "#browse-#{key}-filter", "data-toggle" => "collapse"}
%p
#{key.to_s.underscore.humanize.capitalize}
%span.badge.badge-secondary{"data-show-filter-count-target":"countSpan", style: "#{values[2] && values[2].positive? ? '' : 'display: none;'}"}
= values[2]
%img{:src => "#{asset_path("arrow-down.svg")}"}/
.collapse{id: "browse-#{key}-filter", class: "#{values[2].positive? ? 'show': ''}"}
.browse-filter-checks-container
- values.first.each do |object|
%div
= render ChipsComponent.new(name: object["acronym"], value: object["name"] || object["id"], checked: values[1]&.include?(object["id"]))



.browse-second-row
Expand Down

0 comments on commit c04b47c

Please sign in to comment.