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
@@ -29,6 +29,7 @@ module UiBibz::Ui::Ux
|
|
29
29
|
# * +actionable+ - Boolean
|
30
30
|
# * +sortable+ - Boolean
|
31
31
|
# * +searchable+ - Boolean
|
32
|
+
# * +default_actions+ - Boolean
|
32
33
|
#
|
33
34
|
# ==== Signatures
|
34
35
|
#
|
@@ -39,7 +40,7 @@ module UiBibz::Ui::Ux
|
|
39
40
|
# c.column :id, name: '#'
|
40
41
|
# end
|
41
42
|
# t.actions do |a|
|
42
|
-
# a.
|
43
|
+
# a.link '', url: url, glyph: ''
|
43
44
|
# end
|
44
45
|
# end
|
45
46
|
#
|
@@ -55,9 +56,9 @@ module UiBibz::Ui::Ux
|
|
55
56
|
# c.column :status_id, { name: 'Status', format: lambda{ |records, record| "Test #{ record.id}"} }
|
56
57
|
# end
|
57
58
|
# t.actions do |a|
|
58
|
-
# a.
|
59
|
-
# a.
|
60
|
-
# a.
|
59
|
+
# a.link 'toto', url: users_path(:id), glyph: 'eye'
|
60
|
+
# a.divider
|
61
|
+
# a.link 'momo', url: users_path(:id), glyph: 'home'
|
61
62
|
# end
|
62
63
|
# end.render
|
63
64
|
#
|
@@ -73,8 +74,8 @@ module UiBibz::Ui::Ux
|
|
73
74
|
# end
|
74
75
|
# end
|
75
76
|
# t.actions do |acs|
|
76
|
-
# acs.
|
77
|
-
# acs.
|
77
|
+
# acs.link(content, options = {}, html_options = {})
|
78
|
+
# acs.link(options = {}, html_options = {}) do
|
78
79
|
# content
|
79
80
|
# end
|
80
81
|
# end
|
@@ -140,7 +141,7 @@ module UiBibz::Ui::Ux
|
|
140
141
|
end
|
141
142
|
|
142
143
|
def table_html
|
143
|
-
content_tag(:table,
|
144
|
+
content_tag(:table, html_options) do
|
144
145
|
|
145
146
|
ths = cols.collect do |col|
|
146
147
|
content_tag(:th, sort.header(col)) unless col.hidden?
|
@@ -171,5 +172,11 @@ module UiBibz::Ui::Ux
|
|
171
172
|
end
|
172
173
|
end
|
173
174
|
|
175
|
+
private
|
176
|
+
|
177
|
+
def component_html_classes
|
178
|
+
["table", type]
|
179
|
+
end
|
180
|
+
|
174
181
|
end
|
175
182
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require "ui_bibz/ui/ux/table/components/store"
|
2
2
|
module UiBibz::Ui::Ux
|
3
3
|
|
4
|
-
# Create a
|
4
|
+
# Create a TableCard
|
5
5
|
#
|
6
|
-
# This element is an extend of UiBibz::Ui::Ux::
|
6
|
+
# This element is an extend of UiBibz::Ui::Ux::card.
|
7
7
|
#
|
8
8
|
# ==== Attributes
|
9
9
|
#
|
@@ -25,23 +25,23 @@ module UiBibz::Ui::Ux
|
|
25
25
|
#
|
26
26
|
# ==== Signatures
|
27
27
|
#
|
28
|
-
# UiBibz::Ui::Ux::
|
28
|
+
# UiBibz::Ui::Ux::TableCard.new(store: @store)
|
29
29
|
#
|
30
|
-
# UiBibz::Ui::Ux::
|
30
|
+
# UiBibz::Ui::Ux::TableCard.new(store: @store, tap: true) do |t|
|
31
31
|
# t.columns do |c|
|
32
32
|
# c.column '#', { data_index: '#' }
|
33
33
|
# end
|
34
34
|
# t.actions do |a|
|
35
|
-
# a.
|
35
|
+
# a.link '', url: url, glyph: ''
|
36
36
|
# end
|
37
37
|
# end
|
38
38
|
#
|
39
39
|
# ==== Examples
|
40
40
|
#
|
41
|
-
# UiBibz::Ui::Ux::
|
41
|
+
# UiBibz::Ui::Ux::TableCard.new(store: @users, table_options: { actionable: false }).render
|
42
42
|
#
|
43
|
-
# UiBibz::Ui::Ux::
|
44
|
-
# t.header 'My Table
|
43
|
+
# UiBibz::Ui::Ux::TableCard.new(store: @users).tap do |t|
|
44
|
+
# t.header 'My Table card'
|
45
45
|
# t.columns do |c|
|
46
46
|
# c.column :id, { name: '# }, { class: 'column-id' }
|
47
47
|
# c.column :name_fr, { name: 'Name FR', link: edit_user_path(:id), order: 2 }
|
@@ -49,17 +49,17 @@ module UiBibz::Ui::Ux
|
|
49
49
|
# c.column :status_id, { name: 'Status', format: lambda{ |records, record| "Test #{ record.id}"} }
|
50
50
|
# end
|
51
51
|
# t.actions do |a|
|
52
|
-
# a.
|
53
|
-
# a.
|
54
|
-
# a.
|
52
|
+
# a.link 'toto', url: users_path(:id), glyph: 'eye'
|
53
|
+
# a.divider
|
54
|
+
# a.link 'momo', url: users_path(:id), glyph: 'home'
|
55
55
|
# end
|
56
56
|
# end.render
|
57
57
|
#
|
58
58
|
# ==== Helper
|
59
59
|
#
|
60
|
-
#
|
60
|
+
# table_card(options = {}, html_options = {})
|
61
61
|
#
|
62
|
-
#
|
62
|
+
# table_card(options = { tap: true }, html_options = {}) do |t|
|
63
63
|
# t.header(content, options = {}, html_options = {})
|
64
64
|
# # or
|
65
65
|
# t.header(options = {}, html_options = {}) do
|
@@ -91,7 +91,7 @@ module UiBibz::Ui::Ux
|
|
91
91
|
# content
|
92
92
|
# end
|
93
93
|
# end
|
94
|
-
class
|
94
|
+
class TableCard < UiBibz::Ui::Core::Card
|
95
95
|
|
96
96
|
attr_accessor :columns
|
97
97
|
|
@@ -104,19 +104,15 @@ module UiBibz::Ui::Ux
|
|
104
104
|
|
105
105
|
# Render html tag
|
106
106
|
def render
|
107
|
-
|
108
|
-
initialize_footer
|
107
|
+
init_components
|
109
108
|
|
110
|
-
content_tag :div,
|
109
|
+
content_tag :div, html_options do
|
111
110
|
form_tag(url_for(url_parameters), method: :get) do
|
112
111
|
store.parameters.each do |k,v|
|
113
112
|
concat tag(:input, type: 'hidden', name: k, value: v) if !default_parameters?(k) && !v.blank?
|
114
113
|
end
|
115
114
|
concat tag(:input, type: 'hidden', name: 'store_id', value: store.id) unless store.id.nil? # if there is more one table in html page
|
116
|
-
concat
|
117
|
-
concat(body_html) unless @body.nil?
|
118
|
-
concat(table_html) unless store.nil?
|
119
|
-
concat(footer_html) unless @footer.nil?
|
115
|
+
concat @items.join.html_safe
|
120
116
|
end
|
121
117
|
end
|
122
118
|
end
|
@@ -138,6 +134,10 @@ module UiBibz::Ui::Ux
|
|
138
134
|
|
139
135
|
private
|
140
136
|
|
137
|
+
def component_html_classes
|
138
|
+
%w(card table-card)
|
139
|
+
end
|
140
|
+
|
141
141
|
def store
|
142
142
|
@store ||= if @options[:store].nil?
|
143
143
|
raise 'Store is nil!'
|
@@ -148,6 +148,12 @@ module UiBibz::Ui::Ux
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
|
+
def init_components
|
152
|
+
@items << search.render if search.searchable?
|
153
|
+
@items << table.render unless @store.nil?
|
154
|
+
@items << pagination.render if pagination.paginable?
|
155
|
+
end
|
156
|
+
|
151
157
|
def default_parameters?(k)
|
152
158
|
%w(store_id per_page search utf8 search controller action utf8).include?(k)
|
153
159
|
end
|
@@ -156,8 +162,12 @@ module UiBibz::Ui::Ux
|
|
156
162
|
{ controller: store.controller, action: store.action, id: store.param_id }
|
157
163
|
end
|
158
164
|
|
165
|
+
def table
|
166
|
+
@table
|
167
|
+
end
|
168
|
+
|
159
169
|
def table_html
|
160
|
-
content_tag :div, @table.render, class: '
|
170
|
+
content_tag :div, @table.render, class: 'card-table'
|
161
171
|
end
|
162
172
|
|
163
173
|
def panel_classes
|
@@ -165,23 +175,11 @@ module UiBibz::Ui::Ux
|
|
165
175
|
end
|
166
176
|
|
167
177
|
def search
|
168
|
-
@search ||= Searchable.new store, @options.merge({ wrap_form: false })
|
178
|
+
@search ||= Searchable.new store, @options.merge({ wrap_form: false }), { class: 'card-header' }
|
169
179
|
end
|
170
180
|
|
171
181
|
def pagination
|
172
|
-
@pagination ||= Paginable.new store, @options.merge({ wrap_form: false })
|
173
|
-
end
|
174
|
-
|
175
|
-
def initialize_footer
|
176
|
-
@footer = @table.pagination
|
177
|
-
end
|
178
|
-
|
179
|
-
def initialize_header
|
180
|
-
@header = UiBibz::Ui::Core::Component.new search.render
|
181
|
-
end
|
182
|
-
|
183
|
-
def initialize_footer
|
184
|
-
@footer = UiBibz::Ui::Core::Component.new(pagination.render) if pagination.paginable?
|
182
|
+
@pagination ||= Paginable.new store, @options.merge({ wrap_form: false }), { class: 'card-footer' }
|
185
183
|
end
|
186
184
|
|
187
185
|
end
|
@@ -1,15 +1,18 @@
|
|
1
1
|
require "ui_bibz/ui/ux/table/components/store"
|
2
2
|
module UiBibz::Ui::Ux
|
3
|
-
class TableSearchField < UiBibz::Ui::
|
3
|
+
class TableSearchField < UiBibz::Ui::Core::Component
|
4
4
|
|
5
5
|
# Initialize search_field with component item
|
6
|
-
def initialize options = nil, html_options = nil
|
7
|
-
|
6
|
+
def initialize content = nil, options = nil, html_options = nil
|
7
|
+
html_options = options
|
8
|
+
options = content
|
9
|
+
content = nil
|
10
|
+
super
|
8
11
|
end
|
9
12
|
|
10
13
|
# Render html tag
|
11
14
|
def render
|
12
|
-
if
|
15
|
+
if options[:wrap_form] != false
|
13
16
|
form_tag(url_for(url_parameters), method: :get, class: 'form-table-search-field') do
|
14
17
|
search_field_html_in_wrap
|
15
18
|
end
|
@@ -27,17 +30,18 @@ module UiBibz::Ui::Ux
|
|
27
30
|
|
28
31
|
# Store must be generated by *table_search_pagination* method
|
29
32
|
def store
|
30
|
-
@store ||= if @
|
33
|
+
@store ||= if @options[:store].nil?
|
31
34
|
raise 'Store is nil!'
|
32
|
-
elsif @
|
35
|
+
elsif @options[:store].try(:records).nil?
|
33
36
|
raise 'Store can be created only with "table_search_pagination" method!'
|
34
37
|
else
|
35
|
-
Store.new @
|
38
|
+
Store.new @options.delete :store
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
39
42
|
def search_field_html
|
40
|
-
|
43
|
+
# add surround_field maybe ?
|
44
|
+
content_tag :div, html_options do
|
41
45
|
concat content_tag(:span, UiBibz::Ui::Core::Glyph.new('search').render, class: 'input-group-addon')
|
42
46
|
concat tag(:input, type: 'search', value: store.search, name: 'search', class: 'form-control', placeholder: search_placeholder_field)
|
43
47
|
concat content_tag(:span, UiBibz::Ui::Core::Glyph.new('times-circle').render, class: 'clear-search-btn input-group-addon')
|
@@ -45,18 +49,22 @@ module UiBibz::Ui::Ux
|
|
45
49
|
end
|
46
50
|
|
47
51
|
def search_field_html_in_wrap
|
48
|
-
content_tag :div,
|
52
|
+
content_tag :div, html_options do
|
49
53
|
concat content_tag(:span, UiBibz::Ui::Core::Glyph.new('search').render, class: 'input-group-addon')
|
50
54
|
store.parameters.each do |k,v|
|
51
55
|
concat tag(:input, type: 'hidden', name: k, value: v) unless default_parameters?(k)
|
52
56
|
end
|
53
57
|
concat tag(:input, type: 'hidden', name: 'store_id', value: store.id) unless store.id.nil? # if there is more one table in html page
|
54
58
|
concat tag(:input, type: 'search', value: store.search, name: 'search', class: 'form-control', placeholder: search_placeholder_field)
|
55
|
-
concat content_tag(:span,
|
59
|
+
concat content_tag(:span, clear_button, class: 'input-group-btn')
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
59
|
-
def
|
63
|
+
def clear_button
|
64
|
+
content_tag :button, UiBibz::Ui::Core::Glyph.new('times-circle').render, type: :button, class: 'btn btn-secondary'
|
65
|
+
end
|
66
|
+
|
67
|
+
def component_html_classes
|
60
68
|
%w(input-group input-group-sm table-search-field)
|
61
69
|
end
|
62
70
|
|
data/lib/ui_bibz/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
include UiBibz::Helpers
|
3
|
+
class NavTest < ActionView::TestCase
|
4
|
+
|
5
|
+
test 'breadcrumb' do
|
6
|
+
actual = UiBibz::Ui::Core::Breadcrumb.new.tap do |b|
|
7
|
+
b.link 'Home', url: '#home', glyph: 'home'
|
8
|
+
b.link 'Toto', { url: '#toto', status: :active }
|
9
|
+
end.render
|
10
|
+
expected = "<ol class=\"breadcrumb\"><li><a href=\"#home\"><i class=\"glyph fa fa-home\"></i> Home</a></li><li class=\"active\"><a href=\"#toto\">Toto</a></li></ol>"
|
11
|
+
|
12
|
+
assert_equal expected, actual
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'breadcrumb with store' do
|
16
|
+
users = create_list(:user, 3)
|
17
|
+
actual = UiBibz::Ui::Core::Breadcrumb.new(store: users, link_label: :name_fr, link_url: user_path(:id)).render
|
18
|
+
expected = "<ol class=\"breadcrumb\"><li><a href=\"/users/1/\">Name fr</a></li><li><a href=\"/users/2/\">Name fr</a></li><li>Name fr</li></ol>"
|
19
|
+
|
20
|
+
assert_equal expected, actual
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
|
data/test/ui/button_test.rb
CHANGED
@@ -14,7 +14,7 @@ class ButtonTest < ActionView::TestCase
|
|
14
14
|
actual = UiBibz::Ui::Core::ButtonGroup.new position: :vertical do
|
15
15
|
UiBibz::Ui::Core::Button.new('toto').render
|
16
16
|
end.render
|
17
|
-
expected = "<div class=\"btn-group btn-group-vertical\" role=\"group\"><button class=\"btn-
|
17
|
+
expected = "<div data-toggle=\"buttons\" class=\"btn-group btn-group-vertical\" role=\"group\"><button class=\"btn-primary btn\">toto</button></div>"
|
18
18
|
|
19
19
|
assert_equal expected, actual
|
20
20
|
end
|
@@ -26,6 +26,47 @@ class ButtonTest < ActionView::TestCase
|
|
26
26
|
assert_equal expected, actual
|
27
27
|
end
|
28
28
|
|
29
|
+
test 'button outline' do
|
30
|
+
actual = UiBibz::Ui::Core::Button.new('toto', state: :success, outline: true).render
|
31
|
+
expected = "<button class=\"btn-success-outline btn\">toto</button>"
|
32
|
+
|
33
|
+
assert_equal expected, actual
|
34
|
+
end
|
35
|
+
|
36
|
+
test 'checkbox button checked' do
|
37
|
+
actual = UiBibz::Ui::Core::ButtonChoice.new('Toto', { status: :active }).render
|
38
|
+
expected = "<label class=\"active btn-primary btn\"><input type=\"checkbox\" autocomplete=\"off\" checked=\"checked\" />Toto</label>"
|
39
|
+
|
40
|
+
assert_equal expected, actual
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'checkbox button non checked' do
|
44
|
+
actual = UiBibz::Ui::Core::ButtonChoice.new('Toto', { name: 'toto', id: 'toto', input_html_options: { class: 'toto'}}).render
|
45
|
+
expected = "<label class=\"btn-primary btn\"><input type=\"checkbox\" autocomplete=\"off\" name=\"toto\" id=\"toto\" class=\"toto\" />Toto</label>"
|
46
|
+
|
47
|
+
assert_equal expected, actual
|
48
|
+
end
|
49
|
+
|
50
|
+
test 'button group choice checkbox' do
|
51
|
+
actual = UiBibz::Ui::Core::ButtonGroup.new do
|
52
|
+
concat UiBibz::Ui::Core::ButtonChoice.new('Toto1').render
|
53
|
+
concat UiBibz::Ui::Core::ButtonChoice.new('Toto2').render
|
54
|
+
end.render
|
55
|
+
expected = "<div data-toggle=\"buttons\" class=\"btn-group\" role=\"group\"><label class=\"btn-primary btn\"><input type=\"checkbox\" autocomplete=\"off\" />Toto1</label><label class=\"btn-primary btn\"><input type=\"checkbox\" autocomplete=\"off\" />Toto2</label></div>"
|
56
|
+
|
57
|
+
assert_equal expected, actual
|
58
|
+
end
|
59
|
+
|
60
|
+
test 'button group choice radio' do
|
61
|
+
actual = UiBibz::Ui::Core::ButtonGroup.new do
|
62
|
+
concat UiBibz::Ui::Core::ButtonChoice.new('Toto1', type: :radio).render
|
63
|
+
concat UiBibz::Ui::Core::ButtonChoice.new('Toto2', type: :radio).render
|
64
|
+
end.render
|
65
|
+
expected = "<div data-toggle=\"buttons\" class=\"btn-group\" role=\"group\"><label class=\"btn-primary btn\"><input type=\"radio\" autocomplete=\"off\" />Toto1</label><label class=\"btn-primary btn\"><input type=\"radio\" autocomplete=\"off\" />Toto2</label></div>"
|
66
|
+
|
67
|
+
assert_equal expected, actual
|
68
|
+
end
|
69
|
+
|
29
70
|
test 'button dropdown' do
|
30
71
|
actual = UiBibz::Ui::Core::ButtonDropdown.new("Dropdown", type: :dropup, state: :success).tap do |d|
|
31
72
|
d.link 'toto'
|
@@ -34,7 +75,7 @@ class ButtonTest < ActionView::TestCase
|
|
34
75
|
d.divider
|
35
76
|
d.link 'lolo'
|
36
77
|
end.render
|
37
|
-
expected = "<div class=\"btn-group dropup\" role=\"group\"><button class=\"btn btn-success dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" aria-expanded=\"false\">Dropdown <span class=\"caret\"></span></button><
|
78
|
+
expected = "<div class=\"btn-group dropup\" role=\"group\"><button class=\"btn btn-success dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">Dropdown <span class=\"caret\"></span></button><div class=\"dropdown-menu dropdown-menu-left\"><a class=\"dropdown-item\" href=\"#\">toto</a><h6 class=\"dropdown-header\" role=\"presentation\">header</h6><a class=\"dropdown-item\" href=\"#\">momo</a><div class=\"dropdown-divider\"></div><a class=\"dropdown-item\" href=\"#\">lolo</a></div></div>"
|
38
79
|
|
39
80
|
assert_equal expected, actual
|
40
81
|
end
|
@@ -47,10 +88,9 @@ class ButtonTest < ActionView::TestCase
|
|
47
88
|
d.divider
|
48
89
|
d.link 'lolo'
|
49
90
|
end.render
|
50
|
-
expected = "<div class=\"btn-group dropup\" role=\"group\"><button class=\"btn btn-primary\">Dropdown</button><button class=\"btn btn-primary dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" aria-expanded=\"false\"><span class=\"caret\"></span><span class=\"sr-only\">Toggle Dropdown</span></button><
|
91
|
+
expected = "<div class=\"btn-group dropup\" role=\"group\"><button class=\"btn btn-primary\">Dropdown</button><button class=\"btn btn-primary dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"caret\"></span><span class=\"sr-only\">Toggle Dropdown</span></button><div class=\"dropdown-menu dropdown-menu-left\"><a class=\"dropdown-item\" href=\"#\">toto</a><h6 class=\"dropdown-header\" role=\"presentation\">header</h6><a class=\"dropdown-item\" href=\"#\">momo</a><div class=\"dropdown-divider\"></div><a class=\"dropdown-item\" href=\"#\">lolo</a></div></div>"
|
51
92
|
|
52
93
|
assert_equal expected, actual
|
53
94
|
end
|
54
95
|
|
55
|
-
|
56
96
|
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
include UiBibz::Helpers
|
3
|
+
include UiBibz::Helpers::UiCoreHelper
|
4
|
+
class CardTest < ActionView::TestCase
|
5
|
+
|
6
|
+
test 'create card' do
|
7
|
+
actual = card do
|
8
|
+
'test'
|
9
|
+
end
|
10
|
+
expected = "<div class=\"card card-block\">test</div>"
|
11
|
+
|
12
|
+
assert_equal expected, actual
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'create card with image, list and block' do
|
16
|
+
actual = card(tap: true) do |c|
|
17
|
+
c.image 'image.svg'
|
18
|
+
c.block do
|
19
|
+
"test"
|
20
|
+
end
|
21
|
+
c.list_group do |lg|
|
22
|
+
lg.list "Cras justo odio"
|
23
|
+
lg.list "Dapibas ac facilisis in"
|
24
|
+
lg.list "vestibulum at eros"
|
25
|
+
end
|
26
|
+
c.block do
|
27
|
+
link_to "Card link", '#', class: "card-link"
|
28
|
+
link_to "Card link", '#', class: "card-link"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
expected = "<div class=\"card\"><img src=\"/images/image.svg\" alt=\"Image\" /><div class=\"card-block\">test</div><ul class=\"list-group-flush list-group\"><li class=\"list-group-item\">Cras justo odio</li><li class=\"list-group-item\">Dapibas ac facilisis in</li><li class=\"list-group-item\">vestibulum at eros</li></ul><div class=\"card-block\"><a class=\"card-link\" href=\"#\">Card link</a></div></div>"
|
32
|
+
|
33
|
+
assert_equal expected, actual
|
34
|
+
end
|
35
|
+
|
36
|
+
test 'create card with header, block and footer' do
|
37
|
+
actual = card(state: :danger, tap: true, class: 'toto') do |p|
|
38
|
+
p.header 'toto', glyph: 'eye'
|
39
|
+
p.block 'toto'
|
40
|
+
p.footer 'toto'
|
41
|
+
end
|
42
|
+
expected = "<div class=\"card-danger toto card\"><div class=\"card-header\"><i class=\"glyph fa fa-eye\"></i> toto</div><div class=\"card-block\">toto</div><div class=\"card-footer\">toto</div></div>"
|
43
|
+
|
44
|
+
assert_equal expected, actual
|
45
|
+
end
|
46
|
+
|
47
|
+
test 'create card group' do
|
48
|
+
actual = card_group do |cg|
|
49
|
+
cg.card 'test 1', block: true
|
50
|
+
cg.card 'test 2', block: true
|
51
|
+
cg.card 'test 3', block: true
|
52
|
+
end
|
53
|
+
expected = "<div class=\"card-group\"><div class=\"card card-block\">test 1</div><div class=\"card card-block\">test 2</div><div class=\"card card-block\">test 3</div></div>"
|
54
|
+
|
55
|
+
assert_equal expected, actual
|
56
|
+
end
|
57
|
+
|
58
|
+
test 'create card deck' do
|
59
|
+
actual = card_deck do |cg|
|
60
|
+
cg.card 'test 1', block: true
|
61
|
+
cg.card 'test 2', block: true
|
62
|
+
cg.card 'test 3', block: true
|
63
|
+
end
|
64
|
+
expected = "<div class=\"card-deck-wrapper\"><div class=\"card-deck\"><div class=\"card card-block\">test 1</div><div class=\"card card-block\">test 2</div><div class=\"card card-block\">test 3</div></div></div>"
|
65
|
+
|
66
|
+
assert_equal expected, actual
|
67
|
+
end
|
68
|
+
|
69
|
+
test 'create card column' do
|
70
|
+
actual = card_column do |cg|
|
71
|
+
cg.card 'test 1', block: true
|
72
|
+
cg.card 'test 2', block: true
|
73
|
+
cg.card 'test 3', block: true
|
74
|
+
end
|
75
|
+
expected = "<div class=\"card-columns\"><div class=\"card card-block\">test 1</div><div class=\"card card-block\">test 2</div><div class=\"card card-block\">test 3</div></div>"
|
76
|
+
|
77
|
+
assert_equal expected, actual
|
78
|
+
end
|
79
|
+
|
80
|
+
test 'card list group' do
|
81
|
+
actual = card tap: true do |c|
|
82
|
+
c.list_group do |lg|
|
83
|
+
lg.list "list 1"
|
84
|
+
lg.list "list 2"
|
85
|
+
lg.list "list 3"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
expected = "<div class=\"card\"><ul class=\"list-group-flush list-group\"><li class=\"list-group-item\">list 1</li><li class=\"list-group-item\">list 2</li><li class=\"list-group-item\">list 3</li></ul></div>"
|
89
|
+
|
90
|
+
assert_equal expected, actual
|
91
|
+
end
|
92
|
+
|
93
|
+
test 'card block parameters' do
|
94
|
+
actual = card tap: true do |c|
|
95
|
+
c.block tap: true do |b|
|
96
|
+
b.title "title"
|
97
|
+
b.text "text"
|
98
|
+
b.link 'link'
|
99
|
+
end
|
100
|
+
end
|
101
|
+
expected = "<div class=\"card\"><div class=\"card-block\"><h4 class=\"card-title\">title</h4><p class=\"card-text\">text</p><a class=\"card-title\">link</a></div></div>"
|
102
|
+
|
103
|
+
assert_equal expected, actual
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|