From 678baf479066ad6b517b3a97925a7e37bf5327e4 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 7 Mar 2013 07:38:44 -0500 Subject: softkey form fixed --- app/controllers/softkeys_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/controllers/softkeys_controller.rb') diff --git a/app/controllers/softkeys_controller.rb b/app/controllers/softkeys_controller.rb index 9179d8c..6727de1 100644 --- a/app/controllers/softkeys_controller.rb +++ b/app/controllers/softkeys_controller.rb @@ -2,7 +2,7 @@ class SoftkeysController < ApplicationController load_and_authorize_resource :sip_account, :except => [:sort] load_and_authorize_resource :softkey, :through => [:sip_account], :except => [:sort] - before_filter :set_available_softkey_functions, :only => [ :new, :edit, :update ] + before_filter :set_available_softkey_functions, :only => [ :new, :edit, :update, :create ] before_filter :spread_breadcrumbs, :except => [:sort] def index @@ -35,6 +35,7 @@ class SoftkeysController < ApplicationController redirect_to sip_account_softkey_path(@softkey.sip_account, @softkey), :notice => t('softkeys.controller.successfuly_updated') else delete_call_forward_softkey_if_no_callforward_is_available + render :edit end end -- cgit v1.2.3 From 49549c7053700fb5444a2ae0835f879626d574cc Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 20 Mar 2013 12:19:03 +0100 Subject: possible_call_forwards fixed --- app/controllers/softkeys_controller.rb | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'app/controllers/softkeys_controller.rb') diff --git a/app/controllers/softkeys_controller.rb b/app/controllers/softkeys_controller.rb index 6727de1..adb0e10 100644 --- a/app/controllers/softkeys_controller.rb +++ b/app/controllers/softkeys_controller.rb @@ -13,8 +13,6 @@ class SoftkeysController < ApplicationController def new @softkey = @sip_account.softkeys.build - - delete_call_forward_softkey_if_no_callforward_is_available end def create @@ -27,15 +25,12 @@ class SoftkeysController < ApplicationController end def edit - delete_call_forward_softkey_if_no_callforward_is_available end def update if @softkey.update_attributes(params[:softkey]) redirect_to sip_account_softkey_path(@softkey.sip_account, @softkey), :notice => t('softkeys.controller.successfuly_updated') else - delete_call_forward_softkey_if_no_callforward_is_available - render :edit end end @@ -57,10 +52,13 @@ class SoftkeysController < ApplicationController private def set_available_softkey_functions + @possible_call_forwards = @softkey.possible_call_forwards @softkey_functions = [] SoftkeyFunction.accessible_by(current_ability, :read).each do |softkey_function| if GuiFunction.display?("softkey_function_#{softkey_function.name.downcase}_field_in_softkey_form", current_user) - @softkey_functions << softkey_function + if softkey_function.name != 'call_forwarding' or @possible_call_forwards.count > 0 + @softkey_functions << softkey_function + end end end end @@ -78,12 +76,4 @@ class SoftkeysController < ApplicationController add_breadcrumb t('softkeys.index.page_title'), sip_account_softkeys_path(@sip_account) end end - - def delete_call_forward_softkey_if_no_callforward_is_available - # Don't display the call_forward option if there aren't any call_forwards to choose from. - # - if @softkey.sip_account.phone_numbers.map{|phone_number| phone_number.call_forwards}.flatten.count == 0 - @softkey_functions.delete_if { |softkey_function| softkey_function == SoftkeyFunction.find_by_name('call_forwarding') } - end - end end -- cgit v1.2.3