snaptable 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -2
- data/app/views/base.html.erb +28 -24
- data/lib/snaptable/rails/version.rb +1 -1
- data/lib/snaptable/version.rb +1 -1
- data/snaptable.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a329765ca3e389f8a39ad7df923654c54badf3c
|
4
|
+
data.tar.gz: b4d83a2d3295dc3cc22945a372500894144203da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9342e4c99c083163d97f48253a21063ec3fd5b5ffa488d5992f4d189e04503edbb2bf6c873cefe671734ba11a8f8264d09fde359a3fd5b0493ca8a682c57143
|
7
|
+
data.tar.gz: 157be0ae6d0afd21014f3c83ccb848f3a7f8d065e78ac9af42e33dbcc58a1b2b6d56761a363a8495ec830478839391795e840c196a5373631a1acf46b2565256
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Snaptable
|
2
2
|
|
3
|
-
A gem that generate HTML tables from your models to display in your admin views. It supports pagination
|
3
|
+
A gem that generate HTML tables from your models in order to display them in your admin views. It supports pagination, sorting and searching. It is also possible to customize the tables.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,7 +20,46 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
### Basic table
|
24
|
+
|
25
|
+
In your controller, instanciate a new `Table` with minimum two arguments: the controller itself and the model to use.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
@table = Table.new(self, Article)
|
29
|
+
```
|
30
|
+
|
31
|
+
Then, in order to enable sorting, call the method `respond` on the table.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
@table = Table.new(self, Article)
|
35
|
+
@table.respond
|
36
|
+
```
|
37
|
+
|
38
|
+
Finally, in your view, generate the table where you wish.
|
39
|
+
|
40
|
+
```html
|
41
|
+
<div>
|
42
|
+
<%= @table.present %>
|
43
|
+
</div>
|
44
|
+
```
|
45
|
+
|
46
|
+
### Options
|
47
|
+
|
48
|
+
You can customize the table when you instanciate it. Pass you own collection in the third argument.
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
@articles = Article.last(3)
|
52
|
+
Table.new(self, Article, @articles)
|
53
|
+
```
|
54
|
+
|
55
|
+
Pass the options in the fourth argument. Here is a list:
|
56
|
+
|
57
|
+
* buttons [true]: disable the buttons above the table to add, edit or destroy an element.
|
58
|
+
* search [false]: enable searching. Add a search field above the table.
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
Table.new(self, Article, nil, { search: true, buttons: false })
|
62
|
+
```
|
24
63
|
|
25
64
|
## Contributing
|
26
65
|
|
data/app/views/base.html.erb
CHANGED
@@ -1,25 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
<
|
1
|
+
<div id="admin_table">
|
2
|
+
|
3
|
+
<%= render 'search_field' if presenter.options[:search] == true %>
|
4
|
+
<%= render 'buttons' unless presenter.options[:buttons] == false %>
|
5
|
+
<table>
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
<% presenter.column_names.each do |column| %>
|
9
|
+
<th><%= presenter.sortable(column) %></th>
|
10
|
+
<% end %>
|
11
|
+
</tr>
|
12
|
+
</thead>
|
13
|
+
<tbody>
|
14
|
+
<% if presenter.records.any? %>
|
15
|
+
<% presenter.records.each do |record| %>
|
16
|
+
<tr class="<%= cycle('odd', 'even') %>" data-url="<%= presenter.url(record) %>">
|
17
|
+
<% presenter.values(record).each do |value| %>
|
18
|
+
<td><%= truncate((strip_tags value), length: 40) %></td>
|
19
|
+
<% end %>
|
20
|
+
</tr>
|
21
|
+
<% end %>
|
22
|
+
<% else %>
|
23
|
+
<tr><td class="none" colspan="<%= presenter.column_names.count %>">Il n'y a aucun élément à afficher.</td></tr>
|
8
24
|
<% end %>
|
9
|
-
</
|
10
|
-
</
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
<tr class="<%= cycle('odd', 'even') %>" data-url="<%= presenter.url(record) %>">
|
15
|
-
<% presenter.values(record).each do |value| %>
|
16
|
-
<td><%= truncate((strip_tags value), length: 40) %></td>
|
17
|
-
<% end %>
|
18
|
-
</tr>
|
19
|
-
<% end %>
|
20
|
-
<% else %>
|
21
|
-
<tr><td class="none" colspan="<%= presenter.column_names.count %>">Il n'y a aucun élément à afficher.</td></tr>
|
22
|
-
<% end %>
|
23
|
-
</tbody>
|
24
|
-
</table>
|
25
|
-
<%= will_paginate presenter.records %>
|
25
|
+
</tbody>
|
26
|
+
</table>
|
27
|
+
<%= will_paginate presenter.records %>
|
28
|
+
|
29
|
+
</div>
|
data/lib/snaptable/version.rb
CHANGED
data/snaptable.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snaptable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khcr
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 4.2.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: will_paginate
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0
|
55
69
|
description: A gem that generate HTML tables from your models to display in your admin
|
56
70
|
views.
|
57
71
|
email:
|