diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-06-20 19:06:19 +0200 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-06-20 19:06:19 +0200 |
commit | eb0e1cc5c26275ff3e5c341404e8bc558f8312b8 (patch) | |
tree | 71f449ccd6f15422717de3ac24f87d5e888ddd79 /app/controllers/phones_controller.rb | |
parent | df6e17e48995f25e72509986f30700d778b179b6 (diff) | |
parent | 3b27a5d45b12f6bac65da2a8e17387bfda42a2f1 (diff) |
Merge branch 'develop'
Diffstat (limited to 'app/controllers/phones_controller.rb')
-rw-r--r-- | app/controllers/phones_controller.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb index 3672390..77e7b5e 100644 --- a/app/controllers/phones_controller.rb +++ b/app/controllers/phones_controller.rb @@ -6,7 +6,20 @@ class PhonesController < ApplicationController before_filter :set_and_authorize_parent before_filter :spread_breadcrumbs + helper_method :sort_column, :sort_descending + def index + if @parent.class == Tenant + @phones = @parent.tenant_user_phones.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( + :page => params[:page], + :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') + ) + else + @phones = @parent.phones.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( + :page => params[:page], + :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') + ) + end end def show @@ -85,5 +98,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 |