diff options
author | Peter Kozak <spag@golwen.net> | 2013-03-27 08:13:21 +0100 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-03-27 08:13:21 +0100 |
commit | 41b306402d020aff3615308cdd555b0a05221343 (patch) | |
tree | 353f80b4d70a9b5dc8e8eec6a18067fe1d77d126 | |
parent | df95371d587ca2a0652dff6aee3538c7f0700890 (diff) |
voicemail settings
-rw-r--r-- | app/controllers/voicemail_settings_controller.rb | 5 | ||||
-rw-r--r-- | app/models/voicemail_setting.rb | 34 | ||||
-rw-r--r-- | app/views/voicemail_settings/_form_core.html.haml | 3 | ||||
-rw-r--r-- | app/views/voicemail_settings/_index_core.html.haml | 2 |
4 files changed, 32 insertions, 12 deletions
diff --git a/app/controllers/voicemail_settings_controller.rb b/app/controllers/voicemail_settings_controller.rb index ee8e36b..1b2e371 100644 --- a/app/controllers/voicemail_settings_controller.rb +++ b/app/controllers/voicemail_settings_controller.rb @@ -27,8 +27,9 @@ class VoicemailSettingsController < ApplicationController @voicemail_setting = @voicemail_account.voicemail_settings.find(params[:id]) @no_edit = { :name => { - :input => VoicemailSetting::VOICEMAIL_SETTINGS[@voicemail_setting.name][:input], - :name => @voicemail_setting.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 } diff --git a/app/models/voicemail_setting.rb b/app/models/voicemail_setting.rb index 4a9fbc9..0f34402 100644 --- a/app/models/voicemail_setting.rb +++ b/app/models/voicemail_setting.rb @@ -1,14 +1,32 @@ class VoicemailSetting < ActiveRecord::Base CLASS_TYPES = ['String', 'Integer', 'Boolean'] VOICEMAIL_SETTINGS = { - 'password' => { :type => 'String', :characters => /[^0-9]/, :input => :password }, - 'notify' => { :type => 'Boolean', :input => :boolean }, - 'attachment' => { :type => 'Boolean', :input => :boolean }, - 'mark_read' => { :type => 'Boolean', :input => :boolean }, - 'purge' => { :type => 'Boolean', :input => :boolean }, - 'record_length_max' => { :type => 'Integer', :input => :integer }, - 'record_length_min' => { :type => 'Integer', :input => :integer }, - 'records_max' => { :type => 'Integer', :input => :integer }, + 'pin' => { :type => 'String', :characters => /[^0-9]/, :html => { maxlength: 8 } }, + 'notify' => { :type => 'Boolean', :input => :boolean }, + 'attachment' => { :type => 'Boolean', :input => :boolean }, + 'mark_read' => { :type => 'Boolean', :input => :boolean }, + 'purge' => { :type => 'Boolean', :input => :boolean }, + 'record_length_max' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 100 } }, + 'record_length_min' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 100 } }, + 'records_max' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 100 } }, + 'pin_length_max' => { :type => 'Integer', :input => :integer, :html => { min: 1, max: 10 } }, + 'pin_length_min' => { :type => 'Integer', :input => :integer, :html => { min: 1, max: 8 } }, + 'pin_timeout' => { :type => 'Integer', :input => :integer, :html => { min: 1, max: 10 } }, + 'key_new_messages' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_saved_messages' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_config_menu' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_terminator' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_previous' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_next' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_delete' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_save' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_main_menu' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'silence_lenght_abort' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 100 } }, + 'silence_level' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 1000 } }, + 'record_file_prefix' => { :type => 'String' }, + 'record_file_suffix' => { :type => 'String' }, + 'record_file_path' => { :type => 'String' }, + 'record_repeat' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 10 } }, } attr_accessible :voicemail_account_id, :name, :value, :class_type, :description diff --git a/app/views/voicemail_settings/_form_core.html.haml b/app/views/voicemail_settings/_form_core.html.haml index bf47e46..31c6bbf 100644 --- a/app/views/voicemail_settings/_form_core.html.haml +++ b/app/views/voicemail_settings/_form_core.html.haml @@ -1,9 +1,10 @@ + .inputs - if !@no_edit or !@no_edit[:name] = f.input :name, :collection => VoicemailSetting::VOICEMAIL_SETTINGS.keys.collect{|i, k| [t("voicemail_settings.settings.#{i}"), i]}, :label => t('voicemail_settings.form.name.label'), :hint => conditional_hint('voicemail_settings.form.name.hint'), :autofocus => true, :include_blank => false = f.input :value, :label => t('voicemail_settings.form.value.label'), :hint => conditional_hint('voicemail_settings.form.value.hint') - else - = f.input :value, :label => t("voicemail_settings.settings.#{@no_edit[:name][:name]}"), :hint => conditional_hint('voicemail_settings.form.value.hint'), :as => @no_edit[:name][:input] + = f.input :value, :label => t("voicemail_settings.settings.#{@no_edit[:name][:name]}"), :hint => conditional_hint('voicemail_settings.form.value.hint'), :as => @no_edit[:name][:input], input_html: @no_edit[:name][:html] - if !@no_edit or !@no_edit[:description] = f.input :description, :label => t('voicemail_settings.form.description.label'), :hint => conditional_hint('voicemail_settings.form.description.hint') diff --git a/app/views/voicemail_settings/_index_core.html.haml b/app/views/voicemail_settings/_index_core.html.haml index 94ebfb1..9173fe6 100644 --- a/app/views/voicemail_settings/_index_core.html.haml +++ b/app/views/voicemail_settings/_index_core.html.haml @@ -8,7 +8,7 @@ %tbody - for voicemail_setting in voicemail_settings %tr - %td= voicemail_setting.name + %td= t("voicemail_settings.settings.#{voicemail_setting.name}") %td= voicemail_setting.value %td= voicemail_setting.description =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => voicemail_setting.voicemail_account, :child => voicemail_setting} |