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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41a46aa96e307baf3ccdf299cdf0775f37d558e1
4
- data.tar.gz: bac55a7791146152abeb42727d92c0287434f8e7
3
+ metadata.gz: 2a329765ca3e389f8a39ad7df923654c54badf3c
4
+ data.tar.gz: b4d83a2d3295dc3cc22945a372500894144203da
5
5
  SHA512:
6
- metadata.gz: dcca510c040d61d7dd672c93951ad9cc3198fb208d03c4d705d732ad50758615c87f3dd3dd01180be747851ad0fc227a918052bcfd89a58645af50aa6a7dff7b
7
- data.tar.gz: 8456f737cdf4b70d0e7ae6b2f7adb7c7ab5bb7af6a87a309df92ca219b26ac4ac30e973e121f38a049d14b6de3fafcaea4d10c30d1c54f12be961bd948ad05e0
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 (carrierwave), sorting and searching. It is also possible to customize the tables.
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
- TODO: Write usage instructions here
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
 
@@ -1,25 +1,29 @@
1
- <%= render 'search_field' if presenter.options[:search] == true %>
2
- <%= render 'buttons' unless presenter.options[:buttons] == false %>
3
- <table>
4
- <thead>
5
- <tr>
6
- <% presenter.column_names.each do |column| %>
7
- <th><%= presenter.sortable(column) %></th>
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
- </tr>
10
- </thead>
11
- <tbody>
12
- <% if presenter.records.any? %>
13
- <% presenter.records.each do |record| %>
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>
@@ -1,5 +1,5 @@
1
1
  module Snaptable
2
2
  module Rails
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module Snaptable
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/snaptable.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
 
25
25
  spec.add_dependency "railties", ">= 4.2.0"
26
+ spec.add_dependency "will_paginate", ">= 3.0.0"
26
27
  end
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.0
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-06 00:00:00.000000000 Z
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: