ui_bibz 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.yardoc/checksums +49 -46
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/Gemfile.lock +69 -56
- data/README.md +156 -61
- data/doc/UiBibz/Concerns/Models/Searchable/ClassMethods.html +6 -6
- data/doc/UiBibz/Concerns/Models/Searchable.html +2 -2
- data/doc/UiBibz/Concerns/Models.html +115 -0
- data/doc/UiBibz/Concerns.html +115 -0
- data/doc/UiBibz/Helpers/MetaHelper.html +75 -9
- data/doc/UiBibz/Helpers/UiCoreHelper.html +120 -68
- data/doc/UiBibz/Helpers/UiUxHelper.html +2 -2
- data/doc/UiBibz/Helpers/UtilsHelper.html +2 -2
- data/doc/UiBibz/Helpers.html +115 -0
- data/doc/UiBibz/Rails/Engine.html +1 -1
- data/doc/UiBibz/Rails.html +1 -1
- data/doc/UiBibz/Ui/Base.html +2 -2
- data/doc/UiBibz/Ui/Core/Alert.html +26 -13
- data/doc/UiBibz/Ui/Core/Bar.html +26 -13
- data/doc/UiBibz/Ui/Core/Breadcrumb.html +32 -19
- data/doc/UiBibz/Ui/Core/BreadcrumbLink.html +26 -13
- data/doc/UiBibz/Ui/Core/Button.html +26 -13
- data/doc/UiBibz/Ui/Core/ButtonDropdown.html +31 -18
- data/doc/UiBibz/Ui/Core/ButtonGroup.html +26 -13
- data/doc/UiBibz/Ui/Core/ButtonLink.html +26 -13
- data/doc/UiBibz/Ui/Core/ButtonSplitDropdown.html +27 -14
- data/doc/UiBibz/Ui/Core/Col.html +26 -13
- data/doc/UiBibz/Ui/Core/Component.html +166 -225
- data/doc/UiBibz/Ui/Core/Dropdown.html +61 -410
- data/doc/UiBibz/Ui/Core/DropdownLink.html +373 -0
- data/doc/UiBibz/Ui/Core/DropdownList.html +26 -13
- data/doc/UiBibz/Ui/Core/Glyph.html +26 -386
- data/doc/UiBibz/Ui/Core/Jumbotron.html +26 -13
- data/doc/UiBibz/Ui/Core/Label.html +29 -15
- data/doc/UiBibz/Ui/Core/List.html +64 -25
- data/doc/UiBibz/Ui/Core/ListGroup.html +47 -21
- data/doc/UiBibz/Ui/Core/Nav.html +64 -25
- data/doc/UiBibz/Ui/Core/NavDropdown.html +29 -16
- data/doc/UiBibz/Ui/Core/NavLink.html +30 -15
- data/doc/UiBibz/Ui/Core/Navbar.html +154 -45
- data/doc/UiBibz/Ui/Core/NavbarForm.html +58 -38
- data/doc/UiBibz/Ui/Core/NavbarNav.html +7 -7
- data/doc/UiBibz/Ui/Core/NavbarText.html +26 -13
- data/doc/UiBibz/Ui/Core/Panel.html +38 -237
- data/doc/UiBibz/Ui/Core/ProgressBar.html +45 -19
- data/doc/UiBibz/Ui/Core/Row.html +26 -13
- data/doc/UiBibz/Ui/Core/Stars.html +367 -0
- data/doc/UiBibz/Ui/Core.html +16 -5
- data/doc/UiBibz/Ui/Ux/Actionable.html +1 -1
- data/doc/UiBibz/Ui/Ux/Actions.html +198 -14
- data/doc/UiBibz/Ui/Ux/Column.html +4 -4
- data/doc/UiBibz/Ui/Ux/Columns.html +42 -16
- data/doc/UiBibz/Ui/Ux/Grid.html +31 -371
- data/doc/UiBibz/Ui/Ux/Paginable.html +22 -9
- data/doc/UiBibz/Ui/Ux/Searchable.html +22 -9
- data/doc/UiBibz/Ui/Ux/Sortable.html +18 -7
- data/doc/UiBibz/Ui/Ux/Store.html +160 -56
- data/doc/UiBibz/Ui/Ux/Table.html +109 -374
- data/doc/UiBibz/Ui/Ux/TableAction.html +2 -2
- data/doc/UiBibz/Ui/Ux/TablePagination.html +33 -14
- data/doc/UiBibz/Ui/Ux/TablePaginationPerPage.html +30 -15
- data/doc/UiBibz/Ui/Ux/TablePanel.html +139 -43
- data/doc/UiBibz/Ui/Ux/TableSearchField.html +26 -13
- data/doc/UiBibz/Ui/Ux.html +15 -4
- data/doc/UiBibz/Ui.html +4 -2
- data/doc/UiBibz/Utils/Internationalization.html +1 -1
- data/doc/UiBibz/Utils.html +1 -1
- data/doc/UiBibz.html +5 -5
- data/doc/_index.html +50 -7
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +155 -63
- data/doc/images/stars.png +0 -0
- data/doc/index.html +155 -63
- data/doc/method_list.html +278 -398
- data/doc/top-level-namespace.html +1 -1
- data/lib/ui_bibz/concerns/models/searchable.rb +36 -13
- data/lib/ui_bibz/helpers/meta_helper.rb +22 -3
- data/lib/ui_bibz/helpers/ui_core_helper.rb +4 -0
- data/lib/ui_bibz/ui/core/alert.rb +2 -0
- data/lib/ui_bibz/ui/core/breadcrumb/breadcrumb.rb +3 -0
- data/lib/ui_bibz/ui/core/breadcrumb/components/breadcrumb_link.rb +2 -0
- data/lib/ui_bibz/ui/core/button/button.rb +2 -0
- data/lib/ui_bibz/ui/core/button/button_dropdown.rb +6 -4
- data/lib/ui_bibz/ui/core/button/button_group.rb +2 -0
- data/lib/ui_bibz/ui/core/button/button_link.rb +2 -0
- data/lib/ui_bibz/ui/core/button/button_split_dropdown.rb +2 -0
- data/lib/ui_bibz/ui/core/col.rb +2 -0
- data/lib/ui_bibz/ui/core/component.rb +23 -25
- data/lib/ui_bibz/ui/core/dropdown/components/dropdown_link.rb +57 -0
- data/lib/ui_bibz/ui/core/dropdown/components/dropdown_list.rb +2 -0
- data/lib/ui_bibz/ui/core/dropdown/dropdown.rb +22 -9
- data/lib/ui_bibz/ui/core/glyph.rb +10 -0
- data/lib/ui_bibz/ui/core/jumbotron.rb +2 -0
- data/lib/ui_bibz/ui/core/label.rb +3 -0
- data/lib/ui_bibz/ui/core/list/components/list.rb +4 -0
- data/lib/ui_bibz/ui/core/list/list_group.rb +4 -0
- data/lib/ui_bibz/ui/core/nav/components/nav_dropdown.rb +4 -2
- data/lib/ui_bibz/ui/core/nav/components/nav_link.rb +4 -1
- data/lib/ui_bibz/ui/core/nav/components/navbar_form.rb +39 -3
- data/lib/ui_bibz/ui/core/nav/components/navbar_nav.rb +1 -0
- data/lib/ui_bibz/ui/core/nav/components/navbar_text.rb +8 -0
- data/lib/ui_bibz/ui/core/nav/nav.rb +6 -0
- data/lib/ui_bibz/ui/core/nav/navbar.rb +31 -4
- data/lib/ui_bibz/ui/core/panel.rb +7 -5
- data/lib/ui_bibz/ui/core/progress_bar/components/bar.rb +2 -0
- data/lib/ui_bibz/ui/core/progress_bar/progress_bar.rb +4 -0
- data/lib/ui_bibz/ui/core/row.rb +2 -0
- data/lib/ui_bibz/ui/core/stars.rb +88 -0
- data/lib/ui_bibz/ui/ux/grid.rb +4 -0
- data/lib/ui_bibz/ui/ux/table/components/actions.rb +17 -2
- data/lib/ui_bibz/ui/ux/table/components/column.rb +2 -2
- data/lib/ui_bibz/ui/ux/table/components/columns.rb +4 -2
- data/lib/ui_bibz/ui/ux/table/components/store.rb +10 -1
- data/lib/ui_bibz/ui/ux/table/extensions/actionable.rb +3 -1
- data/lib/ui_bibz/ui/ux/table/extensions/paginable.rb +1 -0
- data/lib/ui_bibz/ui/ux/table/extensions/searchable.rb +1 -0
- data/lib/ui_bibz/ui/ux/table/extensions/sortable.rb +8 -2
- data/lib/ui_bibz/ui/ux/table/table.rb +19 -8
- data/lib/ui_bibz/ui/ux/table/table_pagination.rb +8 -1
- data/lib/ui_bibz/ui/ux/table/table_pagination_per_page.rb +10 -2
- data/lib/ui_bibz/ui/ux/table/table_panel.rb +28 -13
- data/lib/ui_bibz/ui/ux/table/table_search_field.rb +9 -1
- data/lib/ui_bibz/version.rb +1 -1
- data/lib/ui_bibz.rb +1 -0
- data/test/test_helper.rb +5 -0
- data/test/ui/dropdown_test.rb +4 -4
- data/test/ui/stars_test.rb +42 -0
- data/test/ui/table_test.rb +25 -6
- data/ui_bibz.gemspec +4 -1
- data/vendor/assets/fonts/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.svg +640 -0
- data/vendor/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.woff2 +0 -0
- data/vendor/assets/javascripts/bootstrap-datepicker.min.js +8 -0
- data/vendor/assets/javascripts/bootstrap-select.min.js +8 -0
- data/vendor/assets/javascripts/bootstrap-switch.min.js +22 -0
- data/vendor/assets/javascripts/bootstrap.min.js +7 -0
- data/vendor/assets/javascripts/jquery-2.1.4.min.js +4 -0
- data/vendor/assets/javascripts/ui_bibz.js.coffee +8 -0
- data/vendor/assets/stylesheets/bootstrap-datepicker3.min.css +8 -0
- data/vendor/assets/stylesheets/bootstrap-select.min.css +6 -0
- data/vendor/assets/stylesheets/bootstrap-switch.min.css +22 -0
- data/vendor/assets/stylesheets/bootstrap-theme.min.css +5 -0
- data/vendor/assets/stylesheets/bootstrap.min.css +5 -0
- data/vendor/assets/stylesheets/font-awesome.min.css +4 -0
- data/vendor/assets/stylesheets/ui_bibz.sass +23 -0
- metadata +71 -2
@@ -26,7 +26,7 @@ module UiBibz::Ui::Core
|
|
26
26
|
#
|
27
27
|
# ==== Signatures
|
28
28
|
#
|
29
|
-
# UiBibz::Ui::Core::
|
29
|
+
# UiBibz::Ui::Core::NavDropdown.new(options = nil, html_options = nil).tap do |d|
|
30
30
|
# ...
|
31
31
|
# d.list content = nil, options = nil, html_options = nil, &block
|
32
32
|
# d.list content = nil, options = nil, html_options = nil, &block
|
@@ -36,17 +36,19 @@ module UiBibz::Ui::Core
|
|
36
36
|
#
|
37
37
|
# ==== Examples
|
38
38
|
#
|
39
|
-
# UiBibz::Ui::Core::
|
39
|
+
# UiBibz::Ui::Core::NavDropdown.new(name, state: :success).tap do |d|
|
40
40
|
# d.list link_to('test', '#')
|
41
41
|
# d.list link_to('test2', '#')
|
42
42
|
# end.render
|
43
43
|
#
|
44
44
|
class NavDropdown < Dropdown
|
45
45
|
|
46
|
+
# See UiBibz::Ui::Core::Component.initialize
|
46
47
|
def initialize content, options = nil, html_options = nil, &block
|
47
48
|
super
|
48
49
|
end
|
49
50
|
|
51
|
+
# Render html tag
|
50
52
|
def render
|
51
53
|
content_tag :li, class_and_html_options(type) do
|
52
54
|
concat link_html
|
@@ -18,6 +18,7 @@ module UiBibz::Ui::Core
|
|
18
18
|
# (+:active+)
|
19
19
|
# * +url+ - String
|
20
20
|
# * +badge+ - String
|
21
|
+
# * +link_html_options+ - Hash
|
21
22
|
#
|
22
23
|
# ==== Signatures
|
23
24
|
#
|
@@ -29,7 +30,7 @@ module UiBibz::Ui::Core
|
|
29
30
|
#
|
30
31
|
# ==== Examples
|
31
32
|
#
|
32
|
-
# UiBibz::Ui::Core::NavLink.new(content, { badge: 15, url: '/', status: :active },{ class: 'test' }).render
|
33
|
+
# UiBibz::Ui::Core::NavLink.new(content, { badge: 15, url: '/', status: :active, link_html_options: { class: 'link1' }},{ class: 'test' }).render
|
33
34
|
#
|
34
35
|
# UiBibz::Ui::Core::NavLink.new({glyph: { name: 'eye', size: 3 }, { class: 'test' }) do
|
35
36
|
# 'Home'
|
@@ -37,10 +38,12 @@ module UiBibz::Ui::Core
|
|
37
38
|
#
|
38
39
|
class NavLink < Component
|
39
40
|
|
41
|
+
# See UiBibz::Ui::Core::Component.initialize
|
40
42
|
def initialize content = nil, options = nil, html_options = nil, &block
|
41
43
|
super
|
42
44
|
end
|
43
45
|
|
46
|
+
# Render html tag
|
44
47
|
def render
|
45
48
|
content_tag :li, content_htm, class_and_html_options.merge({ role: 'presentation' })
|
46
49
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'haml'
|
1
2
|
module UiBibz::Ui::Core
|
2
3
|
|
3
4
|
# Create a NavbarForm
|
@@ -16,6 +17,8 @@ module UiBibz::Ui::Core
|
|
16
17
|
# You can pass arguments in options attribute:
|
17
18
|
#
|
18
19
|
# http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_for
|
20
|
+
# # and
|
21
|
+
# http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-form_tag
|
19
22
|
#
|
20
23
|
# ==== Signatures
|
21
24
|
#
|
@@ -31,15 +34,48 @@ module UiBibz::Ui::Core
|
|
31
34
|
# f.submit 'Submit'
|
32
35
|
# end.render
|
33
36
|
#
|
34
|
-
|
37
|
+
# UiBibz::Ui::Core::NavbarForm.new('/search', type: :form_tag) do
|
38
|
+
# text_field_tag :field
|
39
|
+
# submit_tag 'Submit'
|
40
|
+
# end.render
|
41
|
+
#
|
42
|
+
class NavbarForm < UiBibz::Ui::Base
|
43
|
+
include Haml::Helpers
|
44
|
+
include ActionView::Helpers#::FormHelper
|
35
45
|
|
36
|
-
|
37
|
-
|
46
|
+
# See UiBibz::Ui::Core::Component.initialize
|
47
|
+
def initialize model_or_url, options = {}, &block
|
48
|
+
init_haml_helpers
|
49
|
+
@options = options
|
50
|
+
if type == :form_for
|
51
|
+
@form = form_for(model_or_url, options, &block)
|
52
|
+
else
|
53
|
+
@form = form_tag(model_or_url, class: "navbar-form #{ position }", &block)
|
54
|
+
end
|
38
55
|
end
|
39
56
|
|
57
|
+
# Render html tag
|
40
58
|
def render
|
41
59
|
@form
|
42
60
|
end
|
43
61
|
|
62
|
+
private
|
63
|
+
|
64
|
+
def protect_against_forgery?
|
65
|
+
false
|
66
|
+
end
|
67
|
+
|
68
|
+
def url
|
69
|
+
@options[:url]
|
70
|
+
end
|
71
|
+
|
72
|
+
def type
|
73
|
+
@options[:type] || :form_for
|
74
|
+
end
|
75
|
+
|
76
|
+
def position
|
77
|
+
"navbar-#{ @options[:position] }" unless @options[:position].nil?
|
78
|
+
end
|
79
|
+
|
44
80
|
end
|
45
81
|
end
|
@@ -33,13 +33,21 @@ module UiBibz::Ui::Core
|
|
33
33
|
#
|
34
34
|
class NavbarText < Component
|
35
35
|
|
36
|
+
# See UiBibz::Ui::Core::Component.initialize
|
36
37
|
def initialize content = nil, options = nil, html_options = nil, &block
|
37
38
|
super
|
38
39
|
end
|
39
40
|
|
41
|
+
# Render html tag
|
40
42
|
def render
|
41
43
|
content_tag :ul, @content, class_and_html_options(["navbar-text", position])
|
42
44
|
end
|
43
45
|
|
46
|
+
private
|
47
|
+
|
48
|
+
def position
|
49
|
+
"navbar-#{ @options[:position] }" unless @options[:position].nil?
|
50
|
+
end
|
51
|
+
|
44
52
|
end
|
45
53
|
end
|
@@ -58,19 +58,25 @@ module UiBibz::Ui::Core
|
|
58
58
|
#
|
59
59
|
class Nav < Component
|
60
60
|
|
61
|
+
# See UiBibz::Ui::Core::Component.initialize
|
61
62
|
def initialize content = nil, options = nil, html_options = nil, &block
|
62
63
|
super
|
63
64
|
@items = []
|
64
65
|
end
|
65
66
|
|
67
|
+
# Render html tag
|
66
68
|
def render
|
67
69
|
content_tag :ul, @items.join.html_safe, class_and_html_options(["nav", type, position])
|
68
70
|
end
|
69
71
|
|
72
|
+
# Add nav link items
|
73
|
+
# See UiBibz::Ui::Core::NavLink
|
70
74
|
def link content = nil, options = {}, html_options = nil, &block
|
71
75
|
@items << NavLink.new(content, options.merge({ nav_type: type }), html_options, &block).render
|
72
76
|
end
|
73
77
|
|
78
|
+
# Add nav dropdown items
|
79
|
+
# See UiBibz::Ui::Core::NavDropdown
|
74
80
|
def dropdown content = nil, options = {}, html_options = nil, &block
|
75
81
|
@items << NavDropdown.new(content, options, html_options).tap(&block).render
|
76
82
|
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'ui_bibz/ui/core/nav/components/navbar_nav'
|
2
|
+
require 'ui_bibz/ui/core/nav/components/navbar_text'
|
3
|
+
require 'ui_bibz/ui/core/nav/components/navbar_form'
|
2
4
|
module UiBibz::Ui::Core
|
3
5
|
|
4
6
|
# Create a Navbar
|
@@ -41,6 +43,11 @@ module UiBibz::Ui::Core
|
|
41
43
|
# n.link 'Link 1', "#"
|
42
44
|
# n.link 'Link 2', "#"
|
43
45
|
# end
|
46
|
+
# nb.form(url: 'search/', type: :form_tag) do
|
47
|
+
# text_field_tag 'search', nil, { class: 'form-control', placeholder: 'Search' }
|
48
|
+
# button 'Submit', type: :submit
|
49
|
+
# end
|
50
|
+
# nb.text 'My text'
|
44
51
|
# end.render
|
45
52
|
#
|
46
53
|
# ==== Helper
|
@@ -56,11 +63,13 @@ module UiBibz::Ui::Core
|
|
56
63
|
#
|
57
64
|
class Navbar < Component
|
58
65
|
|
66
|
+
# See UiBibz::Ui::Core::Component.initialize
|
59
67
|
def initialize content = nil, options = nil, html_options = nil, &block
|
60
68
|
super
|
61
69
|
@items = []
|
62
70
|
end
|
63
71
|
|
72
|
+
# Render html tag
|
64
73
|
def render
|
65
74
|
content_tag :nav, class_and_html_options(['navbar', type, position]) do
|
66
75
|
content_tag :div, class: 'container-fluid' do
|
@@ -70,17 +79,27 @@ module UiBibz::Ui::Core
|
|
70
79
|
end
|
71
80
|
end
|
72
81
|
|
82
|
+
# Add navbar nav items
|
83
|
+
# See UiBibz::Ui::Core::NavbarNav
|
73
84
|
def nav content = nil, options = nil, html_options = nil, &block
|
74
85
|
options = options || {}
|
75
86
|
@items << UiBibz::Ui::Core::NavbarNav.new(content, options, html_options).tap(&block).render
|
76
87
|
end
|
77
88
|
|
78
|
-
|
79
|
-
|
89
|
+
# Add navbar form items
|
90
|
+
# See UiBibz::Ui::Core::NavbarForm
|
91
|
+
def form model_or_url, options = {}, &block
|
92
|
+
@items << UiBibz::Ui::Core::NavbarForm.new(model_or_url, options, &block).render
|
80
93
|
end
|
81
94
|
|
95
|
+
# Add navbar text items
|
96
|
+
# See UiBibz::Ui::Core::NavbarText
|
82
97
|
def text content = nil, options = nil, html_options = nil, &block
|
83
|
-
|
98
|
+
@items << UiBibz::Ui::Core::NavbarText.new(content, options, html_options, &block).render
|
99
|
+
end
|
100
|
+
|
101
|
+
def brand content = nil, options = nil, html_options = nil, &block
|
102
|
+
@brand = UiBibz::Ui::Core::Component.new(content, options, html_options, &block)
|
84
103
|
end
|
85
104
|
|
86
105
|
private
|
@@ -88,7 +107,15 @@ module UiBibz::Ui::Core
|
|
88
107
|
def header_html
|
89
108
|
content_tag :div, class: 'navbar-header' do
|
90
109
|
concat navbar_toggle_button_html
|
91
|
-
concat link_to
|
110
|
+
concat link_to title.content, title.options[:url], title.class_and_html_options('navbar-brand') unless title.nil?
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def title
|
115
|
+
@title ||= if @brand.nil?
|
116
|
+
brand(@options[:title], url: '/') unless @options[:title].nil?
|
117
|
+
else
|
118
|
+
@brand
|
92
119
|
end
|
93
120
|
end
|
94
121
|
|
@@ -78,25 +78,27 @@ module UiBibz::Ui::Core
|
|
78
78
|
#
|
79
79
|
class Panel < Component
|
80
80
|
|
81
|
+
# See UiBibz::Ui::Core::Component.initialize
|
81
82
|
def initialize content = nil, options = nil, html_options = nil, &block
|
82
83
|
super
|
83
84
|
end
|
84
85
|
|
85
|
-
# Header is a component
|
86
|
+
# Add Header which is a component
|
86
87
|
def header content = nil, options = nil, html_options = nil, &block
|
87
88
|
@header = Component.new content, options, html_options, &block
|
88
89
|
end
|
89
90
|
|
90
|
-
# Body is a component
|
91
|
+
# Add Body which is a component
|
91
92
|
def body content = nil, options = nil, html_options = nil, &block
|
92
93
|
@body = Component.new content, options, html_options, &block
|
93
94
|
end
|
94
95
|
|
95
|
-
# Footer is a component
|
96
|
+
# Add Footer which is a component
|
96
97
|
def footer content = nil, options = nil, html_options = nil, &block
|
97
98
|
@footer = Component.new content, options, html_options, &block
|
98
99
|
end
|
99
100
|
|
101
|
+
# Render html tag
|
100
102
|
def render
|
101
103
|
content_tag :div, class_and_html_options("panel") do
|
102
104
|
concat(header_html) unless @header.nil?
|
@@ -105,13 +107,13 @@ module UiBibz::Ui::Core
|
|
105
107
|
end
|
106
108
|
end
|
107
109
|
|
110
|
+
protected
|
111
|
+
|
108
112
|
def state
|
109
113
|
sym = @options[:state] || :default
|
110
114
|
"panel-#{ states[sym] }"
|
111
115
|
end
|
112
116
|
|
113
|
-
protected
|
114
|
-
|
115
117
|
def header_html
|
116
118
|
content_tag :div, @header.render, @header.class_and_html_options("panel-heading")
|
117
119
|
end
|
@@ -43,10 +43,12 @@ module UiBibz::Ui::Core
|
|
43
43
|
#
|
44
44
|
class Bar < Component
|
45
45
|
|
46
|
+
# See UiBibz::Ui::Core::Component.initialize
|
46
47
|
def initialize content = nil, options = nil, html_options = nil, &block
|
47
48
|
super
|
48
49
|
end
|
49
50
|
|
51
|
+
# Render html tag
|
50
52
|
def render
|
51
53
|
content_tag :div, progressbar_inner_html, class_and_html_options(['progress-bar', type]).merge(bar_html_options)
|
52
54
|
end
|
@@ -67,15 +67,19 @@ module UiBibz::Ui::Core
|
|
67
67
|
#
|
68
68
|
class ProgressBar < Component
|
69
69
|
|
70
|
+
# See UiBibz::Ui::Core::Component.initialize
|
70
71
|
def initialize content = nil, options = nil, html_options = nil, &block
|
71
72
|
super
|
72
73
|
@bars = []
|
73
74
|
end
|
74
75
|
|
76
|
+
# Render html tag
|
75
77
|
def render
|
76
78
|
content_tag :div, content, class: 'progress'
|
77
79
|
end
|
78
80
|
|
81
|
+
# Add progressbar bar items
|
82
|
+
# See UiBibz::Ui::Core::Bar
|
79
83
|
def bar content = nil, options = nil, html_options = nil, &block
|
80
84
|
@bars << Bar.new(content, options, html_options, &block).render
|
81
85
|
end
|
data/lib/ui_bibz/ui/core/row.rb
CHANGED
@@ -28,10 +28,12 @@ module UiBibz::Ui::Core
|
|
28
28
|
#
|
29
29
|
class Row < Component
|
30
30
|
|
31
|
+
# See UiBibz::Ui::Core::Component.initialize
|
31
32
|
def initialize content = nil, options = nil, html_options = nil, &block
|
32
33
|
super
|
33
34
|
end
|
34
35
|
|
36
|
+
# Render html tag
|
35
37
|
def render
|
36
38
|
content_tag :div, @content, class_and_html_options('row')
|
37
39
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module UiBibz::Ui::Core
|
2
|
+
|
3
|
+
# Create stars notation
|
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
|
+
# * +state+ - State of élement with symbol value:
|
18
|
+
# (+:default+, +:primary+, +:info+, +:warning+, +:danger+)
|
19
|
+
# * +num+ - Integer, number of stars
|
20
|
+
#
|
21
|
+
# ==== Signatures
|
22
|
+
#
|
23
|
+
# UiBibz::Ui::Core::Stars.new(content, options = nil, html_options = nil)
|
24
|
+
#
|
25
|
+
# UiBibz::Ui::Core::Stars.new(options = nil, html_options = nil) do
|
26
|
+
# content
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# ==== Examples
|
30
|
+
#
|
31
|
+
# UiBibz::Ui::Core::Stars.new(content, state: :success).render
|
32
|
+
#
|
33
|
+
# UiBibz::Ui::Core::Stars.new({ num: 10 }) do
|
34
|
+
# #content
|
35
|
+
# end.render
|
36
|
+
#
|
37
|
+
# ==== Helper
|
38
|
+
#
|
39
|
+
# stars(content, options = {}, html_options = {})
|
40
|
+
#
|
41
|
+
# stars(options = {}, html_options = {}) do
|
42
|
+
# content
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
class Stars < Component
|
46
|
+
|
47
|
+
# See UiBibz::Ui::Core::Component.initialize
|
48
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
49
|
+
super
|
50
|
+
end
|
51
|
+
|
52
|
+
# Render html tag
|
53
|
+
def render
|
54
|
+
content_tag :span, stars_notation.join(' ').html_safe, class_and_html_options('stars-notation')
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def number
|
60
|
+
@options[:num] || 5
|
61
|
+
end
|
62
|
+
|
63
|
+
def stars_notation
|
64
|
+
stars = []
|
65
|
+
number.to_i.times do |star|
|
66
|
+
star = star + 1
|
67
|
+
name = star_name(star)
|
68
|
+
stars << UiBibz::Ui::Core::Glyph.new(name, glyph_opts).render
|
69
|
+
end
|
70
|
+
stars
|
71
|
+
end
|
72
|
+
|
73
|
+
def glyph_opts
|
74
|
+
{ state: @options[:state] } unless @options[:state].nil?
|
75
|
+
end
|
76
|
+
|
77
|
+
def star_name star
|
78
|
+
if star <= @content
|
79
|
+
'star'
|
80
|
+
elsif star > @content && !@content.is_a?(Integer) && star < @content + 1
|
81
|
+
'star-half-o'
|
82
|
+
else
|
83
|
+
'star-o'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
data/lib/ui_bibz/ui/ux/grid.rb
CHANGED
@@ -61,6 +61,7 @@ module UiBibz::Ui::Ux
|
|
61
61
|
@views = {}
|
62
62
|
end
|
63
63
|
|
64
|
+
# Add grid view items
|
64
65
|
def view content = nil, options = nil, html_options = nil, &block
|
65
66
|
o = content.kind_of?(Hash) ? content : options
|
66
67
|
c = UiBibz::Ui::Core::Component.new content, options, html_options, &block
|
@@ -68,6 +69,7 @@ module UiBibz::Ui::Ux
|
|
68
69
|
@views = @views.merge(h)
|
69
70
|
end
|
70
71
|
|
72
|
+
# Render html tag
|
71
73
|
def render
|
72
74
|
define_col_nums
|
73
75
|
UiBibz::Ui::Core::Row.new(class: 'grid') do
|
@@ -84,6 +86,8 @@ module UiBibz::Ui::Ux
|
|
84
86
|
end.render
|
85
87
|
end
|
86
88
|
|
89
|
+
private
|
90
|
+
|
87
91
|
def view_by_num c, num, item_class
|
88
92
|
UiBibz::Ui::Core::Col.new(c.content, c.options.merge({ num: num }), c.class_and_html_options(['col', item_class])).render
|
89
93
|
end
|
@@ -3,18 +3,33 @@ module UiBibz::Ui::Ux
|
|
3
3
|
class Actions
|
4
4
|
|
5
5
|
def initialize store
|
6
|
-
@store
|
7
|
-
@actions
|
6
|
+
@store = store
|
7
|
+
@actions = []
|
8
|
+
@action_order = -1
|
8
9
|
end
|
9
10
|
|
11
|
+
# Add action in table
|
10
12
|
def action content = nil, options = nil, html_options = nil, &block
|
11
13
|
@actions << TableAction.new(content, options, html_options, &block).render
|
12
14
|
end
|
13
15
|
|
16
|
+
def reset
|
17
|
+
@actions = []
|
18
|
+
end
|
19
|
+
|
20
|
+
def format &block
|
21
|
+
@format_action = block
|
22
|
+
end
|
23
|
+
|
24
|
+
# Get all actions
|
14
25
|
def list
|
15
26
|
@actions.empty? ? defaults_actions : @actions
|
16
27
|
end
|
17
28
|
|
29
|
+
def format_action
|
30
|
+
@format_action
|
31
|
+
end
|
32
|
+
|
18
33
|
private
|
19
34
|
|
20
35
|
def defaults_actions
|
@@ -5,10 +5,10 @@ module UiBibz::Ui::Ux
|
|
5
5
|
|
6
6
|
def initialize content = nil, options = nil, html_options = nil, &block
|
7
7
|
super
|
8
|
-
@
|
8
|
+
@data_index = @content
|
9
|
+
@name = @options[:name]
|
9
10
|
@link = @options[:link] # for show or edit action
|
10
11
|
@order = @options[:order]
|
11
|
-
@data_index = @options[:data_index]
|
12
12
|
@date_format = @options[:date_format]
|
13
13
|
@sort = @options[:sort]
|
14
14
|
@custom_sort = @options[:custom_sort]
|
@@ -5,10 +5,12 @@ module UiBibz::Ui::Ux
|
|
5
5
|
@columns = columns || []
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
# Add column in table
|
9
|
+
def column data_index = nil, options = nil, html_options = nil, &block
|
10
|
+
@columns << Column.new(data_index, options, html_options, &block)
|
10
11
|
end
|
11
12
|
|
13
|
+
# Get all columns
|
12
14
|
def list
|
13
15
|
@columns
|
14
16
|
end
|
@@ -5,6 +5,7 @@ module UiBibz::Ui::Ux
|
|
5
5
|
|
6
6
|
attr_accessor :records
|
7
7
|
|
8
|
+
# Store Use WillPaginate store methods
|
8
9
|
def initialize store
|
9
10
|
@records = store.records
|
10
11
|
@store = store
|
@@ -23,6 +24,10 @@ module UiBibz::Ui::Ux
|
|
23
24
|
@records.total_entries
|
24
25
|
end
|
25
26
|
|
27
|
+
def id
|
28
|
+
@store.id
|
29
|
+
end
|
30
|
+
|
26
31
|
def sort
|
27
32
|
@store.sort
|
28
33
|
end
|
@@ -44,7 +49,7 @@ module UiBibz::Ui::Ux
|
|
44
49
|
end
|
45
50
|
|
46
51
|
def columns
|
47
|
-
@columns ||= Columns.new model.new.attributes.keys.map{ |record| Column.new(record
|
52
|
+
@columns ||= Columns.new model.new.attributes.keys.map{ |record| Column.new(record, { name: record.humanize }) }
|
48
53
|
end
|
49
54
|
|
50
55
|
def model
|
@@ -63,5 +68,9 @@ module UiBibz::Ui::Ux
|
|
63
68
|
@store.action
|
64
69
|
end
|
65
70
|
|
71
|
+
def param_id
|
72
|
+
@store.param_id
|
73
|
+
end
|
74
|
+
|
66
75
|
end
|
67
76
|
end
|
@@ -31,9 +31,11 @@ module UiBibz::Ui::Ux
|
|
31
31
|
def dropdown_action record
|
32
32
|
UiBibz::Ui::Core::Dropdown.new(dropdown_action_name, { position: :right, glyph: actions_glyph }, class: 'btn-group-xs dropdown-action').tap do |d|
|
33
33
|
unless @actions.nil?
|
34
|
+
@actions.format_action.call(record) unless @actions.format_action.nil?
|
34
35
|
actions_links(record).each do |l|
|
35
|
-
d.list l.html_safe
|
36
|
+
d.list l.to_s.html_safe
|
36
37
|
end
|
38
|
+
@actions.reset
|
37
39
|
end
|
38
40
|
end.render
|
39
41
|
end
|
@@ -6,10 +6,10 @@ module UiBibz::Ui::Ux
|
|
6
6
|
@options = options
|
7
7
|
end
|
8
8
|
|
9
|
+
# header use i18n
|
9
10
|
def header column, name = nil
|
10
11
|
@column = column
|
11
|
-
|
12
|
-
defaults = [translate_headers_by_defaults, translate_headers_by_defaults_active_record, translate_headers_by_active_record, name]
|
12
|
+
defaults = [translate_headers_by_defaults, translate_headers_by_defaults_active_record, translate_headers_by_active_record, header_name(name)]
|
13
13
|
@name = UiBibz::Utils::Internationalization.new(translate_headers_by_model, default: defaults).translate
|
14
14
|
sortable? ? sortable_link : title
|
15
15
|
end
|
@@ -20,6 +20,11 @@ module UiBibz::Ui::Ux
|
|
20
20
|
link_to title.html_safe, url_options, { class: cls }
|
21
21
|
end
|
22
22
|
|
23
|
+
def header_name name
|
24
|
+
name = name || @column.name.try('titleize')
|
25
|
+
name || @column.data_index.to_s.try('titleize')
|
26
|
+
end
|
27
|
+
|
23
28
|
def translate_headers_by_model
|
24
29
|
"ui_bibz.grid.headers.#{ @store.model.to_s.underscore }.#{ @column.data_index }"
|
25
30
|
end
|
@@ -39,6 +44,7 @@ module UiBibz::Ui::Ux
|
|
39
44
|
def url_options
|
40
45
|
args = {
|
41
46
|
controller: @store.controller,
|
47
|
+
id: @store.param_id,
|
42
48
|
action: @store.action,
|
43
49
|
search: @store.search,
|
44
50
|
sort: sort_name,
|