wheelhouse-forms 1.1 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c534a2c55072660955b2bd53ec519420794a320c
4
+ data.tar.gz: eb1167165d71b3f5e7a5998ebccfe09b39df6519
5
+ SHA512:
6
+ metadata.gz: 11fe367ca692b851a23bdc4bbc29b05b207c5c20f80c76b3bdc73d0b4028b4b048e96968e8fae3d8a915b8c12fd890fe5f46d5d86c6855458ce44292d9cf8de3
7
+ data.tar.gz: 4f8c98b4920bf81e20c6676861303299731d43c3926b189fd894c5cf7c523aa8d17749a9dfbc783ec652685986a10843b552e9d039d5f00d74504049d52802ba
@@ -6,6 +6,12 @@ $(function() {
6
6
  var root = $('#fields');
7
7
  var target;
8
8
 
9
+ var nextId = 0;
10
+ function uniqueId() {
11
+ ++nextId;
12
+ return "content-" + nextId;
13
+ }
14
+
9
15
  function resetTarget() {
10
16
  target = $('.fields:last', root);
11
17
  if (target.length < 1) target = root;
@@ -22,6 +28,7 @@ function insertFieldHandler(template, optionize, callback) {
22
28
  var field = $(template).tmpl({ index: nextIndex, prefix: prefixFor(target, nextIndex) });
23
29
 
24
30
  field.appendTo(target);
31
+ $.scrollTo(field, { duration: 300 });
25
32
  $('input[placeholder]', field).placeholder().click();
26
33
 
27
34
  if (optionize) { $('ul.options', field).options(); }
@@ -41,14 +48,18 @@ $('.tools li.radio-buttons a').click(insertFieldHandler("#radio-buttons-template
41
48
  $('.tools li.states-dropdown a').click(insertFieldHandler("#states-dropdown-template"));
42
49
  $('.tools li.countries-dropdown a').click(insertFieldHandler("#countries-dropdown-template"));
43
50
  $('.tools li.content-field a').click(insertFieldHandler("#content-field-template", false, function(field) {
44
- $('textarea.editor', field).editor();
51
+ var textarea = $('textarea.editor', field);
52
+ textarea.attr('id', uniqueId());
53
+ textarea.editor();
45
54
  }));
46
55
  $('.tools li.custom-field a').click(insertFieldHandler("#custom-field-template"));
47
56
 
48
57
  $('.tools li.field-set a').click(function() {
49
58
  var nextIndex = parseInt($('#fields > :last-child').attr('data-index')) + 1 || 0;
50
59
  var fieldset = $('#field-set-template').tmpl({ index: nextIndex, prefix: prefixFor(root, nextIndex) });
60
+
51
61
  fieldset.appendTo(root);
62
+ $.scrollTo(fieldset, { duration: 300 });
52
63
 
53
64
  target = $('.fields', fieldset);
54
65
  target.sortable(SortableOptions);
@@ -72,41 +83,39 @@ root.delegate('a.delete', 'click', function() {
72
83
  return false;
73
84
  });
74
85
 
86
+ function replacePrefix(input, prefix) {
87
+ var name = $(input).attr('name').replace(/.*(\[[^\[\]]+\](\[\])?)$/, "$1");
88
+ $(input).attr('name', prefix + name);
89
+ }
75
90
 
76
- function refreshFields() {
77
- function replacePrefix(input, prefix) {
78
- var name = $(input).attr('name').replace(/.*(\[[^\[\]]+\](\[\])?)$/, "$1");
79
- $(input).attr('name', prefix + name);
80
- }
91
+ function updateFieldPrefixes(root) {
92
+ var children = $('> div', root);
81
93
 
82
- $('#fields > div').each(function(index) {
83
- var prefix = $('#fields').attr("data-prefix") + "[" + index + "]";
84
- $(this).attr('data-index', index);
94
+ children.each(function(index) {
95
+ var field = $(this);
96
+ field.attr('data-index', index);
97
+
98
+ var prefix = prefixFor(root, index);
85
99
 
86
- $('input:not(.fields input), textarea:not(.fields textarea), select:not(.fields select)', this).each(function() {
100
+ $('input, textarea, select', field).each(function() {
87
101
  replacePrefix(this, prefix);
88
102
  });
89
- $('> .fields', this).attr('data-prefix', prefix + "[fields]");
90
- });
91
-
92
- $('.fields').each(function() {
93
- var fieldsPrefix = $(this).attr('data-prefix');
94
103
 
95
- $('> div', this).each(function(index) {
96
- var prefix = fieldsPrefix + "[" + index + "]";
97
- $(this).attr('data-index', index);
98
-
99
- $('input, textarea, select', this).each(function() { replacePrefix(this, prefix); });
100
- });
104
+ var subfields = $('> .fields', field);
105
+ subfields.attr('data-prefix', prefix + "[fields]");
106
+ updateFieldPrefixes(subfields)
101
107
  });
102
108
  }
103
109
 
110
+ function refreshFields() {
111
+ updateFieldPrefixes(root);
112
+ }
113
+
104
114
  var BaseSortableOptions = {
105
115
  items: '> div',
106
116
  handle: '> .drag',
107
117
  placeholder: 'drag-placeholder',
108
118
  tolerance: 'intersect',
109
- toleranceElement: '> .drag-area',
110
119
  connectWith: '.fields',
111
120
  forcePlaceholderSize: true,
112
121
  start: function(e, ui) {
@@ -122,4 +131,21 @@ var SortableOptions = $.extend({}, BaseSortableOptions, { connectWith: '#fields,
122
131
  $('#fields').sortable(BaseSortableOptions); // Top-level
123
132
  $('.fields').sortable(SortableOptions); // Fieldsets
124
133
 
134
+ $('input:checkbox[data-disable]').on('toggled', function() {
135
+ var selector = $(this).attr('data-disable');
136
+ var target = $(selector);
137
+
138
+ if ($(this).is(':checked')) {
139
+ target.removeClass('disabled')
140
+ target.find('input, textarea').removeClass('disabled').removeAttr('disabled');
141
+ } else {
142
+ target.addClass('disabled');
143
+ target.find('input, textarea').addClass('disabled').attr('disabled', 'disabled');
144
+ }
145
+ }).click(function() {
146
+ $(this).trigger('toggled');
147
+ }).each(function() {
148
+ $(this).trigger('toggled');
149
+ });
150
+
125
151
  });
@@ -0,0 +1,172 @@
1
+ .drag-area
2
+ padding: 6px 6px 6px 38px
3
+ margin-left: -32px
4
+
5
+ .field-set > &
6
+ margin-left: -14px
7
+ padding-bottom: 0
8
+ padding-left: 20px
9
+
10
+ .field
11
+ li
12
+ margin-bottom: 0.2em
13
+
14
+ .fields
15
+ label
16
+ display: inline
17
+
18
+ input[type=text]
19
+ width: 40%
20
+ display: inline
21
+
22
+ select
23
+ margin: 0.4em 0
24
+ padding: 0.5% 0.2% 0.2% 0.2%
25
+ font-size: 110%
26
+
27
+ input, select
28
+ font-size: 100%
29
+
30
+ &.placeholder
31
+ color: #ccc
32
+
33
+ label
34
+ color: #545454
35
+ font-weight: bold
36
+ margin-right: 0.5em
37
+
38
+ &.required
39
+ float: right
40
+ margin: 0.5em 0
41
+ margin-right: 10%
42
+ font-weight: normal
43
+ font-size: 95%
44
+
45
+ input
46
+ margin-right: 4px
47
+
48
+ span.note
49
+ font-size: 95%
50
+ color: #a9a9a9
51
+
52
+ .field-set
53
+ @extend %field
54
+ background: #fdfefe
55
+ border: 1px solid #ccc
56
+ padding-left: 14px
57
+
58
+ .placeholder, .text-field, .text-area, .select-field, .checkbox, .submit-button, .states-dropdown, .countries-dropdown, .radio-buttons, .checkboxes, .custom-field, .content-field
59
+ margin-left: 0
60
+ margin-right: 0
61
+
62
+ .fields
63
+ margin-right: 5px
64
+
65
+ .text-field, .text-area, .select-field, .checkbox, .submit-button, .states-dropdown, .countries-dropdown, .radio-buttons, .checkboxes, .custom-field, .content-field
66
+ @extend %field
67
+ min-height: 26px
68
+
69
+ input[type=text]
70
+ width: 47%
71
+
72
+ select
73
+ display: inline
74
+ width: 17%
75
+ margin-left: 2%
76
+
77
+ .drag
78
+ width: 24px
79
+
80
+ a.delete
81
+ top: 12px
82
+ right: 8px
83
+
84
+ .text-field, .text-area, .content-field
85
+ +blue
86
+
87
+ .checkbox, .radio-buttons, .checkboxes
88
+ +orange
89
+
90
+ .select-field, .states-dropdown, .countries-dropdown
91
+ +green
92
+
93
+ .submit-button, .custom-field
94
+ +purple
95
+
96
+ .drag-placeholder
97
+ @extend %field
98
+ border: 1px dashed #ccc
99
+ padding: 0
100
+
101
+ .content-field
102
+ a.delete
103
+ top: 14px
104
+ right: 14px
105
+
106
+ .field-set .content-field
107
+ a.delete
108
+ right: 12px
109
+
110
+ .custom-field
111
+ input[type=text]
112
+ width: 40%
113
+
114
+ ul.options
115
+ line-height: 2.6em
116
+ min-height: 2em
117
+ margin-top: 0.5em
118
+
119
+ li
120
+ display: inline
121
+ margin-right: 5px
122
+
123
+ input[type=text]
124
+ width: auto
125
+ min-width: 8em
126
+
127
+ .drag
128
+ position: absolute
129
+ top: 0
130
+ left: 0
131
+ cursor: move
132
+ width: 7px
133
+ height: 100%
134
+ background: image-url("wheelhouse/backgrounds/drag.png") repeat
135
+ border-right: 1px solid #dfdfdf
136
+ +border-left-radius(4px)
137
+
138
+ img
139
+ margin: 12px 4px
140
+
141
+ .fields
142
+ min-height: 100px
143
+
144
+ a.delete
145
+ position: absolute
146
+ right: 14px
147
+ top: 16px
148
+ z-index: 99
149
+ width: 16px
150
+ height: 16px
151
+ background: image-url("wheelhouse/icons/delete-item.png") no-repeat
152
+ text-indent: -9999px
153
+ opacity: 0.5
154
+
155
+ &:hover
156
+ opacity: 1.0
157
+
158
+ .field-set a.delete
159
+ top: 12px
160
+
161
+ .field.title
162
+ label
163
+ font-size: 115%
164
+ font-weight: bold
165
+
166
+ .shaded.disabled
167
+ color: #999
168
+ border-color: #e7e7e7
169
+
170
+ input, textarea
171
+ color: #999
172
+
@@ -0,0 +1,28 @@
1
+ %field
2
+ position: relative
3
+ margin: 10px 0
4
+ padding: 0 0 0 32px
5
+ +border-radius(4px)
6
+
7
+ =colored-field( $background, $border, $text )
8
+ background: $background
9
+ border: 1px solid $border
10
+
11
+ label
12
+ color: $text
13
+
14
+ .drag
15
+ border-right: 1px solid $border
16
+
17
+ =blue
18
+ +colored-field(#f3f7fa, #cbd4da, #76828a)
19
+
20
+ =green
21
+ +colored-field(#f3f8f4, #d3dbd2, #748572)
22
+
23
+ =orange
24
+ +colored-field(#faf8f0, #e1ddc8, #8c8977)
25
+
26
+ =purple
27
+ +colored-field(#fdfafd, #e3d2e3, #987898)
28
+
@@ -0,0 +1,16 @@
1
+ .sidebar
2
+ a.spam-submissions
3
+ background-image: image-url("wheelhouse-forms/spam-small.png")
4
+ padding-left: 40px
5
+
6
+ a.latest-submissions
7
+ background-image: image-url("wheelhouse-forms/submissions.png")
8
+ padding-left: 40px
9
+
10
+ a.export-csv
11
+ background-image: image-url("wheelhouse-forms/csv.png")
12
+ padding-left: 40px
13
+
14
+ button.mark-spam, button.not-spam
15
+ width: 222px
16
+
@@ -0,0 +1,8 @@
1
+ .shaded
2
+ h2
3
+ border-bottom: 1px solid #ddd
4
+ padding-bottom: 5px
5
+ margin-right: 6%
6
+
7
+ .inline input
8
+ margin-right: 1em
@@ -0,0 +1,44 @@
1
+ .tools li
2
+ a
3
+ padding-left: 45px
4
+ background-position: 17px center
5
+
6
+ &:hover
7
+ background-color: #d3dadf
8
+
9
+ &.text-field a
10
+ background-image: image-url("wheelhouse-forms/text-field.png")
11
+
12
+ &.text-area a
13
+ background-image: image-url("wheelhouse-forms/text-area.png")
14
+
15
+ &.select-field a
16
+ background-image: image-url("wheelhouse-forms/select.png")
17
+
18
+ &.checkbox a
19
+ background-image: image-url("wheelhouse-forms/checkbox.png")
20
+
21
+ &.checkboxes a
22
+ background-image: image-url("wheelhouse-forms/checkboxes.png")
23
+
24
+ &.radio-buttons a
25
+ background-image: image-url("wheelhouse-forms/radio-buttons.png")
26
+
27
+ &.field-set a
28
+ background-image: image-url("wheelhouse-forms/field-set.png")
29
+
30
+ &.submit-button a
31
+ background-image: image-url("wheelhouse-forms/submit-button.png")
32
+
33
+ &.states-dropdown a
34
+ background-image: image-url("wheelhouse-forms/states.png")
35
+
36
+ &.countries-dropdown a
37
+ background-image: image-url("wheelhouse-forms/countries.png")
38
+
39
+ &.content-field a
40
+ background-image: image-url("wheelhouse-forms/content.png")
41
+
42
+ &.custom-field a
43
+ background-image: image-url("wheelhouse-forms/custom.png")
44
+
@@ -1,256 +1,7 @@
1
1
  @import compass
2
2
 
3
- =field
4
- position: relative
5
- margin: 10px 0
6
- padding: 0 0 0 32px
7
- +border-radius(4px)
8
-
9
- =colored-field( $background, $border, $text )
10
- background: $background
11
- border: 1px solid $border
12
-
13
- label
14
- color: $text
15
-
16
- .drag
17
- border-right: 1px solid $border
18
-
19
- =blue
20
- +colored-field(#f3f7fa, #cbd4da, #76828a)
21
-
22
- =green
23
- +colored-field(#f3f8f4, #d3dbd2, #748572)
24
-
25
- =orange
26
- +colored-field(#faf8f0, #e1ddc8, #8c8977)
27
-
28
- =purple
29
- +colored-field(#fdfafd, #e3d2e3, #987898)
30
-
31
- .drag-area
32
- padding: 6px
33
- margin-left: -32px
34
- padding-left: 38px
35
-
36
- .field-set > &
37
- margin-left: -14px
38
- padding-left: 20px
39
-
40
- #fields
41
- label
42
- display: inline
43
-
44
- input[type=text]
45
- width: 40%
46
- display: inline
47
-
48
- select
49
- margin: 0.4em 0
50
- padding: 0.5% 0.2% 0.2% 0.2%
51
- font-size: 110%
52
-
53
- input, select
54
- font-size: 100%
55
-
56
- &.placeholder
57
- color: #ccc
58
-
59
- label
60
- color: #545454
61
- font-weight: bold
62
- margin-right: 0.5em
63
-
64
- &.required
65
- float: right
66
- margin: 0.5em 0
67
- margin-right: 10%
68
- font-weight: normal
69
- font-size: 95%
70
-
71
- input
72
- margin-right: 4px
73
-
74
- span.note
75
- font-size: 95%
76
- color: #a9a9a9
77
-
78
- .field-set
79
- +field
80
- background: #fdfefe
81
- border: 1px solid #ccc
82
- padding-left: 14px
83
-
84
- .placeholder, .text-field, .text-area, .select-field, .checkbox, .submit-button, .states-dropdown, .countries-dropdown, .radio-buttons, .checkboxes, .custom-field, .content-field
85
- margin-left: 0
86
- margin-right: 0
87
-
88
- .fields
89
- margin-right: 5px
90
-
91
- .text-field, .text-area, .select-field, .checkbox, .submit-button, .states-dropdown, .countries-dropdown, .radio-buttons, .checkboxes, .custom-field, .content-field
92
- +field
93
- min-height: 26px
94
-
95
- input[type=text]
96
- width: 47%
97
-
98
- select
99
- display: inline
100
- width: 17%
101
- margin-left: 2%
102
-
103
- .drag
104
- width: 24px
105
-
106
- a.delete
107
- top: 12px
108
- right: 8px
109
-
110
- .text-field, .text-area, .content-field
111
- +blue
112
-
113
- .checkbox, .radio-buttons, .checkboxes
114
- +orange
115
-
116
- .select-field, .states-dropdown, .countries-dropdown
117
- +green
118
-
119
- .submit-button, .custom-field
120
- +purple
121
-
122
- .drag-placeholder
123
- +field
124
- border: 1px dashed #ccc
125
- padding: 6px 6px 6px 38px
126
-
127
- .content-field
128
- a.delete
129
- top: 14px
130
- right: 14px
131
-
132
- .field-set .content-field
133
- a.delete
134
- right: 12px
135
-
136
- .custom-field
137
- input[type=text]
138
- width: 40%
139
-
140
- ul.options
141
- line-height: 2.6em
142
- min-height: 2em
143
- margin-top: 0.5em
144
-
145
- li
146
- display: inline
147
- margin-right: 5px
148
-
149
- input[type=text]
150
- width: auto
151
- min-width: 8em
152
-
153
- .drag
154
- position: absolute
155
- top: 0
156
- left: 0
157
- cursor: move
158
- width: 7px
159
- height: 100%
160
- background: image-url("wheelhouse/backgrounds/drag.png") repeat
161
- border-right: 1px solid #dfdfdf
162
- +border-left-radius(4px)
163
-
164
- img
165
- margin: 12px 4px
166
-
167
- .fields
168
- min-height: 100px
169
-
170
- a.delete
171
- position: absolute
172
- right: 14px
173
- top: 16px
174
- z-index: 99
175
- width: 16px
176
- height: 16px
177
- background: image-url("wheelhouse/icons/delete-item.png") no-repeat
178
- text-indent: -9999px
179
- opacity: 0.5
180
-
181
- &:hover
182
- opacity: 1.0
183
-
184
- .tools li
185
- a
186
- padding-left: 45px
187
- background-position: 17px center
188
-
189
- &:hover
190
- background-color: #d3dadf
191
-
192
- &.text-field a
193
- background-image: image-url("wheelhouse-forms/text-field.png")
194
-
195
- &.text-area a
196
- background-image: image-url("wheelhouse-forms/text-area.png")
197
-
198
- &.select-field a
199
- background-image: image-url("wheelhouse-forms/select.png")
200
-
201
- &.checkbox a
202
- background-image: image-url("wheelhouse-forms/checkbox.png")
203
-
204
- &.checkboxes a
205
- background-image: image-url("wheelhouse-forms/checkboxes.png")
206
-
207
- &.radio-buttons a
208
- background-image: image-url("wheelhouse-forms/radio-buttons.png")
209
-
210
- &.field-set a
211
- background-image: image-url("wheelhouse-forms/field-set.png")
212
-
213
- &.submit-button a
214
- background-image: image-url("wheelhouse-forms/submit-button.png")
215
-
216
- &.states-dropdown a
217
- background-image: image-url("wheelhouse-forms/states.png")
218
-
219
- &.countries-dropdown a
220
- background-image: image-url("wheelhouse-forms/countries.png")
221
-
222
- &.content-field a
223
- background-image: image-url("wheelhouse-forms/content.png")
224
-
225
- &.custom-field a
226
- background-image: image-url("wheelhouse-forms/custom.png")
227
-
228
- .sidebar
229
- a.spam-submissions
230
- background-image: image-url("wheelhouse-forms/spam-small.png")
231
- padding-left: 40px
232
-
233
- a.latest-submissions
234
- background-image: image-url("wheelhouse-forms/submissions.png")
235
- padding-left: 40px
236
-
237
- a.export-csv
238
- background-image: image-url("wheelhouse-forms/csv.png")
239
- padding-left: 40px
240
-
241
- button.mark-spam, button.not-spam
242
- width: 222px
243
-
244
- .field
245
- li
246
- margin-bottom: 0.2em
247
-
248
- .shaded
249
- h2
250
- border-bottom: 1px solid #ddd
251
- padding-bottom: 5px
252
- margin-right: 6%
253
-
254
- .inline input
255
- margin-right: 1em
256
-
3
+ @import mixins
4
+ @import fields
5
+ @import tools
6
+ @import sidebar
7
+ @import submissions
@@ -1,5 +1,13 @@
1
1
  module Forms::FormsHelper
2
2
  class FormBuilder < ActionView::Helpers::FormBuilder
3
+ def initialize(field, prefix, template)
4
+ if ActionPack::VERSION::STRING >= "4.0.0"
5
+ super(prefix, field, template, {})
6
+ else
7
+ super(prefix, field, template, {}, nil)
8
+ end
9
+ end
10
+
3
11
  def required_field_checkbox
4
12
  @template.content_tag(:label, :class => "required") do
5
13
  check_box(:required, :id => nil) + " This field is required"
@@ -8,13 +16,12 @@ module Forms::FormsHelper
8
16
  end
9
17
 
10
18
  def form_field(field, options={}, &block)
11
- builder = FormBuilder.new(options[:prefix], field, self, {}, block)
12
- icon = options[:icon] || field.class.model_name.demodulize.underscore.dasherize
19
+ builder = FormBuilder.new(field, options[:prefix], self)
13
20
 
14
21
  content_tag(:div, :class => options[:class], :data => { :index => options[:index] }) do
15
22
  concat builder.hidden_field(:type, :value => field.type.demodulize, :id => nil)
16
23
 
17
- concat content_tag(:div, image_tag("wheelhouse-forms/#{icon}.png", :alt => field.class.model_name.human, :title => field.class.model_name.human), :class => "drag")
24
+ concat content_tag(:div, form_field_icon(field, options), :class => "drag")
18
25
 
19
26
  concat content_tag(:div, capture(builder, &block), :class => "drag-area")
20
27
 
@@ -33,4 +40,10 @@ module Forms::FormsHelper
33
40
  render :partial => klass.partial, :object => klass.new, :locals => { :index => "${index}", :prefix => "${prefix}" }
34
41
  end
35
42
  end
43
+
44
+ def form_field_icon(field, options)
45
+ model_name = field.class.model_name
46
+ icon = options[:icon] || model_name.to_s.demodulize.underscore.dasherize
47
+ image_tag("wheelhouse-forms/#{icon}.png", :alt => model_name.human, :title => model_name.human)
48
+ end
36
49
  end
@@ -4,8 +4,15 @@ class Forms::Mailer < ActionMailer::Base
4
4
  def submission(form, submission)
5
5
  @form, @submission = form, submission
6
6
 
7
- mail(:from => "no-reply@#{form.site.domain}",
8
- :to => form.recipients,
7
+ mail(:from => form.email_sender,
8
+ :to => form.recipients,
9
9
  :subject => form.subject)
10
10
  end
11
+
12
+ def confirmation(form, submission)
13
+ mail(:from => form.email_sender,
14
+ :to => submission.email,
15
+ :subject => form.confirmation_email_subject,
16
+ :body => form.confirmation_email_body)
17
+ end
11
18
  end
@@ -7,9 +7,15 @@ class Forms::Form < Wheelhouse::Resource
7
7
 
8
8
  property :title, String, :required => true, :translate => true
9
9
  property :fields, FieldCollection, :default => [Forms::Fields::FieldSet.new]
10
+
11
+ property :submission_notification, Boolean, :default => true
10
12
  property :recipients, MongoModel::Collection[String]
11
13
  property :subject, String, :default => "Form Submission"
12
14
 
15
+ property :confirmation_email, Boolean, :default => false
16
+ property :confirmation_email_subject, String
17
+ property :confirmation_email_body, String
18
+
13
19
  validates_associated :fields
14
20
 
15
21
  has_many :submissions, :class => "Forms::Submission"
@@ -41,8 +47,13 @@ class Forms::Form < Wheelhouse::Resource
41
47
  end
42
48
  end
43
49
 
50
+ def email_sender
51
+ "noreply@#{site.domain}"
52
+ end
53
+
44
54
  def deliver(submission)
45
- Forms::Mailer.submission(self, submission).deliver unless recipients.empty?
55
+ Forms::Mailer.submission(self, submission).deliver if deliver_submission_notification?
56
+ Forms::Mailer.confirmation(self, submission).deliver if deliver_confirmation_email?(submission)
46
57
  rescue
47
58
  # Mail delivery failed
48
59
  end
@@ -63,4 +74,13 @@ class Forms::Form < Wheelhouse::Resource
63
74
  def handler
64
75
  Forms::FormHandler
65
76
  end
77
+
78
+ protected
79
+ def deliver_submission_notification?
80
+ submission_notification? && recipients.any?
81
+ end
82
+
83
+ def deliver_confirmation_email?(submission)
84
+ confirmation_email? && submission.email.present?
85
+ end
66
86
  end
@@ -21,6 +21,10 @@ class Forms::Submission < Wheelhouse::BasicResource
21
21
  end
22
22
  end
23
23
 
24
+ def email
25
+ params.find { |label, value| label =~ /e-?mail/i }.last
26
+ end
27
+
24
28
  def spam!(is_spam)
25
29
  Forms::Plugin.config.wheelhouse.forms.spam_filter.train(self, is_spam)
26
30
  update_attribute(:spam, is_spam)
@@ -1,7 +1,7 @@
1
1
  class Forms::CheckboxRenderer < Forms::FieldRenderer
2
2
  def render
3
3
  super do
4
- label_tag { check_box_tag(name, "Yes", value, html_options) + " " + field.label }
4
+ label_tag { check_box_tag(name, "Yes", value, html_options) + " " + label }
5
5
  end
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ protected
12
12
 
13
13
  def checkbox(option)
14
14
  content_tag(:label, :class => "option #{option.parameterize}") do
15
- check_box_tag("#{name}[]", option, (value || []).include?(option), :id => nil) + " " + option
15
+ check_box_tag("#{name}[]", option, (value || []).include?(option), :id => nil) + " " + option.html_safe
16
16
  end
17
17
  end
18
18
  end
@@ -25,6 +25,10 @@ protected
25
25
  field.label
26
26
  end
27
27
 
28
+ def label
29
+ field.label.html_safe
30
+ end
31
+
28
32
  def field_class
29
33
  field.class.partial.dasherize
30
34
  end
@@ -2,7 +2,7 @@ class Forms::FieldSetRenderer < Forms::FieldRenderer
2
2
  def render
3
3
  content_tag(:fieldset, :class => field.legend? ? field.legend.parameterize : '') do
4
4
  ActiveSupport::SafeBuffer.new.tap do |result|
5
- result << content_tag(:legend, field.legend) if field.legend?
5
+ result << content_tag(:legend, field.legend.html_safe) if field.legend?
6
6
  result << field.fields.render(submission, template)
7
7
  end
8
8
  end
@@ -2,7 +2,7 @@ module Forms::LabelledFieldRenderer
2
2
  def render
3
3
  super do
4
4
  result = ActiveSupport::SafeBuffer.new
5
- result << label_tag(name, field.label.html_safe) if field.label?
5
+ result << label_tag(name, label) if field.label?
6
6
  result << yield if block_given?
7
7
  result
8
8
  end
@@ -12,7 +12,7 @@ protected
12
12
 
13
13
  def radio_button(option)
14
14
  content_tag(:label, :class => "option #{option.parameterize}") do
15
- radio_button_tag(name, option, value == option, :id => nil) + " " + option
15
+ radio_button_tag(name, option, value == option, :id => nil) + " " + option.html_safe
16
16
  end
17
17
  end
18
18
  end
@@ -6,4 +6,9 @@ class Forms::SelectFieldRenderer < Forms::FieldRenderer
6
6
  def render
7
7
  super { select_tag(name, options_for_select(field.options, value), html_options) }
8
8
  end
9
+
10
+ protected
11
+ def html_options
12
+ super.merge(:include_blank => true)
13
+ end
9
14
  end
@@ -1,5 +1,5 @@
1
1
  class Forms::SubmitButtonRenderer < Forms::FieldRenderer
2
2
  def render
3
- content_tag(:div, submit_tag(field.label), :class => "field submit")
3
+ content_tag(:div, submit_tag(label), :class => "field submit")
4
4
  end
5
5
  end
@@ -9,8 +9,8 @@
9
9
 
10
10
  %span.note (leave blank for none)
11
11
 
12
- .fields{ "data-prefix" => "form[fields][#{index}][fields]" }
13
- = render_fields(field_set.fields, "form[fields][#{index}][fields]")
12
+ .fields{ "data-prefix" => "#{prefix}[fields]" }
13
+ = render_fields(field_set.fields, "#{prefix}[fields]")
14
14
 
15
15
  = link_to "Delete", '#', :class => 'delete'
16
16
 
@@ -1,5 +1,5 @@
1
1
  - tab :fields do
2
- #fields{ "data-prefix" => "form[fields]" }
2
+ #fields.fields{ "data-prefix" => "form[fields]" }
3
3
  = render_fields(@form.fields, "form[fields]")
4
4
 
5
5
  = field_template "field-set-template", Forms::Fields::FieldSet
@@ -23,12 +23,27 @@
23
23
  = content
24
24
 
25
25
  - tab :email do
26
- = field :recipients do
27
- = form.text_field :recipients, :value => @form.recipients.join(', ')
28
- = note "Separate email addresses with commas."
26
+ = field :submission_notification, :label => false, :class => "title" do
27
+ = form.check_box :submission_notification, :label => "Submission Notification", :data => { :disable => "#submission-notification-options" }
29
28
 
30
- = field :subject do
31
- = form.text_field :subject
29
+ #submission-notification-options.shaded
30
+ = field :recipients do
31
+ = form.text_field :recipients, :value => @form.recipients.join(', ')
32
+ = note "Separate email addresses with commas."
33
+
34
+ = field :subject do
35
+ = form.text_field :subject
36
+
37
+ = field :confirmation_email, :label => false, :class => "title" do
38
+ = form.check_box :confirmation_email, :label => "Confirmation Email", :data => { :disable => "#confirmation-email-options" }
39
+ = note "Confirmation emails will be sent to the first form field with a label containing \"email\"."
40
+
41
+ #confirmation-email-options.shaded
42
+ = field :confirmation_email_subject do
43
+ = form.text_field :confirmation_email_subject
44
+
45
+ = field :confirmation_email_body do
46
+ = form.text_area :confirmation_email_body, :rows => 20
32
47
 
33
48
  - sidebar do
34
49
  = render "wheelhouse/admin/resource/default_sidebar"
@@ -4,4 +4,6 @@ en:
4
4
  form:
5
5
  title: Form Title
6
6
  content: Form Content
7
+ confirmation_email_subject: Confirmation Email Subject
8
+ confirmation_email_body: Confirmation Email Body
7
9
 
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wheelhouse-forms
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
5
- prerelease:
4
+ version: '1.2'
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sam Pohlenz
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-12 00:00:00.000000000 Z
11
+ date: 2014-03-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: wheelhouse
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.0'
30
27
  description: Integrates forms into your Wheelhouse CMS site.
@@ -33,6 +30,8 @@ executables: []
33
30
  extensions: []
34
31
  extra_rdoc_files: []
35
32
  files:
33
+ - LICENSE
34
+ - README.md
36
35
  - app/assets/images/wheelhouse-forms/checkbox.png
37
36
  - app/assets/images/wheelhouse-forms/checkboxes.png
38
37
  - app/assets/images/wheelhouse-forms/content.png
@@ -57,6 +56,11 @@ files:
57
56
  - app/assets/javascripts/wheelhouse-forms/jquery.autogrow.js
58
57
  - app/assets/javascripts/wheelhouse-forms/jquery.options.js
59
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
60
64
  - app/assets/stylesheets/wheelhouse-forms/admin.css.sass
61
65
  - app/controllers/forms/forms_controller.rb
62
66
  - app/controllers/forms/submissions_controller.rb
@@ -82,8 +86,8 @@ files:
82
86
  - app/models/forms/fields/text_area.rb
83
87
  - app/models/forms/fields/text_field.rb
84
88
  - app/models/forms/form.rb
85
- - app/models/forms/submission/parameters.rb
86
89
  - app/models/forms/submission.rb
90
+ - app/models/forms/submission/parameters.rb
87
91
  - app/renderers/forms/checkbox_renderer.rb
88
92
  - app/renderers/forms/checkboxes_renderer.rb
89
93
  - app/renderers/forms/content_field_renderer.rb
@@ -98,9 +102,9 @@ files:
98
102
  - app/renderers/forms/submit_button_renderer.rb
99
103
  - app/renderers/forms/text_area_renderer.rb
100
104
  - app/renderers/forms/text_field_renderer.rb
101
- - app/templates/form/submission.html.haml
102
105
  - app/templates/form.html.haml
103
106
  - app/templates/form.xhr.haml
107
+ - app/templates/form/submission.html.haml
104
108
  - app/views/forms/forms/_checkbox.haml
105
109
  - app/views/forms/forms/_checkboxes.haml
106
110
  - app/views/forms/forms/_content_field.haml
@@ -130,30 +134,27 @@ files:
130
134
  - lib/forms/csv_exporter.rb
131
135
  - lib/forms/null_filter.rb
132
136
  - lib/wheelhouse-forms.rb
133
- - README.md
134
- - LICENSE
135
137
  homepage: https://www.wheelhousecms.com
136
138
  licenses: []
139
+ metadata: {}
137
140
  post_install_message:
138
141
  rdoc_options: []
139
142
  require_paths:
140
143
  - lib
141
144
  required_ruby_version: !ruby/object:Gem::Requirement
142
- none: false
143
145
  requirements:
144
- - - ! '>='
146
+ - - ">="
145
147
  - !ruby/object:Gem::Version
146
148
  version: 1.8.7
147
149
  required_rubygems_version: !ruby/object:Gem::Requirement
148
- none: false
149
150
  requirements:
150
- - - ! '>='
151
+ - - ">="
151
152
  - !ruby/object:Gem::Version
152
153
  version: 1.3.6
153
154
  requirements: []
154
155
  rubyforge_project:
155
- rubygems_version: 1.8.24
156
+ rubygems_version: 2.2.2
156
157
  signing_key:
157
- specification_version: 3
158
+ specification_version: 4
158
159
  summary: Wheelhouse CMS Forms Plugin
159
160
  test_files: []