From e5d047eaf6d4c9f138fce801f4d9b790e7e8a7e6 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 23 May 2013 11:47:23 +0200 Subject: JavaSctipt added to CallForward view --- app/controllers/call_forwards_controller.rb | 22 +++++++++++++++++++++- app/views/call_forwards/_form_core.html.haml | 13 ++++++++++--- config/locales/views/call_forwards/de.yml | 6 ++++++ config/locales/views/call_forwards/en.yml | 6 ++++++ 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 @@ -81,7 +86,6 @@ class CallForwardsController < ApplicationController redirect_to m.( @parent ), :notice => t('call_forwards.controller.successfuly_destroyed') end - private private def set_and_authorize_parent @parent = @phone_number || @sip_account || @automatic_call_distributor || @hunt_group @@ -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' -- cgit v1.2.3