ui_bibz 2.0.0.alpha32 → 2.0.0.beta2
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 +4 -4
- data/Gemfile +2 -1
- data/Gemfile.lock +111 -87
- data/app/assets/javascripts/form.coffee +24 -8
- data/app/assets/javascripts/ui_bibz.coffee +3 -2
- data/app/assets/stylesheets/bootstrap-switch.sass +17 -8
- data/app/assets/stylesheets/fix-dropdown-select.sass +1 -1
- data/app/assets/stylesheets/table.sass +1 -1
- data/app/assets/stylesheets/ui_bibz.sass +60 -22
- data/app/inputs/ui_bibz_form/ui_bibz_form_builder.rb +35 -0
- data/app/inputs/ui_bibz_inputs/auto_complete_field_input.rb +14 -0
- data/app/inputs/{custom_inputs → ui_bibz_inputs}/base_input.rb +7 -1
- data/app/inputs/{custom_inputs → ui_bibz_inputs}/collection_input.rb +6 -3
- data/app/inputs/{custom_inputs → ui_bibz_inputs}/string_input.rb +5 -1
- data/app/inputs/ui_bibz_inputs/ui_auto_complete_field_input.rb +14 -0
- data/app/inputs/ui_bibz_inputs/ui_button_choices_input.rb +20 -0
- data/app/inputs/{custom_inputs/date_picker_field_input.rb → ui_bibz_inputs/ui_date_picker_field_input.rb} +2 -2
- data/app/inputs/{custom_inputs/dropdown_select_field_input.rb → ui_bibz_inputs/ui_dropdown_select_field_input.rb} +2 -2
- data/app/inputs/{custom_inputs/formula_field_input.rb → ui_bibz_inputs/ui_formula_field_input.rb} +2 -2
- data/app/inputs/{custom_inputs/markdown_editor_field_input.rb → ui_bibz_inputs/ui_markdown_editor_field_input.rb} +2 -2
- data/app/inputs/{custom_inputs/multi_column_field_input.rb → ui_bibz_inputs/ui_multi_column_field_input.rb} +2 -2
- data/app/inputs/ui_bibz_inputs/ui_multi_select_field_input.rb +9 -0
- data/app/inputs/{custom_inputs/radio_field_input.rb → ui_bibz_inputs/ui_radio_field_input.rb} +2 -2
- data/app/inputs/{custom_inputs/select_field_input.rb → ui_bibz_inputs/ui_select_field_input.rb} +2 -2
- data/app/inputs/{custom_inputs/switch_field_input.rb → ui_bibz_inputs/ui_switch_field_input.rb} +2 -2
- data/app/inputs/ui_bibz_inputs/ui_text_field_input.rb +13 -0
- data/config/initializers/ui_bibz.rb +7 -0
- data/lib/ui_bibz/helpers/ui/core/cards_helper.rb +42 -0
- data/lib/ui_bibz/helpers/ui/core/dropdowns_helper.rb +21 -0
- data/lib/ui_bibz/helpers/ui/core/forms_helper.rb +148 -0
- data/lib/ui_bibz/helpers/ui/core/layouts_helper.rb +27 -0
- data/lib/ui_bibz/helpers/ui/core/lists_helper.rb +11 -0
- data/lib/ui_bibz/helpers/ui/core/navs_helper.rb +27 -0
- data/lib/ui_bibz/helpers/ui/core/paths_helper.rb +16 -0
- data/lib/ui_bibz/helpers/ui/core/windows_helper.rb +11 -0
- data/lib/ui_bibz/helpers/ui/core_helper.rb +89 -0
- data/lib/ui_bibz/helpers/{ui_ux_helper.rb → ui/ux_helper.rb} +8 -18
- data/lib/ui_bibz/helpers/utils_helper.rb +22 -1
- data/lib/ui_bibz/rails/engine.rb +6 -2
- data/lib/ui_bibz/ui/base.rb +4 -0
- data/lib/ui_bibz/ui/core/{tag.rb → badge.rb} +10 -10
- data/lib/ui_bibz/ui/core/cards/card.rb +37 -13
- data/lib/ui_bibz/ui/core/cards/components/{block/card_block_link.rb → body/card_body_link.rb} +6 -6
- data/lib/ui_bibz/ui/core/cards/components/{block/card_block_text.rb → body/card_body_text.rb} +6 -6
- data/lib/ui_bibz/ui/core/cards/components/{block/card_block_title.rb → body/card_body_title.rb} +6 -6
- data/lib/ui_bibz/ui/core/cards/components/{card_block.rb → card_body.rb} +17 -13
- data/lib/ui_bibz/ui/core/cards/components/card_footer.rb +5 -1
- data/lib/ui_bibz/ui/core/cards/components/card_header.rb +5 -1
- data/lib/ui_bibz/ui/core/cards/components/card_image.rb +3 -2
- data/lib/ui_bibz/ui/core/component.rb +8 -6
- data/lib/ui_bibz/ui/core/dropdowns/dropdown.rb +21 -5
- data/lib/ui_bibz/ui/core/forms/buttons/button.rb +37 -8
- data/lib/ui_bibz/ui/core/forms/buttons/button_choice.rb +17 -29
- data/lib/ui_bibz/ui/core/forms/buttons/button_group.rb +51 -11
- data/lib/ui_bibz/ui/core/forms/buttons/button_link.rb +18 -5
- data/lib/ui_bibz/ui/core/forms/buttons/button_refresh.rb +13 -4
- data/lib/ui_bibz/ui/core/forms/buttons/button_toolbar.rb +90 -0
- data/lib/ui_bibz/ui/core/forms/buttons/components/choice.rb +116 -0
- data/lib/ui_bibz/ui/core/forms/choices/checkbox_field.rb +21 -8
- data/lib/ui_bibz/ui/core/forms/choices/radio_field.rb +22 -9
- data/lib/ui_bibz/ui/core/forms/choices/switch_field.rb +17 -5
- data/lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb +36 -16
- data/lib/ui_bibz/ui/core/forms/numbers/formula_field.rb +20 -19
- data/lib/ui_bibz/ui/core/forms/selects/abstract_select.rb +99 -0
- data/lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb +16 -16
- data/lib/ui_bibz/ui/core/forms/selects/multi_column_field.rb +8 -13
- data/lib/ui_bibz/ui/core/forms/selects/multi_select_field.rb +17 -18
- data/lib/ui_bibz/ui/core/forms/selects/select_field.rb +8 -20
- data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_addon.rb +25 -0
- data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button.rb +16 -0
- data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_group.rb +16 -0
- data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_link.rb +16 -0
- data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_refresh.rb +16 -0
- data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_checkbox_field.rb +16 -0
- data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_dropdown.rb +16 -0
- data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_radio_field.rb +16 -0
- data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_switch_field.rb +16 -0
- data/lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb +153 -0
- data/lib/ui_bibz/ui/core/forms/texts/auto_complete_field.rb +13 -38
- data/lib/ui_bibz/ui/core/forms/texts/text_field.rb +81 -0
- data/lib/ui_bibz/ui/core/glyph.rb +1 -1
- data/lib/ui_bibz/ui/core/layouts/col.rb +10 -2
- data/lib/ui_bibz/ui/core/layouts/row.rb +7 -1
- data/lib/ui_bibz/ui/core/lists/components/list/list_body.rb +4 -2
- data/lib/ui_bibz/ui/core/lists/components/list/list_header.rb +5 -2
- data/lib/ui_bibz/ui/core/lists/components/list.rb +35 -14
- data/lib/ui_bibz/ui/core/lists/list_group.rb +4 -4
- data/lib/ui_bibz/ui/core/navs/components/navbar_form.rb +7 -2
- data/lib/ui_bibz/ui/core/navs/components/navbar_nav.rb +4 -0
- data/lib/ui_bibz/ui/core/navs/components/navbar_text.rb +1 -1
- data/lib/ui_bibz/ui/core/navs/components/pagination_link.rb +60 -0
- data/lib/ui_bibz/ui/core/navs/nav.rb +31 -3
- data/lib/ui_bibz/ui/core/navs/navbar.rb +32 -22
- data/lib/ui_bibz/ui/core/navs/pagination.rb +97 -0
- data/lib/ui_bibz/ui/core/{alert.rb → notifications/alert.rb} +23 -11
- data/lib/ui_bibz/ui/core/notifications/components/alert_body.rb +50 -0
- data/lib/ui_bibz/ui/core/notifications/components/alert_header.rb +67 -0
- data/lib/ui_bibz/ui/core/{progress.rb → progresses/components/bar.rb} +21 -28
- data/lib/ui_bibz/ui/core/progresses/progress_bar.rb +115 -0
- data/lib/ui_bibz/ui/core/windows/components/modal_header.rb +1 -1
- data/lib/ui_bibz/ui/{core → extensions/core}/component/glyph_extension.rb +2 -2
- data/lib/ui_bibz/ui/{core → extensions/core}/component/klass_extension.rb +1 -2
- data/lib/ui_bibz/ui/extensions/core/forms/connect_extension.rb +31 -0
- data/lib/ui_bibz/ui/extensions/core/forms/surround_extension.rb +48 -0
- data/lib/ui_bibz/utils/internationalization.rb +9 -0
- data/lib/ui_bibz/version.rb +1 -1
- data/lib/ui_bibz.rb +23 -7
- data/test/simple_form_test.rb +58 -41
- data/test/ui/core/badge_test.rb +19 -0
- data/test/ui/core/cards/card_test.rb +34 -35
- data/test/ui/{component_test.rb → core/component_test.rb} +0 -1
- data/test/ui/core/dropdowns/dropdown_test.rb +5 -5
- data/test/ui/core/forms/buttons/button_choice_test.rb +23 -7
- data/test/ui/core/forms/buttons/button_group_test.rb +35 -17
- data/test/ui/core/forms/buttons/button_link_test.rb +74 -4
- data/test/ui/core/forms/buttons/button_refresh_test.rb +1 -2
- data/test/ui/core/forms/buttons/button_test.rb +66 -3
- data/test/ui/core/forms/choices/checkbox_field_test.rb +1 -2
- data/test/ui/core/forms/choices/radio_field_test.rb +1 -2
- data/test/ui/core/forms/choices/switch_field_test.rb +0 -1
- data/test/ui/core/forms/dates/date_picker_field_test.rb +2 -3
- data/test/ui/core/forms/numbers/formula_field_test.rb +1 -2
- data/test/ui/core/forms/selects/dropdown_select_field_test.rb +1 -2
- data/test/ui/core/forms/selects/multi_column_field_test.rb +0 -1
- data/test/ui/core/forms/selects/multi_select_field_test.rb +1 -2
- data/test/ui/core/forms/selects/select_field_test.rb +1 -2
- data/test/ui/core/forms/surrounds/surround_field_test.rb +58 -0
- data/test/ui/core/forms/textareas/markdown_editor_field_test.rb +0 -1
- data/test/ui/core/forms/texts/auto_complete_field_test.rb +21 -4
- data/test/ui/core/forms/texts/text_field_test.rb +25 -0
- data/test/ui/{glyph_test.rb → core/glyph_test.rb} +5 -5
- data/test/ui/core/jumbotron_test.rb +20 -0
- data/test/ui/core/layouts/col_test.rb +31 -0
- data/test/ui/core/layouts/container_test.rb +13 -0
- data/test/ui/core/layouts/row_test.rb +24 -0
- data/test/ui/core/lists/list_group_test.rb +5 -4
- data/test/ui/core/navs/nav_test.rb +4 -5
- data/test/ui/core/navs/navbar_test.rb +39 -0
- data/test/ui/core/notifications/alert_test.rb +22 -0
- data/test/ui/core/paths/breadcrumb_test.rb +15 -4
- data/test/ui/core/progress_test.rb +14 -0
- data/test/ui/{star_test.rb → core/star_test.rb} +6 -7
- data/test/ui/core/windows/modal_test.rb +20 -0
- data/test/ui/ux/tables/table_test.rb +2 -3
- data/ui_bibz.gemspec +2 -1
- data/vendor/assets/javascripts/bootstrap-select.min.js +8 -7
- data/vendor/assets/stylesheets/awesome-bootstrap-checkbox.scss +62 -42
- data/vendor/assets/stylesheets/bootstrap-multiselect.min.css +1 -1
- data/vendor/assets/stylesheets/bootstrap-select.min.css +3 -3
- data/vendor/assets/stylesheets/bootstrap-theme.min.css +1 -1
- metadata +105 -44
- data/app/inputs/custom_inputs/auto_complete_field_input.rb +0 -16
- data/app/inputs/custom_inputs/multi_select_field_input.rb +0 -9
- data/app/inputs/custom_inputs/surround_field_input.rb +0 -10
- data/lib/ui_bibz/helpers/ui_core_helper.rb +0 -347
- data/lib/ui_bibz/ui/core/connected_component.rb +0 -87
- data/lib/ui_bibz/ui/core/forms/texts/surround_field.rb +0 -87
- data/test/ui/core/forms/texts/surround_field_test.rb +0 -26
- data/test/ui/grid_test.rb +0 -31
- data/test/ui_helper_test.rb +0 -109
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'ui_bibz/ui/core/forms/buttons/components/choice'
|
1
2
|
module UiBibz::Ui::Core::Forms::Buttons
|
2
3
|
|
3
4
|
# Create a button choice
|
@@ -49,55 +50,42 @@ module UiBibz::Ui::Core::Forms::Buttons
|
|
49
50
|
#
|
50
51
|
# ==== Helper
|
51
52
|
#
|
52
|
-
#
|
53
|
+
# ui_button_choice(content, options = {}, html_options = {})
|
53
54
|
#
|
54
|
-
#
|
55
|
+
# ui_button_choice(options = {}, html_options = {}) do
|
55
56
|
# content
|
56
57
|
# end
|
57
58
|
#
|
58
|
-
class ButtonChoice < UiBibz::Ui::Core::Forms::Buttons::
|
59
|
+
class ButtonChoice < UiBibz::Ui::Core::Forms::Buttons::ButtonGroup
|
59
60
|
|
60
61
|
# See UiBibz::Ui::Core::Forms::Buttons::Button.initialize
|
61
62
|
def initialize content = nil, options = nil, html_options = nil, &block
|
62
63
|
super
|
63
64
|
end
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
def button content = nil, options = nil, html_options = nil, &block
|
67
|
+
if block.nil?
|
68
|
+
options = @options.merge(options || {})
|
69
|
+
else
|
70
|
+
content = @options.merge(content || {})
|
70
71
|
end
|
72
|
+
|
73
|
+
@items << Choice.new(content, options, html_options, &block).render
|
71
74
|
end
|
72
75
|
|
73
76
|
private
|
74
77
|
|
75
78
|
def component_html_classes
|
76
|
-
['
|
77
|
-
end
|
78
|
-
|
79
|
-
def input_options
|
80
|
-
{ type: type, autocomplete: :off }.merge(checked).merge(name).merge(id).merge(input_html_options)
|
81
|
-
end
|
82
|
-
|
83
|
-
def checked
|
84
|
-
@options[:state] == :active ? { checked: :checked } : {}
|
79
|
+
super << ['button-choice']
|
85
80
|
end
|
86
81
|
|
87
|
-
def
|
88
|
-
|
82
|
+
def component_html_options
|
83
|
+
{}
|
89
84
|
end
|
90
85
|
|
91
|
-
def
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
def input_html_options
|
96
|
-
@options[:input_html_options].nil? ? {} : @options[:input_html_options]
|
97
|
-
end
|
98
|
-
|
99
|
-
def type
|
100
|
-
@options[:type] || :checkbox
|
86
|
+
def component_html_data
|
87
|
+
super
|
88
|
+
add_html_data "toggle", "buttons"
|
101
89
|
end
|
102
90
|
|
103
91
|
end
|
@@ -23,23 +23,22 @@ module UiBibz::Ui::Core::Forms::Buttons
|
|
23
23
|
#
|
24
24
|
# ==== Signatures
|
25
25
|
#
|
26
|
-
# UiBibz::Ui::Core::Forms::Buttons::ButtonGroup.new(options = nil, html_options = nil) do
|
26
|
+
# UiBibz::Ui::Core::Forms::Buttons::ButtonGroup.new(options = nil, html_options = nil) do |bg|
|
27
27
|
# ...
|
28
28
|
# end
|
29
29
|
#
|
30
30
|
# ==== Examples
|
31
31
|
#
|
32
|
-
# UiBibz::Ui::Core::Forms::Buttons::ButtonGroup.new(position: :vertical, size: :xs) do
|
33
|
-
#
|
34
|
-
#
|
32
|
+
# UiBibz::Ui::Core::Forms::Buttons::ButtonGroup.new(position: :vertical, size: :xs) do |bg|
|
33
|
+
# bg.ui_button 'test'
|
34
|
+
# bg.ui_button 'test2'
|
35
35
|
# end.render
|
36
36
|
#
|
37
37
|
# ==== Helper
|
38
38
|
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
# content
|
39
|
+
# ui_button_group(options = {}, html_options = {}) do |bg|
|
40
|
+
# bg.ui_button 'content'
|
41
|
+
# bg.ui_button_link 'Link', url: '#'
|
43
42
|
# end
|
44
43
|
#
|
45
44
|
class ButtonGroup < UiBibz::Ui::Core::Component
|
@@ -47,17 +46,50 @@ module UiBibz::Ui::Core::Forms::Buttons
|
|
47
46
|
# See UiBibz::Ui::Core::Component.initialize
|
48
47
|
def initialize content = nil, options = nil, html_options = nil, &block
|
49
48
|
super
|
49
|
+
@items = []
|
50
50
|
end
|
51
51
|
|
52
52
|
# Render html tag
|
53
53
|
def render
|
54
|
-
content_tag :div,
|
54
|
+
content_tag :div, @items.join.html_safe, html_options
|
55
|
+
end
|
56
|
+
|
57
|
+
def button content = nil, options = nil, html_options = nil, &block
|
58
|
+
if block.nil?
|
59
|
+
options = @options.merge(options || {})
|
60
|
+
else
|
61
|
+
content = @options.merge(content || {})
|
62
|
+
end
|
63
|
+
|
64
|
+
@items << Button.new(content, options, html_options, &block).render
|
65
|
+
end
|
66
|
+
|
67
|
+
def button_link content = nil, options = nil, html_options = nil, &block
|
68
|
+
if block.nil?
|
69
|
+
options = @options.merge(options || {})
|
70
|
+
else
|
71
|
+
content = @options.merge(content || {})
|
72
|
+
end
|
73
|
+
|
74
|
+
@items << ButtonLink.new(content, options, html_options, &block).render
|
75
|
+
end
|
76
|
+
|
77
|
+
def dropdown content, options = {}, html_options = nil, &block
|
78
|
+
options = @options.merge(options)
|
79
|
+
|
80
|
+
@items << UiBibz::Ui::Core::Dropdowns::Dropdown.new(content, options, html_options).tap(&block).render
|
81
|
+
end
|
82
|
+
|
83
|
+
def input attribute_name, options = {}, &block
|
84
|
+
options = @options.merge(options)
|
85
|
+
|
86
|
+
@items << @options[:form].input(attribute_name, options.merge({ label: false, wrapper: false }), &block)
|
55
87
|
end
|
56
88
|
|
57
89
|
private
|
58
90
|
|
59
91
|
def component_html_classes
|
60
|
-
|
92
|
+
super << [class_name, size, position, space]
|
61
93
|
end
|
62
94
|
|
63
95
|
def component_html_options
|
@@ -70,7 +102,10 @@ module UiBibz::Ui::Core::Forms::Buttons
|
|
70
102
|
|
71
103
|
def component_html_data
|
72
104
|
super
|
73
|
-
|
105
|
+
end
|
106
|
+
|
107
|
+
def class_name
|
108
|
+
"btn-group" if options[:position] != :vertical
|
74
109
|
end
|
75
110
|
|
76
111
|
def size
|
@@ -81,5 +116,10 @@ module UiBibz::Ui::Core::Forms::Buttons
|
|
81
116
|
"btn-group-#{ options[:position] }" if options[:position]
|
82
117
|
end
|
83
118
|
|
119
|
+
# 1 to 5
|
120
|
+
def space
|
121
|
+
"mr-#{ options[:space] }" if options[:space]
|
122
|
+
end
|
123
|
+
|
84
124
|
end
|
85
125
|
end
|
@@ -45,9 +45,9 @@ module UiBibz::Ui::Core::Forms::Buttons
|
|
45
45
|
#
|
46
46
|
# ==== Helper
|
47
47
|
#
|
48
|
-
#
|
48
|
+
# ui_button_link(content, options = {}, html_options = {})
|
49
49
|
#
|
50
|
-
#
|
50
|
+
# ui_button_link(options = {}, html_options = {}) do
|
51
51
|
# content
|
52
52
|
# end
|
53
53
|
#
|
@@ -60,17 +60,30 @@ module UiBibz::Ui::Core::Forms::Buttons
|
|
60
60
|
|
61
61
|
# Render html tag
|
62
62
|
def render
|
63
|
-
|
63
|
+
button_link_html_tag
|
64
64
|
end
|
65
65
|
|
66
66
|
private
|
67
67
|
|
68
|
+
def component_html_options
|
69
|
+
opts = super
|
70
|
+
opts = opts.merge({ role: "button" })
|
71
|
+
opts
|
72
|
+
end
|
73
|
+
|
74
|
+
def button_link_html_tag
|
75
|
+
link_to link_url, html_options do
|
76
|
+
concat glyph_and_content_html
|
77
|
+
concat badge_html unless options[:badge].nil?
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
68
81
|
def link_url
|
69
82
|
options[:url] || "#"
|
70
83
|
end
|
71
84
|
|
72
|
-
def
|
73
|
-
|
85
|
+
def status
|
86
|
+
"btn-#{ options[:status] || :secondary }"
|
74
87
|
end
|
75
88
|
|
76
89
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'ui_bibz/ui/extensions/core/forms/connect_extension'
|
1
2
|
module UiBibz::Ui::Core::Forms::Buttons
|
2
3
|
|
3
4
|
# Create a Button Refrash
|
@@ -48,26 +49,30 @@ module UiBibz::Ui::Core::Forms::Buttons
|
|
48
49
|
# end.render
|
49
50
|
#
|
50
51
|
class ButtonRefresh < UiBibz::Ui::Core::Forms::Buttons::Button
|
52
|
+
include ConnectExtension
|
51
53
|
|
52
54
|
# See UiBibz::Ui::Core::Component.initialize
|
53
55
|
def initialize content = nil, options = nil, html_options = nil, &block
|
54
56
|
super
|
55
57
|
end
|
56
58
|
|
57
|
-
# Render with span not a button to avoid submit form bug
|
58
59
|
def render
|
59
|
-
|
60
|
+
button_refresh_html_tag
|
60
61
|
end
|
61
62
|
|
62
63
|
private
|
63
64
|
|
65
|
+
def button_refresh_html_tag
|
66
|
+
content_tag :span, glyph_and_content_html, html_options
|
67
|
+
end
|
68
|
+
|
64
69
|
def component_options
|
65
70
|
options[:connect] = cnt_opts
|
66
|
-
{ glyph: 'refresh', status: options[:status] }
|
71
|
+
super.merge({ glyph: 'refresh', status: options[:status] })
|
67
72
|
end
|
68
73
|
|
69
74
|
def component_html_classes
|
70
|
-
['input-refresh-button', 'btn']
|
75
|
+
super << ['input-refresh-button', 'btn']
|
71
76
|
end
|
72
77
|
|
73
78
|
def cnt_opts
|
@@ -82,5 +87,9 @@ module UiBibz::Ui::Core::Forms::Buttons
|
|
82
87
|
}
|
83
88
|
end
|
84
89
|
|
90
|
+
def status
|
91
|
+
"btn-#{ options[:status] || :secondary }"
|
92
|
+
end
|
93
|
+
|
85
94
|
end
|
86
95
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module UiBibz::Ui::Core::Forms::Buttons
|
2
|
+
|
3
|
+
# Create a button toolbar
|
4
|
+
#
|
5
|
+
# This element is an extend of UiBibz::Ui::Core::Component.
|
6
|
+
#
|
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
|
+
# * +status+ - status of element with +symbol+ value:
|
18
|
+
# (+:primary+, +:secondary+, +:info+, +:warning+, +:danger+)
|
19
|
+
# * +size+ - Size of element with +symbol+ value:
|
20
|
+
# (+:xs+, +:sm+, +:lg+)
|
21
|
+
# * +position+ - Position vertical or horizontal with +symbol+ value:
|
22
|
+
# (+:vertical+, +:horizontal+)
|
23
|
+
#
|
24
|
+
# ==== Signatures
|
25
|
+
#
|
26
|
+
# UiBibz::Ui::Core::Forms::Buttons::ButtonToolbar.new(options = nil, html_options = nil) do |bt|
|
27
|
+
# ...
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# ==== Examples
|
31
|
+
#
|
32
|
+
# UiBibz::Ui::Core::Forms::Buttons::ButtonToolbar.new(status: :primary, size: :xs) do |bt|
|
33
|
+
# bt.button_group do |bg|
|
34
|
+
# bg.ui_button 'test 1'
|
35
|
+
# bg.ui_button 'test 2'
|
36
|
+
# end
|
37
|
+
# bt.button_group do |bg|
|
38
|
+
# bg.ui_button 'test 3'
|
39
|
+
# bg.ui_button 'test 4'
|
40
|
+
# end
|
41
|
+
# end.render
|
42
|
+
#
|
43
|
+
# ==== Helper
|
44
|
+
#
|
45
|
+
# ui_button_toolbar(options = {}, html_options = {}) do |bt|
|
46
|
+
# bt.button_group do |bg|
|
47
|
+
# bg.ui_button 'content'
|
48
|
+
# bg.ui_button_link 'Link', url: '#'
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
class ButtonToolbar < UiBibz::Ui::Core::Component
|
53
|
+
|
54
|
+
# See UiBibz::Ui::Core::Component.initialize
|
55
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
56
|
+
super
|
57
|
+
@items = []
|
58
|
+
end
|
59
|
+
|
60
|
+
# Render html tag
|
61
|
+
def render
|
62
|
+
content_tag :div, @items.join.html_safe, html_options
|
63
|
+
end
|
64
|
+
|
65
|
+
def button_group content = nil, options = nil, html_options = nil, &block
|
66
|
+
if block.nil?
|
67
|
+
options = @options.merge(options || {})
|
68
|
+
else
|
69
|
+
content = @options.merge(content || {})
|
70
|
+
end
|
71
|
+
|
72
|
+
@items << ButtonGroup.new(content, options, html_options).tap(&block).render
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def component_html_classes
|
78
|
+
super << ["btn-toolbar", justify]
|
79
|
+
end
|
80
|
+
|
81
|
+
def component_html_options
|
82
|
+
{ role: 'toolbar' }
|
83
|
+
end
|
84
|
+
|
85
|
+
def justify
|
86
|
+
"justify-content-between" if options[:justify]
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module UiBibz::Ui::Core::Forms::Buttons
|
2
|
+
|
3
|
+
# Create a button choice
|
4
|
+
#
|
5
|
+
# This element is an extend of UiBibz::Ui::Core::Forms::Buttons::Button
|
6
|
+
#
|
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
|
+
# * +type+ - Symbol (+:checkbox+, +:radio+)
|
18
|
+
# * +status+ - status of élement with symbol value:
|
19
|
+
# (+:primary+, +:secondary+, +:info+, +:warning+, +:danger+)
|
20
|
+
# * +size+
|
21
|
+
# (+:xs+, +:sm+, +:lg+)
|
22
|
+
# * +url+ - String url
|
23
|
+
# * +outline+ - Boolean
|
24
|
+
# * +state+ - Symbol (+:active+, +:disabled)
|
25
|
+
# * +type+ - Symbol (+:block)
|
26
|
+
# * +name+ - String name of input checkbox
|
27
|
+
# * +id+ - String id of input checkbox
|
28
|
+
# * +input_html_options+ - Hash of input html options
|
29
|
+
# * +glyph+ - Add glyph with name or hash options
|
30
|
+
# * +name+ - String
|
31
|
+
# * +size+ - Integer
|
32
|
+
# * +type+ - Symbol
|
33
|
+
#
|
34
|
+
# ==== Signatures
|
35
|
+
#
|
36
|
+
# UiBibz::Ui::Core::Forms::Buttons::Choice.new(content, options = nil, html_options = nil)
|
37
|
+
#
|
38
|
+
# UiBibz::Ui::Core::Forms::Buttons::Choice.new(options = nil, html_options = nil) do
|
39
|
+
# content
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# ==== Examples
|
43
|
+
#
|
44
|
+
# UiBibz::Ui::Core::Forms::Buttons::Choice.new('test', state: :active)
|
45
|
+
#
|
46
|
+
# UiBibz::Ui::Core::Forms::Buttons::Choice.new({id: 'state', input_html_options: { class: 'state'}}, { class: 'lable-class'}) do
|
47
|
+
# test
|
48
|
+
# end.render
|
49
|
+
#
|
50
|
+
# ==== Helper
|
51
|
+
#
|
52
|
+
# choice(content, options = {}, html_options = {})
|
53
|
+
#
|
54
|
+
# choice(options = {}, html_options = {}) do
|
55
|
+
# content
|
56
|
+
# end
|
57
|
+
#
|
58
|
+
class Choice < UiBibz::Ui::Core::Forms::Buttons::Button
|
59
|
+
|
60
|
+
# See UiBibz::Ui::Core::Forms::Buttons::Button.initialize
|
61
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
62
|
+
super
|
63
|
+
end
|
64
|
+
|
65
|
+
# Render html tag
|
66
|
+
def render
|
67
|
+
button_choice_html_tag
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def button_choice_html_tag
|
73
|
+
content_tag :label, html_options do
|
74
|
+
concat tag(:input, input_options)
|
75
|
+
concat glyph_and_content_html
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def component_html_classes
|
80
|
+
['btn', size]
|
81
|
+
end
|
82
|
+
|
83
|
+
def input_options
|
84
|
+
{ type: type, autocomplete: :off }.merge(checked).merge(value).merge(name).merge(id).merge(input_html_options)
|
85
|
+
end
|
86
|
+
|
87
|
+
def checked
|
88
|
+
@options[:state] == :active ? { checked: :checked } : {}
|
89
|
+
end
|
90
|
+
|
91
|
+
def value
|
92
|
+
@options[:value].nil? ? {} : { value: options[:value] }
|
93
|
+
end
|
94
|
+
|
95
|
+
def name
|
96
|
+
@options[:name].nil? ? {} : { name: @options[:name] }
|
97
|
+
end
|
98
|
+
|
99
|
+
def id
|
100
|
+
@options[:id].nil? ? {} : { id: @options[:id] }
|
101
|
+
end
|
102
|
+
|
103
|
+
def input_html_options
|
104
|
+
@options[:input_html_options].nil? ? {} : @options[:input_html_options]
|
105
|
+
end
|
106
|
+
|
107
|
+
def type
|
108
|
+
@options[:type] || :checkbox
|
109
|
+
end
|
110
|
+
|
111
|
+
def status
|
112
|
+
"btn-#{ @options[:status] || :secondary }"
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
@@ -52,26 +52,39 @@ module UiBibz::Ui::Core::Forms::Choices
|
|
52
52
|
|
53
53
|
# Render html tag
|
54
54
|
def render
|
55
|
+
checkbox_field_html_tag
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def checkbox_field_html_tag
|
55
61
|
content_tag :div, html_options.except(:id) do
|
56
62
|
concat check_box_tag content, options[:value], options[:checked] || false, checkbox_html_options
|
57
|
-
concat label_tag label_name, label_content
|
63
|
+
concat label_tag label_name, label_content, label_html_options
|
58
64
|
end
|
59
65
|
end
|
60
66
|
|
61
|
-
private
|
62
|
-
|
63
67
|
def checkbox_html_options
|
64
|
-
|
65
|
-
opts = opts.merge({ disabled: true}) if options[:state] == :disabled
|
66
|
-
opts
|
68
|
+
{ class: 'styled', disabled: options[:state] == :disabled }
|
67
69
|
end
|
68
70
|
|
69
71
|
def label_name
|
70
72
|
html_options[:id] || content
|
71
73
|
end
|
72
74
|
|
75
|
+
def label_html_options
|
76
|
+
options[:label] == false ? { class: 'fix-label' } : nil
|
77
|
+
end
|
78
|
+
|
73
79
|
def label_content
|
74
|
-
options[:label]
|
80
|
+
case options[:label]
|
81
|
+
when nil
|
82
|
+
content
|
83
|
+
when false
|
84
|
+
" "
|
85
|
+
else
|
86
|
+
options[:label]
|
87
|
+
end
|
75
88
|
end
|
76
89
|
|
77
90
|
def status
|
@@ -91,7 +104,7 @@ module UiBibz::Ui::Core::Forms::Choices
|
|
91
104
|
end
|
92
105
|
|
93
106
|
def component_html_classes
|
94
|
-
["checkbox", "abc-checkbox", type, indeterminate, inline]
|
107
|
+
super << ["checkbox", "abc-checkbox", type, indeterminate, inline]
|
95
108
|
end
|
96
109
|
|
97
110
|
end
|
@@ -37,9 +37,9 @@ module UiBibz::Ui::Core::Forms::Choices
|
|
37
37
|
#
|
38
38
|
# ==== Helper
|
39
39
|
#
|
40
|
-
#
|
40
|
+
# ui_radio_field(content, options = {}, html_options = {})
|
41
41
|
#
|
42
|
-
#
|
42
|
+
# ui_radio_field(options = {}, html_options = {}) do
|
43
43
|
# content
|
44
44
|
# end
|
45
45
|
#
|
@@ -52,18 +52,24 @@ module UiBibz::Ui::Core::Forms::Choices
|
|
52
52
|
|
53
53
|
# Render html tag
|
54
54
|
def render
|
55
|
+
radio_field_html_tag
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def radio_field_html_tag
|
55
61
|
content_tag :div, html_options.except(:id) do
|
56
62
|
concat radio_button_tag content, options[:value], options[:checked] || false, checkbox_html_options
|
57
|
-
concat label_tag label_name, label_content
|
63
|
+
concat label_tag label_name, label_content, label_html_options
|
58
64
|
end
|
59
65
|
end
|
60
66
|
|
61
|
-
private
|
62
|
-
|
63
67
|
def checkbox_html_options
|
64
|
-
|
65
|
-
|
66
|
-
|
68
|
+
{ disabled: options[:state] == :disabled }
|
69
|
+
end
|
70
|
+
|
71
|
+
def label_html_options
|
72
|
+
options[:label] == false ? { class: 'fix-label' } : nil
|
67
73
|
end
|
68
74
|
|
69
75
|
def label_name
|
@@ -71,7 +77,14 @@ module UiBibz::Ui::Core::Forms::Choices
|
|
71
77
|
end
|
72
78
|
|
73
79
|
def label_content
|
74
|
-
options[:label]
|
80
|
+
case options[:label]
|
81
|
+
when nil
|
82
|
+
content
|
83
|
+
when false
|
84
|
+
" "
|
85
|
+
else
|
86
|
+
options[:label]
|
87
|
+
end
|
75
88
|
end
|
76
89
|
|
77
90
|
def status
|
@@ -51,20 +51,28 @@ module UiBibz::Ui::Core::Forms::Choices
|
|
51
51
|
|
52
52
|
# Render html tag
|
53
53
|
def render
|
54
|
-
|
54
|
+
switch_field_html_tag
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def switch_field_html_tag
|
60
|
+
content_tag :div, class: component_wrapper_html_classes do
|
55
61
|
concat hidden_field_tag content, '0'
|
56
62
|
concat check_box_tag content, '1', html_options[:checked], html_options
|
57
63
|
end
|
58
64
|
end
|
59
65
|
|
60
|
-
private
|
61
|
-
|
62
66
|
def value
|
63
67
|
options[:value]
|
64
68
|
end
|
65
69
|
|
70
|
+
def component_wrapper_html_classes
|
71
|
+
join_classes('switch-field-container', inline)
|
72
|
+
end
|
73
|
+
|
66
74
|
def component_html_classes
|
67
|
-
"switch-field"
|
75
|
+
super << "switch-field"
|
68
76
|
end
|
69
77
|
|
70
78
|
def component_html_data
|
@@ -85,7 +93,7 @@ module UiBibz::Ui::Core::Forms::Choices
|
|
85
93
|
end
|
86
94
|
|
87
95
|
def matching_size
|
88
|
-
{
|
96
|
+
{ sm: 'small', md: 'normal', lg: 'large' }
|
89
97
|
end
|
90
98
|
|
91
99
|
# true, false => default : true
|
@@ -123,5 +131,9 @@ module UiBibz::Ui::Core::Forms::Choices
|
|
123
131
|
add_html_data('label_text', options[:middle_text]) unless options[:middle_text].nil?
|
124
132
|
end
|
125
133
|
|
134
|
+
def inline
|
135
|
+
"btn-group" unless options[:inline].nil?
|
136
|
+
end
|
137
|
+
|
126
138
|
end
|
127
139
|
end
|