Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search tabs #885

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/content_providers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
disabled: { check: events_count.zero?, message: 'No associated events' },
count: events_count) %>

<% if TeSS::Config.feature['user_source_creation'] && policy(@content_provider).update? %>
<% if TeSS::Config.feature['sources'] && policy(@content_provider).update? %>
<%= tab('Sources', icon_class_for_model('sources'), 'sources', count: sources.count, activator: activator) %>
<% end %>
</ul>
Expand Down
11 changes: 5 additions & 6 deletions app/views/search/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@
<p class="empty">No results found</p>
<% else %>
<% tabs = @results.keys.sort_by { |k| TeSS::Config.site['tab_order'].index(k.to_s) || 99 } %>
<% activator = tab_activator %>
<ul class="nav nav-tabs">
<% tabs.each_with_index do |tab, index| %>
<li class="<%= index == 0 ? 'active' : '' %>">
<a data-toggle="tab" href="#<%= tab %>"><i class="<%= icon_class_for_model(tab) %>"></i> <%= tab.to_s.humanize.capitalize %>
(<%= @results[tab].total %>)</a>
</li>
<% tabs.each do |tab| %>
<%= tab(tab.to_s.humanize.capitalize, icon_class_for_model(tab), tab, activator: activator,
disabled: { check: @results[tab].total.zero? }, count: @results[tab].total) %>
<% end %>
</ul>

<div class="tab-content">
<% @results.each do |model, results_for_model| %>
<div class="tab-pane fade in <%= 'active'.html_safe if model == tabs.first %>" id="<%= model %>">
<div class="tab-pane fade <%= 'in active'.html_safe if activator.check_pane(model) %>" id="<%= model %>">
<div class="search-results-count my-3">
Showing <%= pluralize(results_for_model.results.count, model.to_s.humanize.downcase.singularize) %>
<% if results_for_model.total > page_size %>
Expand Down