summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-05-23 11:47:23 +0200
committerPeter Kozak <spag@golwen.net>2013-05-23 11:47:23 +0200
commite5d047eaf6d4c9f138fce801f4d9b790e7e8a7e6 (patch)
tree8d501fafbbab40ee40deb0ef68d742c057be48e6
parent6d53887d83c00b187c297ad5dd74ef8fd19ff87c (diff)
JavaSctipt added to CallForward view
-rw-r--r--app/controllers/call_forwards_controller.rb22
-rw-r--r--app/views/call_forwards/_form_core.html.haml13
-rw-r--r--config/locales/views/call_forwards/de.yml6
-rw-r--r--config/locales/views/call_forwards/en.yml6
4 files changed, 43 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')
diff --git a/config/locales/views/call_forwards/de.yml b/config/locales/views/call_forwards/de.yml
index 0adff59..f4e7090 100644
--- a/config/locales/views/call_forwards/de.yml
+++ b/config/locales/views/call_forwards/de.yml
@@ -57,6 +57,12 @@ de:
label: 'Ziel'
hint: 'Format: +49-30-2270 für eine normale Telefonnummer. 42 für eine interne Durchwahl.'
hint: 'Abhängig vom gewählten Zielart oben: z.B. Telefonnummer (+49301234567 oder 42), Mailboxansage (greeting_12345)'
+ destination_phone_number:
+ label: 'Telefonnummer'
+ hint: 'Telefonnummer (z.B. +49301234567 oder 42)'
+ destination_greeting:
+ label: 'Mailboxansage'
+ hint: 'Mailboxansage'
call_forwarding_destination:
label: 'Zielauswahl'
hint: 'Ziel auswählen und zusätzliche Informationen unten eingeben.'
diff --git a/config/locales/views/call_forwards/en.yml b/config/locales/views/call_forwards/en.yml
index 711f357..eb68979 100644
--- a/config/locales/views/call_forwards/en.yml
+++ b/config/locales/views/call_forwards/en.yml
@@ -56,6 +56,12 @@ en:
destination:
label: 'Destination'
hint: 'Depends on type specified above: e.g. phone number (+15551234567 or 42), voicemail greeting (greeting_12345)'
+ destination_phone_number:
+ label: 'Phone Number'
+ hint: 'Phone number (e.g. +15551234567 or 42)'
+ destination_greeting:
+ label: 'Greeting'
+ hint: 'Voicemail greeting'
call_forwarding_destination:
label: 'Destination Type'
hint: 'Select destination and enter additinal information (e.g. phone number) below'