ui_bibz 0.9.0
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 +7 -0
- data/.gitignore +44 -0
- data/.travis.yml +13 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +171 -0
- data/MIT-LICENSE +20 -0
- data/README.md +728 -0
- data/README.rdoc +0 -0
- data/Rakefile +34 -0
- data/config/locales/en.yml +14 -0
- data/config/locales/fr.yml +14 -0
- data/doc/images/alert.png +0 -0
- data/doc/images/breadcrumb.png +0 -0
- data/doc/images/button.png +0 -0
- data/doc/images/button_dropdown.png +0 -0
- data/doc/images/button_group.png +0 -0
- data/doc/images/button_link.png +0 -0
- data/doc/images/button_split_dropdown.png +0 -0
- data/doc/images/glyph.png +0 -0
- data/doc/images/list.png +0 -0
- data/doc/images/nav.png +0 -0
- data/doc/images/panel.png +0 -0
- data/doc/images/table.png +0 -0
- data/doc/images/table_pagination_per_page.png +0 -0
- data/doc/images/table_panel.png +0 -0
- data/doc/images/table_search_field.png +0 -0
- data/doc/images/ui-bibz-logo-without-border.gif +0 -0
- data/doc/images/ui-bibz-logo.gif +0 -0
- data/lib/tasks/ui_bibz_tasks.rake +4 -0
- data/lib/ui_bibz/concerns/models/searchable.rb +93 -0
- data/lib/ui_bibz/helpers/meta_helper.rb +27 -0
- data/lib/ui_bibz/helpers/ui_helper.rb +108 -0
- data/lib/ui_bibz/helpers/utils_helper.rb +9 -0
- data/lib/ui_bibz/rails/engine.rb +39 -0
- data/lib/ui_bibz/ui/alert.rb +67 -0
- data/lib/ui_bibz/ui/breadcrumb/breadcrumb.rb +54 -0
- data/lib/ui_bibz/ui/breadcrumb/components/breadcrumb_link.rb +62 -0
- data/lib/ui_bibz/ui/button/button.rb +65 -0
- data/lib/ui_bibz/ui/button/button_dropdown.rb +56 -0
- data/lib/ui_bibz/ui/button/button_group.rb +62 -0
- data/lib/ui_bibz/ui/button/button_link.rb +66 -0
- data/lib/ui_bibz/ui/button/button_split_dropdown.rb +80 -0
- data/lib/ui_bibz/ui/component.rb +137 -0
- data/lib/ui_bibz/ui/dropdown/components/dropdown_list.rb +73 -0
- data/lib/ui_bibz/ui/dropdown/dropdown.rb +101 -0
- data/lib/ui_bibz/ui/glyph.rb +92 -0
- data/lib/ui_bibz/ui/grid/components/col.rb +74 -0
- data/lib/ui_bibz/ui/grid/components/row.rb +32 -0
- data/lib/ui_bibz/ui/grid/grid.rb +108 -0
- data/lib/ui_bibz/ui/jumbotron.rb +58 -0
- data/lib/ui_bibz/ui/label.rb +58 -0
- data/lib/ui_bibz/ui/list/components/list.rb +105 -0
- data/lib/ui_bibz/ui/list/list_group.rb +78 -0
- data/lib/ui_bibz/ui/nav/components/nav_link.rb +68 -0
- data/lib/ui_bibz/ui/nav/nav.rb +65 -0
- data/lib/ui_bibz/ui/panel.rb +101 -0
- data/lib/ui_bibz/ui/table/components/actions.rb +44 -0
- data/lib/ui_bibz/ui/table/components/column.rb +34 -0
- data/lib/ui_bibz/ui/table/components/columns.rb +16 -0
- data/lib/ui_bibz/ui/table/components/store.rb +67 -0
- data/lib/ui_bibz/ui/table/components/table_action.rb +21 -0
- data/lib/ui_bibz/ui/table/table.rb +146 -0
- data/lib/ui_bibz/ui/table/table_pagination.rb +29 -0
- data/lib/ui_bibz/ui/table/table_pagination_per_page.rb +53 -0
- data/lib/ui_bibz/ui/table/table_panel.rb +66 -0
- data/lib/ui_bibz/ui/table/table_search_field.rb +62 -0
- data/lib/ui_bibz/ui/table/ux/actionable.rb +59 -0
- data/lib/ui_bibz/ui/table/ux/paginable.rb +35 -0
- data/lib/ui_bibz/ui/table/ux/searchable.rb +47 -0
- data/lib/ui_bibz/ui/table/ux/sortable.rb +93 -0
- data/lib/ui_bibz/ui/ui.rb +14 -0
- data/lib/ui_bibz/utils/internationalization.rb +30 -0
- data/lib/ui_bibz/version.rb +3 -0
- data/lib/ui_bibz.rb +60 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/models/user.rb +5 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +57 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20150123191721_user.rb +4 -0
- data/test/dummy/db/migrate/20150123191805_create_users.rb +12 -0
- data/test/dummy/db/schema.rb +25 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/fixtures/users.yml +13 -0
- data/test/dummy/test/models/user_test.rb +7 -0
- data/test/factories/user.rb +8 -0
- data/test/store_test.rb +46 -0
- data/test/support/factory_girl.rb +6 -0
- data/test/test_helper.rb +23 -0
- data/test/ui/button_test.rb +56 -0
- data/test/ui/component_test.rb +21 -0
- data/test/ui/dropdown_test.rb +18 -0
- data/test/ui/glyph_test.rb +23 -0
- data/test/ui/grid_test.rb +46 -0
- data/test/ui/list_group_test.rb +28 -0
- data/test/ui/nav_test.rb +27 -0
- data/test/ui/panel_test.rb +52 -0
- data/test/ui/table_test.rb +178 -0
- data/test/ui_bibz_test.rb +13 -0
- data/test/ui_helper_test.rb +44 -0
- data/ui_bibz.gemspec +36 -0
- data/vendor/assets/javascripts/ui_bibz.js.coffee +24 -0
- data/vendor/assets/stylesheets/ui_bibz.sass +46 -0
- metadata +398 -0
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'UiBibz'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/doc/images/list.png
ADDED
Binary file
|
data/doc/images/nav.png
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module UiBibz::Concerns::Models::Searchable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# Maybe create a class to put all methods of table_search_pagination
|
6
|
+
def self.table_search_pagination params, session, args = {}
|
7
|
+
@params = params
|
8
|
+
@session = session
|
9
|
+
@arguments = args
|
10
|
+
OpenStruct.new(records: search_sort_paginate,
|
11
|
+
model: self,
|
12
|
+
controller: params[:controller],
|
13
|
+
direction: params[:direction],
|
14
|
+
search: params[:search],
|
15
|
+
sort: params[:sort],
|
16
|
+
searchable_attributes: @searchable_attributes,
|
17
|
+
action: params[:action])
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def self.search
|
24
|
+
sql = all
|
25
|
+
column_args = get_column_args
|
26
|
+
|
27
|
+
# Add joins
|
28
|
+
sql = joins(column_args[:joins]) if column_args[:joins]
|
29
|
+
|
30
|
+
# Append special argument for sort countable
|
31
|
+
sql = generate_select_count_sort_query sql, column_args if column_args[:count]
|
32
|
+
|
33
|
+
# Manage parent sort in the same model
|
34
|
+
sql = generate_parent_sort_query sql if @params[:parent]
|
35
|
+
|
36
|
+
# Main query with argument or not
|
37
|
+
sql = search_by_query sql unless @params[:search].blank?
|
38
|
+
|
39
|
+
# Select Count or Not
|
40
|
+
if column_args[:count]
|
41
|
+
sq = "SELECT * FROM (#{ sql.group(table_name + '.id').to_sql }) countable ORDER BY countable.count #{ @params[:direction] || asc }"
|
42
|
+
self.paginate_by_sql(sq, :page => @params[:page], per_page: @session[:per_page])
|
43
|
+
else
|
44
|
+
sql.order(order_sql).paginate(:page => @params[:page], per_page: @session[:per_page])
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.generate_select_count_sort_query sql, column_args
|
50
|
+
sql.select("#{ table_name }.*, count(#{ column_args[:column] }.*)")
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.generate_parent_sort_query sql
|
54
|
+
sql.select("#{ table_name }2.*, #{ @params[:sort] } AS parent_name").from("#{ table_name } #{ table_name }2").joins("LEFT OUTER JOIN #{ table_name } ON #{ table_name }2.parent_id = #{ table_name }.id")
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.get_column_args
|
58
|
+
column_args = {}
|
59
|
+
if !@arguments[:sortable].nil? && @params[:custom_sort]
|
60
|
+
column_args = [@arguments[:sortable]].flatten.detect{|f| f[:column] = @params[:column_name] } || {}
|
61
|
+
end
|
62
|
+
column_args
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.search_by_query sql
|
66
|
+
sql_query = []
|
67
|
+
sql_attributes = {}
|
68
|
+
|
69
|
+
@searchable_attributes.each do |attribute|
|
70
|
+
sql_query << "lower(#{ self.to_s.downcase.pluralize }.#{ attribute }) LIKE :#{ attribute }"
|
71
|
+
sql_attributes = sql_attributes.merge(Hash[attribute, "%#{ @params[:search].downcase }%"])
|
72
|
+
end
|
73
|
+
|
74
|
+
sql.where([sql_query.join(' OR '), sql_attributes])
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.order_sql
|
78
|
+
@params[:sort].nil? || @params[:direction].nil? ? "#{ self.table_name }.id asc" : "#{ @params[:sort]} #{ @params[:direction] }"
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.search_sort_paginate
|
82
|
+
@session[:per_page] = @params[:per_page] unless @params[:per_page].nil?
|
83
|
+
self.search
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
module ClassMethods
|
88
|
+
def searchable_attributes *args
|
89
|
+
@searchable_attributes ||= args
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module UiBibz::Helpers::MetaHelper
|
2
|
+
|
3
|
+
# Returns html script tags to include boostrap 3.3.1 [js,css], jquery 2.1.1 [js],
|
4
|
+
# font-awesome 4.2.0 [css]
|
5
|
+
#
|
6
|
+
# ui_bibz_meta_links
|
7
|
+
# # => <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" media="screen" rel="stylesheet" />
|
8
|
+
# # <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" media="screen" rel="stylesheet" />
|
9
|
+
# # <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css" media="screen" rel="stylesheet" />
|
10
|
+
# # <script src=="https://code.jquery.com/jquery-2.1.1.min.js"></script>
|
11
|
+
# # <script src=="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
|
12
|
+
def ui_bibz_meta_links
|
13
|
+
capture do
|
14
|
+
# Latest compiled and minified CSS
|
15
|
+
concat stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"
|
16
|
+
# font awesome icons
|
17
|
+
concat stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css"
|
18
|
+
# Optional theme
|
19
|
+
concat stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css"
|
20
|
+
# Jquery is required for boostrap
|
21
|
+
concat javascript_include_tag 'https://code.jquery.com/jquery-2.1.1.min.js'
|
22
|
+
# Latest compiled and minified JavaScript
|
23
|
+
concat javascript_include_tag "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module UiBibz::Helpers::UiHelper
|
2
|
+
|
3
|
+
def panel content = nil, options = nil, html_options = nil, &block
|
4
|
+
is_tap = (content[:tap] if content.kind_of?(Hash)) || (options[:tap] unless options.nil?)
|
5
|
+
if is_tap
|
6
|
+
UiBibz::Ui::Panel.new(content, options, html_options).tap(&block).render
|
7
|
+
else
|
8
|
+
UiBibz::Ui::Panel.new(content, options, html_options, &block).render
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Use "notify" instead of "alert" : due to "actionview (4.2.0) lib/action_view/helpers/form_helper.rb" conflict
|
13
|
+
def notify content = nil, options = nil, html_options = nil, &block
|
14
|
+
UiBibz::Ui::Alert.new(content, options, html_options, &block).render
|
15
|
+
end
|
16
|
+
|
17
|
+
# Use "lab" instead of "label" : due to "actionview (4.2.0) lib/action_view/helpers/form_helper.rb" conflict
|
18
|
+
def lab content = nil, options = nil, html_options = nil, &block
|
19
|
+
UiBibz::Ui::Label.new(content, options, html_options, &block).render
|
20
|
+
end
|
21
|
+
|
22
|
+
def jumbotron content = nil, options = nil, html_options = nil, &block
|
23
|
+
UiBibz::Ui::Jumbotron.new(content, options, html_options, &block).render
|
24
|
+
end
|
25
|
+
|
26
|
+
def nav content = nil, options = nil, html_options = nil, &block
|
27
|
+
UiBibz::Ui::Nav.new(content, options, html_options).tap(&block).render
|
28
|
+
end
|
29
|
+
|
30
|
+
def list_group content = nil, options = nil, html_options = nil, &block
|
31
|
+
UiBibz::Ui::ListGroup.new(content, options, html_options).tap(&block).render
|
32
|
+
end
|
33
|
+
|
34
|
+
def grid options = nil, html_options = nil, &block
|
35
|
+
UiBibz::Ui::Grid.new(options, html_options).tap(&block).render
|
36
|
+
end
|
37
|
+
|
38
|
+
# Table section begin ------------------------------------------------------
|
39
|
+
|
40
|
+
def table content = nil, options = nil, html_options = nil, &block
|
41
|
+
is_tap = (content[:tap] if content.kind_of?(Hash)) || (options[:tap] unless options.nil?)
|
42
|
+
if is_tap
|
43
|
+
UiBibz::Ui::Table.new(content, options, html_options).tap(&block).render
|
44
|
+
else
|
45
|
+
UiBibz::Ui::Table.new(content, options, html_options, &block).render
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def table_search_field options, html_options = nil
|
50
|
+
UiBibz::Ui::TableSearchField.new(options, html_options).render
|
51
|
+
end
|
52
|
+
|
53
|
+
def table_pagination_per_page options, html_options = nil
|
54
|
+
UiBibz::Ui::TablePaginationPerPage.new(options, html_options).render
|
55
|
+
end
|
56
|
+
|
57
|
+
def table_pagination options, html_options = nil
|
58
|
+
UiBibz::Ui::TablePagination.new(options, html_options).render
|
59
|
+
end
|
60
|
+
|
61
|
+
def table_panel content = nil, options = nil, html_options = nil, &block
|
62
|
+
is_tap = (content[:tap] if content.kind_of?(Hash)) || (options[:tap] unless options.nil?)
|
63
|
+
if is_tap
|
64
|
+
UiBibz::Ui::TablePanel.new(content, options, html_options).tap(&block).render
|
65
|
+
else
|
66
|
+
UiBibz::Ui::TablePanel.new(content, options, html_options, &block).render
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Table section end -------------------------------------------------------
|
71
|
+
|
72
|
+
# Button section begin ----------------------------------------------------
|
73
|
+
|
74
|
+
def button_link content = nil, options = nil, html_options = nil, &block
|
75
|
+
UiBibz::Ui::ButtonLink.new(content, options, html_options, &block).render
|
76
|
+
end
|
77
|
+
|
78
|
+
def button_group content = nil, options = nil, html_options = nil, &block
|
79
|
+
UiBibz::Ui::ButtonGroup.new(content, options, html_options, &block).render
|
80
|
+
end
|
81
|
+
|
82
|
+
def button content = nil, options = nil, html_options = nil, &block
|
83
|
+
UiBibz::Ui::Button.new(content, options, html_options, &block).render
|
84
|
+
end
|
85
|
+
|
86
|
+
def button_dropdown name, options = nil, html_options = nil, &block
|
87
|
+
UiBibz::Ui::ButtonDropdown.new(name, options, html_options).tap(&block).render
|
88
|
+
end
|
89
|
+
|
90
|
+
def button_split_dropdown name, options = nil, html_options = nil, &block
|
91
|
+
UiBibz::Ui::ButtonSplitDropdown.new(name, options, html_options).tap(&block).render
|
92
|
+
end
|
93
|
+
|
94
|
+
# Button section end ----------------------------------------------------
|
95
|
+
|
96
|
+
def breadcrumb content = nil, options = nil, html_options = nil, &block
|
97
|
+
UiBibz::Ui::Breadcrumb.new(content, options, html_options).tap(&block).render
|
98
|
+
end
|
99
|
+
|
100
|
+
def dropdown name, options = nil, html_options = nil, &block
|
101
|
+
UiBibz::Ui::Dropdown.new(name, options, html_options).tap(&block).render
|
102
|
+
end
|
103
|
+
|
104
|
+
def glyph content, options = nil, html_options = nil, &block
|
105
|
+
UiBibz::Ui::Glyph.new(content, options, html_options, &block).render
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# to load pagination in rails app
|
2
|
+
require 'will_paginate'
|
3
|
+
|
4
|
+
module UiBibz
|
5
|
+
module Rails
|
6
|
+
class Engine < ::Rails::Engine
|
7
|
+
|
8
|
+
initializer "ui_bibz.helpers" do
|
9
|
+
ActionView::Base.send :include, UiBibz::Helpers::UiHelper
|
10
|
+
ActionView::Base.send :include, UiBibz::Helpers::UtilsHelper
|
11
|
+
ActionView::Base.send :include, UiBibz::Helpers::MetaHelper
|
12
|
+
end
|
13
|
+
|
14
|
+
#initializer 'ui_bibz.include_concerns' do
|
15
|
+
# #ActiveRecord::Base.send :include, UiBibz::Concerns::Models
|
16
|
+
# ActionDispatch::Reloader.to_prepare do
|
17
|
+
# ActionDispatch::Base.send :include, UiBibz::Concerns::Models
|
18
|
+
# #ActionDispatch::Base.send :include, UiBibz::Concerns::Models
|
19
|
+
# end
|
20
|
+
#end
|
21
|
+
|
22
|
+
# Autoload from lib directory
|
23
|
+
#config.autoload_paths << File.expand_path('../../', __FILE__)
|
24
|
+
|
25
|
+
# # Maybe remove ?
|
26
|
+
# initializer "ui_bibz.load_app_instance_data" do |app|
|
27
|
+
# UiBibz.setup do |config|
|
28
|
+
# config.app_root = app.root
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
|
32
|
+
# # Maybe remove ?
|
33
|
+
# initializer "ui_bibz.load_static_assets" do |app|
|
34
|
+
# app.middleware.use ::ActionDispatch::Static, "#{root}/public"
|
35
|
+
# end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module UiBibz::Ui
|
2
|
+
|
3
|
+
# Create an alert
|
4
|
+
#
|
5
|
+
# This element is an extend of UiBibz::Ui::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
|
+
# * +glyph+ - Add glyph with name or hash options
|
20
|
+
# * +name+ - String
|
21
|
+
# * +size+ - Integer
|
22
|
+
# * +type+ - Symbol
|
23
|
+
#
|
24
|
+
# ==== Signatures
|
25
|
+
#
|
26
|
+
# UiBibz::Ui::Alert.new(content, options = nil, html_options = nil)
|
27
|
+
#
|
28
|
+
# UiBibz::Ui::Alert.new(options = nil, html_options = nil) do
|
29
|
+
# content
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# ==== Examples
|
33
|
+
#
|
34
|
+
# UiBibz::Ui::Alert.new(content, { type: :success, glyph: 'eye' },{ class: 'test' }).render
|
35
|
+
# # or
|
36
|
+
# UiBibz::Ui::Alert.new({glyph: { name: 'eye', size: 3}, { class: 'test' }) do
|
37
|
+
# content
|
38
|
+
# end.render
|
39
|
+
#
|
40
|
+
class Alert < Component
|
41
|
+
|
42
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
43
|
+
super
|
44
|
+
end
|
45
|
+
|
46
|
+
def render
|
47
|
+
content_tag :div, class_and_html_options('alert').merge({ role: 'alert'}) do
|
48
|
+
concat glyph_and_content_html
|
49
|
+
concat close_html if @options[:close]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def close_html
|
56
|
+
content_tag :button, type: 'button', class: 'close', "data-dismiss" => "alert", "aria-label" => "Close" do
|
57
|
+
content_tag :span, "x", "aria-hidden" => true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def state
|
62
|
+
sym = @options[:state] || :info
|
63
|
+
"alert-#{ states[sym] }"
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'ui_bibz/ui/breadcrumb/components/breadcrumb_link'
|
2
|
+
module UiBibz::Ui
|
3
|
+
class Breadcrumb < Component
|
4
|
+
|
5
|
+
# Create a breadcrumb
|
6
|
+
#
|
7
|
+
# This element is an extend of UiBibz::Ui::Component.
|
8
|
+
# You can use tap method to add link items.
|
9
|
+
#
|
10
|
+
# ==== Attributes
|
11
|
+
#
|
12
|
+
# * +content+ - Content of element
|
13
|
+
# * +options+ - Options of element
|
14
|
+
# * +html_options+ - Html Options of element
|
15
|
+
#
|
16
|
+
# ==== Signatures
|
17
|
+
#
|
18
|
+
# UiBibz::Ui::Breadcrumb.new().tap do |b|
|
19
|
+
# b.link content = nil, options = nil, html_options = nil, &block
|
20
|
+
# b.link content = nil, options = nil, html_options = nil, &block
|
21
|
+
# b.link content = nil, options = nil, html_options = nil, &block
|
22
|
+
# ...
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# UiBibz::Ui::Alert.new(options = nil, html_options = nil) do
|
26
|
+
# content
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# ==== Examples
|
30
|
+
#
|
31
|
+
# UiBibz::Ui::Breadcrumb.new().tap do |b|
|
32
|
+
# b.link 'Home', url: '#home'
|
33
|
+
# b.link url: '#level-1' do
|
34
|
+
# 'Level 1'
|
35
|
+
# end
|
36
|
+
# b.link 'Level 2', status: :active
|
37
|
+
# end.render
|
38
|
+
#
|
39
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
40
|
+
super
|
41
|
+
@links = []
|
42
|
+
end
|
43
|
+
|
44
|
+
def render
|
45
|
+
content_tag :ol, @links.join.html_safe, class_and_html_options("breadcrumb")
|
46
|
+
end
|
47
|
+
|
48
|
+
# See UiBibz::Ui::BreadcrumbLink
|
49
|
+
def link content = nil, options = nil, html_options = nil, &block
|
50
|
+
@links << BreadcrumbLink.new(content, options, html_options, &block).render
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module UiBibz::Ui
|
2
|
+
|
3
|
+
# Create a BreadcrumbLink
|
4
|
+
#
|
5
|
+
# This element is an extend of UiBibz::Ui::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+ - State of élement with symbol value:
|
18
|
+
# (+:active+)
|
19
|
+
# * +url+ - String
|
20
|
+
# * +glyph+ - Add glyph with name or hash options
|
21
|
+
# * +name+ - String
|
22
|
+
# * +size+ - Integer
|
23
|
+
# * +type+ - Symbol
|
24
|
+
#
|
25
|
+
# ==== Signatures
|
26
|
+
#
|
27
|
+
# UiBibz::Ui::BreadcrumbLink.new(content, options = nil, html_options = nil)
|
28
|
+
#
|
29
|
+
# UiBibz::Ui::BreadcrumbLink.new(options = nil, html_options = nil) do
|
30
|
+
# content
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# ==== Examples
|
34
|
+
#
|
35
|
+
# UiBibz::Ui::BreadcrumbLink.new('Home', { glyph: 'home', status: :active },{ class: 'test' }).render
|
36
|
+
#
|
37
|
+
# UiBibz::Ui::BreadcrumbLink.new({glyph: { name: 'eye', size: 3}, { class: 'test' }) do
|
38
|
+
# 'Home'
|
39
|
+
# end.render
|
40
|
+
#
|
41
|
+
class BreadcrumbLink < Component
|
42
|
+
|
43
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
def render
|
48
|
+
content_tag :li, link_html, class_and_html_options
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def link_html
|
54
|
+
if @options[:url]
|
55
|
+
link_to glyph_and_content_html, @options[:url], @options[:link_html_options]
|
56
|
+
else
|
57
|
+
glyph_and_content_html
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module UiBibz::Ui
|
2
|
+
|
3
|
+
# Create a button
|
4
|
+
#
|
5
|
+
# This element is an extend of UiBibz::Ui::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
|
+
# * +size+
|
20
|
+
# (+:xs+, +:sm+, +:lg+)
|
21
|
+
# * +glyph+ - Add glyph with name or hash options
|
22
|
+
# * +name+ - String
|
23
|
+
# * +size+ - Integer
|
24
|
+
# * +type+ - Symbol
|
25
|
+
#
|
26
|
+
# ==== Signatures
|
27
|
+
#
|
28
|
+
# UiBibz::Ui::Button.new(content, options = nil, html_options = nil)
|
29
|
+
#
|
30
|
+
# UiBibz::Ui::Button.new(options = nil, html_options = nil) do
|
31
|
+
# content
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# ==== Examples
|
35
|
+
#
|
36
|
+
# UiBibz::Ui::Button.new('test', type: :primary, size: :xs).render
|
37
|
+
#
|
38
|
+
# UiBibz::Ui::Button.new(type: :primary) do
|
39
|
+
# test
|
40
|
+
# end.render
|
41
|
+
#
|
42
|
+
class Button < Component
|
43
|
+
|
44
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
45
|
+
super
|
46
|
+
end
|
47
|
+
|
48
|
+
def render
|
49
|
+
content_tag :button, glyph_and_content_html, class_and_html_options(['btn', size])
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def state
|
55
|
+
sym = @options[:state] || :default
|
56
|
+
"btn-#{ states[sym] }"
|
57
|
+
end
|
58
|
+
|
59
|
+
# :lg, :sm or :xs
|
60
|
+
def size
|
61
|
+
"btn-#{ @options[:size] }" if @options[:size]
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|