diff options
author | Igor <idrozdov@gitlab.com> | 2019-04-04 16:28:56 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2019-04-04 16:28:56 +0000 |
commit | 866b58a54e95415ad74b8f004db40abb4343c753 (patch) | |
tree | ed7436c916e4d3db48c255267255e9bbc4fbaa22 /app/helpers/wiki_helper.rb | |
parent | 8647230fa509cbba8e1853aae500315bf1116005 (diff) | |
download | gitlab-ce-866b58a54e95415ad74b8f004db40abb4343c753.tar.gz |
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
Diffstat (limited to 'app/helpers/wiki_helper.rb')
-rw-r--r-- | app/helpers/wiki_helper.rb | 20 |
1 files changed, 20 insertions, 0 deletions
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 |