-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 issue#2445 added both direction sort order #2557
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,12 @@ def index | |
|
||
@title = I18n.t('tag_controller.tags') | ||
@paginated = true | ||
|
||
order_string = "count DESC" | ||
if params[:order] == "asc" | ||
order_string = "count ASC" | ||
end | ||
|
||
if params[:search] | ||
prefix = params[:search] | ||
@tags = Tag.joins(:node_tag, :node) | ||
|
@@ -19,31 +25,39 @@ def index | |
.where('community_tags.date > ?', (DateTime.now - 1.month).to_i) | ||
.where("name LIKE :prefix", prefix: "#{prefix}%") | ||
.group(:name) | ||
.order('count DESC') | ||
.order(order_string) | ||
.paginate(page: params[:page], per_page: 24) | ||
elsif @toggle == "uses" | ||
@tags = Tag.joins(:node_tag, :node) | ||
.select('node.nid, node.status, term_data.*, community_tags.*') | ||
.where('node.status = ?', 1) | ||
.where('community_tags.date > ?', (DateTime.now - 1.month).to_i) | ||
.group(:name) | ||
.order('count DESC') | ||
.order(order_string) | ||
.paginate(page: params[:page], per_page: 24) | ||
elsif @toggle == "name" | ||
order_string = "name DESC" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, if you do what I was saying, creating a function for defining |
||
if params[:order] == "asc" | ||
order_string = "name ASC" | ||
end | ||
@tags = Tag.joins(:node_tag, :node) | ||
.select('node.nid, node.status, term_data.*, community_tags.*') | ||
.where('node.status = ?', 1) | ||
.where('community_tags.date > ?', (DateTime.now - 1.month).to_i) | ||
.group(:name) | ||
.order('name') | ||
.order(order_string) | ||
.paginate(page: params[:page], per_page: 24) | ||
else | ||
order_string = "name DESC" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
if params[:order] == "asc" | ||
order_string = "name ASC" | ||
end | ||
tags = Tag.joins(:node_tag, :node) | ||
.select('node.nid, node.status, term_data.*, community_tags.*') | ||
.where('node.status = ?', 1) | ||
.where('community_tags.date > ?', (DateTime.now - 1.month).to_i) | ||
.group(:name) | ||
.order('name') | ||
.order(order_string) | ||
|
||
followed = [] | ||
not_followed = [] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,12 @@ | |
|
||
<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> | ||
<% order_type = "desc" %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we set |
||
<% if params[:order] == "desc" %> | ||
<% order_type = "asc" %> | ||
<% end %> | ||
<th><a href = "<%= tags_path %>?sort=name&order=<%= order_type %>"><%= t('tag.index.tag') %></a> <i class="fa fa-arrows-v"></i></th> | ||
<th><a href = "<%= tags_path %>?sort=uses&order=<%= order_type %>"><%= t('tag.index.number_of_uses') %></a> <i class="fa fa-arrows-v"></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> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put this into a private method within the controller. e.g.