express_templates 0.3.5 → 0.3.6

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: d742a1eb7b837967378382a6d1d389a272a6bf8c
4
- data.tar.gz: b6b8a96819bb587a242093ca991af100f5e62853
3
+ metadata.gz: 1e11659af9b175019fa94c33686d4f4f197fcc07
4
+ data.tar.gz: 3bd1729777599d3ba3772c72d8b403098aa66b07
5
5
  SHA512:
6
- metadata.gz: 931e15f70ec9d4a1a060c4f6f09c4ae2821e7cc571c91aee3f1580cf26d83e99475ac956d06b1d6282492a2302124e507bae218d1a692d7636623ecb202af428
7
- data.tar.gz: 062fe5cef79a19962a304ca6e53c539ba685af8a5845926a12f3a911201c6b4f7f57d9f533ff4b8df99368e590fb409d800062cad9c2419d1182a487b6b5a101
6
+ metadata.gz: 34b7fedf65a87724dadb3d8c77ecdc78dbef4598d0bf2da4cecbc89bfbbba865bdbf9a9fbf3518d197f93597c0091a18153df7919a988f31bf786b3ef1b257dd
7
+ data.tar.gz: b55b2a3cb61868d5df45738d8c1cfbf423a0bbc60996aca66c65d7cfc72d75dad0bd4831ae352c24c372dbd08fbba6e3fc775c1a5aba08eb295a0960096d0c14
@@ -209,19 +209,27 @@ module ExpressTemplates
209
209
  # # <label class="radio" for="user_age_2"><input type="radio" value="2" name="user[age]" id="user_age_2">Two</label>
210
210
  # # </div>
211
211
  #
212
- def radio(name, collection, value_method, text_method, options = {})
212
+ # f.radio :enable_something, :boolean
213
+ # # <div>
214
+ # # <label class="radio"><input type="radio" value="1" name="user[age]" id="user_age_1">One</label>
215
+ # # <label class="radio"><input type="radio" value="2" name="user[age]" id="user_age_2">Two</label>
216
+ # # </div>
217
+ def radio(name, collection, value_method = :first, text_method = :last, options = {})
213
218
  @fields ||= []
219
+ if collection == :boolean
220
+ collection = [[true, 'True'], [false, 'False']]
221
+ end
214
222
  @fields << Radio.new(name, options.merge!(collection: collection, value_method: value_method, text_method: text_method))
215
223
  end
216
224
 
217
225
  # ==== Examples
218
226
  # f.checkbox :age, [[1, 'One'], [2, 'Two']], :first, :last
219
227
  # # <div>
220
- # # <label class="checkbox" for="user_age_1">
228
+ # # <label class="checkbox">
221
229
  # # <input type="checkbox" value="1" name="user[age][]" id="user_age_1">
222
230
  # # "One"
223
231
  # # </label>
224
- # # <label>
232
+ # # <label class="checkbox">
225
233
  # # <input type="checkbox" value="2" name="user[age][]" id="user_age_2">
226
234
  # # "Two"
227
235
  # # </label>
@@ -305,11 +313,13 @@ module ExpressTemplates
305
313
  label_tag(label_name, field_label)
306
314
  select_tag(resource_field_name, field.options_html, field.options)
307
315
  elsif field_type == 'radio'
316
+ label_tag(label_name, field_label)
308
317
  collection_radio_buttons(my[:id], field_name, field.collection,
309
318
  field.value_method, field.text_method, field.options) do |b|
310
319
  b.label(class: 'radio') { b.radio_button + b.text }
311
320
  end
312
321
  elsif field_type == 'checkbox'
322
+ label_tag(label_name, field_label)
313
323
  collection_check_boxes(my[:id], field_name, field.collection,
314
324
  field.value_method, field.text_method, field.options) do |b|
315
325
  b.label(class: 'checkbox') { b.check_box + b.text }
@@ -1,3 +1,3 @@
1
1
  module ExpressTemplates
2
- VERSION = "0.3.5"
2
+ VERSION = "0.3.6"
3
3
  end
@@ -99,6 +99,7 @@ class FormForTest < ActiveSupport::TestCase
99
99
  fragment = -> {
100
100
  form_for(:resource) do |f|
101
101
  f.radio :age, [[1, 'One'],[2, 'Two']], :first, :last
102
+ f.radio :enable_something, :boolean
102
103
  end
103
104
  }
104
105
  return ctx, fragment
@@ -197,7 +198,13 @@ class FormForTest < ActiveSupport::TestCase
197
198
  </div>
198
199
 
199
200
  <div class=\"\">
200
- "+%Q(#{collection_radio_buttons(:resource, :age, [[1, "One"], [2, "Two"]], :first, :last, {}) do |b|
201
+ "+%Q(#{label_tag("resource_age", "Age")})+%Q(#{collection_radio_buttons(:resource, :age, [[1, "One"], [2, "Two"]], :first, :last, {}) do |b|
202
+ b.label(class: 'radio') { b.radio_button + b.text }
203
+ end})+"
204
+ </div>
205
+
206
+ <div class=\"\">
207
+ "+%Q(#{label_tag("resource_enable_something", "Enable Something")})+%Q(#{collection_radio_buttons(:resource, :enable_something, [[true, "True"], [false, "False"]], :first, :last, {}) do |b|
201
208
  b.label(class: 'radio') { b.radio_button + b.text }
202
209
  end})+"
203
210
  </div>
@@ -221,7 +228,7 @@ class FormForTest < ActiveSupport::TestCase
221
228
  </div>
222
229
 
223
230
  <div class=\"\">
224
- "+%Q(#{collection_check_boxes(:resource, :age, [[1, "One"], [2, "Two"]], :first, :last, {}) do |b|
231
+ "+%Q(#{label_tag("resource_age", "Age")})+%Q(#{collection_check_boxes(:resource, :age, [[1, "One"], [2, "Two"]], :first, :last, {}) do |b|
225
232
  b.label(class: 'checkbox') { b.check_box + b.text }
226
233
  end})+"
227
234
  </div>