diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/sip_accounts_controller.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index 7bb2689..8e88405 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -6,7 +6,13 @@ class SipAccountsController < ApplicationController before_filter :set_and_authorize_parent before_filter :spread_breadcrumbs + helper_method :sort_column, :sort_descending + def index + @sip_accounts = @parent.sip_accounts.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( + :page => @pagination_page_number, + :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') + ) end def show @@ -110,4 +116,12 @@ class SipAccountsController < ApplicationController @possible_voicemail_accounts = @possible_voicemail_accounts + @sip_account.sip_accountable.voicemail_accounts end + def sort_descending + params[:desc].to_s == 'true' + end + + def sort_column + SipAccount.column_names.include?(params[:sort]) ? params[:sort] : 'id' + end + end |