summaryrefslogtreecommitdiff
path: root/app/controllers/phones_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/phones_controller.rb')
-rw-r--r--app/controllers/phones_controller.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb
index 3672390..cfa6d7b 100644
--- a/app/controllers/phones_controller.rb
+++ b/app/controllers/phones_controller.rb
@@ -6,7 +6,13 @@ class PhonesController < ApplicationController
before_filter :set_and_authorize_parent
before_filter :spread_breadcrumbs
+ helper_method :sort_column, :sort_descending
+
def index
+ @phones = @parent.phones.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate(
+ :page => params[:page],
+ :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE')
+ )
end
def show
@@ -85,5 +91,13 @@ class PhonesController < ApplicationController
end
@fallback_sip_accounts = SipAccount.where(:sip_accountable_type => 'Tenant') - SipAccount.where(:id => used_sip_account_ids)
end
+
+ def sort_descending
+ params[:desc].to_s == 'true'
+ end
+
+ def sort_column
+ Phone.column_names.include?(params[:sort]) ? params[:sort] : 'id'
+ end
end