ui_bibz 1.2.5.3 → 2.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +10 -7
- data/README.md +8 -1042
- data/app/assets/javascripts/multi_column.coffee +45 -0
- data/app/assets/javascripts/{ui_bibz.js.coffee → ui_bibz.coffee} +16 -3
- data/app/assets/stylesheets/fix-bootstrap-4.sass +2 -0
- data/app/assets/stylesheets/ui_bibz.sass +22 -9
- data/app/inputs/custom_inputs/date_picker_input.rb +10 -0
- data/app/inputs/custom_inputs/date_picker_input_old.rb +61 -0
- data/app/inputs/custom_inputs/multi_column_input.rb +18 -0
- data/app/inputs/custom_inputs/multi_select_input.rb +15 -0
- data/app/inputs/custom_inputs/surround_input.rb +10 -0
- data/doc/UiBibz.html +2 -2
- data/doc/UiBibz/Concerns.html +1 -1
- data/doc/UiBibz/Concerns/Models.html +1 -1
- data/doc/UiBibz/Concerns/Models/Searchable.html +1 -1
- data/doc/UiBibz/Concerns/Models/Searchable/ClassMethods.html +5 -5
- data/doc/UiBibz/Helpers.html +1 -1
- data/doc/UiBibz/Helpers/MetaHelper.html +1 -1
- data/doc/UiBibz/Helpers/UiCoreHelper.html +1 -1
- data/doc/UiBibz/Helpers/UiUxHelper.html +1 -1
- data/doc/UiBibz/Helpers/UtilsHelper.html +1 -1
- data/doc/UiBibz/Rails.html +1 -1
- data/doc/UiBibz/Rails/Engine.html +1 -1
- data/doc/UiBibz/Ui.html +1 -1
- data/doc/UiBibz/Ui/Base.html +1 -1
- data/doc/UiBibz/Ui/Core.html +1 -1
- data/doc/UiBibz/Ui/Core/Alert.html +1 -1
- data/doc/UiBibz/Ui/Core/Bar.html +1 -1
- data/doc/UiBibz/Ui/Core/Breadcrumb.html +1 -1
- data/doc/UiBibz/Ui/Core/BreadcrumbLink.html +1 -1
- data/doc/UiBibz/Ui/Core/Button.html +1 -1
- data/doc/UiBibz/Ui/Core/ButtonDropdown.html +1 -1
- data/doc/UiBibz/Ui/Core/ButtonGroup.html +1 -1
- data/doc/UiBibz/Ui/Core/ButtonLink.html +1 -1
- data/doc/UiBibz/Ui/Core/ButtonSplitDropdown.html +1 -1
- data/doc/UiBibz/Ui/Core/Col.html +1 -1
- data/doc/UiBibz/Ui/Core/Component.html +1 -1
- data/doc/UiBibz/Ui/Core/Dropdown.html +1 -1
- data/doc/UiBibz/Ui/Core/DropdownDivider.html +1 -1
- data/doc/UiBibz/Ui/Core/DropdownHeader.html +1 -1
- data/doc/UiBibz/Ui/Core/DropdownLink.html +1 -1
- data/doc/UiBibz/Ui/Core/Glyph.html +1 -1
- data/doc/UiBibz/Ui/Core/Jumbotron.html +1 -1
- data/doc/UiBibz/Ui/Core/Label.html +1 -1
- data/doc/UiBibz/Ui/Core/List.html +1 -1
- data/doc/UiBibz/Ui/Core/ListGroup.html +1 -1
- data/doc/UiBibz/Ui/Core/Modal.html +1 -1
- data/doc/UiBibz/Ui/Core/ModalBody.html +1 -1
- data/doc/UiBibz/Ui/Core/ModalFooter.html +1 -1
- data/doc/UiBibz/Ui/Core/ModalHeader.html +1 -1
- data/doc/UiBibz/Ui/Core/Nav.html +1 -1
- data/doc/UiBibz/Ui/Core/NavDropdown.html +1 -1
- data/doc/UiBibz/Ui/Core/NavLink.html +1 -1
- data/doc/UiBibz/Ui/Core/Navbar.html +1 -1
- data/doc/UiBibz/Ui/Core/NavbarForm.html +1 -1
- data/doc/UiBibz/Ui/Core/NavbarNav.html +1 -1
- data/doc/UiBibz/Ui/Core/NavbarText.html +1 -1
- data/doc/UiBibz/Ui/Core/Panel.html +1 -1
- data/doc/UiBibz/Ui/Core/ProgressBar.html +1 -1
- data/doc/UiBibz/Ui/Core/Row.html +1 -1
- data/doc/UiBibz/Ui/Core/Stars.html +1 -1
- data/doc/UiBibz/Ui/Ux.html +1 -1
- data/doc/UiBibz/Ui/Ux/Actionable.html +1 -1
- data/doc/UiBibz/Ui/Ux/Actions.html +1 -1
- data/doc/UiBibz/Ui/Ux/Column.html +1 -1
- data/doc/UiBibz/Ui/Ux/Columns.html +1 -1
- data/doc/UiBibz/Ui/Ux/Grid.html +1 -1
- data/doc/UiBibz/Ui/Ux/Paginable.html +1 -1
- data/doc/UiBibz/Ui/Ux/Searchable.html +1 -1
- data/doc/UiBibz/Ui/Ux/Sortable.html +1 -1
- data/doc/UiBibz/Ui/Ux/Store.html +18 -70
- data/doc/UiBibz/Ui/Ux/Table.html +1 -1
- data/doc/UiBibz/Ui/Ux/TablePagination.html +1 -1
- data/doc/UiBibz/Ui/Ux/TablePaginationPerPage.html +1 -1
- data/doc/UiBibz/Ui/Ux/TablePanel.html +1 -1
- data/doc/UiBibz/Ui/Ux/TableSearchField.html +1 -1
- data/doc/UiBibz/Utils.html +1 -1
- data/doc/UiBibz/Utils/Internationalization.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +47 -51
- data/doc/index.html +47 -51
- data/doc/method_list.html +69 -75
- data/doc/top-level-namespace.html +1 -1
- data/lib/ui_bibz.rb +14 -7
- data/lib/ui_bibz/helpers/ui_core_helper.rb +46 -11
- data/lib/ui_bibz/helpers/ui_ux_helper.rb +7 -3
- data/lib/ui_bibz/rails/engine.rb +2 -2
- data/lib/ui_bibz/ui/base.rb +5 -0
- data/lib/ui_bibz/ui/core/alert.rb +15 -6
- data/lib/ui_bibz/ui/core/breadcrumb/breadcrumb.rb +37 -2
- data/lib/ui_bibz/ui/core/breadcrumb/components/breadcrumb_link.rb +3 -3
- data/lib/ui_bibz/ui/core/button/button.rb +39 -6
- data/lib/ui_bibz/ui/core/button/button_choice.rb +104 -0
- data/lib/ui_bibz/ui/core/button/button_dropdown.rb +15 -2
- data/lib/ui_bibz/ui/core/button/button_group.rb +17 -5
- data/lib/ui_bibz/ui/core/button/button_link.rb +8 -11
- data/lib/ui_bibz/ui/core/button/button_split_dropdown.rb +15 -5
- data/lib/ui_bibz/ui/core/card/card.rb +158 -0
- data/lib/ui_bibz/ui/core/card/card_column.rb +60 -0
- data/lib/ui_bibz/ui/core/card/card_deck.rb +62 -0
- data/lib/ui_bibz/ui/core/card/card_group.rb +60 -0
- data/lib/ui_bibz/ui/core/card/components/block/card_block_link.rb +51 -0
- data/lib/ui_bibz/ui/core/card/components/block/card_block_text.rb +51 -0
- data/lib/ui_bibz/ui/core/card/components/block/card_block_title.rb +51 -0
- data/lib/ui_bibz/ui/core/card/components/card_block.rb +67 -0
- data/lib/ui_bibz/ui/core/card/components/card_footer.rb +55 -0
- data/lib/ui_bibz/ui/core/card/components/card_header.rb +51 -0
- data/lib/ui_bibz/ui/core/card/components/card_image.rb +57 -0
- data/lib/ui_bibz/ui/core/card/components/card_list_group.rb +47 -0
- data/lib/ui_bibz/ui/core/component.rb +78 -32
- data/lib/ui_bibz/ui/core/dropdown/components/dropdown_divider.rb +1 -1
- data/lib/ui_bibz/ui/core/dropdown/components/dropdown_header.rb +11 -1
- data/lib/ui_bibz/ui/core/dropdown/components/dropdown_link.rb +11 -4
- data/lib/ui_bibz/ui/core/dropdown/dropdown.rb +14 -6
- data/lib/ui_bibz/ui/core/glyph.rb +22 -4
- data/lib/ui_bibz/ui/core/input/date_picker_field.rb +125 -0
- data/lib/ui_bibz/ui/core/input/multi_column_field.rb +77 -0
- data/lib/ui_bibz/ui/core/input/multi_select_field.rb +89 -0
- data/lib/ui_bibz/ui/core/input/surround_field.rb +74 -0
- data/lib/ui_bibz/ui/core/jumbotron.rb +10 -6
- data/lib/ui_bibz/ui/core/label.rb +13 -3
- data/lib/ui_bibz/ui/core/{col.rb → layout/col.rb} +38 -18
- data/lib/ui_bibz/ui/core/layout/container.rb +65 -0
- data/lib/ui_bibz/ui/core/{row.rb → layout/row.rb} +7 -1
- data/lib/ui_bibz/ui/core/list/components/list.rb +26 -11
- data/lib/ui_bibz/ui/core/list/components/list_body.rb +36 -0
- data/lib/ui_bibz/ui/core/list/components/list_header.rb +36 -0
- data/lib/ui_bibz/ui/core/list/list_group.rb +7 -3
- data/lib/ui_bibz/ui/core/modal/components/modal_body.rb +7 -1
- data/lib/ui_bibz/ui/core/modal/components/modal_footer.rb +7 -1
- data/lib/ui_bibz/ui/core/modal/components/modal_header.rb +5 -2
- data/lib/ui_bibz/ui/core/modal/modal.rb +13 -2
- data/lib/ui_bibz/ui/core/nav/components/nav_dropdown.rb +6 -2
- data/lib/ui_bibz/ui/core/nav/components/nav_link.rb +7 -18
- data/lib/ui_bibz/ui/core/nav/components/nav_link_link.rb +45 -0
- data/lib/ui_bibz/ui/core/nav/components/nav_link_list.rb +35 -0
- data/lib/ui_bibz/ui/core/nav/components/navbar_brand.rb +40 -0
- data/lib/ui_bibz/ui/core/nav/components/navbar_form.rb +2 -2
- data/lib/ui_bibz/ui/core/nav/components/navbar_nav.rb +1 -1
- data/lib/ui_bibz/ui/core/nav/components/navbar_text.rb +6 -2
- data/lib/ui_bibz/ui/core/nav/nav.rb +22 -4
- data/lib/ui_bibz/ui/core/nav/navbar.rb +26 -17
- data/lib/ui_bibz/ui/core/progress.rb +98 -0
- data/lib/ui_bibz/ui/core/stars.rb +13 -5
- data/lib/ui_bibz/ui/ux/table/components/actions.rb +4 -0
- data/lib/ui_bibz/ui/ux/table/components/store.rb +4 -4
- data/lib/ui_bibz/ui/ux/table/extensions/actionable.rb +15 -13
- data/lib/ui_bibz/ui/ux/table/extensions/paginable.rb +7 -6
- data/lib/ui_bibz/ui/ux/table/extensions/searchable.rb +6 -5
- data/lib/ui_bibz/ui/ux/table/table.rb +14 -7
- data/lib/ui_bibz/ui/ux/table/{table_panel.rb → table_card.rb} +34 -36
- data/lib/ui_bibz/ui/ux/table/table_search_field.rb +19 -11
- data/lib/ui_bibz/version.rb +1 -1
- data/test/ui/breadcrumb_test.rb +25 -0
- data/test/ui/button_test.rb +44 -4
- data/test/ui/card_test.rb +106 -0
- data/test/ui/col_test.rb +22 -0
- data/test/ui/dropdown_test.rb +1 -1
- data/test/ui/inputs_test.rb +81 -0
- data/test/ui/list_group_test.rb +1 -1
- data/test/ui/nav_test.rb +4 -5
- data/test/ui/table_test.rb +11 -11
- data/test/ui_helper_test.rb +29 -18
- data/ui_bibz.gemspec +3 -3
- data/vendor/assets/images/switch.png +0 -0
- data/vendor/assets/javascripts/bootstrap-4.0.0-alpha.min.js +7 -0
- data/vendor/assets/javascripts/bootstrap-multiselect.min.js +1180 -0
- data/vendor/assets/javascripts/jquery.multi-select.min.js +1 -0
- data/vendor/assets/javascripts/jquery.quicksearch.min.js +1 -0
- data/vendor/assets/stylesheets/bootstrap-4.0.0-alpha.min.css +6 -0
- data/vendor/assets/stylesheets/bootstrap-datepicker3.min.css +1 -1
- data/vendor/assets/stylesheets/bootstrap-multiselect.min.css +1 -0
- data/vendor/assets/stylesheets/multi-select.min.css +1 -0
- metadata +70 -24
- data/.yardoc/checksums +0 -59
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/lib/ui_bibz/helpers/meta_helper.rb +0 -32
- data/lib/ui_bibz/ui/core/panel.rb +0 -138
- data/lib/ui_bibz/ui/core/progress_bar/components/bar.rb +0 -105
- data/lib/ui_bibz/ui/core/progress_bar/progress_bar.rb +0 -94
- data/lib/ui_bibz/ui/ux/grid.rb +0 -121
- data/test/ui/grid_test.rb +0 -46
- data/test/ui/panel_test.rb +0 -52
@@ -0,0 +1,47 @@
|
|
1
|
+
module UiBibz::Ui::Core
|
2
|
+
|
3
|
+
# Create a card list_group
|
4
|
+
#
|
5
|
+
# ==== Attributes
|
6
|
+
#
|
7
|
+
# * +content+ - Content of element
|
8
|
+
# * +options+ - Options of element
|
9
|
+
# * +html_options+ - Html Options of element
|
10
|
+
#
|
11
|
+
# ==== Options
|
12
|
+
#
|
13
|
+
# You can add HTML attributes using the +html_options+.
|
14
|
+
# You can pass arguments in options attribute:
|
15
|
+
#
|
16
|
+
# ==== Signatures
|
17
|
+
#
|
18
|
+
# UiBibz::Ui::Core::CardListGroup.new(content, options = nil, html_options = nil)
|
19
|
+
#
|
20
|
+
# UiBibz::Ui::Core::CardListGroup.new(options = nil, html_options = nil) do
|
21
|
+
# content
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# ==== Examples
|
25
|
+
#
|
26
|
+
# UiBibz::Ui::Core::CardListGroup.new.render
|
27
|
+
#
|
28
|
+
# UiBibz::Ui::Core::CardListGroup.new do
|
29
|
+
# 'Exemple'
|
30
|
+
# end.render
|
31
|
+
#
|
32
|
+
class CardListGroup < UiBibz::Ui::Core::ListGroup
|
33
|
+
|
34
|
+
# See UiBibz::Ui::Core::Component.initialize
|
35
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
36
|
+
super
|
37
|
+
@lists = []
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
def component_html_classes
|
43
|
+
["list-group-flush", "list-group"]
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -30,7 +30,7 @@ module UiBibz::Ui::Core
|
|
30
30
|
#
|
31
31
|
# ==== Examples
|
32
32
|
#
|
33
|
-
# UiBibz::Ui::Core::Component.new(content, { type: :success, glyph: 'eye' },{ class: 'test' })
|
33
|
+
# UiBibz::Ui::Core::Component.new(content, { type: :success, glyph: 'eye' }, { class: 'test' })
|
34
34
|
# # or
|
35
35
|
# UiBibz::Ui::Core::Component.new({glyph: { name: 'eye', size: 3}, { class: 'test' }) do
|
36
36
|
# content
|
@@ -59,6 +59,8 @@ module UiBibz::Ui::Core
|
|
59
59
|
end
|
60
60
|
@html_options = @html_options || {}
|
61
61
|
@options = @options || {}
|
62
|
+
init_options
|
63
|
+
init_component_html_options
|
62
64
|
end
|
63
65
|
|
64
66
|
# Render html tag
|
@@ -68,7 +70,7 @@ module UiBibz::Ui::Core
|
|
68
70
|
|
69
71
|
# Render glyph and content html
|
70
72
|
def glyph_and_content_html
|
71
|
-
[glyph_with_space,
|
73
|
+
[glyph_with_space, content].compact.join.html_safe
|
72
74
|
end
|
73
75
|
|
74
76
|
# Render glyph with space html
|
@@ -82,53 +84,97 @@ module UiBibz::Ui::Core
|
|
82
84
|
Glyph.new(glyph_info).render unless glyph_info.nil?
|
83
85
|
end
|
84
86
|
|
85
|
-
|
86
|
-
|
87
|
-
content_tag :span, @options[:badge], class: 'badge'
|
87
|
+
def label_html
|
88
|
+
UiBibz::Ui::Core::Label.new(options[:label], class: 'pull-right', type: :pill, state: (options[:label_state] || :default)).render
|
88
89
|
end
|
89
90
|
|
90
|
-
#
|
91
|
+
# Know if component is tapped or not
|
92
|
+
def is_tap content, options
|
93
|
+
(content[:tap] if content.kind_of?(Hash)) || (options[:tap] unless options.nil?)
|
94
|
+
end
|
95
|
+
|
96
|
+
protected
|
97
|
+
|
98
|
+
# Override this method to add html classes
|
99
|
+
# Accept Array or String
|
100
|
+
def component_html_classes
|
101
|
+
end
|
102
|
+
|
103
|
+
# Override this method to add html data
|
104
|
+
def component_html_data
|
105
|
+
end
|
106
|
+
|
107
|
+
# Override this method to add html Options
|
108
|
+
# Accept Hash
|
109
|
+
def component_html_options
|
110
|
+
{}
|
111
|
+
end
|
112
|
+
|
113
|
+
# Override this method to add Options to the component
|
114
|
+
# Accept Hash
|
115
|
+
def component_options
|
116
|
+
{}
|
117
|
+
end
|
118
|
+
|
119
|
+
# Override this method to add a state class
|
91
120
|
def state
|
92
|
-
sym = options.delete(:state) if options[:state]
|
93
|
-
sym = sym || :default
|
94
|
-
states[:sym]
|
95
121
|
end
|
96
122
|
|
97
|
-
#
|
98
|
-
def
|
99
|
-
|
123
|
+
# Join classes
|
124
|
+
def join_classes *classes
|
125
|
+
klasses = [*classes].flatten.compact.uniq.reject(&:blank?)
|
126
|
+
klasses.empty? ? nil : klasses
|
127
|
+
end
|
128
|
+
|
129
|
+
# Add html data arguments
|
130
|
+
def add_html_data name, value = true
|
131
|
+
html_options[:data] = {} if html_options[:data].nil?
|
132
|
+
html_options[:data].update(Hash[name, value])
|
133
|
+
end
|
134
|
+
|
135
|
+
private
|
136
|
+
|
137
|
+
def initialize_component_html_classes
|
100
138
|
cls = [
|
101
139
|
html_options[:class],
|
102
140
|
status,
|
103
141
|
state,
|
104
|
-
|
142
|
+
effect,
|
143
|
+
options_classes,
|
144
|
+
component_html_classes
|
105
145
|
]
|
106
|
-
|
107
|
-
cls = cls.flatten.compact
|
108
|
-
html_options[:class] = cls.join(' ') unless cls.empty?
|
109
|
-
html_options
|
146
|
+
html_options[:class] = join_classes(cls)
|
110
147
|
end
|
111
148
|
|
112
|
-
|
113
|
-
|
114
|
-
classes.compact.join(' ')
|
149
|
+
def init_options
|
150
|
+
@options = component_options.merge(@options)
|
115
151
|
end
|
116
152
|
|
117
|
-
|
153
|
+
# Set effect class
|
154
|
+
def effect
|
155
|
+
options[:effect]
|
156
|
+
end
|
118
157
|
|
119
|
-
def
|
120
|
-
options[:
|
158
|
+
def options_classes
|
159
|
+
options[:class] if options.kind_of?(Hash)
|
121
160
|
end
|
122
161
|
|
123
|
-
def
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
162
|
+
def initialize_component_html_data
|
163
|
+
component_html_data
|
164
|
+
end
|
165
|
+
|
166
|
+
def initialize_component_html_options
|
167
|
+
html_options.merge!(component_html_options)
|
168
|
+
end
|
169
|
+
|
170
|
+
def init_component_html_options
|
171
|
+
initialize_component_html_data
|
172
|
+
initialize_component_html_classes
|
173
|
+
initialize_component_html_options
|
174
|
+
end
|
175
|
+
|
176
|
+
def status
|
177
|
+
options[:status] unless options[:status].nil?
|
132
178
|
end
|
133
179
|
|
134
180
|
end
|
@@ -40,7 +40,17 @@ module UiBibz::Ui::Core
|
|
40
40
|
|
41
41
|
# Render html tag
|
42
42
|
def render
|
43
|
-
content_tag :
|
43
|
+
content_tag :h6, content, html_options
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def component_html_classes
|
49
|
+
'dropdown-header'
|
50
|
+
end
|
51
|
+
|
52
|
+
def component_html_options
|
53
|
+
{ role: 'presentation' }
|
44
54
|
end
|
45
55
|
|
46
56
|
end
|
@@ -44,19 +44,26 @@ module UiBibz::Ui::Core
|
|
44
44
|
# See UiBibz::Ui::Core::Component.initialize
|
45
45
|
def initialize content = nil, options = nil, html_options = nil, &block
|
46
46
|
super
|
47
|
+
@html_options = @html_options.merge(link_html_options)
|
47
48
|
end
|
48
49
|
|
49
50
|
# Render html tag
|
50
51
|
def render
|
51
|
-
|
52
|
-
link_to glyph_and_content_html, link_url, @options[:link_html_options]
|
53
|
-
end
|
52
|
+
link_to glyph_and_content_html, link_url, html_options
|
54
53
|
end
|
55
54
|
|
56
55
|
private
|
57
56
|
|
57
|
+
def component_html_classes
|
58
|
+
'dropdown-item'
|
59
|
+
end
|
60
|
+
|
58
61
|
def link_url
|
59
|
-
|
62
|
+
options[:url] || "#"
|
63
|
+
end
|
64
|
+
|
65
|
+
def link_html_options
|
66
|
+
@options[:link_html_options].nil? ? {} : @options[:link_html_options]
|
60
67
|
end
|
61
68
|
|
62
69
|
end
|
@@ -19,7 +19,7 @@ module UiBibz::Ui::Core
|
|
19
19
|
# You can add HTML attributes using the +html_options+.
|
20
20
|
# You can pass arguments in options attribute:
|
21
21
|
# * +state+ - State of élement with symbol value:
|
22
|
-
# (+:
|
22
|
+
# (+:primary+, +:secondary+, +:info+, +:warning+, +:danger+)
|
23
23
|
# * +size+
|
24
24
|
# (+:xs+, +:sm+, +:lg+)
|
25
25
|
# * +glyph+ - Add glyph with name or hash options
|
@@ -70,7 +70,7 @@ module UiBibz::Ui::Core
|
|
70
70
|
|
71
71
|
# Render html tag
|
72
72
|
def render
|
73
|
-
content_tag :div,
|
73
|
+
content_tag :div, html_options do
|
74
74
|
concat button_html
|
75
75
|
concat ul_html
|
76
76
|
end
|
@@ -101,16 +101,20 @@ module UiBibz::Ui::Core
|
|
101
101
|
|
102
102
|
protected
|
103
103
|
|
104
|
+
def component_html_classes
|
105
|
+
[type, "btn-group", open]
|
106
|
+
end
|
107
|
+
|
104
108
|
def button_content
|
105
109
|
[glyph_with_space, @content, ' ', caret].compact.join.html_safe
|
106
110
|
end
|
107
111
|
|
108
112
|
def button_html
|
109
|
-
content_tag :button, button_content, class:
|
113
|
+
content_tag :button, button_content, class: join_classes("btn", button_state, size, "dropdown-toggle"), type: 'button', "data-toggle" => 'dropdown', "aria-haspopup" => true, "aria-expanded" => false
|
110
114
|
end
|
111
115
|
|
112
116
|
def ul_html
|
113
|
-
content_tag :
|
117
|
+
content_tag :div, @items.join.html_safe, class: "dropdown-menu dropdown-menu-#{ position }"
|
114
118
|
end
|
115
119
|
|
116
120
|
def caret
|
@@ -125,9 +129,13 @@ module UiBibz::Ui::Core
|
|
125
129
|
@options[:type] || 'dropdown'
|
126
130
|
end
|
127
131
|
|
132
|
+
def open
|
133
|
+
"open" if @options[:open]
|
134
|
+
end
|
135
|
+
|
128
136
|
def button_state
|
129
|
-
sym = @state || :
|
130
|
-
"btn-#{
|
137
|
+
sym = @state || :primary
|
138
|
+
"btn-#{ sym }"
|
131
139
|
end
|
132
140
|
|
133
141
|
# :lg, :sm or :xs
|
@@ -18,7 +18,7 @@ module UiBibz::Ui::Core
|
|
18
18
|
# * +size+ - Integer
|
19
19
|
# * +type+ - Symbol
|
20
20
|
# * +state+ - Symbol
|
21
|
-
# (+:
|
21
|
+
# (+:secondary+, +:primary+, +:info+, +:warning+, +:danger+)
|
22
22
|
#
|
23
23
|
# ==== Signatures
|
24
24
|
#
|
@@ -63,23 +63,37 @@ module UiBibz::Ui::Core
|
|
63
63
|
|
64
64
|
# Render html tag
|
65
65
|
def render
|
66
|
-
content_tag :i, '',
|
66
|
+
content_tag :i, '', html_options
|
67
67
|
end
|
68
68
|
|
69
69
|
private
|
70
70
|
|
71
|
+
def component_html_classes
|
72
|
+
join_classes(classes)
|
73
|
+
end
|
74
|
+
|
71
75
|
def classes
|
72
76
|
cls = ["glyph", "fa", "fa-#{ content }"]
|
73
77
|
cls << "fa-#{ size }x" unless size.nil?
|
74
78
|
cls << "fa-rotate-#{ rotate }" unless rotate.nil?
|
75
79
|
cls << "fa-flip-#{ flip }" unless flip.nil?
|
80
|
+
cls << "fa-inverse" unless inverse.nil?
|
76
81
|
cls << "fa-stack-#{ stack }x" unless stack.nil?
|
77
82
|
cls << "fa-#{ type }" unless type.nil?
|
78
|
-
cls
|
83
|
+
cls
|
79
84
|
end
|
80
85
|
|
81
86
|
def size
|
82
|
-
@options[:size]
|
87
|
+
case @options[:size]
|
88
|
+
when :xs
|
89
|
+
1
|
90
|
+
when :md
|
91
|
+
3
|
92
|
+
when :lg
|
93
|
+
5
|
94
|
+
else
|
95
|
+
@options[:size]
|
96
|
+
end
|
83
97
|
end
|
84
98
|
|
85
99
|
def stack
|
@@ -90,6 +104,10 @@ module UiBibz::Ui::Core
|
|
90
104
|
@options[:rotate]
|
91
105
|
end
|
92
106
|
|
107
|
+
def inverse
|
108
|
+
@options[:inverse]
|
109
|
+
end
|
110
|
+
|
93
111
|
def flip
|
94
112
|
@options[:flip]
|
95
113
|
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
module UiBibz::Ui::Core
|
2
|
+
|
3
|
+
# Create a DatePickerField
|
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
|
+
# * +prepend+ - String
|
18
|
+
# * +append+ - String
|
19
|
+
# * +range+ - String
|
20
|
+
# * +date_today_highlight+ - Boolean
|
21
|
+
# * +calendar_weeks+ - Boolean
|
22
|
+
# * +date_disabled+ - Array, String
|
23
|
+
#
|
24
|
+
# ==== Signatures
|
25
|
+
#
|
26
|
+
# UiBibz::Ui::Core::DatePickerField.new(content, options = {}, html_options = {}).render
|
27
|
+
#
|
28
|
+
# UiBibz::Ui::Core::DatePickerField.new(options = {}, html_options = {}) do
|
29
|
+
# content
|
30
|
+
# end.render
|
31
|
+
#
|
32
|
+
# ==== Examples
|
33
|
+
#
|
34
|
+
# UiBibz::Ui::Core::DatePickerField.new('date', { prepend: 'Prepend content', append: 'Append content' }, { class: 'test' })
|
35
|
+
#
|
36
|
+
# UiBibz::Ui::Core::DatePickerField.new({ date_today_highlight: true, calendar_weeks: true, range: 'to' }, { class: 'test' }) do
|
37
|
+
# 'date'
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# ==== Helper
|
41
|
+
#
|
42
|
+
# date_picker_field(content, options = {}, html_options = {})
|
43
|
+
#
|
44
|
+
class DatePickerField < Component
|
45
|
+
|
46
|
+
# See UiBibz::Ui::Core::Component.initialize
|
47
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
48
|
+
super
|
49
|
+
end
|
50
|
+
|
51
|
+
# Render html tag
|
52
|
+
def render
|
53
|
+
if options[:range]
|
54
|
+
content_tag :div, class: join_classes('input-group', 'input-daterange', size) do
|
55
|
+
concat content_tag :span, options[:append], class: 'input-group-addon' unless @options[:append].nil?
|
56
|
+
concat text_field_tag content, html_options[:value], html_options
|
57
|
+
concat content_tag :span, options[:range], class: 'input-group-addon input-group-range'
|
58
|
+
concat text_field_tag content, html_options[:value], html_options
|
59
|
+
concat content_tag :span, options[:prepend], class: 'input-group-addon' unless @options[:prepend].nil?
|
60
|
+
end
|
61
|
+
else
|
62
|
+
UiBibz::Ui::Core::SurroundField.new(content, options, html_options).render
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def component_html_data
|
69
|
+
date_locale
|
70
|
+
provide
|
71
|
+
date_format
|
72
|
+
date_today_btn
|
73
|
+
date_today_highlight
|
74
|
+
calendar_weeks
|
75
|
+
autoclose
|
76
|
+
dates_disabled
|
77
|
+
end
|
78
|
+
|
79
|
+
def component_html_classes
|
80
|
+
%w(date_picker form-control)
|
81
|
+
end
|
82
|
+
|
83
|
+
def date_locale
|
84
|
+
add_html_data "date_locale", I18n.locale.to_s
|
85
|
+
end
|
86
|
+
|
87
|
+
def provide
|
88
|
+
add_html_data "provide", 'datepicker'
|
89
|
+
end
|
90
|
+
|
91
|
+
def date_format
|
92
|
+
add_html_data "date_format", picker_pattern
|
93
|
+
end
|
94
|
+
|
95
|
+
def picker_pattern
|
96
|
+
I18n.t('datepicker.pformat', default: 'dd/mm/yyyy')
|
97
|
+
end
|
98
|
+
|
99
|
+
def date_today_btn
|
100
|
+
add_html_data 'date_today_btn', 'linked'
|
101
|
+
end
|
102
|
+
|
103
|
+
def date_today_highlight
|
104
|
+
add_html_data('date_today_highlight') if options[:date_today_highlight]
|
105
|
+
end
|
106
|
+
|
107
|
+
def calendar_weeks
|
108
|
+
add_html_data("calendar_weeks") if options[:calendar_weeks]
|
109
|
+
end
|
110
|
+
|
111
|
+
def autoclose
|
112
|
+
add_html_data("autoclose") if options[:autoclose]
|
113
|
+
end
|
114
|
+
|
115
|
+
def dates_disabled
|
116
|
+
add_html_data("dates_disabled", [options[:dates_disabled]].flatten) if options[:dates_disabled]
|
117
|
+
end
|
118
|
+
|
119
|
+
# :lg, :sm or :xs
|
120
|
+
def size
|
121
|
+
"input-group-#{ options[:size] }" if options[:size]
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|