cama_contact_form 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac9d232c087c6da9750c56fa75175057b06d9bdb
4
- data.tar.gz: bc3a4141e2239b671ec0d8335613f8a55567251d
3
+ metadata.gz: 79f5408cc5871edfdbd3ed0fb697114eeb2e25c3
4
+ data.tar.gz: 23273662b1911e32621c4620a4653a940a950acc
5
5
  SHA512:
6
- metadata.gz: bf3c887a2ba812faba249df7680612c59de3b7c4beddecdcfcbe9fa580a3513a70751505777b39a1f046842c8d36023f67a47ec2fe688a781d0dcc8f38901d0c
7
- data.tar.gz: d83aec5505ce3f3263dee5a0d8dba3024998a5e537fab9f1b2bc003b24a47f4cfbfb490cba39cde05c8105215c26ff50ba378aca9bb5e6821acfe0fadbb77029
6
+ metadata.gz: 42a40daf5a2f72c7a25f2ba0fd165c7440443fa2023b554f74c38b4587b918e27ceb6be770c516a3773d53aec00645e0833ccfdb09b58825060ab29827441406
7
+ data.tar.gz: 4c5e6aaa633869ea020f8c1adea7c852cedd41acfe9287607b91d64f2d6b77c8f04bf50b1fafd553e663b33834ca6f122000e60599133f83ce8480b2fa6f6d04
@@ -64,20 +64,23 @@ module Plugins::CamaContactForm::ContactFormControllerConcern
64
64
  def convert_form_values(form, fields)
65
65
  values = {}
66
66
  form.fields.each do |field|
67
+ next unless relevant_field?(field)
68
+ ft = field[:field_type]
67
69
  cid = field[:cid].to_sym
68
70
  label = values.keys.include?(field[:label]) ? "#{field[:label]} (#{cid})" : field[:label].to_s.translate
69
71
  values[label] = []
70
- if field[:field_type] == 'submit' || field[:field_type] == 'button'
71
- elsif field[:field_type] == 'file'
72
+ if ft == 'file'
72
73
  values[label] << fields[cid].split('/').last if fields[cid].present?
73
- elsif field[:field_type] == 'captcha'
74
- values[label] << (params[:captcha] rescue '')
75
- elsif field[:field_type] == 'radio' || field[:field_type] == 'checkboxes'
74
+ elsif ft == 'radio' || ft == 'checkboxes'
76
75
  values[label] << fields[cid].map { |f| f.to_s.translate }.join(', ') if fields[cid].present?
77
76
  else
78
77
  values[label] << fields[cid] if fields[cid].present?
79
78
  end
80
79
  end
81
- return values
80
+ values
81
+ end
82
+
83
+ def relevant_field?(field)
84
+ !%w(captcha submit button).include? field[:field_type]
82
85
  end
83
86
  end
@@ -1,5 +1,6 @@
1
1
  class Plugins::CamaContactForm::AdminFormsController < CamaleonCms::Apps::PluginsAdminController
2
2
  include Plugins::CamaContactForm::MainHelper
3
+ include Plugins::CamaContactForm::ContactFormControllerConcern
3
4
  before_action :set_form, only: ['show','edit','update','destroy']
4
5
  add_breadcrumb I18n.t("plugins.cama_contact_form.title", default: 'Contact Form'), :admin_plugins_cama_contact_form_admin_forms_path
5
6
 
@@ -80,8 +81,4 @@ class Plugins::CamaContactForm::AdminFormsController < CamaleonCms::Apps::Plugin
80
81
  redirect_to cama_admin_path
81
82
  end
82
83
  end
83
-
84
- def relevant_field?(field)
85
- !%w(captcha submit button).include? field[:field_type]
86
- end
87
84
  end
@@ -139,15 +139,16 @@ module Plugins::CamaContactForm::MainHelper
139
139
  end
140
140
 
141
141
  options.each do |op|
142
+ label = op[:label].translate
142
143
  if type == "radio" || type == "checkbox"
143
144
  html += "<div class=\"#{type} #{ob[:custom_class]}\">
144
145
  <label for=\"#{ob[:cid]}\">
145
- <input #{ob[:custom_attrs].to_attr_format} type=\"#{type}\" #{'checked' if op[:checked].to_s.cama_true?} name=\"#{f_name}[]\" class=\"\" value=\"#{op[:label].downcase}\">
146
- #{op[:label]}
146
+ <input #{ob[:custom_attrs].to_attr_format} type=\"#{type}\" #{'checked' if op[:checked].to_s.cama_true?} name=\"#{f_name}[]\" class=\"\" value=\"#{label.downcase}\">
147
+ #{label}
147
148
  </label>
148
149
  </div>"
149
150
  else
150
- html += "<option value=\"#{op[:label].downcase.gsub(" ", "_")}\" #{"selected" if "#{op[:label].downcase.gsub(" ", "_")}" == values[cid] || op[:checked].to_s.cama_true? } >#{op[:label]}</option>"
151
+ html += "<option value=\"#{label.downcase.gsub(" ", "_")}\" #{"selected" if "#{label.downcase.gsub(" ", "_")}" == values[cid] || op[:checked].to_s.cama_true? } >#{label}</option>"
151
152
  end
152
153
  end
153
154
 
@@ -1,3 +1,3 @@
1
1
  module CamaContactForm
2
- VERSION = "0.0.23"
2
+ VERSION = "0.0.24"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cama_contact_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Owen Peredo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-08 00:00:00.000000000 Z
11
+ date: 2017-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails