formbuilder-rb 0.0.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +219 -0
- data/Guardfile +17 -0
- data/{MIT-LICENSE → LICENSE.md} +1 -1
- data/README.md +86 -0
- data/app/controllers/formbuilder/concerns/forms_controller.rb +59 -0
- data/app/models/formbuilder/entry_attachment.rb +2 -8
- data/app/models/formbuilder/form.rb +53 -0
- data/app/models/formbuilder/response_field.rb +23 -10
- data/app/models/formbuilder/response_field_address.rb +12 -1
- data/app/models/formbuilder/response_field_checkboxes.rb +38 -0
- data/app/models/formbuilder/response_field_date.rb +7 -1
- data/app/models/formbuilder/response_field_dropdown.rb +2 -1
- data/app/models/formbuilder/response_field_email.rb +14 -2
- data/app/models/formbuilder/response_field_file.rb +75 -20
- data/app/models/formbuilder/response_field_number.rb +9 -2
- data/app/models/formbuilder/response_field_page_break.rb +13 -0
- data/app/models/formbuilder/response_field_paragraph.rb +19 -3
- data/app/models/formbuilder/response_field_price.rb +10 -6
- data/app/models/formbuilder/response_field_radio.rb +11 -2
- data/app/models/formbuilder/response_field_section_break.rb +12 -2
- data/app/models/formbuilder/response_field_table.rb +222 -0
- data/app/models/formbuilder/response_field_text.rb +9 -2
- data/app/models/formbuilder/response_field_time.rb +8 -1
- data/app/models/formbuilder/response_field_website.rb +26 -2
- data/app/uploaders/formbuilder/entry_attachment_uploader.rb +11 -1
- data/bin/rails +8 -0
- data/circle.yml +9 -0
- data/config/spring.rb +1 -0
- data/db/migrate/20130924185815_create_formbuilder_entry_attachments.rb +1 -0
- data/formbuilder-rb.gemspec +41 -0
- data/formbuilder-rb.sublime-project +20 -0
- data/lib/formbuilder.rb +8 -3
- data/lib/formbuilder/entry.rb +102 -159
- data/lib/formbuilder/entry_validator.rb +13 -6
- data/lib/formbuilder/version.rb +1 -1
- data/lib/formbuilder/views/entry_dl.rb +56 -0
- data/lib/formbuilder/views/form.rb +81 -0
- data/lib/formbuilder/views/form_field.rb +45 -0
- data/spec/controllers/formbuilder/forms_controller_spec.rb +40 -0
- data/spec/dummy/.ruby-gemset +1 -0
- data/spec/dummy/.ruby-version +1 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/forms_controller.rb +3 -0
- data/spec/dummy/app/controllers/test_controller.rb +57 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/entry.rb +7 -0
- data/spec/dummy/app/models/entry_with_alternate_column_name.rb +11 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/test/_form.rb +2 -0
- data/spec/dummy/app/views/test/render_entry.html.erb +1 -0
- data/spec/dummy/app/views/test/show_form.html.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +25 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml.ci +15 -0
- data/spec/dummy/config/database.yml.example +15 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +52 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +12 -0
- data/spec/dummy/db/migrate/20130924182939_create_entries.rb +13 -0
- data/spec/dummy/db/migrate/20130924192151_create_formbuilder_forms.formbuilder.rb +11 -0
- data/spec/dummy/db/migrate/20130924192152_create_formbuilder_response_fields.formbuilder.rb +17 -0
- data/spec/dummy/db/migrate/20130926205845_create_formbuilder_entry_attachments.formbuilder.rb +12 -0
- data/spec/dummy/db/migrate/20140128000000_create_entry_with_alternate_column_names.rb +13 -0
- data/spec/dummy/db/schema.rb +64 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/test/fixtures/entries.yml +9 -0
- data/spec/dummy/test/fixtures/response_fields.yml +19 -0
- data/spec/dummy/test/models/entry_test.rb +7 -0
- data/spec/dummy/test/models/response_field_test.rb +7 -0
- data/spec/factories/formbuilder_forms.rb +45 -0
- data/spec/features/form_renderer_spec.rb +30 -0
- data/spec/features/submitting_an_entry_spec.rb +79 -0
- data/spec/fixtures/test_files/text.txt +1 -0
- data/spec/fixtures/test_files/text2.txt +1 -0
- data/spec/lib/formbuilder/entry_spec.rb +199 -0
- data/spec/lib/formbuilder/entry_validator_spec.rb +215 -0
- data/spec/lib/formbuilder/entry_with_alternate_column_name_spec.rb +37 -0
- data/spec/lib/formbuilder/views/entry_dl_spec.rb +38 -0
- data/spec/models/formbuilder/entry_attachment_spec.rb +17 -0
- data/spec/models/formbuilder/form_spec.rb +100 -0
- data/spec/models/formbuilder/response_field_address_spec.rb +25 -0
- data/spec/models/formbuilder/response_field_checkboxes_spec.rb +57 -0
- data/spec/models/formbuilder/response_field_file_spec.rb +80 -0
- data/spec/models/formbuilder/response_field_paragraph_spec.rb +22 -0
- data/spec/models/formbuilder/response_field_radio_spec.rb +30 -0
- data/spec/models/formbuilder/response_field_spec.rb +21 -0
- data/spec/models/formbuilder/response_field_table_spec.rb +124 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/support/database_cleaner.rb +21 -0
- data/spec/support/submitting_an_entry_spec_helper.rb +151 -0
- metadata +286 -44
- data/app/controllers/formbuilder/forms_controller.rb +0 -53
- data/lib/formbuilder/entry_renderer.rb +0 -47
- data/lib/formbuilder/entry_table_renderer.rb +0 -58
- data/lib/formbuilder/form_renderer.rb +0 -102
@@ -4,6 +4,8 @@ module Formbuilder
|
|
4
4
|
has_many :response_fields, dependent: :destroy
|
5
5
|
belongs_to :formable, polymorphic: true
|
6
6
|
|
7
|
+
attr_accessor :show_blind, :show_admin_only
|
8
|
+
|
7
9
|
def input_fields
|
8
10
|
response_fields.reject { |rf| !rf.input_field }
|
9
11
|
end
|
@@ -12,5 +14,56 @@ module Formbuilder
|
|
12
14
|
self.response_fields.to_json(methods: [:field_type, :cid])
|
13
15
|
end
|
14
16
|
|
17
|
+
def copy_response_fields!(other_form)
|
18
|
+
other_form.response_fields.each_with_index do |response_field, i|
|
19
|
+
self.response_fields.create(
|
20
|
+
label: response_field.label,
|
21
|
+
type: response_field.type,
|
22
|
+
field_options: response_field.field_options,
|
23
|
+
sort_order: response_field.sort_order,
|
24
|
+
required: response_field.required,
|
25
|
+
blind: response_field.blind,
|
26
|
+
admin_only: response_field.admin_only
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def multi_page?
|
32
|
+
num_pages > 1
|
33
|
+
end
|
34
|
+
|
35
|
+
def num_pages
|
36
|
+
response_fields_by_page.length
|
37
|
+
end
|
38
|
+
|
39
|
+
def filtered_response_fields
|
40
|
+
query = response_fields
|
41
|
+
query = query.reject { |rf| rf.blind? } unless show_blind
|
42
|
+
query = query.reject { |rf| rf.admin_only? } unless show_admin_only
|
43
|
+
query
|
44
|
+
end
|
45
|
+
|
46
|
+
def response_fields_by_page
|
47
|
+
[].tap do |a|
|
48
|
+
a.push []
|
49
|
+
|
50
|
+
page_index = 0
|
51
|
+
filtered_response_fields.each do |response_field|
|
52
|
+
if response_field.field_type == 'page_break'
|
53
|
+
a << []
|
54
|
+
else
|
55
|
+
a.last << response_field
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
a.delete_if { |page| page.empty? }
|
60
|
+
a.push([]) if a.empty?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def response_fields_for_page(x)
|
65
|
+
response_fields_by_page[x - 1] # 0-indexed
|
66
|
+
end
|
67
|
+
|
15
68
|
end
|
16
69
|
end
|
@@ -22,6 +22,9 @@ module Formbuilder
|
|
22
22
|
# Underscored name of this field
|
23
23
|
attr_accessor :field_type
|
24
24
|
|
25
|
+
# Search type for this field
|
26
|
+
attr_accessor :search_type
|
27
|
+
|
25
28
|
after_initialize -> {
|
26
29
|
@input_field = true
|
27
30
|
}
|
@@ -59,14 +62,6 @@ module Formbuilder
|
|
59
62
|
return_hash.select { |k, v| v.present? }
|
60
63
|
end
|
61
64
|
|
62
|
-
def render_entry_for_table(value, opts = {})
|
63
|
-
"""
|
64
|
-
<td data-column-id='#{self.id}'>
|
65
|
-
#{render_entry(value, opts)}
|
66
|
-
</td>
|
67
|
-
"""
|
68
|
-
end
|
69
|
-
|
70
65
|
def render_input(value, opts = {})
|
71
66
|
raise 'Not implemented'
|
72
67
|
end
|
@@ -75,10 +70,28 @@ module Formbuilder
|
|
75
70
|
value
|
76
71
|
end
|
77
72
|
|
78
|
-
def
|
73
|
+
def render_entry_text(value, opts = {})
|
74
|
+
render_entry(value, opts)
|
75
|
+
end
|
76
|
+
|
77
|
+
def audit_response(value, all_responses); end;
|
78
|
+
|
79
|
+
def normalize_response(value, all_responses); end;
|
80
|
+
|
81
|
+
def validate_response(value); end;
|
82
|
+
|
83
|
+
def before_response_destroyed(entry); end;
|
84
|
+
|
85
|
+
def transform_raw_value(raw_value, entry, opts = {})
|
86
|
+
raw_value
|
87
|
+
end
|
88
|
+
|
89
|
+
def options_array
|
90
|
+
Array(self.field_options['options']).map { |o| o['label'] }
|
79
91
|
end
|
80
92
|
|
81
|
-
def
|
93
|
+
def sortable_value(value)
|
94
|
+
value[0..10] # do we really need to sort more than the first 10 characters of a string?
|
82
95
|
end
|
83
96
|
|
84
97
|
end
|
@@ -4,6 +4,7 @@ module Formbuilder
|
|
4
4
|
after_initialize -> {
|
5
5
|
@serialized = true
|
6
6
|
@field_type = 'address'
|
7
|
+
@search_type = 'address'
|
7
8
|
}
|
8
9
|
|
9
10
|
def render_input(value, opts = {})
|
@@ -12,7 +13,7 @@ module Formbuilder
|
|
12
13
|
"""
|
13
14
|
<div class='input-line'>
|
14
15
|
<span class='street'>
|
15
|
-
<input type'text' name='response_fields[#{self[:id]}][street]' value='#{value['street']}' />
|
16
|
+
<input type'text' name='response_fields[#{self[:id]}][street]' id='response_fields_#{self[:id]}' value='#{value['street']}' />
|
16
17
|
<label>Address</label>
|
17
18
|
</span>
|
18
19
|
</div>
|
@@ -53,6 +54,12 @@ module Formbuilder
|
|
53
54
|
"""
|
54
55
|
end
|
55
56
|
|
57
|
+
def render_entry_text(value, opts = {})
|
58
|
+
"#{value['street']}\n" +
|
59
|
+
"#{value['city']} #{value['state']} #{value['zipcode']}\n" +
|
60
|
+
"#{value['country']}"
|
61
|
+
end
|
62
|
+
|
56
63
|
def audit_response(value, all_responses)
|
57
64
|
begin
|
58
65
|
coords = Geocoder.coordinates("#{value['street']} #{value['city']} " +
|
@@ -66,6 +73,10 @@ module Formbuilder
|
|
66
73
|
end
|
67
74
|
end
|
68
75
|
|
76
|
+
def sortable_value(value)
|
77
|
+
"#{value['street']} #{value['city']} #{value['state']} #{value['zipcode']} #{value['country']}"
|
78
|
+
end
|
79
|
+
|
69
80
|
private
|
70
81
|
def country_options(selected_country)
|
71
82
|
all_countries.map do |k, v|
|
@@ -5,6 +5,7 @@ module Formbuilder
|
|
5
5
|
@serialized = true
|
6
6
|
@options_field = true
|
7
7
|
@field_type = 'checkboxes'
|
8
|
+
@search_type = 'multiple_options'
|
8
9
|
}
|
9
10
|
|
10
11
|
def render_input(value, opts = {})
|
@@ -64,5 +65,42 @@ module Formbuilder
|
|
64
65
|
"""
|
65
66
|
end
|
66
67
|
|
68
|
+
def render_entry_text(value, opts = {})
|
69
|
+
(value || {}).map do |k, v|
|
70
|
+
"#{k}: #{v ? (k == 'Other' ? v : 'y') : 'n'}"
|
71
|
+
end.join("\n")
|
72
|
+
end
|
73
|
+
|
74
|
+
def sortable_value(value)
|
75
|
+
nil # see :normalize_response for override
|
76
|
+
end
|
77
|
+
|
78
|
+
def normalize_response(value, all_responses)
|
79
|
+
options_array.each do |option_label|
|
80
|
+
all_responses["#{self.id}_sortable_values_#{option_label}"] = value[option_label]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def transform_raw_value(raw_value, entry, opts = {})
|
85
|
+
raw_value ||= {}
|
86
|
+
|
87
|
+
{}.tap do |h|
|
88
|
+
options_array.each_with_index do |label, index|
|
89
|
+
h[label] = raw_value[index.to_s] == "on"
|
90
|
+
end
|
91
|
+
|
92
|
+
if raw_value['other_checkbox'] == 'on'
|
93
|
+
entry.get_responses["#{self.id}_other"] = true
|
94
|
+
h['Other'] = raw_value['other']
|
95
|
+
end
|
96
|
+
|
97
|
+
if h.find { |_, v| v }.present?
|
98
|
+
entry.get_responses["#{self.id}_present"] = true
|
99
|
+
else
|
100
|
+
entry.get_responses.delete("#{self.id}_present")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
67
105
|
end
|
68
106
|
end
|
@@ -5,13 +5,14 @@ module Formbuilder
|
|
5
5
|
@serialized = true
|
6
6
|
@sort_as_numeric = true
|
7
7
|
@field_type = 'date'
|
8
|
+
@search_type = 'date'
|
8
9
|
}
|
9
10
|
|
10
11
|
def render_input(value, opts = {})
|
11
12
|
"""
|
12
13
|
<div class='input-line'>
|
13
14
|
<span class='month'>
|
14
|
-
<input type='text' name='response_fields[#{self[:id]}][month]' value='#{value['month']}' maxlength='2' />
|
15
|
+
<input type='text' name='response_fields[#{self[:id]}][month]' value='#{value['month']}' id='response_fields_#{self[:id]}' maxlength='2' />
|
15
16
|
<label>MM</label>
|
16
17
|
</span>
|
17
18
|
|
@@ -42,5 +43,10 @@ module Formbuilder
|
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
46
|
+
def sortable_value(value)
|
47
|
+
['year', 'month', 'day'].each { |x| return 0 unless value[x].try(:present?) }
|
48
|
+
DateTime.new(value['year'].to_i, value['month'].to_i, value['day'].to_i).to_i rescue 0
|
49
|
+
end
|
50
|
+
|
45
51
|
end
|
46
52
|
end
|
@@ -4,6 +4,7 @@ module Formbuilder
|
|
4
4
|
after_initialize -> {
|
5
5
|
@options_field = true
|
6
6
|
@field_type = 'dropdown'
|
7
|
+
@search_type = 'one_option'
|
7
8
|
}
|
8
9
|
|
9
10
|
def render_input(value, opts = {})
|
@@ -16,7 +17,7 @@ module Formbuilder
|
|
16
17
|
end
|
17
18
|
|
18
19
|
"""
|
19
|
-
<select name='response_fields[#{self[:id]}]'>
|
20
|
+
<select name='response_fields[#{self[:id]}]' id='response_fields_#{self[:id]}'>
|
20
21
|
#{options}
|
21
22
|
</select>
|
22
23
|
"""
|
@@ -5,17 +5,29 @@ module Formbuilder
|
|
5
5
|
|
6
6
|
after_initialize -> {
|
7
7
|
@field_type = 'email'
|
8
|
+
@search_type = 'text'
|
8
9
|
}
|
9
10
|
|
10
11
|
def render_input(value, opts = {})
|
11
|
-
tag(
|
12
|
-
|
12
|
+
tag(
|
13
|
+
:input,
|
14
|
+
type: 'text',
|
15
|
+
name: "response_fields[#{self.id}]",
|
16
|
+
id: "response_fields_#{self[:id]}",
|
17
|
+
class: "rf-size-#{self[:field_options]['size']}",
|
18
|
+
data: self.length_validations,
|
19
|
+
value: value
|
20
|
+
)
|
13
21
|
end
|
14
22
|
|
15
23
|
def render_entry(value, opts = {})
|
16
24
|
"<a href='mailto:#{value}'>#{value}</a>"
|
17
25
|
end
|
18
26
|
|
27
|
+
def render_entry_text(value, opts = {})
|
28
|
+
value
|
29
|
+
end
|
30
|
+
|
19
31
|
def validate_response(value)
|
20
32
|
unless value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
21
33
|
"isn't a valid email address."
|
@@ -1,43 +1,98 @@
|
|
1
1
|
module Formbuilder
|
2
2
|
class ResponseFieldFile < ResponseField
|
3
3
|
|
4
|
+
# Notes:
|
5
|
+
# I'm modifying this class to accept multiple attachments,
|
6
|
+
# even though the frontend will only accept one (for now).
|
7
|
+
|
4
8
|
after_initialize -> {
|
5
9
|
@field_type = 'file'
|
10
|
+
@search_type = 'file'
|
6
11
|
}
|
7
12
|
|
8
|
-
|
9
|
-
|
10
|
-
|
13
|
+
def get_attachments(value)
|
14
|
+
if value.blank?
|
15
|
+
[]
|
16
|
+
else
|
17
|
+
EntryAttachment.where('id IN (?)', value.split(','))
|
18
|
+
end
|
19
|
+
end
|
11
20
|
|
21
|
+
def render_input(value, opts = {})
|
12
22
|
"""
|
13
|
-
<span class='existing-filename'>#{
|
14
|
-
<input type='file' name='response_fields[#{self[:id]}]' />
|
23
|
+
<span class='existing-filename'>#{get_attachments(value).first.try(:upload).try(:raw_filename)}</span>
|
24
|
+
<input type='file' name='response_fields[#{self[:id]}][]' id='response_fields_#{self[:id]}' />
|
15
25
|
"""
|
16
26
|
end
|
17
27
|
|
18
28
|
def render_entry(value, opts = {})
|
19
|
-
|
29
|
+
return_str = ""
|
20
30
|
|
21
|
-
|
31
|
+
return_str << get_attachments(value).map do |attachment|
|
32
|
+
String.new.tap do |str|
|
33
|
+
str << """
|
34
|
+
<a href='#{attachment.upload.url}' target='_blank'>
|
35
|
+
"""
|
22
36
|
|
23
|
-
|
37
|
+
if attachment.upload.send(:active_versions).include?(:thumb)
|
38
|
+
str << """
|
39
|
+
<img src='#{attachment.upload.thumb.url}' /><br />
|
40
|
+
"""
|
41
|
+
end
|
24
42
|
|
25
|
-
|
26
|
-
|
27
|
-
|
43
|
+
str << """
|
44
|
+
#{attachment.upload.try(:raw_filename)}
|
45
|
+
</a>
|
46
|
+
"""
|
47
|
+
end
|
48
|
+
end.join('<br /><br />').squish
|
28
49
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
50
|
+
return_str
|
51
|
+
end
|
52
|
+
|
53
|
+
def render_entry_text(value, opts = {})
|
54
|
+
get_attachments(value).map { |attachment|
|
55
|
+
attachment.upload.url
|
56
|
+
}.join(', ')
|
57
|
+
end
|
58
|
+
|
59
|
+
def audit_response(value, all_responses)
|
60
|
+
return unless value
|
61
|
+
all_responses["#{self.id}_filename"] = get_attachments(value).try(:first).try(:upload).try(:raw_filename)
|
62
|
+
end
|
63
|
+
|
64
|
+
def sortable_value(value)
|
65
|
+
value.present? ? 1 : 0
|
66
|
+
end
|
67
|
+
|
68
|
+
def before_response_destroyed(entry)
|
69
|
+
remove_entry_attachments(entry.get_responses[self.id.to_s])
|
70
|
+
end
|
71
|
+
|
72
|
+
def transform_raw_value(raw_value, entry, opts = {})
|
73
|
+
raw_value = [raw_value] unless raw_value.is_a?(Array)
|
74
|
+
raw_value = raw_value.reject { |x| x.blank? }
|
75
|
+
|
76
|
+
# if the file is already uploaded and we're not uploading another, be sure to keep it
|
77
|
+
# @todo currently no way of removing a file
|
78
|
+
if raw_value.empty?
|
79
|
+
entry.responses_column_was.try(:[], self.id.to_s)
|
80
|
+
else
|
81
|
+
remove_entry_attachments(entry.get_responses.try(:[], self.id.to_s)) # remove old attachments
|
82
|
+
remove_entry_attachments(entry.responses_column_was.try(:[], self.id.to_s)) # remove old attachments
|
83
|
+
|
84
|
+
raw_value.map do |file|
|
85
|
+
EntryAttachment.create(upload: file).id
|
86
|
+
end.join(',')
|
33
87
|
end
|
88
|
+
end
|
34
89
|
|
35
|
-
|
36
|
-
|
37
|
-
</a>
|
38
|
-
"""
|
90
|
+
def remove_entry_attachments(entry_attachment_ids)
|
91
|
+
return unless entry_attachment_ids.present?
|
39
92
|
|
40
|
-
|
93
|
+
entry_attachment_ids.to_s.split(',').each do |x|
|
94
|
+
EntryAttachment.find_by(id: x).try(:destroy)
|
95
|
+
end
|
41
96
|
end
|
42
97
|
|
43
98
|
end
|
@@ -6,11 +6,18 @@ module Formbuilder
|
|
6
6
|
after_initialize -> {
|
7
7
|
@sort_as_numeric = true
|
8
8
|
@field_type = 'number'
|
9
|
+
@search_type = 'number'
|
9
10
|
}
|
10
11
|
|
11
12
|
def render_input(value, opts = {})
|
12
|
-
str = tag(
|
13
|
-
|
13
|
+
str = tag(
|
14
|
+
:input,
|
15
|
+
type: 'text',
|
16
|
+
name: "response_fields[#{self.id}]",
|
17
|
+
id: "response_fields_#{self.id}",
|
18
|
+
class: "rf-size-#{self[:field_options]['size']}",
|
19
|
+
value: value
|
20
|
+
)
|
14
21
|
|
15
22
|
if (units = self[:field_options]['units'].presence)
|
16
23
|
str += "<span class='units'>#{units}</span>".html_safe
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rinku'
|
2
|
+
|
1
3
|
module Formbuilder
|
2
4
|
class ResponseFieldParagraph < ResponseField
|
3
5
|
|
@@ -6,15 +8,29 @@ module Formbuilder
|
|
6
8
|
|
7
9
|
after_initialize -> {
|
8
10
|
@field_type = 'paragraph'
|
11
|
+
@search_type = 'text'
|
9
12
|
}
|
10
13
|
|
11
14
|
def render_input(value, opts = {})
|
12
|
-
content_tag(
|
13
|
-
|
15
|
+
content_tag(
|
16
|
+
:textarea,
|
17
|
+
name: "response_fields[#{self.id}]",
|
18
|
+
id: "response_fields_#{self.id}",
|
19
|
+
class: "rf-size-#{self[:field_options]['size']}",
|
20
|
+
data: self.length_validations
|
21
|
+
) { value }
|
14
22
|
end
|
15
23
|
|
16
24
|
def render_entry(value, opts = {})
|
17
|
-
|
25
|
+
if value.present?
|
26
|
+
ActionController::Base.helpers.simple_format(Rinku.auto_link(value))
|
27
|
+
else
|
28
|
+
''
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def render_entry_text(value, opts = {})
|
33
|
+
value
|
18
34
|
end
|
19
35
|
|
20
36
|
end
|