inline_forms 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/app/helpers/form_elements/radio_button.rb +26 -0
- data/lib/app/helpers/inline_forms_helper.rb +2 -1
- data/lib/app/validators/is_curacao_phone_validator.rb +3 -19
- data/lib/app/views/inline_forms/_new.html.erb +1 -1
- data/lib/app/views/inline_forms/_show.html.erb +1 -1
- data/lib/inline_forms/version.rb +1 -1
- metadata +5 -4
@@ -0,0 +1,26 @@
|
|
1
|
+
InlineForms::SPECIAL_COLUMN_TYPES[:radio_button]=:integer
|
2
|
+
# radio buttons are integers in this version
|
3
|
+
# us like this:
|
4
|
+
# [ :sex , "gender", :radio_button, { 1 => 'male', 2 => 'female' } ],
|
5
|
+
|
6
|
+
def radio_button_show(object, attribute)
|
7
|
+
values = attribute_values(object, attribute)
|
8
|
+
link_to_inline_edit object, attribute, object.send(attribute)
|
9
|
+
end
|
10
|
+
|
11
|
+
def radio_button_edit(object, attribute)
|
12
|
+
out ='<ul class="radio_list">'
|
13
|
+
attribute_values(object, attribute).each do |n,value|
|
14
|
+
out << '<li>'
|
15
|
+
out << radio_button_tag(attribute.to_s, value, value == object.send(attribute))
|
16
|
+
out << value
|
17
|
+
out << '</li>'
|
18
|
+
end
|
19
|
+
out << '</ul>'
|
20
|
+
raw out
|
21
|
+
end
|
22
|
+
|
23
|
+
def radio_button_update(object, attribute)
|
24
|
+
object[attribute.to_s.to_sym] = params[attribute.to_s.to_sym].nil? ? 0 : 1
|
25
|
+
end
|
26
|
+
|
@@ -122,7 +122,8 @@ module InlineFormsHelper
|
|
122
122
|
# if we have an array ['a','d','b'] will result in [[0,'a'],[2,'b'],[1,'d']] (sorted on value)
|
123
123
|
# if we have a hash { 0=>'a', 2=>'b', 3=>'d' } will result in [[0,'a'],[2,'b'],[3,'d']] (it will keep the index and sort on the index)
|
124
124
|
# TODO work this out better!
|
125
|
-
|
125
|
+
attributes = @inline_forms_attribute_list || object.inline_forms_attribute_list # if we do this as a form_element, @inline.. is nil!!!
|
126
|
+
values = attributes.assoc(attribute.to_sym)[3]
|
126
127
|
raise "No Values defined in #{@Klass}, #{attribute}" if values.nil?
|
127
128
|
if values.is_a?(Hash)
|
128
129
|
temp = Array.new
|
@@ -4,33 +4,17 @@
|
|
4
4
|
# taken from http://lindsaar.net/2010/1/31/validates_rails_3_awesome_is_true
|
5
5
|
# (It's probably a fake regex but hey, it looks legit.)
|
6
6
|
class IsCuracaoPhoneValidator < ActiveModel::EachValidator
|
7
|
-
EmailAddress = begin
|
8
|
-
qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'
|
9
|
-
dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'
|
10
|
-
atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-' +
|
11
|
-
'\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'
|
12
|
-
quoted_pair = '\\x5c[\\x00-\\x7f]'
|
13
|
-
domain_literal = "\\x5b(?:#{dtext}|#{quoted_pair})*\\x5d"
|
14
|
-
quoted_string = "\\x22(?:#{qtext}|#{quoted_pair})*\\x22"
|
15
|
-
domain_ref = atom
|
16
|
-
sub_domain = "(?:#{domain_ref}|#{domain_literal})"
|
17
|
-
word = "(?:#{atom}|#{quoted_string})"
|
18
|
-
domain = "#{sub_domain}(?:\\x2e#{sub_domain})*"
|
19
|
-
local_part = "#{word}(?:\\x2e#{word})*"
|
20
|
-
addr_spec = "#{local_part}\\x40#{domain}"
|
21
|
-
pattern = /\A#{addr_spec}\z/
|
22
|
-
end
|
23
7
|
|
24
8
|
def error_message
|
25
|
-
"is
|
9
|
+
"is geen geldig Curaçao telefoon nummer."
|
26
10
|
end
|
27
11
|
|
28
12
|
def help_message
|
29
|
-
"
|
13
|
+
"Telefoonnummer moet 7 cijfers zijn, bijvoorbeeld 6781256."
|
30
14
|
end
|
31
15
|
|
32
16
|
def validate_each(record, attribute, value)
|
33
|
-
unless value =~
|
17
|
+
unless value =~ /[4-8][0-9]{6}/
|
34
18
|
record.errors[attribute] << (options[:message] || error_message )
|
35
19
|
end
|
36
20
|
end
|
@@ -18,7 +18,7 @@
|
|
18
18
|
</div>
|
19
19
|
</th>
|
20
20
|
</tr>
|
21
|
-
<% attributes
|
21
|
+
<% attributes = @inline_forms_attribute_list || @object.inline_forms_attribute_list -%>
|
22
22
|
<% attributes.each do | attribute, name, form_element | -%>
|
23
23
|
<% unless form_element.to_sym == :associated -%>
|
24
24
|
<% css_class_id = "attribute_#{attribute}_#{@object.id}" -%>
|
@@ -11,7 +11,7 @@
|
|
11
11
|
</div>
|
12
12
|
</th>
|
13
13
|
</tr>
|
14
|
-
<% attributes
|
14
|
+
<% attributes = @inline_forms_attribute_list || @object.inline_forms_attribute_list -%>
|
15
15
|
<% attributes.each do | attribute, name, form_element | -%>
|
16
16
|
<% css_class_id = "#{@object.class.to_s.underscore}_#{@object.id}_#{attribute}" -%>
|
17
17
|
<tr>
|
data/lib/inline_forms/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inline_forms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 4
|
10
|
+
version: 1.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ace Suares
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-13 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec-rails
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- lib/app/helpers/form_elements/info.rb
|
157
157
|
- lib/app/helpers/form_elements/infoadmin.rb
|
158
158
|
- lib/app/helpers/form_elements/question_list.rb
|
159
|
+
- lib/app/helpers/form_elements/radio_button.rb
|
159
160
|
- lib/app/helpers/form_elements/scale_with_integers.rb
|
160
161
|
- lib/app/helpers/form_elements/scale_with_values.rb
|
161
162
|
- lib/app/helpers/form_elements/slider_with_values.rb
|