0a6345c60b
This commit implements the sort functionality for the user lists (by name, email, last_activity) and ordergroup lists (by name). It is a first attempt addressing issue #560.
19 lines
623 B
Ruby
19 lines
623 B
Ruby
class Foodcoop::UsersController < ApplicationController
|
|
def index
|
|
@users = User.undeleted.sort_by_param(params["sort"])
|
|
|
|
# if somebody uses the search field:
|
|
@users = @users.natural_search(params[:user_name]) unless params[:user_name].blank?
|
|
|
|
if params[:ordergroup_name]
|
|
@users = @users.joins(:groups).where("groups.type = 'Ordergroup' AND groups.name LIKE ?", "%#{params[:ordergroup_name]}%")
|
|
end
|
|
|
|
@users = @users.page(params[:page]).per(@per_page)
|
|
|
|
respond_to do |format|
|
|
format.html # index.html.haml
|
|
format.js { render :layout => false } # index.js.erb
|
|
end
|
|
end
|
|
end
|