mighty_grid 0.0.5 → 0.0.6
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28a9d936cc145275674c22df2de88c431524ae5b
|
4
|
+
data.tar.gz: 4e6db4d74e7ba04cdda5562d819a94d23982b8c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f037624c6a4f702cc5fa535eb774fdfa9a6cb2fc1cb2c623d734e202c87ef1be3c2fb2234e7c69c3c93de68ea899094ca8602218d9ac821b3beeaeb84768b6ac
|
7
|
+
data.tar.gz: 27beaa0e88adbe6ca4108b74aa6c49ac16b070173b7a45de5cc0d232248c2c6a1cf85cdb040a28dcf304755586de2e7988ba587c13e27a1637aa379daacc1872
|
data/README.md
CHANGED
@@ -21,6 +21,27 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
$ gem install mighty_grid
|
23
23
|
|
24
|
+
## Quick Start
|
25
|
+
|
26
|
+
### Controller
|
27
|
+
|
28
|
+
You can define class or relation in <tt>init_grid</tt> method.
|
29
|
+
```
|
30
|
+
def index
|
31
|
+
@products_grid = init_grid(Product)
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
### Show View
|
36
|
+
|
37
|
+
```
|
38
|
+
<%= grid @products_grid do |g| %>
|
39
|
+
<% - g.column :id %>
|
40
|
+
<% - g.column :name %>
|
41
|
+
<% - g.column :description %>
|
42
|
+
<% end %>
|
43
|
+
```
|
44
|
+
|
24
45
|
## Usage
|
25
46
|
|
26
47
|
### General configuration options
|
@@ -31,6 +52,8 @@ per_page # 15 by default
|
|
31
52
|
order_direction # 'asc' by default
|
32
53
|
grid_name # 'grid' by default
|
33
54
|
table_class # '' by default
|
55
|
+
header_tr_class # '' by default
|
56
|
+
pagination_theme # 'mighty_grid' by default
|
34
57
|
```
|
35
58
|
|
36
59
|
There's a handy generator that generates the default configuration file into config/initializers directory.
|
data/lib/mighty_grid/config.rb
CHANGED
@@ -15,7 +15,9 @@ module MightyGrid
|
|
15
15
|
config_accessor :per_page
|
16
16
|
config_accessor :order_direction
|
17
17
|
config_accessor :grid_name
|
18
|
+
config_accessor :header_tr_class
|
18
19
|
config_accessor :table_class
|
20
|
+
config_accessor :pagination_theme
|
19
21
|
end
|
20
22
|
|
21
23
|
configure do |config|
|
@@ -23,5 +25,7 @@ module MightyGrid
|
|
23
25
|
config.order_direction = 'asc'
|
24
26
|
config.grid_name = 'grid'
|
25
27
|
config.table_class = ''
|
28
|
+
config.header_tr_class = ''
|
29
|
+
config.pagination_theme = 'mighty_grid'
|
26
30
|
end
|
27
31
|
end
|
@@ -14,9 +14,12 @@ module MightyGrid
|
|
14
14
|
table_html_attrs = options[:html] || {}
|
15
15
|
table_html_attrs[:class] ||= ''
|
16
16
|
table_html_classes = ["mighty-grid"] + MightyGrid.config.table_class.split(' ')
|
17
|
-
table_html_attrs[:class] = (table_html_classes + table_html_attrs[:class].split(' ')).reject(&:blank?).join(' ')
|
17
|
+
table_html_attrs[:class] = (table_html_classes + table_html_attrs[:class].split(' ')).reject(&:blank?).uniq.join(' ')
|
18
18
|
|
19
19
|
header_tr_html = options[:header_tr_html] || {}
|
20
|
+
header_tr_html[:class] ||= ''
|
21
|
+
header_tr_html_classes = MightyGrid.config.header_tr_class.split(' ')
|
22
|
+
header_tr_html[:class] = (header_tr_html_classes + header_tr_html[:class].split(' ')).reject(&:blank?).uniq.join(' ')
|
20
23
|
|
21
24
|
grid.read
|
22
25
|
|
@@ -38,7 +41,7 @@ module MightyGrid
|
|
38
41
|
html += content_tag :tfoot do
|
39
42
|
html_record = content_tag :tr do
|
40
43
|
content_tag :td, colspan: rendering.total_columns do
|
41
|
-
html_pag = paginate(grid.relation, theme:
|
44
|
+
html_pag = paginate(grid.relation, theme: MightyGrid.config.pagination_theme, param_name: "#{grid.name}[page]")
|
42
45
|
html_pag += page_entries_info(grid.relation)
|
43
46
|
html_pag.html_safe
|
44
47
|
end
|
data/lib/mighty_grid/version.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -46,4 +46,26 @@ describe MightyGrid::Configuration do
|
|
46
46
|
after { MightyGrid.configure {|c| c.table_class = ''} }
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
describe 'header_tr_class' do
|
51
|
+
context 'by default' do
|
52
|
+
its(:header_tr_class) { should == '' }
|
53
|
+
end
|
54
|
+
context 'configured via config block' do
|
55
|
+
before { MightyGrid.configure {|c| c.header_tr_class = 'active'} }
|
56
|
+
its(:header_tr_class) { should == 'active' }
|
57
|
+
after { MightyGrid.configure {|c| c.header_tr_class = ''} }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'pagination_template' do
|
62
|
+
context 'by default' do
|
63
|
+
its(:pagination_theme) { should == 'mighty_grid' }
|
64
|
+
end
|
65
|
+
context 'configured via config block' do
|
66
|
+
before { MightyGrid.configure {|c| c.pagination_theme = 'pagination1'} }
|
67
|
+
its(:pagination_theme) { should == 'pagination1' }
|
68
|
+
after { MightyGrid.configure {|c| c.pagination_theme = 'mighty_grid'} }
|
69
|
+
end
|
70
|
+
end
|
49
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mighty_grid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jurrick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|