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

Fixed first part of Issue #2352 Sorting headers added in wiki index page #2353

Merged
merged 2 commits into from
Jun 3, 2018
Merged
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
18 changes: 13 additions & 5 deletions app/controllers/wiki_controller.rb
Original file line number Diff line number Diff line change
@@ -306,11 +306,19 @@ def diff

def index
@title = I18n.t('wiki_controller.wiki')

order_string = if params[:order] == 'alphabetic'
'node_revisions.title ASC'
else
'node_revisions.timestamp DESC'
sort_param = params[:sort]
order_string = 'node_revisions.timestamp DESC'

if sort_param == 'title'
order_string = 'node_revisions.title ASC'
elsif sort_param == 'last_edited'
order_string = 'node_revisions.timestamp DESC'
elsif sort_param == 'edits'
order_string = 'drupal_node_revisions_count DESC'
elsif sort_param == 'page_views'
order_string = 'views DESC'
elsif sort_param == 'likes'
order_string = 'cached_likes DESC'
end

@wikis = Node.includes(:revision)
6 changes: 3 additions & 3 deletions app/views/tag/index.html.erb
Original file line number Diff line number Diff line change
@@ -21,11 +21,11 @@

<table class="table">
<tr>
<th><a href = "<%= tags_path %>?sort=name"><%= t('tag.index.tag') %></a> <i class="fa fa-arrows-v"></i></th>
<th><a href = "<%= tags_path %>?sort=uses"><%= t('tag.index.number_of_uses') %></a> <i class="fa fa-arrows-v"></i></th>
<th><a href = "<%= tags_path %>?sort=name"><%= t('tag.index.tag') %></a> <i class="fa fa-sort" aria-hidden="true"></i></th>
<th><a href = "<%= tags_path %>?sort=uses"><%= t('tag.index.number_of_uses') %></a> <i class="fa fa-sort" aria-hidden="true"></i></th>
<th><%= t('tag.index.number_of_subscriptions')%></th>
<% if current_user %>
<th><a href = "<%= tags_path %>?sort=subscribers"><%= t('tag.index.subscriptions') %></a> <i class="fa fa-arrows-v"></i></th>
<th><a href = "<%= tags_path %>?sort=subscribers"><%= t('tag.index.subscriptions') %></a> <i class="fa fa-sort" aria-hidden="true"></i></th>
<% end %>
</tr>
<% @tags.each do |tag| %>
7 changes: 5 additions & 2 deletions app/views/wiki/_wikis.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<table class="table">
<tr>
<%= raw t('wiki._wikis.table_content') %>
<th> <%= t('wiki._wikis.likes') %></th>
<th><a href = "<%= wiki_path %>?sort=title"> <%= t('wiki._wikis.title') %></a> <i class="fa fa-sort" aria-hidden="true"></i></th>
<th><a href = "<%= wiki_path %>?sort=last_edited"> <%= t('wiki._wikis.last_edited') %></a> <i class="fa fa-sort" aria-hidden="true"></i></th>
<th><a href = "<%= wiki_path %>?sort=edits"> <%= t('wiki._wikis.edits') %></a> <i class="fa fa-sort" aria-hidden="true"></i></th>
<th><a href = "<%= wiki_path %>?sort=page_views"> <%= t('wiki._wikis.page_views') %></a> <i class="fa fa-sort" aria-hidden="true"></i></th>
<th><a href = "<%= wiki_path %>?sort=likes"> <%= t('wiki._wikis.likes') %></a> <i class="fa fa-sort" aria-hidden="true"></i></th>
</tr>
<% @wikis.each do |wiki| %>
<tr>
31 changes: 1 addition & 30 deletions app/views/wiki/index.html.erb
Original file line number Diff line number Diff line change
@@ -22,40 +22,11 @@
<a style="margin-bottom:4px;" href="/wiki/new" class="btn btn-default">
<i class="fa fa-plus-circle"></i> <%= t('wiki.index.create_wiki_page') %>
</a>
<span style="margin-top:4px;" class="pull-right"> <%= t('wiki.index.sort_by') %>

<% if params[:action] == "index" && params[:order] !="alphabetic" %>
<span style="color:#aaa"><%= t('wiki.index.by_recency') %></span> |
<% else %>
<a href="/wiki/"><%= t('wiki.index.by_recency') %></a> |
<% end %>

<% if params[:order] == "alphabetic" %>
<span style="color:#aaa"><%= t('wiki.index.by_alphabetic') %></span> |
<% else %>
<a href="/wiki/?order=alphabetic"><%= t('wiki.index.by_alphabetic') %></a> |
<% end %>

<% if params[:action] == "liked" %>
<span style="color:#aaa"><%= t('wiki.index.by_number_of_likes') %></span> |
<% else %>
<a href="/wiki/liked"><%= t('wiki.index.by_number_of_likes') %></a> |
<% end %>


<% if params[:action] == "popular" %>
<span style="color:#aaa"><%= t('wiki.index.by_popularity') %></span>
<% else %>
<a href="/wiki/popular"><%= t('wiki.index.by_popularity') %></a>
<% end %>

</span>
</p>


<%= render :partial => "wiki/wikis" %>

<hr />

</div>

</div><!--/span-->
9 changes: 4 additions & 5 deletions config/locales/views/wiki/_wikis/en.yml
Original file line number Diff line number Diff line change
@@ -3,11 +3,10 @@
en:
wiki:
_wikis:
table_content: |
<th>Title</th>
<th>Last edited</th>
<th>Edits</th>
<th class="hidden-xs">Pageviews</th>
title: 'Title'
last_edited: 'Last edited'
edits: 'Edits'
page_views: 'Page Views'
likes: 'Likes'
by: 'by'