Merge pull request #1142 from okriuchykhin/ok_SCI_2411

Fix pagination in global search inside repositories [SCI-2411]
This commit is contained in:
okriuchykhin 2018-05-16 10:19:05 +02:00 committed by GitHub
commit 19ed711ce2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 4 deletions

View file

@ -154,6 +154,15 @@ class SearchController < ApplicationController
count_total
end
def current_repository_search_count
@repository_search_count.each_value do |counter|
res = counter[:repositories].values.detect do |rep|
rep[:id] == @repository.id
end
return res[:count]
end
end
def count_search_results
@project_search_count = fetch_cached_count Project
@experiment_search_count = fetch_cached_count Experiment
@ -265,7 +274,7 @@ class SearchController < ApplicationController
whole_word: @search_whole_word,
whole_phrase: @search_whole_phrase)
end
@search_count = @repository_search_count_total
@search_count = current_repository_search_count
end
def search_assets

View file

@ -298,23 +298,33 @@
<% end %>
<% if @search_pages > 1 %>
<% params = { q: @search_query,
category: @search_category,
utf8: '✓',
search_id: @search_id } %>
<% if @search_category == :repositories %>
<% params[:repository] = @repository.id %>
<% end %>
<nav class="text-center">
<ul class="pagination">
<% if @search_page > 1 %>
<% params[:page] = @search_page - 1 %>
<li>
<a href="?<%= {q: @search_query, category: @search_category, page: @search_page - 1, utf8: '✓'}.to_query %>" aria-label="Previous">
<a href="?<%= params.to_query %>" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
<% end %>
<% (@start_page..@end_page).each do |page_i| %>
<% params[:page] = page_i %>
<li <% if @search_page == page_i %>class="active"<% end %>>
<a href="?<%= {q: @search_query, category: @search_category, page: page_i, utf8: '✓'}.to_query %>"><%= page_i %></a>
<a href="?<%= params.to_query %>"><%= page_i %></a>
</li>
<% end %>
<% if @search_page < @search_pages %>
<% params[:page] = @search_page + 1 %>
<li>
<a href="?<%= {q: @search_query, category: @search_category, page: @search_page + 1, utf8: '✓'}.to_query %>" aria-label="Previous">
<a href="?<%= params.to_query %>" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>

View file

@ -20,6 +20,7 @@
<%=t "search.index.repositories.added_by" %>
<%= highlight repository_row.created_by.full_name, search_query.strip.split(/\s+/) %>
</span>
<br>
<% repository_row.repository_cells.each do |cell| %>
<span>
<%=t "search.index.repositories.custom_column", column: cell.repository_column.name %>