summaryrefslogtreecommitdiff
path: root/app/controllers/sip_accounts_controller.rb
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-04-29 15:40:37 +0200
committerPeter Kozak <spag@golwen.net>2013-04-29 15:40:37 +0200
commit265c6e89e46be414cac6e8a33b35591282cb0ae9 (patch)
tree608b0f52a5c3cc6524df53f73e5d4ccc41b5421e /app/controllers/sip_accounts_controller.rb
parentf7ecf4866953cbfb0bc2a092b8547192f2943242 (diff)
sorting and paginations
Diffstat (limited to 'app/controllers/sip_accounts_controller.rb')
-rw-r--r--app/controllers/sip_accounts_controller.rb14
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