diff options
-rw-r--r-- | app/controllers/phones_controller.rb | 15 | ||||
-rw-r--r-- | app/views/phones/_index_core.html.haml | 5 | ||||
-rw-r--r-- | app/views/phones/index.html.haml | 2 | ||||
-rw-r--r-- | app/views/tenants/_table_of_phones.html.haml | 7 |
4 files changed, 21 insertions, 8 deletions
diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb index cfa6d7b..77e7b5e 100644 --- a/app/controllers/phones_controller.rb +++ b/app/controllers/phones_controller.rb @@ -9,10 +9,17 @@ class PhonesController < ApplicationController 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') - ) + 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 diff --git a/app/views/phones/_index_core.html.haml b/app/views/phones/_index_core.html.haml index a77395c..175aeb0 100644 --- a/app/views/phones/_index_core.html.haml +++ b/app/views/phones/_index_core.html.haml @@ -4,6 +4,8 @@ %table.table.table-striped %thead %tr + - if defined?(show_phoneable) && show_phoneable + %th= sortable :phoneable_id, t('phones.index.phoneable') %th= sortable :mac_address, t('phones.index.mac_address') %th %span.hidden-phone @@ -20,6 +22,9 @@ %tbody - for phone in phones %tr{:class => (phone.ip_address.blank? ? 'warning' : '')} + - if defined?(show_phoneable) && show_phoneable + %td + = phone.phoneable %td= phone.pretty_mac_address %td= phone.phone_model %td diff --git a/app/views/phones/index.html.haml b/app/views/phones/index.html.haml index 4de7919..8e61706 100644 --- a/app/views/phones/index.html.haml +++ b/app/views/phones/index.html.haml @@ -1,6 +1,6 @@ - content_for :title, t("phones.index.page_title") - if @phones.count > 0 - = render "index_core", :phones => @phones + = render "index_core", :phones => @phones, :show_phoneable => (@parent.class == Tenant) = render :partial => 'shared/create_link', :locals => {:parent => @parent, :child_class => Phone}
\ No newline at end of file diff --git a/app/views/tenants/_table_of_phones.html.haml b/app/views/tenants/_table_of_phones.html.haml index 820afc7..9736ece 100644 --- a/app/views/tenants/_table_of_phones.html.haml +++ b/app/views/tenants/_table_of_phones.html.haml @@ -1,9 +1,10 @@ -- cache(['tenant_show_table_of_phones', I18n.locale, tenant, tenant.phones.count, tenant.phones.reorder(:updated_at).last]) do +- phones = @tenant.tenant_user_phones +- cache(['tenant_show_table_of_phones', I18n.locale, tenant, phones.count, phones.reorder(:updated_at).last]) do -# Phones -# %h2= t('phones.index.page_title') - - if @tenant.phones.count <= GsParameter.get('NUMBER_OF_SHOWN_ITEMS') - = render "phones/index_core", :phones => tenant.phones + - if phones.count <= GsParameter.get('NUMBER_OF_SHOWN_ITEMS') + = render "phones/index_core", :phones => phones, :show_phoneable => true = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Phone} - else %p |