diff options
author | Peter Kozak <spag@golwen.net> | 2013-06-13 11:21:07 +0200 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-06-13 11:21:07 +0200 |
commit | 525aaf6dcb5bafe5a949a078dee6abb24d87e2a5 (patch) | |
tree | d1e1ee41188b28d1ae07a2015b84c057fb7dfdad /app | |
parent | 06feae4f6303ab9b08eceea5a051ddba3fc5f911 (diff) |
display tenant and user sip_accounts combined
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/sip_accounts_controller.rb | 15 | ||||
-rw-r--r-- | app/views/sip_accounts/_index_core.html.haml | 5 | ||||
-rw-r--r-- | app/views/sip_accounts/index.html.haml | 2 | ||||
-rw-r--r-- | app/views/tenants/_table_of_sip_accounts.html.haml | 7 |
4 files changed, 21 insertions, 8 deletions
diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index 32d1210..cd34953 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -9,10 +9,17 @@ class SipAccountsController < ApplicationController helper_method :sort_column, :sort_descending def index - @sip_accounts = @parent.sip_accounts.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( - :page => params[:page], - :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') - ) + if @parent.class == Tenant + @sip_accounts = @parent.tenant_user_sip_accounts.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( + :page => params[:page], + :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') + ) + else + @sip_accounts = @parent.sip_accounts.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/sip_accounts/_index_core.html.haml b/app/views/sip_accounts/_index_core.html.haml index d91a3ef..be1f4cb 100644 --- a/app/views/sip_accounts/_index_core.html.haml +++ b/app/views/sip_accounts/_index_core.html.haml @@ -5,6 +5,8 @@ %table.table.table-striped %thead %tr + - if defined?(show_sip_accountable) && show_sip_accountable + %th= sortable :sip_accountable_id, t('sip_accounts.index.sip_accountable') %th %span.hidden-phone = t('sip_accounts.index.online') @@ -20,6 +22,9 @@ %tbody - for sip_account in sip_accounts %tr{:class => (sip_account.registration ? '' : 'warning')} + - if defined?(show_sip_accountable) && show_sip_accountable + %td + = sip_account.sip_accountable %td - if sip_account.registration %i.icon-ok diff --git a/app/views/sip_accounts/index.html.haml b/app/views/sip_accounts/index.html.haml index fbdba48..114943e 100644 --- a/app/views/sip_accounts/index.html.haml +++ b/app/views/sip_accounts/index.html.haml @@ -1,6 +1,6 @@ - content_for :title, t("sip_accounts.index.page_title") - if @sip_accounts.count > 0 - = render "index_core", :sip_accounts => @sip_accounts + = render "index_core", :sip_accounts => @sip_accounts, :show_sip_accountable => (@parent.class == Tenant) = render :partial => 'shared/create_link', :locals => {:parent => @parent, :child_class => SipAccount}
\ No newline at end of file diff --git a/app/views/tenants/_table_of_sip_accounts.html.haml b/app/views/tenants/_table_of_sip_accounts.html.haml index e0acbc2..4a1d570 100644 --- a/app/views/tenants/_table_of_sip_accounts.html.haml +++ b/app/views/tenants/_table_of_sip_accounts.html.haml @@ -5,7 +5,7 @@ -# %h2= t('sip_accounts.index.page_title') - if tenant.sip_accounts.any? - = render "sip_accounts/index_core", :sip_accounts => tenant.sip_accounts + = render "sip_accounts/index_core", :sip_accounts => tenant.sip_accounts, :show_sip_accountable => true = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => SipAccount} .span8 @@ -18,9 +18,10 @@ .span12 -# SIP accounts -# + - sip_accounts = @tenant.tenant_user_sip_accounts %h2= t('sip_accounts.index.page_title') - - if @tenant.sip_accounts.count <= GsParameter.get('NUMBER_OF_SHOWN_ITEMS') - = render "sip_accounts/index_core", :sip_accounts => tenant.sip_accounts + - if sip_accounts.count <= GsParameter.get('NUMBER_OF_SHOWN_ITEMS') + = render "sip_accounts/index_core", :sip_accounts => sip_accounts, :show_sip_accountable => true = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => SipAccount} - else %p |