ui_bibz 3.0.0.alpha3 → 3.0.0.alpha5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +5 -5
  3. data/README.md +1 -1
  4. data/lib/ui_bibz.rb +0 -1
  5. data/lib/ui_bibz/helpers/ui/core/forms_helper.rb +2 -1
  6. data/lib/ui_bibz/infos.rb +1 -1
  7. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_checkbox_field_input.rb +5 -1
  8. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_multi_select_field_input.rb +3 -3
  9. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_slider_field_input.rb +1 -1
  10. data/lib/ui_bibz/rails/engine.rb +0 -4
  11. data/lib/ui_bibz/ui/concerns/card_itemable_concern.rb +2 -0
  12. data/lib/ui_bibz/ui/core/boxes/components/card_body.rb +8 -0
  13. data/lib/ui_bibz/ui/core/boxes/components/card_image.rb +1 -1
  14. data/lib/ui_bibz/ui/core/forms/choices/checkbox_field.rb +6 -3
  15. data/lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb +12 -8
  16. data/lib/ui_bibz/ui/core/forms/dropdowns/split_dropdown.rb +7 -2
  17. data/lib/ui_bibz/ui/core/forms/numbers/slider_header.rb +2 -2
  18. data/lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb +41 -59
  19. data/lib/ui_bibz/ui/core/navigations/components/nav_dropdown.rb +2 -2
  20. data/lib/ui_bibz/ui/core/navigations/components/nav_link_link.rb +1 -1
  21. data/lib/ui_bibz/utils/breakdown_class_name_generator.rb +6 -1
  22. data/test/simple_form_test.rb +5 -27
  23. data/test/ui/core/boxes/card_test.rb +1 -1
  24. data/test/ui/core/forms/buttons/button_group_test.rb +1 -1
  25. data/test/ui/core/forms/choices/checkbox_field_test.rb +7 -0
  26. data/test/ui/core/forms/dropdowns/dropdown_test.rb +2 -2
  27. data/test/ui/core/forms/selects/multi_select_field_test.rb +5 -5
  28. data/test/ui/core/navigations/nav_test.rb +7 -6
  29. data/test/ui/core/navigations/navbar_test.rb +3 -2
  30. data/test/ui/core/navigations/tab_group_test.rb +4 -4
  31. metadata +2 -6
  32. data/lib/ui_bibz/ui/core/forms/selects/multi_select_field.rb +0 -122
  33. data/package.json +0 -5
  34. data/test/ui/core/forms/selects/dropdown_select_field_test.rb +0 -84
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66b83873c408d7f000b851a81c55c3ccc16133cd1e9737902fa80437fd213bf6
4
- data.tar.gz: fdf60c814dae76c0f7e158469120911e984c9453814c28cbabfaed75329ef405
3
+ metadata.gz: daf6fae8ebb33a996aababffe959f600d9cce3c84554a9574d54f8623bc12d8e
4
+ data.tar.gz: 5f3aa30344b85d267698918a1dc63bbbc8a220fef61395e5f9ca141666175c82
5
5
  SHA512:
6
- metadata.gz: 96d77724b67f8c30b7a15ae47a9fa25eb3d45e4ba97b8f4116c45e18ece64d97fc45f9a8168b6c8df81de47fa8c3047efdd44e985b75cc1f0ef10676f477792e
7
- data.tar.gz: 43b3745ed55353ed63c5bb122de4ab1da826da54c649e13b653f1e102e7869e933072851aa8c2b96d97a469a7b68d7ef46c4e2c11524e55ff5b673c807068d9a
6
+ metadata.gz: b9fecae8a62e153525d66d32626d01be6cb28ae0fb777ccc99ff14fabcbf3cb802c84c6095acef8da1232b2d02508e7199d28102b12dae75f09a7d7acd1e5482
7
+ data.tar.gz: 4c20b4a4117f93a2539a6121b6b86471585c10eac3df4aeaf51c0521224a1ffa70de65447559413b5ab2503f3cab07027a497ddf7f253d2c90012d43362a24ba
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ui_bibz (3.0.0.alpha3)
4
+ ui_bibz (3.0.0.alpha5)
5
5
  rails (~> 6.0.3, >= 6.0.3.2)
6
6
  will-paginate-i18n
7
7
  will_paginate (~> 3.1.0)
@@ -159,7 +159,7 @@ GEM
159
159
  rake (13.0.1)
160
160
  regexp_parser (1.8.2)
161
161
  rexml (3.2.4)
162
- rubocop (0.93.1)
162
+ rubocop (1.0.0)
163
163
  parallel (~> 1.10)
164
164
  parser (>= 2.7.1.5)
165
165
  rainbow (>= 2.2.2, < 4.0)
@@ -168,7 +168,7 @@ GEM
168
168
  rubocop-ast (>= 0.6.0)
169
169
  ruby-progressbar (~> 1.7)
170
170
  unicode-display_width (>= 1.4.0, < 2.0)
171
- rubocop-ast (0.8.0)
171
+ rubocop-ast (1.1.0)
172
172
  parser (>= 2.7.1.5)
173
173
  rubocop-minitest (0.10.1)
174
174
  rubocop (>= 0.87)
@@ -186,7 +186,7 @@ GEM
186
186
  simple_form (5.0.3)
187
187
  actionpack (>= 5.0)
188
188
  activemodel (>= 5.0)
189
- simplecov (0.19.0)
189
+ simplecov (0.19.1)
190
190
  docile (~> 1.1)
191
191
  simplecov-html (~> 0.11)
192
192
  simplecov-html (0.12.3)
@@ -212,7 +212,7 @@ GEM
212
212
  will_paginate (3.1.8)
213
213
  will_paginate-bootstrap4 (0.2.2)
214
214
  will_paginate (~> 3.0, >= 3.0.0)
215
- zeitwerk (2.4.0)
215
+ zeitwerk (2.4.1)
216
216
 
217
217
  PLATFORMS
218
218
  ruby
data/README.md CHANGED
@@ -19,7 +19,7 @@ Ui Bibz load [Bootstrap](http://getbootstrap.com/) and [Font Awesome](http://fon
19
19
 
20
20
  ## Documentation
21
21
  Full documentation is here with bootstrap 5:
22
- [Ui Bibz v3](http://hummel.link/Ui-Bibz/docs/v3/)
22
+ [Ui Bibz v3](http://hummel.link/Ui-Bibz/)
23
23
 
24
24
  Older documentation is here with bootstrap 4:
25
25
  [Ui Bibz v2.5](http://hummel.link/Ui-Bibz/docs/v2.5/)
@@ -24,7 +24,6 @@ module UiBibzInputs
24
24
  autoload :UiFormulaFieldInput, 'ui_bibz/inputs/ui_bibz_inputs/ui_formula_field_input'
25
25
  autoload :UiMarkdownEditorFieldInput, 'ui_bibz/inputs/ui_bibz_inputs/ui_markdown_editor_field_input'
26
26
  autoload :UiMultiColumnFieldInput, 'ui_bibz/inputs/ui_bibz_inputs/ui_multi_column_field_input'
27
- autoload :UiMultiSelectFieldInput, 'ui_bibz/inputs/ui_bibz_inputs/ui_multi_select_field_input'
28
27
  autoload :UiNumberFieldInput, 'ui_bibz/inputs/ui_bibz_inputs/ui_number_field_input'
29
28
  autoload :UiRadioFieldInput, 'ui_bibz/inputs/ui_bibz_inputs/ui_radio_field_input'
30
29
  autoload :UiSelectFieldInput, 'ui_bibz/inputs/ui_bibz_inputs/ui_select_field_input'
@@ -62,7 +62,8 @@ module UiBibz::Helpers::Ui::Core::FormsHelper
62
62
  # +options+ (Hash)
63
63
  # +html_options+ (Hash)
64
64
  def ui_multi_select_field(content = nil, options = nil, html_options = nil, &block)
65
- UiBibz::Ui::Core::Forms::Selects::MultiSelectField.new(content, options, html_options, &block).render
65
+ options = (options || {}).merge(multiple: true)
66
+ UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new(content, options, html_options, &block).render
66
67
  end
67
68
 
68
69
  # Formula Field Component
@@ -12,6 +12,6 @@ module UiBibz
12
12
  REPO = 'git+https://github.com/thooams/Ui-Bibz.git'
13
13
  EMAIL = 'thomas@hummel.link'
14
14
  AUTHOR = 'Thooams'
15
- VERSION = '3.0.0.alpha3'
15
+ VERSION = '3.0.0.alpha5'
16
16
  AUTHORS = ['Thooams'].freeze
17
17
  end
@@ -4,6 +4,10 @@ module UiBibzInputs
4
4
  class UiCheckboxFieldInput < BaseInput
5
5
  include UiBibz::Ui::Core::Forms::Choices
6
6
 
7
+ def label
8
+ false
9
+ end
10
+
7
11
  def input(_wrapper_options)
8
12
  UiBibz::Ui::Core::Forms::Choices::CheckboxField.new(input_attribute_name, new_options, new_input_html_options).render
9
13
  end
@@ -17,7 +21,7 @@ module UiBibzInputs
17
21
  end
18
22
 
19
23
  def new_options
20
- options.merge({ label: attribute_name.to_s.titleize })
24
+ options.merge({ label: options[:label] || attribute_name.to_s.titleize })
21
25
  end
22
26
  end
23
27
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UiBibzInputs
4
- class UiMultiSelectFieldInput < CollectionInput
5
- def input(_wrapper_options)
6
- UiBibz::Ui::Core::Forms::Selects::MultiSelectField.new(input_attribute_name, new_options, input_html_options).render
4
+ class UiMultiSelectFieldInput < UiDropdownSelectFieldInput
5
+ def new_options
6
+ (super || {}).merge(multiple: true)
7
7
  end
8
8
  end
9
9
  end
@@ -5,7 +5,7 @@ module UiBibzInputs
5
5
  include UiBibz::Ui::Core::Forms::Numbers
6
6
 
7
7
  def input(_wrapper_options)
8
- input_html_options[:id] = @builder.options[:html][:id]
8
+ input_html_options[:id] = "#{sanitize_to_id(input_attribute_name)}_slider"
9
9
  UiBibz::Ui::Core::Forms::Numbers::SliderField.new(input_attribute_name, options, input_html_options).render
10
10
  end
11
11
  end
@@ -21,10 +21,6 @@ module UiBibz
21
21
  initializer 'ui_bibz.helpers.form' do
22
22
  ActionView::Base.include UiBibzForm
23
23
  end
24
-
25
- config.after_initialize do
26
- warn '[Ui Bibz] Ui Bibz is not configured in the application and will use the default values. Use `rails generate ui_bibz:install` to generate the Ui Bibz configuration.' unless UiBibz.configured?
27
- end
28
24
  end
29
25
  end
30
26
  end
@@ -40,6 +40,8 @@ module UiBibz::Ui::Concerns::CardItemableConcern #:nodoc:
40
40
 
41
41
  # Add Image which is a component
42
42
  def image(content = nil, options = nil, html_options = nil, &block)
43
+ # Add position top to the image if the image is in top of the card
44
+ options = (options || {}).merge(position: :top) if @header.nil? && @items.empty? && options.try(:[], :position).nil?
43
45
  @items << UiBibz::Ui::Core::Boxes::Components::CardImage.new(content, options, html_options, &block).render
44
46
  end
45
47
 
@@ -70,6 +70,14 @@ module UiBibz::Ui::Core::Boxes::Components
70
70
  @items << UiBibz::Ui::Core::Boxes::Components::Body::CardBodyText.new(content, options, html_options, &block).render
71
71
  end
72
72
 
73
+ def row(content = nil, options = nil, html_options = nil, &block)
74
+ @items << if tapped?(block)
75
+ UiBibz::Ui::Core::Layouts::Row.new(content, options, html_options).tap(&block).render
76
+ else
77
+ UiBibz::Ui::Core::Layouts::Row.new(content, options, html_options, &block).render
78
+ end
79
+ end
80
+
73
81
  private
74
82
 
75
83
  def component_html_classes
@@ -48,7 +48,7 @@ module UiBibz::Ui::Core::Boxes::Components
48
48
  end
49
49
 
50
50
  def position
51
- "card-img-#{@options[:position] || :top}"
51
+ "card-img-#{@options[:position] || :top}" if @options[:position]
52
52
  end
53
53
  end
54
54
  end
@@ -20,7 +20,8 @@ module UiBibz::Ui::Core::Forms::Choices
20
20
  # * +inline+ - Boolean
21
21
  # * +checked+ - Boolean
22
22
  # * +action+ - String Stimulus Option
23
- # * +label+ - String
23
+ # * +label+ - [String/Boolean]
24
+ # * +boolean+ - Boolean Add an hidden field for rails
24
25
  #
25
26
  # ==== Signatures
26
27
  #
@@ -58,7 +59,7 @@ module UiBibz::Ui::Core::Forms::Choices
58
59
 
59
60
  def checkbox_field_html_tag
60
61
  content_tag(:div, html_options.except(:id, 'data-action')) do
61
- concat hidden_field_tag content, '0', id: "#{content}-hidden"
62
+ concat hidden_field_tag content, '0', id: "#{content}-hidden" if options[:boolean]
62
63
  concat check_box_tag content, options[:value] || '1', options[:checked] || html_options[:checked], checkbox_html_options
63
64
  concat label_tag(label_name, label_content, class: 'form-check-label') if options[:label] != false
64
65
  end
@@ -70,7 +71,9 @@ module UiBibz::Ui::Core::Forms::Choices
70
71
  indeterminate: options[:indeterminate],
71
72
  "data-action": options[:action],
72
73
  class: 'form-check-input'
73
- }
74
+ }.tap do |html|
75
+ html[:id] = html_options[:id] if html_options[:id]
76
+ end
74
77
  end
75
78
 
76
79
  def label_name
@@ -27,6 +27,10 @@ module UiBibz::Ui::Core::Forms::Dropdowns
27
27
  # * +size+ - Integer
28
28
  # * +type+ - Symbol
29
29
  # * +html_button+ - Hash
30
+ # * +position+ - Symbol
31
+ # (+:up+, +:right+, +:down+, +:left+)
32
+ # * +alignement+ - Symbol
33
+ # (+:right)
30
34
  #
31
35
  # ==== Signatures
32
36
  #
@@ -103,7 +107,7 @@ module UiBibz::Ui::Core::Forms::Dropdowns
103
107
  protected
104
108
 
105
109
  def component_html_classes
106
- [type, open, inline, without_caret, keep_open]
110
+ [position, open, inline, without_caret, keep_open]
107
111
  end
108
112
 
109
113
  def button_content
@@ -113,26 +117,26 @@ module UiBibz::Ui::Core::Forms::Dropdowns
113
117
  def button_html
114
118
  html_button = options[:html_button] || {}
115
119
  if options[:tag] == :a
116
- content_tag dropdown_tag, button_content, { class: join_classes('btn', button_status, state, size, 'dropdown-toggle'), href: '#', role: 'button', 'data-toggle' => 'dropdown', 'aria-haspopup' => true, 'aria-expanded' => false, 'id' => id }.merge(html_button)
120
+ content_tag dropdown_tag, button_content, { class: join_classes('btn', button_status, state, size, 'dropdown-toggle'), role: 'button', 'data-toggle' => 'dropdown', 'aria-haspopup' => true, 'aria-expanded' => false, 'id' => id }.merge(html_button)
117
121
  else
118
122
  content_tag dropdown_tag, button_content, { class: join_classes('btn', button_status, state, size, 'dropdown-toggle'), type: 'button', 'data-toggle' => 'dropdown', 'aria-haspopup' => true, 'aria-expanded' => false, 'id' => id }.merge(html_button)
119
123
  end
120
124
  end
121
125
 
122
126
  def ul_html
123
- content_tag :div, @items.join.html_safe, class: join_classes('dropdown-menu', theme, position, open), 'arial-labelledby' => id
127
+ content_tag :div, @items.join.html_safe, class: join_classes('dropdown-menu', theme, alignement, open), 'arial-labelledby' => id
124
128
  end
125
129
 
126
130
  def dropdown_tag
127
131
  options[:tag] || :button
128
132
  end
129
133
 
130
- def position
131
- "dropdown-menu-#{@options[:position]}" unless @options[:position].nil?
134
+ def alignement
135
+ "dropdown-menu-#{@options[:alignement]}" unless @options[:alignement].nil?
132
136
  end
133
137
 
134
- def type
135
- @options[:type] || 'dropdown'
138
+ def position
139
+ "drop#{@options[:position] || 'down'}"
136
140
  end
137
141
 
138
142
  def open
@@ -144,7 +148,7 @@ module UiBibz::Ui::Core::Forms::Dropdowns
144
148
  end
145
149
 
146
150
  def inline
147
- 'btn-group' if @options[:inline]
151
+ 'btn-group' if @options[:inline] || @options[:alignement]
148
152
  end
149
153
 
150
154
  def without_caret
@@ -69,7 +69,7 @@ module UiBibz::Ui::Core::Forms::Dropdowns
69
69
  private
70
70
 
71
71
  def component_html_classes
72
- ['btn-group', type]
72
+ ['btn-group', position, alignement, open, inline, keep_open]
73
73
  end
74
74
 
75
75
  def button_html
@@ -77,13 +77,18 @@ module UiBibz::Ui::Core::Forms::Dropdowns
77
77
  end
78
78
 
79
79
  def split_html
80
- content_tag :button, split_content, class: join_classes('btn', button_status, size, 'dropdown-toggle', 'dropdown-toggle-split'), type: 'button', 'data-toggle' => 'dropdown', 'aria-haspopup' => true, 'aria-expanded' => false
80
+ content_tag :button, split_content, class: split_classes, type: 'button',
81
+ 'data-toggle' => 'dropdown', 'aria-haspopup' => true, 'aria-expanded' => false
81
82
  end
82
83
 
83
84
  def split_content
84
85
  src_only
85
86
  end
86
87
 
88
+ def split_classes
89
+ join_classes('btn', button_status, size, 'dropdown-toggle', 'dropdown-toggle-split')
90
+ end
91
+
87
92
  def src_only
88
93
  content_tag :span, 'Toggle Dropdown', class: 'sr-only'
89
94
  end
@@ -53,14 +53,14 @@ module UiBibz::Ui::Core::Forms::Numbers
53
53
  def header_min
54
54
  content_tag :div, class: 'slider-header-min' do
55
55
  concat content_tag :label, options[:label_min] || 'Min: '
56
- concat content_tag :span, options[:thumb_min]
56
+ concat content_tag :span, options[:thumb_min], "data-unit": options[:unit] || options[:unit_min]
57
57
  end
58
58
  end
59
59
 
60
60
  def header_max
61
61
  content_tag :div, class: 'slider-header-max' do
62
62
  concat content_tag :label, options[:label_max] || 'max: '
63
- concat content_tag :span, options[:thumb_max]
63
+ concat content_tag :span, options[:thumb_max], "data-unit": options[:unit] || options[:unit_max]
64
64
  end
65
65
  end
66
66
 
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ui_bibz/ui/extensions/core/forms/surround_extension'
4
3
  module UiBibz::Ui::Core::Forms::Selects
5
4
  # Create a DropdownSelectField
6
5
  #
7
- # This element is an extend of UiBibz::Ui::Core::Component.
8
- # source : http://silviomoreto.github.io/bootstrap-select/examples/
6
+ # This element is an extend of UiBibz::Ui::Core::Forms::Buttons::Button
7
+ # source : http://loudev.com/
9
8
  #
10
9
  # ==== Attributes
11
10
  #
@@ -17,18 +16,14 @@ module UiBibz::Ui::Core::Forms::Selects
17
16
  #
18
17
  # You can add HTML attributes using the +html_options+.
19
18
  # You can pass arguments in options attribute:
20
- # * +status+ - status of element with symbol value:
21
- # (+:primary+, +:secondary+, +:info+, +:warning+, +:danger+, +:link+)
22
19
  # * +option_tags+ - Array, Object [required]
20
+ # * +multiple+ - Boolean
21
+ # * +outline+ - Boolean
22
+ # * +theme+ - String
23
+ # * +clickable_opt_group+ - Boolean
24
+ # * +collapsible_opt_group+ - Boolean
23
25
  # * +searchable+ - Boolean
24
- # * +max_options+ - Integer
25
- # * +selected_text_format+ - String
26
- # * +menu_size+ - Integer
27
- # * +header+ - String
28
- # * +actions_box+ - Boolean
29
- # * +show_tick+ - Boolean
30
- # * +show_menu_arrow+ - Boolean
31
- # * +dropup+ - Boolean
26
+ # * +select_all_option+ - Boolean
32
27
  # * +append+ - String, Html
33
28
  # * +prepend+ - String, Html
34
29
  # * +connect+ - Hash
@@ -38,13 +33,6 @@ module UiBibz::Ui::Core::Forms::Selects
38
33
  # * +selector+ - String
39
34
  # * +data+ - Array
40
35
  # * +url+ - String
41
- # * +refresh+ - Hash
42
- # * +event+ - String
43
- # * +mode+ - String
44
- # * +target+ - Hash
45
- # * +selector+ - String
46
- # * +data+ - Array
47
- # * +url+ - String
48
36
  #
49
37
  # ==== Signatures
50
38
  #
@@ -58,7 +46,7 @@ module UiBibz::Ui::Core::Forms::Selects
58
46
  #
59
47
  # UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('fruits', { option_tags: list_of_fruits, searchable: true }, { class: 'test' })
60
48
  #
61
- # UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new({ option_tags: list_of_fruits, actions_box: true }, { class: 'test' }) do
49
+ # UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new({ option_tags: list_of_fruits, select_all_option: true }, { class: 'test' }) do
62
50
  # 'fruits'
63
51
  # end
64
52
  #
@@ -67,77 +55,71 @@ module UiBibz::Ui::Core::Forms::Selects
67
55
  # dropdown_select_field(content, options = {}, html_options = {})
68
56
  #
69
57
  class DropdownSelectField < UiBibz::Ui::Core::Forms::Selects::AbstractSelect
70
- # See UiBibz::Ui::Core::Component.initialize
58
+ # See UiBibz::Ui::Core::Forms::Buttons::Button.initialize
71
59
 
72
60
  private
73
61
 
74
62
  def component_html_options
75
- super.merge({}.tap do |h|
76
- h[:multiple] = true if options[:multiple]
77
- h[:disabled] = options[:state] == :disabled
78
- h[:include_blank] = options[:include_blank]
79
- h[:title] = h.delete(:prompt) unless options[:prompt].nil?
80
- end)
63
+ super.merge({
64
+ multiple: options[:multiple],
65
+ disabled: options[:state] == :disabled,
66
+ include_blank: false,
67
+ prompt: false
68
+ })
81
69
  end
82
70
 
83
71
  def component_html_classes
84
- super << ['dropdown-select-field', show_tick, dropup]
72
+ [size, type, button_status, 'multi-select-field']
85
73
  end
86
74
 
87
75
  def component_html_data
88
76
  super
77
+ clickable_opt_group
78
+ collapsible_opt_group
89
79
  searchable
90
- max_options
91
- selected_text_format
92
- menu_size
93
- style
94
- header
95
- actions_box
96
- add_status
80
+ select_all_options
81
+ number_displayed
97
82
  end
98
83
 
99
- ############################ Data html options
100
-
101
- def max_options
102
- add_html_data('max_options', value: options[:max_options]) if options[:max_options]
84
+ def clickable_opt_group
85
+ add_html_data('enable_clickable_opt_groups') if options[:clickable_opt_group]
103
86
  end
104
87
 
105
- def selected_text_format
106
- add_html_data('selected_text_format', value: options[:selected_text_format]) if options[:selected_text_format]
88
+ def collapsible_opt_group
89
+ add_html_data('enable_collapsible_opt_groups') if options[:collapsible_opt_group]
107
90
  end
108
91
 
109
92
  def searchable
110
- add_html_data('live_search') if options[:searchable]
93
+ add_html_data('enable_filtering') if options[:searchable]
111
94
  end
112
95
 
113
- def style
114
- add_html_data('style', value: "btn-#{options[:status] || :secondary}")
96
+ def number_displayed
97
+ add_html_data('number_displayed') if options[:number_displayed]
115
98
  end
116
99
 
117
- def menu_size
118
- add_html_data('size', value: options[:menu_size]) if options[:menu_size]
100
+ def select_all_options
101
+ add_html_data('include_select_all_option') if options[:select_all_options]
119
102
  end
120
103
 
121
- def actions_box
122
- add_html_data('actions_box') if options[:actions_box]
104
+ def type
105
+ 'btn-block' if options[:type] == :block
123
106
  end
124
107
 
125
- def header
126
- add_html_data('header', value: options[:header]) if options[:header]
108
+ # :lg, :sm or :xs
109
+ def size
110
+ "btn-#{options[:size]}" if options[:size]
127
111
  end
128
112
 
129
- def add_status
130
- add_html_data('style', value: "btn-#{options[:status]}") if options[:status]
113
+ def button_status
114
+ ['btn', outline, options[:status] || :secondary].compact.join('-')
131
115
  end
132
116
 
133
- ############################# Css classes
134
-
135
- def show_tick
136
- 'show-tick' if options[:show_tick]
117
+ def outline
118
+ 'outline' if options[:outline]
137
119
  end
138
120
 
139
- def dropup
140
- 'dropup' if options[:dropup]
121
+ def theme
122
+ 'dropdown-menu-dark' if @options[:theme]
141
123
  end
142
124
  end
143
125
  end
@@ -56,11 +56,11 @@ module UiBibz::Ui::Core::Navigations
56
56
  private
57
57
 
58
58
  def component_html_classes
59
- [type, 'nav-item', without_caret]
59
+ [position, open, keep_open, 'nav-item', without_caret]
60
60
  end
61
61
 
62
62
  def link_html
63
- link_to button_content, '#', class: join_classes(size, state, 'dropdown-toggle', 'nav-link'), 'data-toggle' => 'dropdown', 'aria-expanded' => false
63
+ content_tag :a, button_content, class: join_classes(size, state, 'dropdown-toggle', 'nav-link'), 'data-toggle' => 'dropdown', 'aria-expanded' => false
64
64
  end
65
65
  end
66
66
  end
@@ -23,7 +23,7 @@ module UiBibz::Ui::Core::Navigations
23
23
 
24
24
  # Render html tag
25
25
  def pre_render
26
- link_to options[:url], html_options do
26
+ content_tag :a, { href: options[:url] }.merge(html_options) do
27
27
  concat glyph_and_content_html
28
28
  concat tag_html if options[:tag]
29
29
  end
@@ -3,7 +3,7 @@
3
3
  module UiBibz::Utils
4
4
  # Generate the col class name
5
5
  class BreakdownClassNameGenerator
6
- POSITIONING = %i[num offset push pull].freeze
6
+ POSITIONING = %i[num offset push pull order].freeze
7
7
  BREAKPOINTS = UiBibz::Ui::Core::Component::BREAKPOINTS
8
8
  PARAMETERS = BREAKPOINTS + POSITIONING + [:position]
9
9
 
@@ -52,6 +52,11 @@ module UiBibz::Utils
52
52
  [@klass_name, size, 'push', number].compact.join('-')
53
53
  end
54
54
 
55
+ # order-md-9
56
+ def order(size, number)
57
+ ['order', size, number].compact.join('-')
58
+ end
59
+
55
60
  # col-md-pull-9
56
61
  def pull(size, number)
57
62
  [@klass_name, size, 'pull', number].compact.join('-')
@@ -42,28 +42,6 @@ class SimpleFormTest < ActionView::TestCase
42
42
  assert_equal expected, actual
43
43
  end
44
44
 
45
- test 'dropdown field select input in simple form' do
46
- actual = simple_form_for @user do |f|
47
- f.input :name_fr, as: :ui_dropdown_select_field, collection: @users, label_method: :name_fr
48
- end
49
-
50
- expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_dropdown_select_field optional user_name_fr\"><label class=\"control-label ui_dropdown_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"dropdown-select-field\" data-style=\"btn-secondary\"><option value=\"1\">test1</option>
51
- <option value=\"2\">test2</option></select></div></form>"
52
-
53
- assert_equal expected, actual
54
- end
55
-
56
- test 'dropdown field select input with grouped option in simple form' do
57
- actual = simple_form_for @user do |f|
58
- f.input :name_fr, as: :ui_dropdown_select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
59
- end
60
-
61
- expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_dropdown_select_field optional user_name_fr\"><label class=\"control-label ui_dropdown_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"dropdown-select-field\" data-style=\"btn-secondary\"><optgroup label=\"Europe\"><option value=\"1\">France</option>
62
- <option value=\"2\">Deutchland</option></optgroup></select></div></form>"
63
-
64
- assert_equal expected, actual
65
- end
66
-
67
45
  test 'formula field input in simple form' do
68
46
  @user.price = 3.0
69
47
  @user.price_formula = '1+2'
@@ -101,10 +79,10 @@ test1</textarea></div></form>"
101
79
 
102
80
  test 'multi select field input in simple form' do
103
81
  actual = simple_form_for @user do |f|
104
- f.input :name_fr, as: :ui_multi_select_field, collection: @users, label_method: :name_fr
82
+ f.input :name_fr, as: :ui_dropdown_select_field, multiple: true, collection: @users, label_method: :name_fr
105
83
  end
106
84
 
107
- expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_multi_select_field optional user_name_fr\"><label class=\"control-label ui_multi_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr][]\" id=\"user_name_fr\" class=\"btn-secondary multi-select-field\" multiple=\"multiple\"><option value=\"1\">test1</option>
85
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_dropdown_select_field optional user_name_fr\"><label class=\"control-label ui_dropdown_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr][]\" id=\"user_name_fr\" class=\"btn-secondary multi-select-field\" multiple=\"multiple\"><option value=\"1\">test1</option>
108
86
  <option value=\"2\">test2</option></select></div></form>"
109
87
 
110
88
  assert_equal expected, actual
@@ -112,10 +90,10 @@ test1</textarea></div></form>"
112
90
 
113
91
  test 'multi select input with grouped option in simple form' do
114
92
  actual = simple_form_for @user do |f|
115
- f.input :name_fr, as: :ui_multi_select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
93
+ f.input :name_fr, as: :ui_dropdown_select_field, multiple: true, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
116
94
  end
117
95
 
118
- expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_multi_select_field optional user_name_fr\"><label class=\"control-label ui_multi_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr][]\" id=\"user_name_fr\" class=\"btn-secondary multi-select-field\" multiple=\"multiple\"><optgroup label=\"Europe\"><option value=\"1\">France</option>
96
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_dropdown_select_field optional user_name_fr\"><label class=\"control-label ui_dropdown_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr][]\" id=\"user_name_fr\" class=\"btn-secondary multi-select-field\" multiple=\"multiple\"><optgroup label=\"Europe\"><option value=\"1\">France</option>
119
97
  <option value=\"2\">Deutchland</option></optgroup></select></div></form>"
120
98
 
121
99
  assert_equal expected, actual
@@ -244,7 +222,7 @@ test1</textarea></div></form>"
244
222
  f.input :name_en, as: :ui_slider_field
245
223
  end
246
224
 
247
- expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_slider_field optional user_name_en\"><label class=\"control-label ui_slider_field optional\" for=\"user_name_en\">Name en</label><div class=\"ui_slider_field optional slider\" id=\"edit_user_1\"><div><div class=\"slider-inverse-left\" style=\"width: 100%\"></div><div class=\"slider-inverse-right\" style=\"width: 100%\"></div><div class=\"slider-range\" style=\"left: 0%; right: 0%\"></div><div class=\"slider-thumb slider-thumb-left\" style=\"left: 0%\"></div><div class=\"slider-thumb slider-thumb-right\" style=\"left: 100%\"></div></div><input type=\"range\" name=\"user[name_en_min]\" id=\"user_name_en_min\" value=\"0\" max=\"100\" min=\"0\" step=\"1\" /><input type=\"range\" name=\"user[name_en_max]\" id=\"user_name_en_max\" value=\"100\" max=\"100\" min=\"0\" step=\"1\" /></div></div></form>"
225
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_slider_field optional user_name_en\"><label class=\"control-label ui_slider_field optional\" for=\"user_name_en\">Name en</label><div class=\"ui_slider_field optional slider\" id=\"user_name_en_slider\"><div><div class=\"slider-inverse-left\" style=\"width: 100%\"></div><div class=\"slider-inverse-right\" style=\"width: 100%\"></div><div class=\"slider-range\" style=\"left: 0%; right: 0%\"></div><div class=\"slider-thumb slider-thumb-left\" style=\"left: 0%\"></div><div class=\"slider-thumb slider-thumb-right\" style=\"left: 100%\"></div></div><input type=\"range\" name=\"user[name_en_min]\" id=\"user_name_en_min\" value=\"0\" max=\"100\" min=\"0\" step=\"1\" /><input type=\"range\" name=\"user[name_en_max]\" id=\"user_name_en_max\" value=\"100\" max=\"100\" min=\"0\" step=\"1\" /></div></div></form>"
248
226
 
249
227
  assert_equal expected, actual
250
228
  end
@@ -145,7 +145,7 @@ class CardTest < ActionView::TestCase
145
145
  end
146
146
  end
147
147
  end
148
- expected = '<div class="card"><div class="card-header"><ul class="nav nav-tabs card-header-tabs"><li class="nav-item"><a class="nav-link" data-toggle="tab" role="tab" href="#link1">link1</a></li><li class="nav-item"><a class="nav-link" data-toggle="tab" role="tab" href="#link2">link2</a></li></ul></div></div>'
148
+ expected = "<div class=\"card\"><div class=\"card-header\"><ul class=\"nav nav-tabs card-header-tabs\"><li class=\"nav-item\"><a href=\"#link1\" class=\"nav-link\" data-toggle=\"tab\" role=\"tab\">link1</a></li><li class=\"nav-item\"><a href=\"#link2\" class=\"nav-link\" data-toggle=\"tab\" role=\"tab\">link2</a></li></ul></div></div>"
149
149
 
150
150
  assert_equal expected, actual
151
151
  end
@@ -43,7 +43,7 @@ class ButtonGroupTest < ActionView::TestCase
43
43
 
44
44
  test 'button group with dropdown' do
45
45
  actual = ui_button_group do |bg|
46
- bg.dropdown('Dropdown', { type: :dropup, status: :success }, { id: 'dropdown-test' }) do |d|
46
+ bg.dropdown('Dropdown', { position: :up, status: :success }, { id: 'dropdown-test' }) do |d|
47
47
  d.link 'Link 1', url: '#link1', glyph: 'eye'
48
48
  end
49
49
  end
@@ -5,6 +5,13 @@ require 'test_helper'
5
5
  class CheckboxFieldTest < ActionView::TestCase
6
6
  test 'checkbox_field' do
7
7
  actual = UiBibz::Ui::Core::Forms::Choices::CheckboxField.new('John', { value: 1 }).render
8
+ expected = "<div class=\"form-check\"><input type=\"checkbox\" name=\"John\" id=\"John\" value=\"1\" class=\"form-check-input\" /><label class=\"form-check-label\" for=\"John\">John</label></div>"
9
+
10
+ assert_equal expected, actual
11
+ end
12
+
13
+ test 'checkbox_field which is a boolean' do
14
+ actual = UiBibz::Ui::Core::Forms::Choices::CheckboxField.new('John', { boolean: true, value: 1 }).render
8
15
  expected = "<div class=\"form-check\"><input type=\"hidden\" name=\"John\" id=\"John-hidden\" value=\"0\" /><input type=\"checkbox\" name=\"John\" id=\"John\" value=\"1\" class=\"form-check-input\" /><label class=\"form-check-label\" for=\"John\">John</label></div>"
9
16
 
10
17
  assert_equal expected, actual
@@ -32,14 +32,14 @@ class DropdownTest < ActionView::TestCase
32
32
  end
33
33
 
34
34
  test 'Dropdown options' do
35
- actual = UiBibz::Ui::Core::Forms::Dropdowns::Dropdown.new('Dropdown', type: :dropup, status: :success, glyph: 'diamond').tap do |d|
35
+ actual = UiBibz::Ui::Core::Forms::Dropdowns::Dropdown.new('Dropdown', position: :up, alignement: :right, status: :success, glyph: 'diamond').tap do |d|
36
36
  d.link 'Link 1', url: '#link1', glyph: 'eye'
37
37
  d.header 'header'
38
38
  d.link 'Link 2', url: '#link2'
39
39
  d.divider
40
40
  d.link 'Link3', url: '#link3'
41
41
  end
42
- expected = "<div class=\"dropup\"><button class=\"btn btn-success dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" id=\"#{actual.id}\"><i class=\"glyph fas fa-diamond\"></i> Dropdown</button><div class=\"dropdown-menu\" arial-labelledby=\"#{actual.id}\"><a class=\"dropdown-item\" href=\"#link1\"><i class=\"glyph fas fa-eye\"></i> Link 1</a><h6 class=\"dropdown-header\" role=\"presentation\">header</h6><a class=\"dropdown-item\" href=\"#link2\">Link 2</a><div class=\"dropdown-divider\"></div><a class=\"dropdown-item\" href=\"#link3\">Link3</a></div></div>"
42
+ expected = "<div class=\"dropup btn-group\"><button class=\"btn btn-success dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" id=\"#{actual.id}\"><i class=\"glyph fas fa-diamond\"></i> Dropdown</button><div class=\"dropdown-menu dropdown-menu-right\" arial-labelledby=\"#{actual.id}\"><a class=\"dropdown-item\" href=\"#link1\"><i class=\"glyph fas fa-eye\"></i> Link 1</a><h6 class=\"dropdown-header\" role=\"presentation\">header</h6><a class=\"dropdown-item\" href=\"#link2\">Link 2</a><div class=\"dropdown-divider\"></div><a class=\"dropdown-item\" href=\"#link3\">Link3</a></div></div>"
43
43
 
44
44
  assert_equal expected, actual.render
45
45
  end
@@ -2,10 +2,10 @@
2
2
 
3
3
  require 'test_helper'
4
4
 
5
- class MultiSelectFieldTest < ActionView::TestCase
5
+ class DropdownSelectFieldTest < ActionView::TestCase
6
6
  test 'Multi Select Field' do
7
7
  options = options_for_select(Array.new(2) { |i| "option #{i}" })
8
- actual = UiBibz::Ui::Core::Forms::Selects::MultiSelectField.new('example', option_tags: options).render
8
+ actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('example', multiple: true, option_tags: options).render
9
9
  expected = "<select name=\"example[]\" id=\"example\" class=\"btn-secondary multi-select-field\" multiple=\"multiple\"><option value=\"option 0\">option 0</option>
10
10
  <option value=\"option 1\">option 1</option></select>"
11
11
 
@@ -14,8 +14,8 @@ class MultiSelectFieldTest < ActionView::TestCase
14
14
 
15
15
  test 'Multi Select Field data html options' do
16
16
  grouped_options = { 'North America' => [['United statuss', 'US'], 'Canada'], 'Europe' => %w[Denmark Germany France] }
17
- actual = UiBibz::Ui::Core::Forms::Selects::MultiSelectField.new('example', { option_tags: grouped_options_for_select(grouped_options), clickable_opt_group: true, collapsible_opt_group: true, searchable: true, select_all_options: true, number_displayed: 2, status: :danger }).render
18
- expected = "<select name=\"example[]\" id=\"example\" data-enable-clickable-opt-groups=\"true\" data-enable-collapsible-opt-groups=\"true\" data-enable-filtering=\"true\" data-include-select-all-option=\"true\" data-number-displayed=\"true\" class=\"btn-danger btn-secondary multi-select-field\" multiple=\"multiple\"><optgroup label=\"North America\"><option value=\"US\">United statuss</option>
17
+ actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('example', { multiple: true, option_tags: grouped_options_for_select(grouped_options), clickable_opt_group: true, collapsible_opt_group: true, searchable: true, select_all_options: true, number_displayed: 2, status: :danger }).render
18
+ expected = "<select name=\"example[]\" id=\"example\" data-enable-clickable-opt-groups=\"true\" data-enable-collapsible-opt-groups=\"true\" data-enable-filtering=\"true\" data-include-select-all-option=\"true\" data-number-displayed=\"true\" class=\"btn-danger multi-select-field\" multiple=\"multiple\"><optgroup label=\"North America\"><option value=\"US\">United statuss</option>
19
19
  <option value=\"Canada\">Canada</option></optgroup><optgroup label=\"Europe\"><option value=\"Denmark\">Denmark</option>
20
20
  <option value=\"Germany\">Germany</option>
21
21
  <option value=\"France\">France</option></optgroup></select>"
@@ -24,7 +24,7 @@ class MultiSelectFieldTest < ActionView::TestCase
24
24
  end
25
25
 
26
26
  test 'Multi select Field refresh option' do
27
- actual = UiBibz::Ui::Core::Forms::Selects::MultiSelectField.new('test', { refresh: { target: { url: '/' } } }).render
27
+ actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { multiple: true, refresh: { target: { url: '/' } } }).render
28
28
  expected = '<div class="field-refresh input-group ui_surround_field"><select name="test[]" id="test" class="btn-secondary multi-select-field" multiple="multiple"></select><span data-connect="{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;remote&quot;,&quot;target&quot;:{&quot;selector&quot;:&quot;#test&quot;,&quot;url&quot;:&quot;/&quot;,&quot;data&quot;:[]}}" class="btn-secondary ui-bibz-connect btn input-refresh-button"><i class="glyph fas fa-sync-alt"></i> </span></div>'
29
29
 
30
30
  assert_equal expected, actual
@@ -10,7 +10,8 @@ class NavTest < ActionView::TestCase
10
10
  n.link 'Profile', url: '#profile', selector: 'profile'
11
11
  n.link 'Messages', url: '#messages', selector: 'messages'
12
12
  end
13
- expected = '<ul class="nav nav-tabs"><li class="nav-item"><a class="active nav-link" data-toggle="tab" role="tab" href="#Home">Home</a></li><li class="nav-item"><a class="nav-link" data-toggle="tab" role="tab" href="#profile">Profile</a></li><li class="nav-item"><a class="nav-link" data-toggle="tab" role="tab" href="#messages">Messages</a></li></ul>'
13
+ expected = "<ul class=\"nav nav-tabs\"><li class=\"nav-item\"><a href=\"#Home\" class=\"active nav-link\" data-toggle=\"tab\" role=\"tab\">Home</a></li><li class=\"nav-item\"><a href=\"#profile\" class=\"nav-link\" data-toggle=\"tab\" role=\"tab\">Profile</a></li><li class=\"nav-item\"><a href=\"#messages\" class=\"nav-link\" data-toggle=\"tab\" role=\"tab\">Messages</a></li></ul>"
14
+
14
15
  assert_equal expected, actual
15
16
  end
16
17
 
@@ -20,7 +21,7 @@ class NavTest < ActionView::TestCase
20
21
  n.link 'Profile', url: '#profile', selector: 'profile', label: 16
21
22
  n.link 'Messages', url: '#messages', selector: 'messages', state: :disabled
22
23
  end
23
- expected = '<ul class="nav nav-pills"><li class="nav-item"><a class="active nav-link" href="#Home">Home</a></li><li class="nav-item"><a class="nav-link" href="#profile">Profile</a></li><li class="nav-item"><a class="disabled nav-link" href="#messages">Messages</a></li></ul>'
24
+ expected = "<ul class=\"nav nav-pills\"><li class=\"nav-item\"><a href=\"#Home\" class=\"active nav-link\">Home</a></li><li class=\"nav-item\"><a href=\"#profile\" class=\"nav-link\">Profile</a></li><li class=\"nav-item\"><a href=\"#messages\" class=\"disabled nav-link\">Messages</a></li></ul>"
24
25
 
25
26
  assert_equal expected, actual
26
27
  end
@@ -31,7 +32,7 @@ class NavTest < ActionView::TestCase
31
32
  n.link 'Profile', url: '#profile', selector: 'profile', label: 16
32
33
  n.link 'Messages', url: '#messages', selector: 'messages', state: :disabled
33
34
  end
34
- expected = '<ul class="nav justify-content-end"><li class="nav-item"><a class="active nav-link" href="#Home">Home</a></li><li class="nav-item"><a class="nav-link" href="#profile">Profile</a></li><li class="nav-item"><a class="disabled nav-link" href="#messages">Messages</a></li></ul>'
35
+ expected = "<ul class=\"nav justify-content-end\"><li class=\"nav-item\"><a href=\"#Home\" class=\"active nav-link\">Home</a></li><li class=\"nav-item\"><a href=\"#profile\" class=\"nav-link\">Profile</a></li><li class=\"nav-item\"><a href=\"#messages\" class=\"disabled nav-link\">Messages</a></li></ul>"
35
36
 
36
37
  assert_equal expected, actual
37
38
  end
@@ -42,7 +43,7 @@ class NavTest < ActionView::TestCase
42
43
  n.link 'Profile', url: '#profile', selector: 'profile', label: 16
43
44
  n.link 'Messages', url: '#messages', selector: 'messages', state: :disabled
44
45
  end
45
- expected = '<ul class="nav"><li class="nav-item"><a class="active nav-link" href="#Home">Home</a></li><li class="nav-item"><a class="nav-link" href="#profile">Profile</a></li><li class="nav-item"><a class="disabled nav-link" href="#messages">Messages</a></li></ul>'
46
+ expected = "<ul class=\"nav\"><li class=\"nav-item\"><a href=\"#Home\" class=\"active nav-link\">Home</a></li><li class=\"nav-item\"><a href=\"#profile\" class=\"nav-link\">Profile</a></li><li class=\"nav-item\"><a href=\"#messages\" class=\"disabled nav-link\">Messages</a></li></ul>"
46
47
 
47
48
  assert_equal expected, actual
48
49
  end
@@ -53,7 +54,7 @@ class NavTest < ActionView::TestCase
53
54
  n.link 'Profile', url: '#profile', selector: 'profile', label: 16
54
55
  n.link 'Messages', url: '#messages', selector: 'messages', state: :disabled
55
56
  end
56
- expected = '<ul class="nav flex-column"><li class="nav-item"><a class="active nav-link" href="#Home">Home</a></li><li class="nav-item"><a class="nav-link" href="#profile">Profile</a></li><li class="nav-item"><a class="disabled nav-link" href="#messages">Messages</a></li></ul>'
57
+ expected = "<ul class=\"nav flex-column\"><li class=\"nav-item\"><a href=\"#Home\" class=\"active nav-link\">Home</a></li><li class=\"nav-item\"><a href=\"#profile\" class=\"nav-link\">Profile</a></li><li class=\"nav-item\"><a href=\"#messages\" class=\"disabled nav-link\">Messages</a></li></ul>"
57
58
 
58
59
  assert_equal expected, actual
59
60
  end
@@ -64,7 +65,7 @@ class NavTest < ActionView::TestCase
64
65
  n.link 'Profile', url: '#profile', selector: 'profile', label: 16
65
66
  n.link 'Messages', url: '#messages', selector: 'messages', state: :disabled
66
67
  end
67
- expected = "<div class=\"list-group\" role=\"tablist\"><a class=\"active list-group-item list-group-item-action\" data-toggle=\"tab\" role=\"tab\" aria-controls=\"Home\" href=\"#Home\">Home</a><a class=\"list-group-item list-group-item-action\" data-toggle=\"tab\" role=\"tab\" aria-controls=\"Profile\" href=\"#profile\">Profile</a><a class=\"disabled list-group-item list-group-item-action\" data-toggle=\"tab\" role=\"tab\" aria-controls=\"Messages\" href=\"#messages\">Messages</a></div>"
68
+ expected = "<div class=\"list-group\" role=\"tablist\"><a href=\"#Home\" class=\"active list-group-item list-group-item-action\" data-toggle=\"tab\" role=\"tab\" aria-controls=\"Home\">Home</a><a href=\"#profile\" class=\"list-group-item list-group-item-action\" data-toggle=\"tab\" role=\"tab\" aria-controls=\"Profile\">Profile</a><a href=\"#messages\" class=\"disabled list-group-item list-group-item-action\" data-toggle=\"tab\" role=\"tab\" aria-controls=\"Messages\">Messages</a></div>"
68
69
 
69
70
  assert_equal expected, actual
70
71
  end
@@ -32,7 +32,7 @@ class NavbarTest < ActionView::TestCase
32
32
  end
33
33
  nb.text 'test'
34
34
  end
35
- expected = "<nav class=\"navbar navbar-light navbar-expand-lg\"><div class=\"container\"><span class=\"navbar-brand\">Brand</span><button class=\"navbar-toggler hidden-sm-up\" type=\"button\" data-toggle=\"collapse\" data-target=\"##{actual.id}\">☰</button><div class=\"navbar-collapse collapse\" id=\"#{actual.id}\"><ul class=\"navbar-nav\"><li class=\"nav-item\"><a class=\"active nav-link\" href=\"#Home\">Home</a></li><li class=\"nav-item\"><a class=\"nav-link\" href=\"#profile\">Profile</a></li><li class=\"nav-item\"><a class=\"nav-link\" href=\"#messages\">Messages</a></li></ul><form type=\"form_tag\" position=\"right\" class=\"d-flex\" action=\"#\" accept-charset=\"UTF-8\" method=\"post\"><button class=\"btn-secondary btn\">Search</button></form><span class=\"navbar-text\">test</span></div></div></nav>"
35
+ expected = "<nav class=\"navbar navbar-light navbar-expand-lg\"><div class=\"container\"><span class=\"navbar-brand\">Brand</span><button class=\"navbar-toggler hidden-sm-up\" type=\"button\" data-toggle=\"collapse\" data-target=\"##{actual.id}\">☰</button><div class=\"navbar-collapse collapse\" id=\"#{actual.id}\"><ul class=\"navbar-nav\"><li class=\"nav-item\"><a href=\"#Home\" class=\"active nav-link\">Home</a></li><li class=\"nav-item\"><a href=\"#profile\" class=\"nav-link\">Profile</a></li><li class=\"nav-item\"><a href=\"#messages\" class=\"nav-link\">Messages</a></li></ul><form type=\"form_tag\" position=\"right\" class=\"d-flex\" action=\"#\" accept-charset=\"UTF-8\" method=\"post\"><button class=\"btn-secondary btn\">Search</button></form><span class=\"navbar-text\">test</span></div></div></nav>"
36
36
 
37
37
  assert_equal expected, actual.render
38
38
  end
@@ -44,7 +44,8 @@ class NavbarTest < ActionView::TestCase
44
44
  n.link 'Link', url: '#link'
45
45
  end
46
46
  end
47
- expected = "<nav class=\"bg-dark navbar navbar-dark navbar-expand-lg\"><div class=\"container\"><span class=\"navbar-brand\"><img src=\"/images/ruby-white\" /></span><button class=\"navbar-toggler hidden-sm-up\" type=\"button\" data-toggle=\"collapse\" data-target=\"##{actual.id}\">☰</button><div class=\"navbar-collapse collapse\" id=\"#{actual.id}\"><ul class=\"navbar-nav\"><li class=\"nav-item\"><a class=\"nav-link\" href=\"#link\">Link</a></li></ul></div></div></nav>"
47
+ expected =
48
+ "<nav class=\"bg-dark navbar navbar-dark navbar-expand-lg\"><div class=\"container\"><span class=\"navbar-brand\"><img src=\"/images/ruby-white\" /></span><button class=\"navbar-toggler hidden-sm-up\" type=\"button\" data-toggle=\"collapse\" data-target=\"##{actual.id}\">☰</button><div class=\"navbar-collapse collapse\" id=\"#{actual.id}\"><ul class=\"navbar-nav\"><li class=\"nav-item\"><a href=\"#link\" class=\"nav-link\">Link</a></li></ul></div></div></nav>"
48
49
 
49
50
  assert_equal expected, actual.render
50
51
  end
@@ -10,7 +10,7 @@ class TabGroupTest < ActionView::TestCase
10
10
  n.tab 'Profile', url: '#profile', selector: 'profile'
11
11
  n.tab 'Messages', url: '#messages', selector: 'messages'
12
12
  end
13
- expected = '<ul class="nav nav-tabs"><li class="nav-item"><a class="active nav-link" data-toggle="tab" role="tab" href="#Home">Home</a></li><li class="nav-item"><a class="nav-link" data-toggle="tab" role="tab" href="#profile">Profile</a></li><li class="nav-item"><a class="nav-link" data-toggle="tab" role="tab" href="#messages">Messages</a></li></ul>'
13
+ expected = "<ul class=\"nav nav-tabs\"><li class=\"nav-item\"><a href=\"#Home\" class=\"active nav-link\" data-toggle=\"tab\" role=\"tab\">Home</a></li><li class=\"nav-item\"><a href=\"#profile\" class=\"nav-link\" data-toggle=\"tab\" role=\"tab\">Profile</a></li><li class=\"nav-item\"><a href=\"#messages\" class=\"nav-link\" data-toggle=\"tab\" role=\"tab\">Messages</a></li></ul>"
14
14
 
15
15
  assert_equal expected, actual
16
16
  end
@@ -21,7 +21,7 @@ class TabGroupTest < ActionView::TestCase
21
21
  n.tab 'Profile', url: '#profile', selector: 'profile'
22
22
  n.tab 'Messages', url: '#messages', selector: 'messages'
23
23
  end
24
- expected = '<ul class="nav nav-tabs"><li class="nav-item"><a class="active nav-link" data-toggle="tab" role="tab" href="#Home">Home</a></li><li class="nav-item"><a class="nav-link" data-toggle="tab" role="tab" href="#profile">Profile</a></li><li class="nav-item"><a class="nav-link" data-toggle="tab" role="tab" href="#messages">Messages</a></li></ul>'
24
+ expected = "<ul class=\"nav nav-tabs\"><li class=\"nav-item\"><a href=\"#Home\" class=\"active nav-link\" data-toggle=\"tab\" role=\"tab\">Home</a></li><li class=\"nav-item\"><a href=\"#profile\" class=\"nav-link\" data-toggle=\"tab\" role=\"tab\">Profile</a></li><li class=\"nav-item\"><a href=\"#messages\" class=\"nav-link\" data-toggle=\"tab\" role=\"tab\">Messages</a></li></ul>"
25
25
 
26
26
  assert_equal expected, actual
27
27
  end
@@ -43,7 +43,7 @@ class TabGroupTest < ActionView::TestCase
43
43
  n.tab 'Profile', url: '#profile', selector: 'profile', label: 16
44
44
  n.tab 'Messages', url: '#messages', selector: 'messages', state: :disabled
45
45
  end
46
- expected = '<ul class="nav nav-tabs justify-content-end"><li class="nav-item"><a class="active nav-link" data-toggle="tab" role="tab" href="#Home">Home</a></li><li class="nav-item"><a class="nav-link" data-toggle="tab" role="tab" href="#profile">Profile</a></li><li class="nav-item"><a class="disabled nav-link" data-toggle="tab" role="tab" href="#messages">Messages</a></li></ul>'
46
+ expected = "<ul class=\"nav nav-tabs justify-content-end\"><li class=\"nav-item\"><a href=\"#Home\" class=\"active nav-link\" data-toggle=\"tab\" role=\"tab\">Home</a></li><li class=\"nav-item\"><a href=\"#profile\" class=\"nav-link\" data-toggle=\"tab\" role=\"tab\">Profile</a></li><li class=\"nav-item\"><a href=\"#messages\" class=\"disabled nav-link\" data-toggle=\"tab\" role=\"tab\">Messages</a></li></ul>"
47
47
 
48
48
  assert_equal expected, actual
49
49
  end
@@ -54,7 +54,7 @@ class TabGroupTest < ActionView::TestCase
54
54
  n.tab 'Profile', url: '#profile', selector: 'profile', label: 16
55
55
  n.tab 'Messages', url: '#messages', selector: 'messages', state: :disabled
56
56
  end
57
- expected = '<ul class="nav nav-tabs"><li class="nav-item"><a class="active nav-link" data-toggle="tab" role="tab" href="#Home">Home</a></li><li class="nav-item"><a class="nav-link" data-toggle="tab" role="tab" href="#profile">Profile</a></li><li class="nav-item"><a class="disabled nav-link" data-toggle="tab" role="tab" href="#messages">Messages</a></li></ul>'
57
+ expected = "<ul class=\"nav nav-tabs\"><li class=\"nav-item\"><a href=\"#Home\" class=\"active nav-link\" data-toggle=\"tab\" role=\"tab\">Home</a></li><li class=\"nav-item\"><a href=\"#profile\" class=\"nav-link\" data-toggle=\"tab\" role=\"tab\">Profile</a></li><li class=\"nav-item\"><a href=\"#messages\" class=\"disabled nav-link\" data-toggle=\"tab\" role=\"tab\">Messages</a></li></ul>"
58
58
 
59
59
  assert_equal expected, actual
60
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ui_bibz
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.alpha3
4
+ version: 3.0.0.alpha5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thooams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-16 00:00:00.000000000 Z
11
+ date: 2020-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -357,7 +357,6 @@ files:
357
357
  - lib/ui_bibz/ui/core/forms/selects/abstract_select.rb
358
358
  - lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb
359
359
  - lib/ui_bibz/ui/core/forms/selects/multi_column_field.rb
360
- - lib/ui_bibz/ui/core/forms/selects/multi_select_field.rb
361
360
  - lib/ui_bibz/ui/core/forms/selects/select_field.rb
362
361
  - lib/ui_bibz/ui/core/forms/surrounds/components/surround_addon.rb
363
362
  - lib/ui_bibz/ui/core/forms/surrounds/components/surround_button.rb
@@ -450,7 +449,6 @@ files:
450
449
  - lib/ui_bibz/utils/glyph_changer.rb
451
450
  - lib/ui_bibz/utils/internationalization.rb
452
451
  - lib/ui_bibz/utils/screwdriver.rb
453
- - package.json
454
452
  - structure.md
455
453
  - test/dummy/README.rdoc
456
454
  - test/dummy/Rakefile
@@ -541,7 +539,6 @@ files:
541
539
  - test/ui/core/forms/numbers/number_field_test.rb
542
540
  - test/ui/core/forms/numbers/range_field_test.rb
543
541
  - test/ui/core/forms/numbers/slider_field_test.rb
544
- - test/ui/core/forms/selects/dropdown_select_field_test.rb
545
542
  - test/ui/core/forms/selects/multi_column_field_test.rb
546
543
  - test/ui/core/forms/selects/multi_select_field_test.rb
547
544
  - test/ui/core/forms/selects/select_field_test.rb
@@ -752,7 +749,6 @@ test_files:
752
749
  - test/ui/core/forms/numbers/number_field_test.rb
753
750
  - test/ui/core/forms/numbers/range_field_test.rb
754
751
  - test/ui/core/forms/numbers/slider_field_test.rb
755
- - test/ui/core/forms/selects/dropdown_select_field_test.rb
756
752
  - test/ui/core/forms/selects/multi_column_field_test.rb
757
753
  - test/ui/core/forms/selects/multi_select_field_test.rb
758
754
  - test/ui/core/forms/selects/select_field_test.rb
@@ -1,122 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module UiBibz::Ui::Core::Forms::Selects
4
- # Create a MultiSelectField
5
- #
6
- # This element is an extend of UiBibz::Ui::Core::Forms::Buttons::Button
7
- # source : http://loudev.com/
8
- #
9
- # ==== Attributes
10
- #
11
- # * +content+ - Content of element
12
- # * +options+ - Options of element
13
- # * +html_options+ - Html Options of element
14
- #
15
- # ==== Options
16
- #
17
- # You can add HTML attributes using the +html_options+.
18
- # You can pass arguments in options attribute:
19
- # * +option_tags+ - Array, Object [required]
20
- # * +clickable_opt_group+ - Boolean
21
- # * +collapsible_opt_group+ - Boolean
22
- # * +searchable+ - Boolean
23
- # * +select_all_option+ - Boolean
24
- # * +append+ - String, Html
25
- # * +prepend+ - String, Html
26
- # * +connect+ - Hash
27
- # * +event+ - String
28
- # * +mode+ - String
29
- # * +target+ - Hash
30
- # * +selector+ - String
31
- # * +data+ - Array
32
- # * +url+ - String
33
- #
34
- # ==== Signatures
35
- #
36
- # UiBibz::Ui::Core::Forms::Selects::MultiSelectField.new(content, options = {}, html_options = {}).render
37
- #
38
- # UiBibz::Ui::Core::Forms::Selects::MultiSelectField.new(options = {}, html_options = {}) do
39
- # content
40
- # end.render
41
- #
42
- # ==== Examples
43
- #
44
- # UiBibz::Ui::Core::Forms::Selects::MultiSelectField.new('fruits', { option_tags: list_of_fruits, searchable: true }, { class: 'test' })
45
- #
46
- # UiBibz::Ui::Core::Forms::Selects::MultiSelectField.new({ option_tags: list_of_fruits, select_all_option: true }, { class: 'test' }) do
47
- # 'fruits'
48
- # end
49
- #
50
- # ==== Helper
51
- #
52
- # multi_select_field(content, options = {}, html_options = {})
53
- #
54
- class MultiSelectField < UiBibz::Ui::Core::Forms::Selects::AbstractSelect
55
- # See UiBibz::Ui::Core::Forms::Buttons::Button.initialize
56
-
57
- private
58
-
59
- def component_html_options
60
- super.merge({
61
- multiple: true,
62
- disabled: options[:state] == :disabled,
63
- include_blank: false,
64
- prompt: false
65
- })
66
- end
67
-
68
- def component_html_classes
69
- super << [size, type, status, button_outline, 'multi-select-field']
70
- end
71
-
72
- def component_html_data
73
- super
74
- clickable_opt_group
75
- collapsible_opt_group
76
- searchable
77
- select_all_options
78
- number_displayed
79
- end
80
-
81
- def clickable_opt_group
82
- add_html_data('enable_clickable_opt_groups') if options[:clickable_opt_group]
83
- end
84
-
85
- def collapsible_opt_group
86
- add_html_data('enable_collapsible_opt_groups') if options[:collapsible_opt_group]
87
- end
88
-
89
- def searchable
90
- add_html_data('enable_filtering') if options[:searchable]
91
- end
92
-
93
- def number_displayed
94
- add_html_data('number_displayed') if options[:number_displayed]
95
- end
96
-
97
- def select_all_options
98
- add_html_data('include_select_all_option') if options[:select_all_options]
99
- end
100
-
101
- def status
102
- options[:status].nil? ? 'btn-secondary' : "btn-#{options[:status]}"
103
- end
104
-
105
- def type
106
- 'btn-block' if options[:type] == :block
107
- end
108
-
109
- # :lg, :sm or :xs
110
- def size
111
- "btn-#{options[:size]}" if options[:size]
112
- end
113
-
114
- def button_outline
115
- ['btn', outline, @status || :secondary].compact.join('-')
116
- end
117
-
118
- def outline
119
- 'outline' if @options[:outline]
120
- end
121
- end
122
- end
@@ -1,5 +0,0 @@
1
- {
2
- "dependencies": {
3
- "ui-bibz-js": "file:/home/thomas/Apps/ui-bibz-js"
4
- }
5
- }
@@ -1,84 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class DropdownSelectFieldTest < ActionView::TestCase
6
- test 'dropdown_select_field' do
7
- options = options_for_select(Array.new(2) { |i| "option #{i}" })
8
- actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', options_tags: options).render
9
- expected = '<select name="test" id="test" data-style="btn-secondary" class="dropdown-select-field"></select>'
10
-
11
- assert_equal expected, actual
12
- end
13
-
14
- test 'dropdown_select_field searchable' do
15
- options = options_for_select(Array.new(2) { |i| "option #{i}" })
16
- actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, searchable: true }).render
17
- expected = '<select name="test" id="test" data-live-search="true" data-style="btn-secondary" class="dropdown-select-field"></select>'
18
-
19
- assert_equal expected, actual
20
- end
21
-
22
- test 'dropdown_select_field max_options' do
23
- options = options_for_select(Array.new(2) { |i| "option #{i}" })
24
- actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, max_options: 2 }).render
25
- expected = '<select name="test" id="test" data-max-options="2" data-style="btn-secondary" class="dropdown-select-field"></select>'
26
-
27
- assert_equal expected, actual
28
- end
29
-
30
- test 'dropdown_select_field selected_text_format' do
31
- options = options_for_select(Array.new(2) { |i| "option #{i}" })
32
- actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, selected_text_format: 'count > x' }).render
33
- expected = '<select name="test" id="test" data-selected-text-format="count &gt; x" data-style="btn-secondary" class="dropdown-select-field"></select>'
34
-
35
- assert_equal expected, actual
36
- end
37
-
38
- test 'dropdown_select_field menu_size' do
39
- options = options_for_select(Array.new(2) { |i| "option #{i}" })
40
- actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, menu_size: 2 }).render
41
- expected = '<select name="test" id="test" data-size="2" data-style="btn-secondary" class="dropdown-select-field"></select>'
42
-
43
- assert_equal expected, actual
44
- end
45
-
46
- test 'dropdown_select_field actions_box' do
47
- options = options_for_select(Array.new(2) { |i| "option #{i}" })
48
- actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, actions_box: true }).render
49
- expected = '<select name="test" id="test" data-style="btn-secondary" data-actions-box="true" class="dropdown-select-field"></select>'
50
-
51
- assert_equal expected, actual
52
- end
53
-
54
- test 'dropdown_select_field show_tick' do
55
- options = options_for_select(Array.new(2) { |i| "option #{i}" })
56
- actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, show_tick: true }).render
57
- expected = '<select name="test" id="test" data-style="btn-secondary" class="dropdown-select-field show-tick"></select>'
58
-
59
- assert_equal expected, actual
60
- end
61
-
62
- test 'dropdown_select_field show_menu_arrow' do
63
- options = options_for_select(Array.new(2) { |i| "option #{i}" })
64
- actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, show_menu_arrow: true }).render
65
- expected = '<select name="test" id="test" data-style="btn-secondary" class="dropdown-select-field"></select>'
66
-
67
- assert_equal expected, actual
68
- end
69
-
70
- test 'dropdown_select_field dropup' do
71
- options = options_for_select(Array.new(2) { |i| "option #{i}" })
72
- actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, dropup: true }).render
73
- expected = '<select name="test" id="test" data-style="btn-secondary" class="dropdown-select-field dropup"></select>'
74
-
75
- assert_equal expected, actual
76
- end
77
-
78
- test 'dropdown_select_field refresh' do
79
- actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { refresh: { mode: 'local', target: { data: [] } } }).render
80
- expected = '<div class="field-refresh input-group ui_surround_field"><select name="test" id="test" data-style="btn-secondary" class="dropdown-select-field"></select><span data-connect="{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;local&quot;,&quot;target&quot;:{&quot;selector&quot;:&quot;#test&quot;,&quot;url&quot;:&quot;&quot;,&quot;data&quot;:[]}}" class="btn-secondary ui-bibz-connect btn input-refresh-button"><i class="glyph fas fa-sync-alt"></i> </span></div>'
81
-
82
- assert_equal expected, actual
83
- end
84
- end