wheelhouse-forms 1.2.1 → 1.2.2

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
- SHA1:
3
- metadata.gz: 7444097ab4ea54c3c2ecca71f86eef1114d1c19e
4
- data.tar.gz: 883db66b60d52273a7523bb05145b156ea20c36f
2
+ SHA256:
3
+ metadata.gz: c9e4acf942d7b099c05b7b709e534b023c89b3a2758b47dd2814b97eea8362aa
4
+ data.tar.gz: 0bce8ca31b37e8ffc140dd80cc8a603bce405175fddff249d0db53a3e17b637b
5
5
  SHA512:
6
- metadata.gz: 4ec4d2283e2b276b19bad963301773b25d096afcdfda7215c144536fb4cbe4657e7a1384706e825373e83efb7a557eff84f8ccedf329c6e5f4f0ce14ad80127e
7
- data.tar.gz: 7d46fa3ffd93d90992357cd25f9a557634c0838559a4fbfeb740d377ec2c9b0af264efa1219f50abb52a61c6f50c51cbe9671b289bc1b93ed08cf424796df40e
6
+ metadata.gz: e997f10c3997c8de42fa9956a567d79109081bb485ef4e54c70ae7264b4c38c30fba5451567701964caf159d16e03f12eaab3fd8c9f92b94d7a52543c3b7b958
7
+ data.tar.gz: ff1022522ac5b740efd27e55443e75f14d3b4a7aec15e37f00979a3d138d886fb8892c599165cce29cf12660824d775394f202c3acfbe55b01232de288fa028d
@@ -1,7 +1,7 @@
1
1
  .drag-area
2
2
  padding: 6px 6px 6px 38px
3
3
  margin-left: -32px
4
-
4
+
5
5
  .field-set > &
6
6
  margin-left: -14px
7
7
  padding-bottom: 0
@@ -14,7 +14,7 @@
14
14
  .fields
15
15
  label
16
16
  display: inline
17
-
17
+
18
18
  input[type=text]
19
19
  width: 40%
20
20
  display: inline
@@ -26,104 +26,104 @@
26
26
 
27
27
  input, select
28
28
  font-size: 100%
29
-
29
+
30
30
  &.placeholder
31
31
  color: #ccc
32
-
32
+
33
33
  label
34
34
  color: #545454
35
35
  font-weight: bold
36
36
  margin-right: 0.5em
37
-
37
+
38
38
  &.required
39
39
  float: right
40
40
  margin: 0.5em 0
41
41
  margin-right: 10%
42
42
  font-weight: normal
43
43
  font-size: 95%
44
-
44
+
45
45
  input
46
46
  margin-right: 4px
47
-
47
+
48
48
  span.note
49
49
  font-size: 95%
50
50
  color: #a9a9a9
51
-
51
+
52
52
  .field-set
53
53
  @extend %field
54
54
  background: #fdfefe
55
55
  border: 1px solid #ccc
56
56
  padding-left: 14px
57
-
57
+
58
58
  .placeholder, .text-field, .text-area, .select-field, .checkbox, .submit-button, .states-dropdown, .countries-dropdown, .radio-buttons, .checkboxes, .custom-field, .content-field
59
59
  margin-left: 0
60
60
  margin-right: 0
61
-
61
+
62
62
  .fields
63
63
  margin-right: 5px
64
-
64
+
65
65
  .text-field, .text-area, .select-field, .checkbox, .submit-button, .states-dropdown, .countries-dropdown, .radio-buttons, .checkboxes, .custom-field, .content-field
66
66
  @extend %field
67
67
  min-height: 26px
68
-
68
+
69
69
  input[type=text]
70
70
  width: 47%
71
-
71
+
72
72
  select
73
73
  display: inline
74
74
  width: 17%
75
75
  margin-left: 2%
76
-
76
+
77
77
  .drag
78
78
  width: 24px
79
-
79
+
80
80
  a.delete
81
81
  top: 12px
82
82
  right: 8px
83
-
83
+
84
84
  .text-field, .text-area, .content-field
85
85
  +blue
86
-
86
+
87
87
  .checkbox, .radio-buttons, .checkboxes
88
88
  +orange
89
-
89
+
90
90
  .select-field, .states-dropdown, .countries-dropdown
91
91
  +green
92
-
92
+
93
93
  .submit-button, .custom-field
94
94
  +purple
95
-
95
+
96
96
  .drag-placeholder
97
97
  @extend %field
98
98
  border: 1px dashed #ccc
99
99
  padding: 0
100
-
100
+
101
101
  .content-field
102
102
  a.delete
103
103
  top: 14px
104
104
  right: 14px
105
-
105
+
106
106
  .field-set .content-field
107
107
  a.delete
108
108
  right: 12px
109
-
109
+
110
110
  .custom-field
111
111
  input[type=text]
112
112
  width: 40%
113
-
113
+
114
114
  ul.options
115
115
  line-height: 2.6em
116
116
  min-height: 2em
117
117
  margin-top: 0.5em
118
-
118
+
119
119
  li
120
120
  display: inline
121
121
  margin-right: 5px
122
-
122
+
123
123
  input[type=text]
124
124
  width: auto
125
125
  min-width: 8em
126
-
126
+
127
127
  .drag
128
128
  position: absolute
129
129
  top: 0
@@ -133,14 +133,15 @@
133
133
  height: 100%
134
134
  background: image-url("wheelhouse/backgrounds/drag.png") repeat
135
135
  border-right: 1px solid #dfdfdf
136
- +border-left-radius(4px)
137
-
136
+ border-top-left-radius: 4px
137
+ border-bottom-left-radius: 4px
138
+
138
139
  img
139
140
  margin: 12px 4px
140
-
141
+
141
142
  .fields
142
143
  min-height: 100px
143
-
144
+
144
145
  a.delete
145
146
  position: absolute
146
147
  right: 14px
@@ -151,10 +152,10 @@
151
152
  background: image-url("wheelhouse/icons/delete-item.png") no-repeat
152
153
  text-indent: -9999px
153
154
  opacity: 0.5
154
-
155
+
155
156
  &:hover
156
157
  opacity: 1.0
157
-
158
+
158
159
  .field-set a.delete
159
160
  top: 12px
160
161
 
@@ -162,11 +163,10 @@
162
163
  label
163
164
  font-size: 115%
164
165
  font-weight: bold
165
-
166
+
166
167
  .shaded.disabled
167
168
  color: #999
168
169
  border-color: #e7e7e7
169
-
170
+
170
171
  input, textarea
171
172
  color: #999
172
-
@@ -2,15 +2,15 @@
2
2
  position: relative
3
3
  margin: 10px 0
4
4
  padding: 0 0 0 32px
5
- +border-radius(4px)
5
+ border-radius: 4px
6
6
 
7
7
  =colored-field( $background, $border, $text )
8
8
  background: $background
9
9
  border: 1px solid $border
10
-
10
+
11
11
  label
12
12
  color: $text
13
-
13
+
14
14
  .drag
15
15
  border-right: 1px solid $border
16
16
 
@@ -25,4 +25,3 @@
25
25
 
26
26
  =purple
27
27
  +colored-field(#fdfafd, #e3d2e3, #987898)
28
-
@@ -1,5 +1,3 @@
1
- @import compass
2
-
3
1
  @import mixins
4
2
  @import fields
5
3
  @import tools
@@ -1,22 +1,22 @@
1
1
  require_dependency "forms/csv_exporter"
2
2
 
3
3
  class Forms::SubmissionsController < Wheelhouse::ResourceController
4
- belongs_to :form, :class_name => Forms::Form
4
+ belongs_to :form, :class_name => "Forms::Form"
5
5
  self.resource_class = Forms::Submission
6
-
6
+
7
7
  manage_site_breadcrumb
8
8
  breadcrumb { [parent.label, parent] }
9
-
9
+
10
10
  actions :show, :destroy, :update
11
-
11
+
12
12
  respond_to :csv
13
-
13
+
14
14
  def index
15
15
  respond_with(parent) do |format|
16
16
  format.csv { render :text => Forms::CsvExporter.new(parent).to_csv }
17
17
  end
18
18
  end
19
-
19
+
20
20
  def update
21
21
  resource.spam!(params[:spam])
22
22
  respond_with(resource)
@@ -1,17 +1,25 @@
1
1
  class Forms::FormHandler < Wheelhouse::ResourceHandler
2
- skip_before_filter :verify_authenticity_token
3
-
4
- before_filter :set_form_context
5
-
2
+ skip_before_action :verify_authenticity_token, raise: false
3
+
4
+ before_action :set_form_context
5
+
6
6
  get do
7
7
  end
8
-
8
+
9
9
  post do
10
- @form.submit(params[:submission], request)
10
+ @form.submit(submission_params, request)
11
11
  end
12
12
 
13
13
  private
14
14
  def set_form_context
15
15
  @form.view_context = view_context
16
16
  end
17
+
18
+ def submission_params
19
+ if params.respond_to?(:require)
20
+ params.require(:submission).permit!
21
+ else
22
+ params[:submission]
23
+ end
24
+ end
17
25
  end
@@ -4,14 +4,15 @@ class Forms::Mailer < ActionMailer::Base
4
4
  def submission(form, submission)
5
5
  @form, @submission = form, submission
6
6
 
7
- mail(:from => form.email_sender,
8
- :to => form.recipients,
9
- :subject => form.subject)
7
+ mail(:to => form.notification_email_recipients,
8
+ :from => form.notification_email_sender,
9
+ :subject => form.notification_email_subject,
10
+ :reply_to => submission.email)
10
11
  end
11
12
 
12
13
  def confirmation(form, submission)
13
- mail(:from => form.email_sender,
14
- :to => submission.email,
14
+ mail(:to => submission.email,
15
+ :from => form.confirmation_email_sender,
15
16
  :subject => form.confirmation_email_subject,
16
17
  :body => form.confirmation_email_body)
17
18
  end
@@ -2,27 +2,22 @@ module Forms::Fields
2
2
  class Field < Wheelhouse::EmbeddedResource
3
3
  class_attribute :renderer
4
4
  self.renderer = Forms::FieldRenderer
5
-
5
+
6
6
  def render(submission, template)
7
7
  self.class.renderer.new(self, submission, template).render
8
8
  end
9
-
9
+
10
10
  def required?
11
11
  read_attribute(:required)
12
12
  end
13
-
13
+
14
14
  def self.partial
15
15
  name.demodulize.underscore
16
16
  end
17
-
17
+
18
18
  def self.cast(attrs)
19
- case attrs
20
- when Hash
21
- type = attrs.delete('type')
22
- Forms::Fields.const_get(type).new(attrs)
23
- else
24
- super
25
- end
19
+ type = attrs.delete('type')
20
+ Forms::Fields.const_get(type).new(attrs)
26
21
  end
27
22
  end
28
23
  end
@@ -4,40 +4,42 @@ class Forms::Form < Wheelhouse::Resource
4
4
  include Wheelhouse::Resource::Addressable
5
5
  include Wheelhouse::Resource::Versioned
6
6
  include Wheelhouse::Resource::Content
7
-
7
+
8
8
  property :title, String, :required => true, :translate => true
9
9
  property :fields, FieldCollection, :default => [Forms::Fields::FieldSet.new]
10
-
10
+
11
11
  property :submission_notification, Boolean, :default => true
12
- property :recipients, MongoModel::Collection[String]
13
- property :subject, String, :default => "Form Submission"
14
-
12
+ property :notification_email_sender, String
13
+ property :notification_email_recipients, MongoModel::Collection[String], :as => 'recipients'
14
+ property :notification_email_subject, String, :default => "Form Submission", :as => 'subject'
15
+
15
16
  property :confirmation_email, Boolean, :default => false
17
+ property :confirmation_email_sender, String
16
18
  property :confirmation_email_subject, String
17
19
  property :confirmation_email_body, String
18
-
20
+
19
21
  validates_associated :fields
20
-
22
+
21
23
  has_many :submissions, :class => "Forms::Submission"
22
-
24
+
23
25
  activities :all
24
-
26
+
25
27
  icon "wheelhouse-forms/form.png"
26
-
28
+
27
29
  attr_accessor :view_context, :current_submission, :success
28
-
30
+
29
31
  def to_s
30
32
  render(view_context)
31
33
  end
32
-
34
+
33
35
  def render(template)
34
36
  Forms::FormRenderer.new(self, current_submission, template).render
35
37
  end
36
-
38
+
37
39
  def submit(params, request)
38
40
  submission = submissions.build(:params => params, :ip_address => request.remote_ip)
39
41
  Forms::Plugin.config.wheelhouse.forms.spam_filter.check(submission)
40
-
42
+
41
43
  if submission.save
42
44
  deliver(submission) unless submission.spam?
43
45
  self.success = true
@@ -46,40 +48,48 @@ class Forms::Form < Wheelhouse::Resource
46
48
  self.success = false
47
49
  end
48
50
  end
49
-
50
- def email_sender
51
- "noreply@#{site.domain}"
51
+
52
+ def notification_email_sender
53
+ read_attribute(:notification_email_sender).presence || default_email_sender
54
+ end
55
+
56
+ def confirmation_email_sender
57
+ read_attribute(:confirmation_email_sender).presence || default_email_sender
52
58
  end
53
-
59
+
60
+ def default_email_sender
61
+ "noreply@#{site.domain}" if site
62
+ end
63
+
54
64
  def deliver(submission)
55
65
  Forms::Mailer.submission(self, submission).deliver if deliver_submission_notification?
56
66
  Forms::Mailer.confirmation(self, submission).deliver if deliver_confirmation_email?(submission)
57
67
  rescue
58
68
  # Mail delivery failed
59
69
  end
60
-
70
+
61
71
  def success?
62
72
  @success
63
73
  end
64
-
74
+
65
75
  def first_content_field
66
76
  @first_content_field ||= fields.flatten.find { |f| f.respond_to?(:label) }
67
77
  end
68
-
69
- def recipients=(recipients)
78
+
79
+ def notification_email_recipients=(recipients)
70
80
  recipients = recipients.split(/,/) if recipients.is_a?(String)
71
- write_attribute(:recipients, recipients.map(&:strip))
81
+ write_attribute(:notification_email_recipients, recipients.map(&:strip))
72
82
  end
73
-
83
+
74
84
  def handler
75
85
  Forms::FormHandler
76
86
  end
77
87
 
78
88
  protected
79
89
  def deliver_submission_notification?
80
- submission_notification? && recipients.any?
90
+ submission_notification? && notification_email_recipients.any?
81
91
  end
82
-
92
+
83
93
  def deliver_confirmation_email?(submission)
84
94
  confirmation_email? && submission.email.present?
85
95
  end
@@ -7,16 +7,17 @@ class Forms::Submission
7
7
  end
8
8
  result
9
9
  end
10
-
10
+
11
11
  def self.cast(params)
12
12
  case params
13
- when Hash
14
- self[params]
15
13
  when Array
16
14
  params.each_with_object({}) { |v, hash| hash[v[0]] = v[1] }
15
+ else
16
+ # Assume params behaves like a hash
17
+ self[params]
17
18
  end
18
19
  end
19
-
20
+
20
21
  def self.from_mongo(params)
21
22
  cast(params)
22
23
  end
@@ -4,7 +4,8 @@
4
4
  %head
5
5
 
6
6
  %body
7
- %p= link_to "View this submission online", @submission.admin_url
7
+ - if Rails.application.config.wheelhouse.forms.show_admin_link_in_notifications
8
+ %p= link_to "View this submission online", @submission.admin_url
8
9
 
9
10
  %p
10
11
  %strong Submitted at:
@@ -27,18 +27,24 @@
27
27
  = form.check_box :submission_notification, :label => "Submission Notification", :data => { :disable => "#submission-notification-options" }
28
28
 
29
29
  #submission-notification-options.shaded
30
- = field :recipients do
31
- = form.text_field :recipients, :value => @form.recipients.join(', ')
30
+ = field :notification_email_recipients do
31
+ = form.text_field :notification_email_recipients, :value => @form.notification_email_recipients.join(', ')
32
32
  = note "Separate email addresses with commas."
33
+
34
+ = field :notification_email_sender do
35
+ = form.text_field :notification_email_sender, :placeholder => @form.default_email_sender
33
36
 
34
- = field :subject do
35
- = form.text_field :subject
37
+ = field :notification_email_subject do
38
+ = form.text_field :notification_email_subject
36
39
 
37
40
  = field :confirmation_email, :label => false, :class => "title" do
38
41
  = form.check_box :confirmation_email, :label => "Confirmation Email", :data => { :disable => "#confirmation-email-options" }
39
42
  = note "Confirmation emails will be sent to the first form field with a label containing \"email\"."
40
43
 
41
44
  #confirmation-email-options.shaded
45
+ = field :confirmation_email_sender do
46
+ = form.text_field :confirmation_email_sender, :placeholder => @form.default_email_sender
47
+
42
48
  = field :confirmation_email_subject do
43
49
  = form.text_field :confirmation_email_subject
44
50
 
@@ -4,6 +4,7 @@ en:
4
4
  form:
5
5
  title: Form Title
6
6
  content: Form Content
7
+ confirmation_email_sender: Confirmation Email Sender
7
8
  confirmation_email_subject: Confirmation Email Subject
8
9
  confirmation_email_body: Confirmation Email Body
9
10
 
@@ -15,10 +15,14 @@ module Forms
15
15
  class Plugin < Wheelhouse::Plugin
16
16
  config.wheelhouse.forms = ActiveSupport::OrderedOptions.new
17
17
 
18
- # Disable custom fields by default
18
+ # Disable custom fields by default.
19
19
  config.wheelhouse.forms.custom_fields = false
20
+
21
+ # Show 'view submission' link in notification emails.
22
+ # You may wish to disable this if you plan to reply directly to notification emails.
23
+ config.wheelhouse.forms.show_admin_link_in_notifications = true
20
24
 
21
- # Set default spam filter
25
+ # Set default spam filter.
22
26
  config.wheelhouse.forms.spam_filter = defined?(Rakismet) ? AkismetFilter : NullFilter
23
27
 
24
28
  isolate_namespace Forms
@@ -30,7 +34,7 @@ module Forms
30
34
  end
31
35
 
32
36
  initializer :precompile_assets do |app|
33
- app.config.assets.precompile += %w(wheelhouse-forms/admin.* wheelhouse-forms/designer.js wheelhouse-forms/submissions.js)
37
+ app.config.assets.precompile += %w(wheelhouse-forms/admin.* wheelhouse-forms/designer.js wheelhouse-forms/submissions.js wheelhouse-forms/*.png)
34
38
  end
35
39
 
36
40
  def self.load_yaml(file)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wheelhouse-forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Pohlenz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-30 00:00:00.000000000 Z
11
+ date: 2018-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: wheelhouse
@@ -56,12 +56,12 @@ files:
56
56
  - app/assets/javascripts/wheelhouse-forms/jquery.autogrow.js
57
57
  - app/assets/javascripts/wheelhouse-forms/jquery.options.js
58
58
  - app/assets/javascripts/wheelhouse-forms/submissions.js
59
- - app/assets/stylesheets/wheelhouse-forms/_fields.css.sass
60
- - app/assets/stylesheets/wheelhouse-forms/_mixins.css.sass
61
- - app/assets/stylesheets/wheelhouse-forms/_sidebar.css.sass
62
- - app/assets/stylesheets/wheelhouse-forms/_submissions.css.sass
63
- - app/assets/stylesheets/wheelhouse-forms/_tools.css.sass
64
- - app/assets/stylesheets/wheelhouse-forms/admin.css.sass
59
+ - app/assets/stylesheets/wheelhouse-forms/_fields.sass
60
+ - app/assets/stylesheets/wheelhouse-forms/_mixins.sass
61
+ - app/assets/stylesheets/wheelhouse-forms/_sidebar.sass
62
+ - app/assets/stylesheets/wheelhouse-forms/_submissions.sass
63
+ - app/assets/stylesheets/wheelhouse-forms/_tools.sass
64
+ - app/assets/stylesheets/wheelhouse-forms/admin.sass
65
65
  - app/controllers/forms/forms_controller.rb
66
66
  - app/controllers/forms/submissions_controller.rb
67
67
  - app/handlers/forms/form_handler.rb
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  version: 1.3.6
154
154
  requirements: []
155
155
  rubyforge_project:
156
- rubygems_version: 2.4.5
156
+ rubygems_version: 2.7.3
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: Wheelhouse CMS Forms Plugin