wheelhouse-forms 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/LICENSE +22 -0
  2. data/README.md +39 -0
  3. data/app/assets/images/wheelhouse-forms/checkbox.png +0 -0
  4. data/app/assets/images/wheelhouse-forms/checkboxes.png +0 -0
  5. data/app/assets/images/wheelhouse-forms/content.png +0 -0
  6. data/app/assets/images/wheelhouse-forms/countries.png +0 -0
  7. data/app/assets/images/wheelhouse-forms/csv.png +0 -0
  8. data/app/assets/images/wheelhouse-forms/custom.png +0 -0
  9. data/app/assets/images/wheelhouse-forms/drag.png +0 -0
  10. data/app/assets/images/wheelhouse-forms/field-set.png +0 -0
  11. data/app/assets/images/wheelhouse-forms/form.png +0 -0
  12. data/app/assets/images/wheelhouse-forms/radio-buttons.png +0 -0
  13. data/app/assets/images/wheelhouse-forms/select.png +0 -0
  14. data/app/assets/images/wheelhouse-forms/states.png +0 -0
  15. data/app/assets/images/wheelhouse-forms/submit-button.png +0 -0
  16. data/app/assets/images/wheelhouse-forms/text-area.png +0 -0
  17. data/app/assets/images/wheelhouse-forms/text-field.png +0 -0
  18. data/app/assets/javascripts/wheelhouse-forms/admin.js +125 -0
  19. data/app/assets/javascripts/wheelhouse-forms/jquery.autogrow.js +50 -0
  20. data/app/assets/javascripts/wheelhouse-forms/jquery.options.js +24 -0
  21. data/app/assets/stylesheets/wheelhouse-forms/admin.css.sass +244 -0
  22. data/app/controllers/forms/forms_controller.rb +9 -0
  23. data/app/controllers/forms/submissions_controller.rb +19 -0
  24. data/app/handlers/forms/form_handler.rb +17 -0
  25. data/app/helpers/forms/forms_helper.rb +36 -0
  26. data/app/helpers/forms/mailer_helper.rb +67 -0
  27. data/app/helpers/forms/submissions_helper.rb +71 -0
  28. data/app/mailers/forms/mailer.rb +11 -0
  29. data/app/models/forms/field_collection.rb +21 -0
  30. data/app/models/forms/fields/checkbox.rb +8 -0
  31. data/app/models/forms/fields/checkboxes.rb +10 -0
  32. data/app/models/forms/fields/content_field.rb +7 -0
  33. data/app/models/forms/fields/countries_dropdown.rb +14 -0
  34. data/app/models/forms/fields/custom_field.rb +8 -0
  35. data/app/models/forms/fields/field.rb +28 -0
  36. data/app/models/forms/fields/field_set.rb +14 -0
  37. data/app/models/forms/fields/optioned_field.rb +17 -0
  38. data/app/models/forms/fields/radio_buttons.rb +10 -0
  39. data/app/models/forms/fields/select_field.rb +10 -0
  40. data/app/models/forms/fields/states_dropdown.rb +15 -0
  41. data/app/models/forms/fields/submit_button.rb +7 -0
  42. data/app/models/forms/fields/text_area.rb +8 -0
  43. data/app/models/forms/fields/text_field.rb +21 -0
  44. data/app/models/forms/form.rb +65 -0
  45. data/app/models/forms/submission.rb +53 -0
  46. data/app/renderers/forms/checkbox_renderer.rb +7 -0
  47. data/app/renderers/forms/checkboxes_renderer.rb +18 -0
  48. data/app/renderers/forms/content_field_renderer.rb +5 -0
  49. data/app/renderers/forms/custom_field_renderer.rb +5 -0
  50. data/app/renderers/forms/field_collection_renderer.rb +13 -0
  51. data/app/renderers/forms/field_renderer.rb +57 -0
  52. data/app/renderers/forms/field_set_renderer.rb +10 -0
  53. data/app/renderers/forms/form_renderer.rb +30 -0
  54. data/app/renderers/forms/labelled_field_renderer.rb +10 -0
  55. data/app/renderers/forms/radio_buttons_renderer.rb +18 -0
  56. data/app/renderers/forms/select_field_renderer.rb +9 -0
  57. data/app/renderers/forms/submit_button_renderer.rb +5 -0
  58. data/app/renderers/forms/text_area_renderer.rb +7 -0
  59. data/app/renderers/forms/text_field_renderer.rb +7 -0
  60. data/app/templates/form.html.haml +9 -0
  61. data/app/templates/form.xhr.haml +4 -0
  62. data/app/templates/form/submission.html.haml +15 -0
  63. data/app/views/forms/forms/_checkbox.haml +3 -0
  64. data/app/views/forms/forms/_checkboxes.haml +10 -0
  65. data/app/views/forms/forms/_content_field.haml +3 -0
  66. data/app/views/forms/forms/_countries_dropdown.haml +4 -0
  67. data/app/views/forms/forms/_custom_field.haml +4 -0
  68. data/app/views/forms/forms/_field_set.haml +16 -0
  69. data/app/views/forms/forms/_radio_buttons.haml +10 -0
  70. data/app/views/forms/forms/_select_field.haml +10 -0
  71. data/app/views/forms/forms/_states_dropdown.haml +4 -0
  72. data/app/views/forms/forms/_submissions.haml +20 -0
  73. data/app/views/forms/forms/_submit_button.haml +2 -0
  74. data/app/views/forms/forms/_text_area.haml +3 -0
  75. data/app/views/forms/forms/_text_field.haml +4 -0
  76. data/app/views/forms/forms/designer.haml +56 -0
  77. data/app/views/forms/forms/edit.html.haml +5 -0
  78. data/app/views/forms/forms/form.haml +22 -0
  79. data/app/views/forms/forms/new.html.haml +4 -0
  80. data/app/views/forms/forms/show.html.haml +4 -0
  81. data/app/views/forms/submissions/form.haml +16 -0
  82. data/app/views/forms/submissions/show.html.haml +4 -0
  83. data/config/countries.yml +245 -0
  84. data/config/locales/en.yml +7 -0
  85. data/config/routes.rb +7 -0
  86. data/config/states.yml +62 -0
  87. data/lib/forms/csv_exporter.rb +41 -0
  88. data/lib/wheelhouse-forms.rb +26 -0
  89. metadata +149 -0
@@ -0,0 +1,10 @@
1
+ = form_field(radio_buttons, :index => index, :prefix => prefix, :class => "radio-buttons") do |f|
2
+ = f.text_field :label, :title => "Radio Buttons Label", :placeholder => "Radio Buttons Label", :id => nil
3
+ = f.required_field_checkbox
4
+
5
+ %ul.options
6
+ %li
7
+ %label Options:
8
+
9
+ - radio_buttons.options(true).each do |option|
10
+ %li= text_field_tag "#{prefix}[options][]", option, :id => nil
@@ -0,0 +1,10 @@
1
+ = form_field(select_field, :index => index, :prefix => prefix, :class => "select-field", :icon => "select") do |f|
2
+ = f.text_field :label, :title => "Select Field Label", :placeholder => "Select Field Label", :id => nil
3
+ = f.required_field_checkbox
4
+
5
+ %ul.options
6
+ %li
7
+ %label Options:
8
+
9
+ - select_field.options(true).each do |option|
10
+ %li= text_field_tag "#{prefix}[options][]", option, :id => nil
@@ -0,0 +1,4 @@
1
+ = form_field(states_dropdown, :index => index, :prefix => prefix, :class => "states-dropdown", :icon => "states") do |f|
2
+ = f.text_field :label, :title => "States Dropdown Label", :placeholder => "States Dropdown Label", :id => nil
3
+ = f.select :country, [["US States", "US"], ["Australian States", "Australia"]], {}, :id => nil
4
+ = f.required_field_checkbox
@@ -0,0 +1,20 @@
1
+ - @submissions = resource.submissions.paginate(:page => params[:p])
2
+
3
+ %h2 Latest Submissions
4
+
5
+ = table_for Forms::Submission do |table|
6
+ - table.rows(@submissions) do |row, submission|
7
+ - row.resource = [@form, submission]
8
+
9
+ - if resource.first_content_field
10
+ = row.column(resource.first_content_field.label) { submission.value_for(resource.first_content_field) }
11
+
12
+ = row.column(:submitted_at) { submission.created_at.in_time_zone.to_s(:long) }
13
+
14
+ = row.controls do |c|
15
+ = c.delete
16
+
17
+ - table.empty do
18
+ No submissions have been posted.
19
+
20
+ = will_paginate @submissions
@@ -0,0 +1,2 @@
1
+ = form_field(submit_button, :index => index, :prefix => prefix, :class => "submit-button") do |f|
2
+ = f.text_field :label, :title => "Submit Button Label", :placeholder => "Submit Button Label", :id => nil
@@ -0,0 +1,3 @@
1
+ = form_field(text_area, :index => index, :prefix => prefix, :class => "text-area") do |f|
2
+ = f.text_field :label, :title => "Text Area Label", :placeholder => "Text Area Label", :id => nil
3
+ = f.required_field_checkbox
@@ -0,0 +1,4 @@
1
+ = form_field(text_field, :index => index, :prefix => prefix, :class => "text-field") do |f|
2
+ = f.text_field :label, :title => "Text Field Label", :placeholder => "Text Field Label", :id => nil
3
+ = f.select :input_type, Forms::Fields::TextField::INPUT_TYPES, {}, :id => nil
4
+ = f.required_field_checkbox
@@ -0,0 +1,56 @@
1
+ - tab :fields do
2
+ #fields{ "data-prefix" => "form[fields]" }
3
+ = render_fields(@form.fields, "form[fields]")
4
+
5
+ = field_template "field-set-template", Forms::Fields::FieldSet
6
+ = field_template "text-field-template", Forms::Fields::TextField
7
+ = field_template "text-area-template", Forms::Fields::TextArea
8
+ = field_template "select-field-template", Forms::Fields::SelectField
9
+ = field_template "checkbox-template", Forms::Fields::Checkbox
10
+ = field_template "checkboxes-template", Forms::Fields::Checkboxes
11
+ = field_template "radio-buttons-template", Forms::Fields::RadioButtons
12
+ = field_template "submit-button-template", Forms::Fields::SubmitButton
13
+ = field_template "states-dropdown-template", Forms::Fields::StatesDropdown
14
+ = field_template "countries-dropdown-template", Forms::Fields::CountriesDropdown
15
+ = field_template "content-field-template", Forms::Fields::ContentField
16
+ = field_template "custom-field-template", Forms::Fields::CustomField if Forms::Plugin.config.wheelhouse.forms.custom_fields
17
+
18
+ - tab :content do
19
+ = field :title do
20
+ = form.text_field :title, :title => true
21
+ = note "The form title will appear in the title bar of the user's browser window."
22
+
23
+ = content
24
+
25
+ - tab :email do
26
+ = field :recipients do
27
+ = form.text_field :recipients, :value => @form.recipients.join(', ')
28
+ = note "Separate email addresses with commas."
29
+
30
+ = field :subject do
31
+ = form.text_field :subject
32
+
33
+ - sidebar do
34
+ = render "wheelhouse/admin/resource/default_sidebar"
35
+
36
+ %ul#primary-tools.tools
37
+ %li.text-field= link_to "Add Text Field", "#"
38
+ %li.text-area= link_to "Add Text Area", "#"
39
+ %li.select-field= link_to "Add Select Field", "#"
40
+ %li.checkbox= link_to "Add Single Checkbox", "#"
41
+ %li.checkboxes= link_to "Add Checkboxes", "#"
42
+ %li.radio-buttons= link_to "Add Radio Buttons", "#"
43
+ %li.field-set= link_to "Add Field Set", "#"
44
+ %li.submit-button= link_to "Add Submit Button", "#"
45
+
46
+ %ul#extra-tools.tools
47
+ %li.states-dropdown= link_to "Add States Dropdown", "#"
48
+ %li.countries-dropdown= link_to "Add Countries Dropdown", "#"
49
+ %li.content-field= link_to "Add Content Field", "#"
50
+ %li.custom-field= link_to "Add Custom Field", "#" if Forms::Plugin.config.wheelhouse.forms.custom_fields
51
+
52
+ - content_for(:head) do
53
+ = stylesheet_link_tag "wheelhouse-forms/admin"
54
+
55
+ - content_for(:javascript) do
56
+ = javascript_include_tag "wheelhouse-forms/admin"
@@ -0,0 +1,5 @@
1
+ - title "Editing Form"
2
+ - breadcrumb @form.label, form_path(@form)
3
+ - breadcrumb "Editing Form"
4
+
5
+ = render_form "designer"
@@ -0,0 +1,22 @@
1
+ - tab :submissions => "submissions"
2
+
3
+ - sidebar do
4
+ .buttons
5
+ = button "Form Designer", :icon => :publish, :url => edit_form_path(@form)
6
+
7
+ %hr
8
+
9
+ %ul
10
+ %li= link_to "Export results as CSV", form_submissions_path(@form, :format => :csv), :class => "export-csv"
11
+
12
+ %hr
13
+
14
+ - if last_submission = @form.submissions.first
15
+ %p.owner Last submission: #{timestamp(last_submission.created_at)}
16
+
17
+ = owner
18
+
19
+ %hr
20
+
21
+ - content_for(:head) do
22
+ = stylesheet_link_tag "wheelhouse-forms/admin"
@@ -0,0 +1,4 @@
1
+ - title "New Form"
2
+ - breadcrumb "New Form"
3
+
4
+ = render_form "designer"
@@ -0,0 +1,4 @@
1
+ - title @form.label
2
+ - breadcrumb @form.label
3
+
4
+ = render_form
@@ -0,0 +1,16 @@
1
+ - form! [@form, @submission], :as => :submission, :url => @submission.admin_path
2
+
3
+ - tab :submission do
4
+ - @form.fields.each do |field|
5
+ = render_field(field)
6
+
7
+ - sidebar do
8
+ .buttons
9
+ = button "Back to list", :url => @form
10
+
11
+ %hr
12
+
13
+ %p.owner Submitted: #{timestamp(@submission.created_at)}
14
+
15
+ - content_for(:head) do
16
+ = stylesheet_link_tag "wheelhouse-forms/admin"
@@ -0,0 +1,4 @@
1
+ - title "Viewing Submission"
2
+ - breadcrumb "Viewing Submission"
3
+
4
+ = render_form
@@ -0,0 +1,245 @@
1
+ - Afghanistan
2
+ - Aland Islands
3
+ - Albania
4
+ - Algeria
5
+ - American Samoa
6
+ - Andorra
7
+ - Angola
8
+ - Anguilla
9
+ - Antarctica
10
+ - Antigua And Barbuda
11
+ - Argentina
12
+ - Armenia
13
+ - Aruba
14
+ - Australia
15
+ - Austria
16
+ - Azerbaijan
17
+ - Bahamas
18
+ - Bahrain
19
+ - Bangladesh
20
+ - Barbados
21
+ - Belarus
22
+ - Belgium
23
+ - Belize
24
+ - Benin
25
+ - Bermuda
26
+ - Bhutan
27
+ - Bolivia
28
+ - Bosnia and Herzegowina
29
+ - Botswana
30
+ - Bouvet Island
31
+ - Brazil
32
+ - British Indian Ocean Territory
33
+ - Brunei Darussalam
34
+ - Bulgaria
35
+ - Burkina Faso
36
+ - Burundi
37
+ - Cambodia
38
+ - Cameroon
39
+ - Canada
40
+ - Cape Verde
41
+ - Cayman Islands
42
+ - Central African Republic
43
+ - Chad
44
+ - Chile
45
+ - China
46
+ - Christmas Island
47
+ - Cocos (Keeling) Islands
48
+ - Colombia
49
+ - Comoros
50
+ - Congo
51
+ - Congo, the Democratic Republic of the
52
+ - Cook Islands
53
+ - Costa Rica
54
+ - Cote d'Ivoire
55
+ - Croatia
56
+ - Cuba
57
+ - Cyprus
58
+ - Czech Republic
59
+ - Denmark
60
+ - Djibouti
61
+ - Dominica
62
+ - Dominican Republic
63
+ - Ecuador
64
+ - Egypt
65
+ - El Salvador
66
+ - Equatorial Guinea
67
+ - Eritrea
68
+ - Estonia
69
+ - Ethiopia
70
+ - Falkland Islands (Malvinas)
71
+ - Faroe Islands
72
+ - Fiji
73
+ - Finland
74
+ - France
75
+ - French Guiana
76
+ - French Polynesia
77
+ - French Southern Territories
78
+ - Gabon
79
+ - Gambia
80
+ - Georgia
81
+ - Germany
82
+ - Ghana
83
+ - Gibraltar
84
+ - Greece
85
+ - Greenland
86
+ - Grenada
87
+ - Guadeloupe
88
+ - Guam
89
+ - Guatemala
90
+ - Guernsey
91
+ - Guinea
92
+ - Guinea-Bissau
93
+ - Guyana
94
+ - Haiti
95
+ - Heard and McDonald Islands
96
+ - Holy See (Vatican City State)
97
+ - Honduras
98
+ - Hong Kong
99
+ - Hungary
100
+ - Iceland
101
+ - India
102
+ - Indonesia
103
+ - Iran, Islamic Republic of
104
+ - Iraq
105
+ - Ireland
106
+ - Isle of Man
107
+ - Israel
108
+ - Italy
109
+ - Jamaica
110
+ - Japan
111
+ - Jersey
112
+ - Jordan
113
+ - Kazakhstan
114
+ - Kenya
115
+ - Kiribati
116
+ - Korea, Democratic People's Republic of
117
+ - Korea, Republic of
118
+ - Kuwait
119
+ - Kyrgyzstan
120
+ - Lao People's Democratic Republic
121
+ - Latvia
122
+ - Lebanon
123
+ - Lesotho
124
+ - Liberia
125
+ - Libyan Arab Jamahiriya
126
+ - Liechtenstein
127
+ - Lithuania
128
+ - Luxembourg
129
+ - Macao
130
+ - Macedonia, The Former Yugoslav Republic Of
131
+ - Madagascar
132
+ - Malawi
133
+ - Malaysia
134
+ - Maldives
135
+ - Mali
136
+ - Malta
137
+ - Marshall Islands
138
+ - Martinique
139
+ - Mauritania
140
+ - Mauritius
141
+ - Mayotte
142
+ - Mexico
143
+ - Micronesia, Federated States of
144
+ - Moldova, Republic of
145
+ - Monaco
146
+ - Mongolia
147
+ - Montenegro
148
+ - Montserrat
149
+ - Morocco
150
+ - Mozambique
151
+ - Myanmar
152
+ - Namibia
153
+ - Nauru
154
+ - Nepal
155
+ - Netherlands
156
+ - Netherlands Antilles
157
+ - New Caledonia
158
+ - New Zealand
159
+ - Nicaragua
160
+ - Niger
161
+ - Nigeria
162
+ - Niue
163
+ - Norfolk Island
164
+ - Northern Mariana Islands
165
+ - Norway
166
+ - Oman
167
+ - Pakistan
168
+ - Palau
169
+ - Palestinian Territory, Occupied
170
+ - Panama
171
+ - Papua New Guinea
172
+ - Paraguay
173
+ - Peru
174
+ - Philippines
175
+ - Pitcairn
176
+ - Poland
177
+ - Portugal
178
+ - Puerto Rico
179
+ - Qatar
180
+ - Reunion
181
+ - Romania
182
+ - Russian Federation
183
+ - Rwanda
184
+ - Saint Barthelemy
185
+ - Saint Helena
186
+ - Saint Kitts and Nevis
187
+ - Saint Lucia
188
+ - Saint Pierre and Miquelon
189
+ - Saint Vincent and the Grenadines
190
+ - Samoa
191
+ - San Marino
192
+ - Sao Tome and Principe
193
+ - Saudi Arabia
194
+ - Senegal
195
+ - Serbia
196
+ - Seychelles
197
+ - Sierra Leone
198
+ - Singapore
199
+ - Slovakia
200
+ - Slovenia
201
+ - Solomon Islands
202
+ - Somalia
203
+ - South Africa
204
+ - South Georgia and the South Sandwich Islands
205
+ - Spain
206
+ - Sri Lanka
207
+ - Sudan
208
+ - Suriname
209
+ - Svalbard and Jan Mayen
210
+ - Swaziland
211
+ - Sweden
212
+ - Switzerland
213
+ - Syrian Arab Republic
214
+ - Taiwan, Province of China
215
+ - Tajikistan
216
+ - Tanzania, United Republic of
217
+ - Thailand
218
+ - Timor-Leste
219
+ - Togo
220
+ - Tokelau
221
+ - Tonga
222
+ - Trinidad and Tobago
223
+ - Tunisia
224
+ - Turkey
225
+ - Turkmenistan
226
+ - Turks and Caicos Islands
227
+ - Tuvalu
228
+ - Uganda
229
+ - Ukraine
230
+ - United Arab Emirates
231
+ - United Kingdom
232
+ - United States
233
+ - United States Minor Outlying Islands
234
+ - Uruguay
235
+ - Uzbekistan
236
+ - Vanuatu
237
+ - Venezuela
238
+ - Viet Nam
239
+ - Virgin Islands, British
240
+ - Virgin Islands, U.S.
241
+ - Wallis and Futuna
242
+ - Western Sahara
243
+ - Yemen
244
+ - Zambia
245
+ - Zimbabwe
@@ -0,0 +1,7 @@
1
+ en:
2
+ helpers:
3
+ label:
4
+ form:
5
+ title: Form Title
6
+ content: Form Content
7
+