From ae05a20f5b474071dfa9b6c8760636304861a7d1 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 25 Apr 2013 12:12:12 +0200 Subject: voicemail_settings controller value input_type --- app/controllers/voicemail_settings_controller.rb | 25 ++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'app/controllers/voicemail_settings_controller.rb') diff --git a/app/controllers/voicemail_settings_controller.rb b/app/controllers/voicemail_settings_controller.rb index 1b2e371..8a7c411 100644 --- a/app/controllers/voicemail_settings_controller.rb +++ b/app/controllers/voicemail_settings_controller.rb @@ -10,6 +10,19 @@ class VoicemailSettingsController < ApplicationController end def new + @names_possible = [] + VoicemailSetting::VOICEMAIL_SETTINGS.keys.each do |name| + if @voicemail_account.voicemail_settings.where(:name => name).first + next + end + + label = t("voicemail_settings.settings.#{name}") + if label =~ /^translation missing/ + label = name.to_s.gsub('_', ' ').capitalize; + end + + @names_possible << [label, name] + end end def create @@ -25,14 +38,8 @@ class VoicemailSettingsController < ApplicationController def edit @voicemail_setting = @voicemail_account.voicemail_settings.find(params[:id]) - @no_edit = { - :name => { - :input => VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:input, {}), - :name => @voicemail_setting.name.to_s, - :html => VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:html, {}), - }, - :description => true - } + @input_type = VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:input, 'String') + @input_html = VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:html, {}) end def update @@ -41,6 +48,8 @@ class VoicemailSettingsController < ApplicationController m = method( :"#{@voicemail_account.voicemail_accountable.class.name.underscore}_voicemail_account_path" ) redirect_to m.( @voicemail_account.voicemail_accountable, @voicemail_account ), :notice => t('voicemail_settings.controller.successfuly_updated') else + @input_type = VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:input, 'String') + @input_html = VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:html, {}) render :edit end end -- cgit v1.2.3