summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/call_forwards_controller.rb22
-rw-r--r--app/views/call_forwards/_form_core.html.haml13
2 files changed, 31 insertions, 4 deletions
diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb
index fe54b55..1721aa3 100644
--- a/app/controllers/call_forwards_controller.rb
+++ b/app/controllers/call_forwards_controller.rb
@@ -30,6 +30,7 @@ class CallForwardsController < ApplicationController
@call_forward.active = true
@call_forwarding_destinations = call_forwarding_destination_types()
@call_forward.destination = GsParameter.get('CALLFORWARD_DESTINATION_DEFAULT').to_s if defined?(GsParameter.get('CALLFORWARD_DESTINATION_DEFAULT'))
+ @destination_phone_number = @call_forward.destination
@available_call_forward_cases = []
CallForwardCase.all.each do |available_call_forward_case|
@@ -45,6 +46,8 @@ class CallForwardsController < ApplicationController
@call_forward.call_forward_case_id = CallForwardCase.find_by_value('noanswer').id
@call_forward.timeout = 45
end
+
+ @available_greetings = available_greetings()
end
def create
@@ -62,6 +65,8 @@ class CallForwardsController < ApplicationController
def edit
@available_call_forward_cases = CallForwardCase.all
@call_forwarding_destinations = call_forwarding_destination_types()
+ @available_greetings = available_greetings()
+ @destination_phone_number = @call_forward.destination if @call_forward.call_forwarding_destination == ':PhoneNumber'
end
def update
@@ -82,7 +87,6 @@ class CallForwardsController < ApplicationController
end
private
- private
def set_and_authorize_parent
@parent = @phone_number || @sip_account || @automatic_call_distributor || @hunt_group
authorize! :read, @parent
@@ -216,4 +220,20 @@ class CallForwardsController < ApplicationController
return call_forwarding_destinations
end
+ def available_greetings
+ if @parent.class == PhoneNumber
+ owner = @parent.phone_numberable
+ else
+ owner = @parent
+ end
+
+ if owner.class == SipAccount
+ owner = owner.sip_accountable
+ elsif owner.class == FaxAccount
+ owner = owner.fax_accountable
+ end
+
+ return GenericFile.where(:category => 'greeting', :owner_type => owner.class.to_s, :owner_id => owner.id).map {|x| [x.to_s, x.name] }
+ end
+
end
diff --git a/app/views/call_forwards/_form_core.html.haml b/app/views/call_forwards/_form_core.html.haml
index 83de044..b730941 100644
--- a/app/views/call_forwards/_form_core.html.haml
+++ b/app/views/call_forwards/_form_core.html.haml
@@ -1,11 +1,18 @@
.inputs
= f.input :call_forward_case_id, :as => :select, :collection => @available_call_forward_cases.map {|x| [I18n.t("call_forward_cases.#{x.value}"), x.id] }, :label => t('call_forwards.form.call_forward_case.label'), :hint => conditional_hint('call_forwards.form.call_forward_case_id.hint'), :include_blank => false, :autofocus => true
- = f.input :timeout, :label => t('call_forwards.form.timeout.label'), :hint => conditional_hint('call_forwards.form.timeout.hint')
+
+ %div{:id => 'timeout_div'}
+ = f.input :timeout, :label => t('call_forwards.form.timeout.label'), :hint => conditional_hint('call_forwards.form.timeout.hint')
= f.input :call_forwarding_destination , :as => :select, :collection => @call_forwarding_destinations, :label => t('call_forwards.form.call_forwarding_destination.label'), :hint => conditional_hint('call_forwards.form.call_forwarding_destination.hint'), :include_blank => false
- = f.input :destination, :label => t('call_forwards.form.destination.label'), :hint => conditional_hint('call_forwards.form.destination.hint')
+ %div{:id => 'destination_phone_number_div'}
+ = f.input :destination, :label => t('call_forwards.form.destination_phone_number.label'), :hint => conditional_hint('call_forwards.form.destination_phone_number.hint'), :input_html => { :id => 'destination_phone_number', :value => @destination_phone_number }
+ - if @available_greetings.any?
+ %div{:id => 'destination_greeting_div'}
+ = f.input :destination, :as => :select, :collection => @available_greetings, :label => t('call_forwards.form.destination_greeting.label'), :hint => conditional_hint('call_forwards.form.destination_greeting.hint'), :input_html => { :id => 'destination_greeting' }
- = f.input :source, :label => t('call_forwards.form.source.label'), :hint => conditional_hint('call_forwards.form.source.hint')
= f.input :active, :label => t('call_forwards.form.active.label'), :hint => conditional_hint('call_forwards.form.active.hint')
+
+ = f.input :source, :label => t('call_forwards.form.source.label'), :hint => conditional_hint('call_forwards.form.source.hint')