formbuilder-rb 0.2.3 → 0.2.4

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
2
  SHA1:
3
- metadata.gz: b0237c994ea6bf9a2fa67cf0a5693a89a047b984
4
- data.tar.gz: a54619515112c3d9a35bee51a422ad315d90f643
3
+ metadata.gz: fa5979c702d1ad8a7a6156603e714749abd43dfa
4
+ data.tar.gz: e3f1a72bbc34add5397dc89b277f833c27e01f69
5
5
  SHA512:
6
- metadata.gz: e3ac88c11bf6057fa288a168c34f7b20bf6a5d4bbdf62ce0c041cf5e73ba1a43e6d704116464fd6c30f770f773e41a9e00d7162a92a4c6e7ccb2346c2f280be1
7
- data.tar.gz: 540b867ba74f7abe13288be88621a5ca9ed74e7b4ab02462b6958a6ed51a49d2a3582e2bff1bda92e2c68c6b5e82854eab461011d0b8155eddb05427e386f241
6
+ metadata.gz: f8aa928ad564bf1d064921393db0cd14a2ee4ab36cc99a6dd9b3f09f837b66d3386845fb2560238423e8201154a4fffcc438468b1a49029ca04fe5e4e474cc3a
7
+ data.tar.gz: 31e70756368eed6353c8c477a5be413b41f48e7fa2e07e0ae4b9f30a783953b600e7a75b4378bb56195b03eb2c46aa448ab089da3a977018fc4f042427136741
@@ -0,0 +1,18 @@
1
+ module Formbuilder
2
+ class ResponseFieldBlockOfText < ResponseField
3
+
4
+ after_initialize -> {
5
+ @input_field = false
6
+ @field_type = 'block_of_text'
7
+ }
8
+
9
+ def render_input(value, opts = {})
10
+ """
11
+ <div class='block-of-text block-of-text-size-#{self[:field_options]['size']}'>
12
+ #{self[:label]}
13
+ </div>
14
+ """
15
+ end
16
+
17
+ end
18
+ end
@@ -9,7 +9,9 @@ module Formbuilder
9
9
  }
10
10
 
11
11
  def render_input(value, opts = {})
12
- """
12
+ value ||= {}
13
+
14
+ str = """
13
15
  <div class='input-line'>
14
16
  <span class='hours'>
15
17
  <input type='text' name='response_fields[#{self[:id]}][hours]' id='response_fields_#{self[:id]}' value='#{value['hours']}' maxlength='2' />
@@ -22,14 +24,21 @@ module Formbuilder
22
24
  <input type='text' name='response_fields[#{self[:id]}][minutes]' value='#{value['minutes']}' maxlength='2' />
23
25
  <label>MM</label>
24
26
  </span>
27
+ """
25
28
 
29
+
30
+ if !self[:field_options]['disable_seconds']
31
+ str += """
26
32
  <span class='above-line'>:</span>
27
33
 
28
34
  <span class='seconds'>
29
35
  <input type='text' name='response_fields[#{self[:id]}][seconds]' value='#{value['seconds']}' maxlength='2' />
30
36
  <label>SS</label>
31
37
  </span>
38
+ """
39
+ end
32
40
 
41
+ str += """
33
42
  <span class='am_pm'>
34
43
  <select name='response_fields[#{self[:id]}][am_pm]'>
35
44
  <option value='AM' #{value['am_pm'] == "AM" ? 'selected' : ''}>AM</option>
@@ -38,6 +47,8 @@ module Formbuilder
38
47
  </span>
39
48
  </div>
40
49
  """
50
+
51
+ str
41
52
  end
42
53
 
43
54
  def render_entry(value, opts = {})
@@ -1,3 +1,3 @@
1
1
  module Formbuilder
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Formbuilder::ResponseFieldTime do
4
+
5
+ let!(:form) { Formbuilder::Form.create }
6
+ let!(:response_field) { Formbuilder::ResponseFieldTime.create(form: form) }
7
+ let!(:entry) { Entry.create(form: form) }
8
+
9
+ subject { response_field }
10
+ subject(:rf) { response_field }
11
+
12
+ describe '#render_input' do
13
+ it 'renders properly' do
14
+ rendered_html = rf.render_input(nil)
15
+ expect(rendered_html).to match 'HH'
16
+ expect(rendered_html).to match 'SS'
17
+ end
18
+
19
+ context 'with seconds field disabled' do
20
+ before { rf.update_attributes(field_options: { 'disable_seconds' => true } )}
21
+
22
+ it 'does not render the seconds field' do
23
+ rendered_html = rf.render_input(nil)
24
+ expect(rendered_html).to match 'HH'
25
+ expect(rendered_html).to_not match 'SS'
26
+ end
27
+ end
28
+ end
29
+
30
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formbuilder-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Becker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-05 00:00:00.000000000 Z
11
+ date: 2014-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -391,6 +391,7 @@ files:
391
391
  - app/models/formbuilder/form.rb
392
392
  - app/models/formbuilder/response_field.rb
393
393
  - app/models/formbuilder/response_field_address.rb
394
+ - app/models/formbuilder/response_field_block_of_text.rb
394
395
  - app/models/formbuilder/response_field_checkboxes.rb
395
396
  - app/models/formbuilder/response_field_date.rb
396
397
  - app/models/formbuilder/response_field_dropdown.rb
@@ -500,6 +501,7 @@ files:
500
501
  - spec/models/formbuilder/response_field_radio_spec.rb
501
502
  - spec/models/formbuilder/response_field_spec.rb
502
503
  - spec/models/formbuilder/response_field_table_spec.rb
504
+ - spec/models/formbuilder/response_field_time_spec.rb
503
505
  - spec/spec_helper.rb
504
506
  - spec/support/database_cleaner.rb
505
507
  - spec/support/submitting_an_entry_spec_helper.rb
@@ -604,6 +606,7 @@ test_files:
604
606
  - spec/models/formbuilder/response_field_radio_spec.rb
605
607
  - spec/models/formbuilder/response_field_spec.rb
606
608
  - spec/models/formbuilder/response_field_table_spec.rb
609
+ - spec/models/formbuilder/response_field_time_spec.rb
607
610
  - spec/spec_helper.rb
608
611
  - spec/support/database_cleaner.rb
609
612
  - spec/support/submitting_an_entry_spec_helper.rb