diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2012-12-28 19:32:51 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2012-12-28 19:32:51 +0100 |
commit | a945a74ae1d0fbafb79c1f36f5cb3ec59970c6fe (patch) | |
tree | 6107e30015715160fa4a7e35d5fd0761631dc864 /app | |
parent | b2e5168b917202ebd71f3032f125691ef1fd062f (diff) | |
parent | 3b07751150c0cd70eee4e750dd7a3670120a8675 (diff) |
Merge branch 'show_fallback_sip_account' into develop
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/application.js | 1 | ||||
-rw-r--r-- | app/assets/javascripts/phones.js.coffee | 5 | ||||
-rw-r--r-- | app/controllers/phones_controller.rb | 6 | ||||
-rw-r--r-- | app/views/layouts/application.html.haml | 1 | ||||
-rw-r--r-- | app/views/phones/_form_core.html.haml | 8 | ||||
-rw-r--r-- | app/views/phones/show.html.haml | 14 |
6 files changed, 22 insertions, 13 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 2e0b0d8..1762043 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -10,4 +10,5 @@ //= require vendor/modernizr-2.0.6.min.js //= require vendor/jquery.condom.js //= require vendor/jquery.survival-kit +//= require phones //= require softkeys diff --git a/app/assets/javascripts/phones.js.coffee b/app/assets/javascripts/phones.js.coffee new file mode 100644 index 0000000..ff54777 --- /dev/null +++ b/app/assets/javascripts/phones.js.coffee @@ -0,0 +1,5 @@ +jQuery -> + $(".fallback_sip_account_dropdown").hide() + + $("#phone_hot_deskable").change -> + $(".fallback_sip_account_dropdown").show("slow") diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb index b865cb1..b23a589 100644 --- a/app/controllers/phones_controller.rb +++ b/app/controllers/phones_controller.rb @@ -13,9 +13,11 @@ class PhonesController < ApplicationController end def new - used_sip_account_ids = Phone.where('fallback_sip_account_id IS NOT NULL').collect {|r| r.fallback_sip_account } - @fallback_sip_accounts = SipAccount.where('sip_accountable_type = "Tenant" AND id NOT IN (?)', used_sip_account_ids).all + used_sip_account_ids = Phone.where(:fallback_sip_account_id => SipAccount.pluck(:id)).pluck(:fallback_sip_account_id) + @fallback_sip_accounts = SipAccount.where(:sip_accountable_type => 'Tenant').where(:hotdeskable => true) - SipAccount.where(:id => used_sip_account_ids) + @phone = @phoneable.phones.build() + # Use the last phone.phone_model as the default. # @phone.phone_model_id = Phone.last.try(:phone_model).try(:id) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f2aff0a..8ab9039 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -20,7 +20,6 @@ %body #container = render :partial => "shared/header" - = render :partial => "shared/system_message" = render :partial => "shared/flash", :locals => { :flash => flash} #content{:role => 'main'} diff --git a/app/views/phones/_form_core.html.haml b/app/views/phones/_form_core.html.haml index 96e53e6..20ea054 100644 --- a/app/views/phones/_form_core.html.haml +++ b/app/views/phones/_form_core.html.haml @@ -1,8 +1,10 @@ .inputs = f.input :mac_address, :label => t('phones.form.mac_address.label'), :hint => conditional_hint('phones.form.mac_address.hint') - = f.association :phone_model, :label => t('phones.form.phone_model_id.label'), :hint => conditional_hint('phones.form.phone_model_id.hint') - = f.input :hot_deskable, :label => t('phones.form.hot_deskable.label'), :hint => conditional_hint('phones.form.hot_deskable.hint') - = f.association :fallback_sip_account, :collection => @fallback_sip_accounts, :label => t('phones.form.fallback_sip_account_id.label'), :hint => conditional_hint('phones.form.fallback_sip_account_id.hint'), :include_blank => true + = f.association :phone_model, :label => t('phones.form.phone_model_id.label'), :hint => conditional_hint('phones.form.phone_model_id.hint'), :include_blank => false + - if @fallback_sip_accounts.any? + = f.input :hot_deskable, :label => t('phones.form.hot_deskable.label'), :hint => conditional_hint('phones.form.hot_deskable.hint') + .fallback_sip_account_dropdown + = f.association :fallback_sip_account, :collection => @fallback_sip_accounts, :label => t('phones.form.fallback_sip_account_id.label'), :hint => conditional_hint('phones.form.fallback_sip_account_id.hint'), :include_blank => false - if defined? NIGHTLY_REBOOT_OF_PHONES && NIGHTLY_REBOOT_OF_PHONES == true = f.input :nightly_reboot, :label => t('phones.form.nightly_reboot.label'), :hint => conditional_hint('phones.form.nightly_reboot.hint') - if defined? PROVISIONING_KEY_LENGTH && PROVISIONING_KEY_LENGTH > 0 diff --git a/app/views/phones/show.html.haml b/app/views/phones/show.html.haml index 7629fb9..090323e 100644 --- a/app/views/phones/show.html.haml +++ b/app/views/phones/show.html.haml @@ -6,13 +6,13 @@ %p %strong= t('phones.show.phone_model_id') + ":" = @phone.phone_model -%p - %strong= t('phones.show.hot_deskable') + ":" - = @phone.hot_deskable - -%p - %strong= t('phones.show.fallback_sip_account_id') + ":" - = @phone.fallback_sip_account +- if @phone.hot_deskable == true + %p + %strong= t('phones.show.hot_deskable') + ":" + = @phone.hot_deskable + %p + %strong= t('phones.show.fallback_sip_account_id') + ":" + = @phone.fallback_sip_account - if defined? NIGHTLY_REBOOT_OF_PHONES && NIGHTLY_REBOOT_OF_PHONES == true %p |