Merge pull request #145 from abf/rosa-build:136-ability-to-sort-users-by-created-date
[refs #136]: Ability to sort users by created date in admin page
This commit is contained in:
commit
53df444d20
|
@ -58,13 +58,13 @@ class Admin::UsersController < Admin::BaseController
|
|||
|
||||
def list
|
||||
if params[:system] != 'true'
|
||||
colName, @users = ['users.name', 'users.uname', 'users.email'], @users.opened
|
||||
colName, @users = %w(name uname email created_at), @users.opened
|
||||
else
|
||||
colName, @users, @system_list = ['users.uname'], @users.system, true
|
||||
colName, @users, @system_list = ['uname'], @users.system, true
|
||||
end
|
||||
sort_col = params[:iSortCol_0] || 0
|
||||
sort_dir = params[:sSortDir_0]=="asc" ? 'asc' : 'desc'
|
||||
order = "#{colName[sort_col.to_i]} #{sort_dir}"
|
||||
order = "users.#{colName[sort_col.to_i]} #{sort_dir}"
|
||||
|
||||
@users = @users.paginate(:page => (params[:iDisplayStart].to_i/params[:iDisplayLength].to_i).to_i + 1, :per_page => params[:iDisplayLength])
|
||||
@total_users = @users.count
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
users = @users.map do |user|
|
||||
link_block = [
|
||||
(link_to t('layout.show'), user if can?(:read, user) && !@system_list),
|
||||
(link_to t('layout.edit'), edit_admin_user_path(user) if can?(:edit, user) && !@system_list),
|
||||
(link_to t('layout.users.reset_token'), reset_auth_token_admin_user_path(user), :method => :put, :confirm => t('layout.users.confirm_reset_token') if can?(:edit, user) && @system_list),
|
||||
(link_to t('layout.delete'), admin_user_path(user), :method => :delete, :confirm => t('layout.users.confirm_delete') if can? :destroy, user)
|
||||
|
@ -9,8 +8,9 @@ users = @users.map do |user|
|
|||
if !@system_list
|
||||
[
|
||||
user.name,
|
||||
user.uname,
|
||||
(can?(:read, user) ? link_to(user.uname, user) : user.uname),
|
||||
user.email,
|
||||
user.created_at.to_date,
|
||||
content_tag(:span, user.role, :style => user.access_locked? ? 'background: #FEDEDE' : ''),
|
||||
link_block
|
||||
]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
-if @filter == 'system'
|
||||
- columns = [{:type => 'html'}, {:type => nil, :sortable => false, :searchable => false, :class => 'buttons'}]
|
||||
-else
|
||||
- columns = [{:type => 'html'}, {:type => 'html'}, {:type => 'html'}, {:type => 'html', :sortable => false, :searchable => false}, {:type => nil, :sortable => false, :searchable => false, :class => 'buttons'}]
|
||||
- columns = [{:type => 'html'}, {:type => 'html'}, {:type => 'html'}, {:type => 'html'}, {:type => 'html', :sortable => false, :searchable => false}, {:type => nil, :sortable => false, :searchable => false, :class => 'buttons'}]
|
||||
= raw datatable(columns, {:sort_by => "[0, 'asc']", :processing => t("layout.processing"), :search_label => t("layout.search.header"),
|
||||
:pagination_labels => {:previous => t("datatables.previous_label"), :next => t("datatables.next_label")},
|
||||
:empty_label => t("datatables.empty_label"),
|
||||
|
@ -23,6 +23,7 @@
|
|||
%th.th1= t("activerecord.attributes.user.name")
|
||||
%th.th2= t("activerecord.attributes.user.uname")
|
||||
%th.th3= t("activerecord.attributes.user.email")
|
||||
%th.th1= t("activerecord.attributes.user.created_at")
|
||||
%th.th4= t("activerecord.attributes.user.role")
|
||||
%th.last
|
||||
%tbody
|
||||
|
|
Loading…
Reference in New Issue