From 866b58a54e95415ad74b8f004db40abb4343c753 Mon Sep 17 00:00:00 2001 From: Igor Date: Thu, 4 Apr 2019 16:28:56 +0000 Subject: Allow to sort wiki pages by date and title - Add controls for sorting by title and date - Execute Gitaly call which now accepts sorting params for wikis --- app/helpers/wiki_helper.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'app/helpers/wiki_helper.rb') diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb index 647f34e57ed..edd48f82729 100644 --- a/app/helpers/wiki_helper.rb +++ b/app/helpers/wiki_helper.rb @@ -47,4 +47,24 @@ module WikiHelper def wiki_attachment_upload_url expose_url(api_v4_projects_wikis_attachments_path(id: @project.id)) end + + def wiki_sort_controls(project, sort, direction) + sort ||= ProjectWiki::TITLE_ORDER + link_class = 'btn btn-default has-tooltip reverse-sort-btn qa-reverse-sort' + reversed_direction = direction == 'desc' ? 'asc' : 'desc' + icon_class = direction == 'desc' ? 'highest' : 'lowest' + + link_to(project_wikis_pages_path(project, sort: sort, direction: reversed_direction), + type: 'button', class: link_class, title: _('Sort direction')) do + sprite_icon("sort-#{icon_class}", size: 16) + end + end + + def wiki_sort_title(key) + if key == ProjectWiki::CREATED_AT_ORDER + s_("Wiki|Created date") + else + s_("Wiki|Title") + end + end end -- cgit v1.2.1