repres-bootstrap 1.6 → 1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 247620ffb0346a2e9e9c5c73f2091c040dfa9b2e
4
- data.tar.gz: 20e0dff7f8a722012e302abb3fde777d4ab3a04a
3
+ metadata.gz: 309bfe03948746cee3496b3e5df751637a652eec
4
+ data.tar.gz: b6cb52184a5623de498c3181f99d1f7eea4e4f23
5
5
  SHA512:
6
- metadata.gz: fb84b1dbc7adc8c9fe319b5626a26193e36f77adc867d16852822bc09bb51a50a0b731572f50e85033a572f9e6aec42bee5ade1f6b59a77f0f857ec3697af964
7
- data.tar.gz: 6bf1a8709a0d864e9183a9d694366b1bfd3fe4c4975371c6c7cfcb62c82fd035c99a1204c511f63ed0bec90f6e574ae9036cf88cc669a6dd12ecd4315829067f
6
+ metadata.gz: ef09100366b0c6a2f4d087bab824356e4ceae1d0fc32dcd70ddb474d805c028af97d7393444160f0fb6c3c610ec59986c48aaeab9bed0691d1ed5944f91f5b27
7
+ data.tar.gz: 7c3dca48becd68f137388f2c2b1f77c2977803580faef2b7f3152206089d288d19ac3a39175ce9f7d5fbf63e882114d1da11379fd68c8d19f71637d770190dd0
data/README.md CHANGED
@@ -56,6 +56,10 @@ include Repres::Bootstrap::FormHelper
56
56
  <!-- or the following line works identically -->
57
57
  <%= bootstrap_form_select_box model: model, form: f, name: :gender, choices: { 'Male' => '1', 'Female' => '2' }, options: { include_blank: 'Please Select...' } %>
58
58
 
59
+ <%= render partial: 'repres/bootstrap/form_check_box', locals: { options: { model: model, form: f, name: :gender, choices: { 'Male' => '1', 'Female' => '2' }, options: {} } } %>
60
+
61
+ <%= render partial: 'repres/bootstrap/form_radio_box', locals: { options: { model: model, form: f, name: :gender, choices: { 'Male' => '1', 'Female' => '2' }, options: {} } } %>
62
+
59
63
  <% end %>
60
64
  </div>
61
65
 
@@ -0,0 +1,101 @@
1
+ <%
2
+ model = options[:model]
3
+ form = options[:form]
4
+ name = options[:name]
5
+
6
+ group_class_list = [ 'form-group', options[:group_class] ]
7
+ label_class_list = [ 'control-label', options[:label_class] ]
8
+ field_class_list = [ 'input-group', options[:field_class] ]
9
+ input_class_list = [ 'form-control', options[:input_class] ]
10
+ error_class_list = [ 'text-danger', options[:error_class] ]
11
+ group_class_list << 'has-error' if model.errors[name].present?
12
+
13
+ group_class = group_class_list.flatten.join ' '
14
+ label_class = label_class_list.flatten.join ' '
15
+ field_class = field_class_list.flatten.join ' '
16
+ input_class = input_class_list.flatten.join ' '
17
+ error_class = error_class_list.flatten.join ' '
18
+
19
+ input_prefix = options[:input_prefix]
20
+ input_suffix = options[:input_suffix]
21
+
22
+ label_text = options[:label_text]
23
+ label_prefix = options[:label_prefix]
24
+ label_suffix = options[:label_suffix]
25
+
26
+ input_options = {
27
+ class: input_class_list,
28
+ disabled: options[:disabled]
29
+ }
30
+
31
+ error_hidden = options[:error_hidden]
32
+
33
+ choices = options[:choices]
34
+ flags = options[:options]||{}
35
+ %>
36
+
37
+ <div class='<%= group_class %>'>
38
+
39
+ <%= form.label name, class: label_class do %><%= label_prefix %><%= label_text||model.class.human_attribute_name(name.to_sym) %><%= label_suffix %><% end %>
40
+
41
+ <% if input_prefix.present? || input_suffix.present? %>
42
+
43
+ <div class='<%= field_class %>'>
44
+
45
+ <% if input_prefix.present? %>
46
+ <span class='input-group-addon'><%= input_prefix %></span>
47
+ <% end %>
48
+
49
+ <%= form.hidden_field name, { name: "#{form.object_name}[#{name}][]", value: '' } %>
50
+ <%= form.fields_for '' do |field| %>
51
+ <% choices.each do |title, value| %>
52
+ <%= field.label name, '', for: "#{form.object_name}_#{name}_#{value.to_s.downcase}" do %>
53
+ <%= field.check_box name, { id: "#{form.object_name}_#{name}_#{value.to_s.downcase}", name: "#{form.object_name}[#{name}][]" }, value, nil %>
54
+ <%= title %>
55
+ <% end %>
56
+ <% end %>
57
+ <% end %>
58
+
59
+ <% if input_suffix.present? %>
60
+ <span class='input-group-addon'><%= input_suffix %></span>
61
+ <% end %>
62
+
63
+ </div>
64
+
65
+ <% else %>
66
+
67
+ <% if options[:field_class].present? %>
68
+ <div class='<%= [ options[:field_class] ].flatten.join ' ' %>'>
69
+
70
+ <%= form.hidden_field name, { name: "#{form.object_name}[#{name}][]", value: '' } %>
71
+ <%= form.fields_for '' do |field| %>
72
+ <% choices.each do |title, value| %>
73
+ <%= field.label name, '', for: "#{form.object_name}_#{name}_#{value.to_s.downcase}" do %>
74
+ <%= field.check_box name, { id: "#{form.object_name}_#{name}_#{value.to_s.downcase}", name: "#{form.object_name}[#{name}][]" }, value, nil %>
75
+ <%= title %>
76
+ <% end %>
77
+ <% end %>
78
+ <% end %>
79
+
80
+ </div>
81
+ <% else %>
82
+
83
+ <%= form.hidden_field name, { name: "#{form.object_name}[#{name}][]", value: '' } %>
84
+ <%= form.fields_for '' do |field| %>
85
+ <% choices.each do |title, value| %>
86
+ <%= field.label name, '', for: "#{form.object_name}_#{name}_#{value.to_s.downcase}" do %>
87
+ <%= field.check_box name, { id: "#{form.object_name}_#{name}_#{value.to_s.downcase}", name: "#{form.object_name}[#{name}][]" }, value, nil %>
88
+ <%= title %>
89
+ <% end %>
90
+ <% end %>
91
+ <% end %>
92
+
93
+ <% end %>
94
+
95
+ <% end %>
96
+
97
+ <% if model.errors[name].present? && !error_hidden %>
98
+ <p class='<%= error_class %>'><%= model.errors[name].first %></p>
99
+ <% end %>
100
+
101
+ </div>
@@ -0,0 +1,92 @@
1
+ <%
2
+ model = options[:model]
3
+ form = options[:form]
4
+ name = options[:name]
5
+
6
+ group_class_list = [ 'form-group', options[:group_class] ]
7
+ label_class_list = [ 'control-label', options[:label_class] ]
8
+ field_class_list = [ 'input-group', options[:field_class] ]
9
+ input_class_list = [ 'form-control', options[:input_class] ]
10
+ error_class_list = [ 'text-danger', options[:error_class] ]
11
+ group_class_list << 'has-error' if model.errors[name].present?
12
+
13
+ group_class = group_class_list.flatten.join ' '
14
+ label_class = label_class_list.flatten.join ' '
15
+ field_class = field_class_list.flatten.join ' '
16
+ input_class = input_class_list.flatten.join ' '
17
+ error_class = error_class_list.flatten.join ' '
18
+
19
+ input_prefix = options[:input_prefix]
20
+ input_suffix = options[:input_suffix]
21
+
22
+ label_text = options[:label_text]
23
+ label_prefix = options[:label_prefix]
24
+ label_suffix = options[:label_suffix]
25
+
26
+ input_options = {
27
+ class: input_class_list,
28
+ disabled: options[:disabled]
29
+ }
30
+
31
+ error_hidden = options[:error_hidden]
32
+
33
+ choices = options[:choices]
34
+ flags = options[:options]||{}
35
+ %>
36
+
37
+ <div class='<%= group_class %>'>
38
+
39
+ <%= form.label name, class: label_class do %><%= label_prefix %><%= label_text||model.class.human_attribute_name(name.to_sym) %><%= label_suffix %><% end %>
40
+
41
+ <% if input_prefix.present? || input_suffix.present? %>
42
+
43
+ <div class='<%= field_class %>'>
44
+
45
+ <% if input_prefix.present? %>
46
+ <span class='input-group-addon'><%= input_prefix %></span>
47
+ <% end %>
48
+
49
+ <% choices.each do |title, value| %>
50
+ <%= form.label "#{name}_#{value.to_s.downcase}" do %>
51
+ <%= form.radio_button name, value %>
52
+ <%= title %>
53
+ <% end %>
54
+ <% end %>
55
+
56
+ <% if input_suffix.present? %>
57
+ <span class='input-group-addon'><%= input_suffix %></span>
58
+ <% end %>
59
+
60
+ </div>
61
+
62
+ <% else %>
63
+
64
+ <% if options[:field_class].present? %>
65
+ <div class='<%= [ options[:field_class] ].flatten.join ' ' %>'>
66
+
67
+ <% choices.each do |title, value| %>
68
+ <%= form.label "#{name}_#{value.to_s.downcase}" do %>
69
+ <%= form.radio_button name, value %>
70
+ <%= title %>
71
+ <% end %>
72
+ <% end %>
73
+
74
+ </div>
75
+ <% else %>
76
+
77
+ <% choices.each do |title, value| %>
78
+ <%= form.label "#{name}_#{value.to_s.downcase}" do %>
79
+ <%= form.radio_button name, value %>
80
+ <%= title %>
81
+ <% end %>
82
+ <% end %>
83
+
84
+ <% end %>
85
+
86
+ <% end %>
87
+
88
+ <% if model.errors[name].present? && !error_hidden %>
89
+ <p class='<%= error_class %>'><%= model.errors[name].first %></p>
90
+ <% end %>
91
+
92
+ </div>
@@ -56,7 +56,13 @@
56
56
 
57
57
  <% else %>
58
58
 
59
- <%= form.select name, choices, flags, input_options %>
59
+ <% if options[:field_class].present? %>
60
+ <div class='<%= [ options[:field_class] ].flatten.join ' ' %>'>
61
+ <%= form.select name, choices, flags, input_options %>
62
+ </div>
63
+ <% else %>
64
+ <%= form.select name, choices, flags, input_options %>
65
+ <% end %>
60
66
 
61
67
  <% end %>
62
68
 
@@ -1,5 +1,5 @@
1
1
  module Repres
2
2
  module Bootstrap
3
- VERSION = '1.6'.freeze
3
+ VERSION = '1.7'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repres-bootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.6'
4
+ version: '1.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-06 00:00:00.000000000 Z
11
+ date: 2016-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -60,7 +60,9 @@ files:
60
60
  - app/mailers/repres/bootstrap/application_mailer.rb
61
61
  - app/models/repres/bootstrap/application_record.rb
62
62
  - app/views/layouts/repres/bootstrap/application.html.erb
63
+ - app/views/repres/bootstrap/_form_check_box.html.erb
63
64
  - app/views/repres/bootstrap/_form_field.html.erb
65
+ - app/views/repres/bootstrap/_form_radio_box.html.erb
64
66
  - app/views/repres/bootstrap/_form_select_box.html.erb
65
67
  - app/views/repres/bootstrap/_script.html.erb
66
68
  - app/views/repres/bootstrap/_style.html.erb