ui_bibz 2.1.6 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +19 -10
  3. data/app/assets/javascripts/interface.coffee +8 -0
  4. data/app/assets/javascripts/ui_bibz.coffee.erb +3 -0
  5. data/app/assets/stylesheets/fix_addon.sass +2 -2
  6. data/lib/ui_bibz.rb +8 -0
  7. data/lib/ui_bibz/helpers/ui/core/forms_helper.rb +35 -0
  8. data/lib/ui_bibz/infos.rb +2 -2
  9. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_box_switch_field_input.rb +18 -0
  10. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_file_field_input.rb +10 -0
  11. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_range_field_input.rb +10 -0
  12. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_switch_field_input.rb +5 -1
  13. data/lib/ui_bibz/ui/core/component.rb +4 -0
  14. data/lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb +141 -0
  15. data/lib/ui_bibz/ui/core/forms/choices/checkbox_field.rb +18 -27
  16. data/lib/ui_bibz/ui/core/forms/choices/radio_field.rb +15 -40
  17. data/lib/ui_bibz/ui/core/forms/choices/switch_field.rb +11 -95
  18. data/lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb +25 -0
  19. data/lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb +5 -1
  20. data/lib/ui_bibz/ui/core/forms/files/file_field.rb +72 -0
  21. data/lib/ui_bibz/ui/core/forms/numbers/number_field.rb +15 -0
  22. data/lib/ui_bibz/ui/core/forms/numbers/range_field.rb +66 -0
  23. data/lib/ui_bibz/ui/core/forms/selects/multi_select_field.rb +9 -1
  24. data/lib/ui_bibz/ui/core/forms/texts/text_field.rb +3 -0
  25. data/test/simple_form_test.rb +33 -3
  26. data/test/ui/core/forms/choices/{switch_field_test.rb → box_switch_field_test.rb} +21 -21
  27. data/test/ui/core/forms/choices/checkbox_field_test.rb +1 -1
  28. data/test/ui/core/forms/choices/radio_field_test.rb +1 -1
  29. data/test/ui/core/forms/files/text_field_test.rb +11 -0
  30. data/test/ui/core/forms/numbers/number_field_test.rb +18 -0
  31. data/test/ui/core/forms/numbers/range_field_test.rb +18 -0
  32. data/vendor/assets/javascripts/bs-custom-file-input.min.js +7 -0
  33. metadata +19 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc93e1f6e25ab337d80b307a374924508f9d667b08b0d030aaad4b89a448993e
4
- data.tar.gz: 05cc31f7e7d1caaf78416377e5469bda4d0481a32983cfdc747d04d9c83675e0
3
+ metadata.gz: 28b2120a42b008d9db7300223c513f47f29b5e2b31d65d39483e87e55834a3b6
4
+ data.tar.gz: 430093a7d9f3ae35d3f371ba20425ef0d42c2926be31c61334e425dcc7383e79
5
5
  SHA512:
6
- metadata.gz: effedc75df8ae266ef0dacd1eb510f60a3503792625e9b21078da481d7a0a31b41fcca0fabbea80e71c1d05dedba83970c93d35fe40d38612d571cca9b484858
7
- data.tar.gz: 5086e9fc5aec716e4e710e37ce25fa201712c2d86631156e97319d9e20ae8ec3afb6453d1c61b7dbf14895c207973be5a216a085a948eab71ab57215b0ca6fe9
6
+ metadata.gz: 308f601643a668e5764ae6898e8d28440f0f440b2be2767c57a231f040993c035d1c057b9a8b9cc4eb263bb8bc7a6e85b634775921d96baa06696c0b0062224a
7
+ data.tar.gz: d2aabe40d98a154d48ced23dcadabece4405cf888b93071fbcd58f072fe36ac62950538d1279090856acc7d7d8fd8d3bccbeb9f6035fd7c2b2c4daae34606a16
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ui_bibz (2.1.6)
5
- bootstrap (= 4.1.3)
4
+ ui_bibz (2.2.0)
5
+ bootstrap (= 4.2.1)
6
6
  haml
7
7
  haml-rails
8
8
  jquery-rails (>= 3.1.0)
@@ -57,13 +57,13 @@ GEM
57
57
  minitest (~> 5.1)
58
58
  tzinfo (~> 1.1)
59
59
  arel (9.0.0)
60
- autoprefixer-rails (9.4.3)
60
+ autoprefixer-rails (9.4.4)
61
61
  execjs
62
62
  awesome_print (1.8.0)
63
- bootstrap (4.1.3)
64
- autoprefixer-rails (>= 6.0.3)
65
- popper_js (>= 1.12.9, < 2)
66
- sass (>= 3.5.2)
63
+ bootstrap (4.2.1)
64
+ autoprefixer-rails (>= 9.1.0)
65
+ popper_js (>= 1.14.3, < 2)
66
+ sassc-rails (>= 2.0.0)
67
67
  builder (3.2.3)
68
68
  byebug (10.0.2)
69
69
  codeclimate-test-reporter (1.0.7)
@@ -96,7 +96,7 @@ GEM
96
96
  haml (>= 4.0, < 6)
97
97
  nokogiri (>= 1.6.0)
98
98
  ruby_parser (~> 3.5)
99
- i18n (1.3.0)
99
+ i18n (1.5.1)
100
100
  concurrent-ruby (~> 1.0)
101
101
  jquery-rails (4.3.3)
102
102
  rails-dom-testing (>= 1, < 3)
@@ -116,7 +116,7 @@ GEM
116
116
  mini_portile2 (2.4.0)
117
117
  minitest (5.11.3)
118
118
  nio4r (2.3.1)
119
- nokogiri (1.9.1)
119
+ nokogiri (1.10.0)
120
120
  mini_portile2 (~> 2.4.0)
121
121
  popper_js (1.14.5)
122
122
  rack (2.0.6)
@@ -152,7 +152,7 @@ GEM
152
152
  ffi (~> 1.0)
153
153
  ruby_parser (3.12.0)
154
154
  sexp_processor (~> 4.9)
155
- sass (3.7.2)
155
+ sass (3.7.3)
156
156
  sass-listen (~> 4.0.0)
157
157
  sass-listen (4.0.0)
158
158
  rb-fsevent (~> 0.9, >= 0.9.4)
@@ -163,6 +163,15 @@ GEM
163
163
  sprockets (>= 2.8, < 4.0)
164
164
  sprockets-rails (>= 2.0, < 4.0)
165
165
  tilt (>= 1.1, < 3)
166
+ sassc (2.0.0)
167
+ ffi (~> 1.9.6)
168
+ rake
169
+ sassc-rails (2.1.0)
170
+ railties (>= 4.0.0)
171
+ sassc (>= 2.0)
172
+ sprockets (> 3.0)
173
+ sprockets-rails
174
+ tilt
166
175
  sexp_processor (4.11.0)
167
176
  simple_form (4.1.0)
168
177
  actionpack (>= 5.0)
@@ -7,10 +7,14 @@
7
7
  @checkbox()
8
8
  @popover()
9
9
  @notify()
10
+ @fileInputBrowser()
10
11
 
11
12
  nav: ->
12
13
  #$('.nav-tabs .nav-item .nav-link').tab('show')
13
14
 
15
+ fileInputBrowser: ->
16
+ bsCustomFileInput.init()
17
+
14
18
  popover: ->
15
19
  $('[data-toggle="popover"]').popover()
16
20
 
@@ -20,6 +24,10 @@
20
24
 
21
25
  dropdown: ->
22
26
  $('.dropdown-toggle').dropdown()
27
+ # $('.dropdown-toggle').on 'click', ->
28
+ # $(this).next().toggle()
29
+ # $('.dropdown-menu.keep-open').on 'click', (e) ->
30
+ # e.stopPropagation()
23
31
 
24
32
  notify: ->
25
33
  $('.alert').each ->
@@ -30,6 +30,9 @@
30
30
  #= require marked
31
31
  #= require bootstrap-markdown
32
32
 
33
+ # File Input Browser
34
+ #= require bs-custom-file-input.min
35
+
33
36
  # Ui Bibz
34
37
  #= require table
35
38
  #= require interface
@@ -122,7 +122,7 @@ $input-group-btn-border-color: $input-border-color
122
122
  // Reset rounded corners
123
123
  //
124
124
 
125
- .input-group .form-control:not(:last-child),
125
+ //.input-group .form-control:not(:last-child),
126
126
  .input-group-addon:not(:last-child),
127
127
  .input-group-btn:not(:last-child) > .btn,
128
128
  .input-group-btn:not(:last-child) > .btn-group > .btn,
@@ -134,7 +134,7 @@ $input-group-btn-border-color: $input-border-color
134
134
  .input-group-addon:not(:last-child)
135
135
  border-right: 0
136
136
 
137
- .input-group .form-control:not(:first-child),
137
+ //.input-group .form-control:not(:first-child),
138
138
  .input-group-addon:not(:first-child),
139
139
  .input-group-btn:not(:first-child) > .btn,
140
140
  .input-group-btn:not(:first-child) > .btn-group > .btn,
@@ -24,8 +24,10 @@ module UiBibzInputs
24
24
  autoload :UiNumberFieldInput, "ui_bibz/inputs/ui_bibz_inputs/ui_number_field_input"
25
25
  autoload :UiRadioFieldInput, "ui_bibz/inputs/ui_bibz_inputs/ui_radio_field_input"
26
26
  autoload :UiSelectFieldInput, "ui_bibz/inputs/ui_bibz_inputs/ui_select_field_input"
27
+ autoload :UiBoxSwitchFieldInput, "ui_bibz/inputs/ui_bibz_inputs/ui_box_switch_field_input"
27
28
  autoload :UiSwitchFieldInput, "ui_bibz/inputs/ui_bibz_inputs/ui_switch_field_input"
28
29
  autoload :UiTextFieldInput, "ui_bibz/inputs/ui_bibz_inputs/ui_text_field_input"
30
+ autoload :UiFileFieldInput, "ui_bibz/inputs/ui_bibz_inputs/ui_file_field_input"
29
31
 
30
32
  end
31
33
 
@@ -92,14 +94,20 @@ module UiBibz
92
94
 
93
95
  module Choices
94
96
  autoload :SwitchField, "ui_bibz/ui/core/forms/choices/switch_field"
97
+ autoload :BoxSwitchField, "ui_bibz/ui/core/forms/choices/box_switch_field"
95
98
  autoload :CheckboxField, "ui_bibz/ui/core/forms/choices/checkbox_field"
96
99
  autoload :RadioField, "ui_bibz/ui/core/forms/choices/radio_field"
97
100
  autoload :ChoiceGroup, "ui_bibz/ui/core/forms/choices/choice_group"
98
101
  end
99
102
 
103
+ module Files
104
+ autoload :FileField, "ui_bibz/ui/core/forms/files/file_field"
105
+ end
106
+
100
107
  module Numbers
101
108
  autoload :FormulaField, "ui_bibz/ui/core/forms/numbers/formula_field"
102
109
  autoload :NumberField, "ui_bibz/ui/core/forms/numbers/number_field"
110
+ autoload :RangeField, "ui_bibz/ui/core/forms/numbers/range_field"
103
111
  end
104
112
 
105
113
  module Selects
@@ -80,6 +80,14 @@ module UiBibz::Helpers::Ui::Core::FormsHelper
80
80
  UiBibz::Ui::Core::Forms::Texts::TextField.new(content, options, html_options, &block).render
81
81
  end
82
82
 
83
+ # Box Switch Field Component
84
+ #
85
+ # +options+ (Hash)
86
+ # +html_options+ (Hash)
87
+ def ui_box_switch_field content = nil, options = nil, html_options = nil, &block
88
+ UiBibz::Ui::Core::Forms::Choices::BoxSwitchField.new(content, options, html_options, &block).render
89
+ end
90
+
83
91
  # Switch Field Component
84
92
  #
85
93
  # +options+ (Hash)
@@ -153,5 +161,32 @@ module UiBibz::Helpers::Ui::Core::FormsHelper
153
161
  def ui_split_dropdown name, options = nil, html_options = nil, &block
154
162
  UiBibz::Ui::Core::Forms::Dropdowns::SplitDropdown.new(name, options, html_options).tap(&block).render
155
163
  end
164
+
165
+ # Number Component
166
+ #
167
+ # +name+ (String) [Required]
168
+ # +options+ (Hash)
169
+ # +html_options+ (Hash)
170
+ def ui_number_field name, options = nil, html_options = nil, &block
171
+ UiBibz::Ui::Core::Forms::Numbers::NumberField.new(name, options, html_options, &block).render
172
+ end
173
+
174
+ # Range Component
175
+ #
176
+ # +name+ (String) [Required]
177
+ # +options+ (Hash)
178
+ # +html_options+ (Hash)
179
+ def ui_range_field name, options = nil, html_options = nil, &block
180
+ UiBibz::Ui::Core::Forms::Numbers::RangeField.new(name, options, html_options, &block).render
181
+ end
182
+
183
+ # File Component
184
+ #
185
+ # +name+ (String) [Required]
186
+ # +options+ (Hash)
187
+ # +html_options+ (Hash)
188
+ def ui_file_field name, options = nil, html_options = nil, &block
189
+ UiBibz::Ui::Core::Forms::Files::FileField.new(name, options, html_options, &block).render
190
+ end
156
191
  end
157
192
 
@@ -1,9 +1,9 @@
1
1
  module UiBibz
2
2
  NAME = "Ui Bibz"
3
- VERSION = "2.1.6"
3
+ VERSION = "2.2.0"
4
4
  DESCRIPTION = "A Rails Interface Framework using Bootstrap."
5
5
  SUMMARY = "Create your project with Ui Bibz. Over a thirty reusable components built to provide iconography, dropdowns, input groups, navigation, alerts, and much more."
6
6
  LICENSE = "MIT"
7
7
  FONTAWESOME_VERSION = "5.5.0"
8
- BOOTSTRAP_VERSION = "4.1.3"
8
+ BOOTSTRAP_VERSION = "4.2.1"
9
9
  end
@@ -0,0 +1,18 @@
1
+ module UiBibzInputs
2
+ class UiBoxSwitchFieldInput < BaseInput
3
+ include UiBibz::Ui::Core::Forms::Choices
4
+
5
+ def input(wrapper_options)
6
+ UiBibz::Ui::Core::Forms::Choices::BoxSwitchField.new(input_attribute_name, options, new_input_html_options).render
7
+ end
8
+
9
+ def new_input_html_options
10
+ input_html_options.merge({ checked: value.nil? ? false : value })
11
+ end
12
+
13
+ def value
14
+ @value ||= @builder.object.send(attribute_name)
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ module UiBibzInputs
2
+ class UiFileFieldInput < StringInput
3
+ include UiBibz::Ui::Core::Forms::Texts
4
+
5
+ def input(wrapper_options)
6
+ UiBibz::Ui::Core::Forms::Files::FileField.new(input_attribute_name, options, input_html_options).render
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module UiBibzInputs
2
+ class UiRangeFieldInput < UiTextFieldInput
3
+ include UiBibz::Ui::Core::Forms::Numbers
4
+
5
+ def input(wrapper_options)
6
+ UiBibz::Ui::Core::Forms::Numbers::RangeField.new(input_attribute_name, options, input_html_options).render
7
+ end
8
+
9
+ end
10
+ end
@@ -3,7 +3,7 @@ module UiBibzInputs
3
3
  include UiBibz::Ui::Core::Forms::Choices
4
4
 
5
5
  def input(wrapper_options)
6
- UiBibz::Ui::Core::Forms::Choices::SwitchField.new(input_attribute_name, options, new_input_html_options).render
6
+ UiBibz::Ui::Core::Forms::Choices::SwitchField.new(input_attribute_name, new_options, new_input_html_options).render
7
7
  end
8
8
 
9
9
  def new_input_html_options
@@ -14,5 +14,9 @@ module UiBibzInputs
14
14
  @value ||= @builder.object.send(attribute_name)
15
15
  end
16
16
 
17
+ def new_options
18
+ options.merge({ label: attribute_name.to_s.titleize })
19
+ end
20
+
17
21
  end
18
22
  end
@@ -135,6 +135,10 @@ module UiBibz::Ui::Core
135
135
  html_options[:data].update(Hash[name, value])
136
136
  end
137
137
 
138
+ def is_disabled?
139
+ options[:state] == :disabled || html_options[:disabled]
140
+ end
141
+
138
142
  private
139
143
 
140
144
  def render_with_or_without_cache
@@ -0,0 +1,141 @@
1
+ module UiBibz::Ui::Core::Forms::Choices
2
+
3
+ # Create a SurroundField
4
+ #
5
+ # This element is an extend of UiBibz::Ui::Core::Component.
6
+ # Source : http://www.bootstrap-switch.org/documentation-2.html
7
+ # ==== Attributes
8
+ #
9
+ # * +content+ - Content of element
10
+ # * +options+ - Options of element
11
+ # * +html_options+ - Html Options of element
12
+ #
13
+ # ==== Options
14
+ #
15
+ # You can add HTML attributes using the +html_options+.
16
+ # You can pass arguments in options attribute:
17
+ # * +state+ - Symbol
18
+ # (+:active+, +:disabled+)
19
+ # * +inline+ - Boolean
20
+ # * +animate+ - Boolean
21
+ # * +on_color+ - String
22
+ # * +off_color+ - String
23
+ # * +on_text+ - String
24
+ # * +off_text+ - String
25
+ # * +label_text+ - String
26
+ # * +readonly+ - Boolean
27
+ # * +checked+ - Boolean
28
+ #
29
+ # ==== Signatures
30
+ #
31
+ # UiBibz::Ui::Core::Forms::BoxSwitchField.new(content, options = {}, html_options = {}).render
32
+ #
33
+ # UiBibz::Ui::Core::Forms::BoxSwitchField.new(options = {}, html_options = {}) do
34
+ # content
35
+ # end.render
36
+ #
37
+ # ==== Examples
38
+ #
39
+ # box_switch_field 'name', { on_color: :primary }, { readonly: true }
40
+ #
41
+ # ==== Helper
42
+ #
43
+ # box_switch_field(options = {}, html_options = {}) do
44
+ # # content
45
+ # end
46
+ #
47
+ class BoxSwitchField < UiBibz::Ui::Core::Component
48
+
49
+ # See UiBibz::Ui::Core::Component.initialize
50
+ def initialize content = nil, options = nil, html_options = nil, &block
51
+ super
52
+ end
53
+
54
+ # Render html tag
55
+ def pre_render
56
+ box_switch_field_html_tag
57
+ end
58
+
59
+ private
60
+
61
+ def box_switch_field_html_tag
62
+ content_tag :div, class: component_wrapper_html_classes do
63
+ concat hidden_field_tag content, '0'
64
+ concat check_box_tag content, '1', html_options[:checked], html_options
65
+ end
66
+ end
67
+
68
+ def value
69
+ options[:value]
70
+ end
71
+
72
+ def component_wrapper_html_classes
73
+ join_classes('switch-field-container', inline)
74
+ end
75
+
76
+ def component_html_classes
77
+ super << "switch-field"
78
+ end
79
+
80
+ def component_html_data
81
+ super
82
+ size
83
+ state
84
+ animate
85
+ left_color
86
+ right_color
87
+ left_text
88
+ right_text
89
+ middle_text
90
+ end
91
+
92
+ # '', 'mini', 'small', 'normal', 'large'
93
+ def size
94
+ add_html_data('size', matching_size[options[:size]]) unless options[:size].nil?
95
+ end
96
+
97
+ def matching_size
98
+ { sm: 'small', md: 'normal', lg: 'large' }
99
+ end
100
+
101
+ # true, false => default : true
102
+ def animate
103
+ add_html_data('animate', options.delete(:animate)) unless options[:animate].nil?
104
+ end
105
+
106
+ # active, disabled => default : active
107
+ def state
108
+ html_options[:disabled] = true if options[:state] == 'disabled'
109
+ end
110
+
111
+ # 'primary', 'info', 'success', 'warning', 'danger', 'default' => default : default
112
+ def left_color
113
+ add_html_data('on_color', options[:left_color]) unless options[:left_color].nil?
114
+ end
115
+
116
+ # 'primary', 'info', 'success', 'warning', 'danger', 'default' => default : default
117
+ def right_color
118
+ add_html_data('off_color', options[:right_color]) unless options[:right_color].nil?
119
+ end
120
+
121
+ # String => default : "ON"
122
+ def left_text
123
+ add_html_data('on_text', options[:left_text]) unless options[:left_text].nil?
124
+ end
125
+
126
+ # String => default : "OFF"
127
+ def right_text
128
+ add_html_data('off_text', options[:right_text]) unless options[:right_text].nil?
129
+ end
130
+
131
+ # String => default : '&nbsp;'
132
+ def middle_text
133
+ add_html_data('label_text', options[:middle_text]) unless options[:middle_text].nil?
134
+ end
135
+
136
+ def inline
137
+ "btn-group" unless options[:inline].nil?
138
+ end
139
+
140
+ end
141
+ end