[refs #818] refactoring part4
This commit is contained in:
parent
be095223e4
commit
182a90af4a
|
@ -9,8 +9,7 @@ class Admin::UsersController < Admin::BaseController
|
|||
end
|
||||
|
||||
def system
|
||||
@users = @users.system
|
||||
@filter = 'system'
|
||||
@users, @filter = @users.system, 'system'
|
||||
render :index
|
||||
end
|
||||
|
||||
|
@ -58,10 +57,10 @@ class Admin::UsersController < Admin::BaseController
|
|||
end
|
||||
|
||||
def list
|
||||
if action_name == 'list'
|
||||
if params[:system] != 'true'
|
||||
colName, @users = ['users.name', 'users.uname', 'users.email'], @users.opened
|
||||
else # system_list
|
||||
colName, @users = ['users.uname'], @users.system
|
||||
else
|
||||
colName, @users, @system_list = ['users.uname'], @users.system, true
|
||||
end
|
||||
sort_col = params[:iSortCol_0] || 0
|
||||
sort_dir = params[:sSortDir_0]=="asc" ? 'asc' : 'desc'
|
||||
|
@ -79,10 +78,6 @@ class Admin::UsersController < Admin::BaseController
|
|||
render :partial => 'users_ajax', :layout => false
|
||||
end
|
||||
|
||||
def system_list
|
||||
list
|
||||
end
|
||||
|
||||
def reset_auth_token
|
||||
@user.reset_authentication_token!
|
||||
flash[:notice] = t("flash.user.reset_auth_token")
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
users = @users.map do |user|
|
||||
link_block = [
|
||||
(link_to t('layout.show'), user if can?(:read, user) && action_name == 'list'),
|
||||
(link_to t('layout.edit'), edit_admin_user_path(user) if can?(:edit, user) && action_name == '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) && action_name == 'system_list'),
|
||||
(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)
|
||||
].compact.join(' | ').html_safe
|
||||
|
||||
if action_name == 'list'
|
||||
if !@system_list
|
||||
[
|
||||
user.name,
|
||||
user.uname,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
:filtered_label => t("datatables.filtered_label"),
|
||||
:table_dom_id => 'datatable',
|
||||
:auto_width => 'false',
|
||||
:ajax_source => "#{url_for :controller => 'admin/users', :action => @filter == 'system' ? :system_list : :list}",
|
||||
:ajax_source => "#{url_for :controller => 'admin/users', :action => :list, :system => (@filter == 'system')}",
|
||||
:additional_data => {:filter => "' + $('#users_filter[type=\"radio\"]:checked').val() + '"} })
|
||||
|
||||
%table#datatable.tablesorter.list-users{:cellspacing => 0, :cellpadding => 0}
|
||||
|
|
|
@ -98,7 +98,6 @@ Rosa::Application.routes.draw do
|
|||
collection do
|
||||
get :list
|
||||
get :system
|
||||
get :system_list
|
||||
end
|
||||
put :reset_auth_token, :on => :member
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue