tabulatr2 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/Changelog.textile +124 -0
- data/Gemfile +21 -0
- data/LICENSE +23 -0
- data/README.md +242 -0
- data/Rakefile +11 -0
- data/app/assets/images/tabulatr/buttons_lite_background.png +0 -0
- data/app/assets/images/tabulatr/pager_arrow_left.gif +0 -0
- data/app/assets/images/tabulatr/pager_arrow_left_off.gif +0 -0
- data/app/assets/images/tabulatr/pager_arrow_right.gif +0 -0
- data/app/assets/images/tabulatr/pager_arrow_right_off.gif +0 -0
- data/app/assets/images/tabulatr/sort_arrow_down.gif +0 -0
- data/app/assets/images/tabulatr/sort_arrow_down_off.gif +0 -0
- data/app/assets/images/tabulatr/sort_arrow_up.gif +0 -0
- data/app/assets/images/tabulatr/sort_arrow_up_off.gif +0 -0
- data/app/assets/javascripts/tabulatr/application.js +452 -0
- data/app/assets/javascripts/tabulatr/jquery.inview.min.js +3 -0
- data/app/assets/javascripts/tabulatr.js +1 -0
- data/app/assets/stylesheets/tabulatr/application.css +40 -0
- data/app/assets/stylesheets/tabulatr.css +4 -0
- data/init.rb +1 -0
- data/lib/generators/tabulatr/install_generator.rb +44 -0
- data/lib/generators/tabulatr/templates/tabulatr.rb +5 -0
- data/lib/generators/tabulatr/templates/tabulatr.yml +14 -0
- data/lib/initializers/action_controller.rb +13 -0
- data/lib/initializers/action_view.rb +31 -0
- data/lib/initializers/active_record.rb +48 -0
- data/lib/initializers/mark_as_localizable.rb +43 -0
- data/lib/tabulatr/engine.rb +3 -0
- data/lib/tabulatr/tabulatr/adapter/active_record.rb +84 -0
- data/lib/tabulatr/tabulatr/adapter.rb +55 -0
- data/lib/tabulatr/tabulatr/batch_actions.rb +51 -0
- data/lib/tabulatr/tabulatr/data_cell.rb +132 -0
- data/lib/tabulatr/tabulatr/dummy_record.rb +40 -0
- data/lib/tabulatr/tabulatr/empty_cell.rb +44 -0
- data/lib/tabulatr/tabulatr/filter_cell.rb +145 -0
- data/lib/tabulatr/tabulatr/filter_icon.rb +6 -0
- data/lib/tabulatr/tabulatr/finder/find_for_table.rb +187 -0
- data/lib/tabulatr/tabulatr/finder.rb +64 -0
- data/lib/tabulatr/tabulatr/formattr.rb +55 -0
- data/lib/tabulatr/tabulatr/header_cell.rb +146 -0
- data/lib/tabulatr/tabulatr/json_builder.rb +57 -0
- data/lib/tabulatr/tabulatr/paginator.rb +76 -0
- data/lib/tabulatr/tabulatr/row_builder.rb +128 -0
- data/lib/tabulatr/tabulatr/security.rb +21 -0
- data/lib/tabulatr/tabulatr/settings.rb +158 -0
- data/lib/tabulatr/tabulatr.rb +343 -0
- data/lib/tabulatr/version.rb +3 -0
- data/lib/tabulatr.rb +34 -0
- data/spec/dummy/.gitignore +18 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +16 -0
- data/spec/dummy/app/assets/stylesheets/application.css.scss +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/products_controller.rb +24 -0
- data/spec/dummy/app/controllers/tags_controller.rb +5 -0
- data/spec/dummy/app/controllers/vendors_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +9 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/product.rb +5 -0
- data/spec/dummy/app/models/tag.rb +3 -0
- data/spec/dummy/app/models/vendor.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/products/count_tags.html.erb +9 -0
- data/spec/dummy/app/views/products/one_item_per_page.html.erb +9 -0
- data/spec/dummy/app/views/products/simple_index.html.erb +9 -0
- data/spec/dummy/app/views/products/stupid_array.html.erb +20 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/tabulatr.rb +5 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/locales/tabulatr.yml +14 -0
- data/spec/dummy/config/routes.rb +13 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20130730132101_create_vendors.rb +12 -0
- data/spec/dummy/db/migrate/20130730132321_create_products.rb +12 -0
- data/spec/dummy/db/migrate/20130730132348_create_tags.rb +14 -0
- data/spec/dummy/db/schema.rb +47 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/features/tabulatrs_spec.rb +227 -0
- data/spec/lib/tabulatr/tabulatr/finder/find_for_table_spec.rb +187 -0
- data/spec/spec_helper.rb +45 -0
- data/tabulatr.gemspec +29 -0
- metadata +258 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ed16072e8467181351d73105aa639ef912bf45ac
|
4
|
+
data.tar.gz: 2687df6d54ad1eb562ec38af9ee643659103f51d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 94aa03bf3924604e5e9d884f58b61a605fdc2b79f557b0e40fb01953438c06f7a17516f2f6df7555ec1e2d3b27b29699744ba55c38a9cb7dd1d040aedae33ee4
|
7
|
+
data.tar.gz: 2b19e830e2ffd98159636950e057c8fc5939f9cf9922942af7d7f09326ec82bfa031497485f0d18f54b9f2b5dfce7db14b851df0f13d08753f1b436a87b660f8
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/.travis.yml
ADDED
data/Changelog.textile
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
h1. Changelog for tabulatr
|
2
|
+
|
3
|
+
* Fixed <tt>:filter_width</tt> not working for <tt>select</tt> filters.
|
4
|
+
* Giving a Hash as <tt>:format</tt> option gives the corresponding value.
|
5
|
+
* We now allow column presets:
|
6
|
+
<pre>
|
7
|
+
Tabulatr.config do |config|
|
8
|
+
#...
|
9
|
+
config.column_presets({
|
10
|
+
config.column_presets({
|
11
|
+
:action_column => {:width => '100px'},
|
12
|
+
:smallint => { :width => '55px', :filter_width => '30px', :align => 'right' },
|
13
|
+
:id => :smallint,
|
14
|
+
:sid => { :width => '200px', :filter_width => '170px', :filter => :like },
|
15
|
+
:title => { :filter => :like },
|
16
|
+
:count => { :map => false, :width => '40px', :filter => false, :align => 'right' },
|
17
|
+
:moo => { :width => '155px', :filter_width => '120px', :align => 'right' }
|
18
|
+
})
|
19
|
+
end
|
20
|
+
</pre>
|
21
|
+
|
22
|
+
Now, every column will check whether there is as entry corresponding to its name in this table and get the content as 'default' options.
|
23
|
+
|
24
|
+
<pre>
|
25
|
+
<%= table_for @regions do |t|
|
26
|
+
t.column :id
|
27
|
+
t.column :sid
|
28
|
+
# ...
|
29
|
+
end %>
|
30
|
+
</pre>
|
31
|
+
|
32
|
+
so, the :id column has all the options defined above. The :action_column entry is used for 'action' columns.
|
33
|
+
|
34
|
+
But even better, you can use arbitrary presets:
|
35
|
+
|
36
|
+
<pre>
|
37
|
+
t.column :foo, :preset => :moo
|
38
|
+
</pre>
|
39
|
+
|
40
|
+
gets the :moo preset.
|
41
|
+
|
42
|
+
h2. 0.4.2
|
43
|
+
|
44
|
+
* Fixed two more bugs breaking ruby 1.8 compatibility. (Thanks to <a href="https://github.com/moabite">moabite</a> for reporting)
|
45
|
+
|
46
|
+
h2. 0.4.1
|
47
|
+
|
48
|
+
* Fixed a "bug" breaking ruby 1.8 compatibility. (Thanks to <a href="https://github.com/moabite">moabite</a> for reporting)
|
49
|
+
|
50
|
+
h2. 0.4.0
|
51
|
+
|
52
|
+
* Mongoid now really works.
|
53
|
+
* A lot of cleanup in the finder code (million thanks to <a href="https://github.com/plukevdh">plukevdh</a>)
|
54
|
+
* You can use <tt>table_for</tt> for 'normal' arrays that weren't found with <tt>find_for_table</tt>.
|
55
|
+
* Added a :name_mapping option to find_for_table to allow filtering by compund expressions, example:
|
56
|
+
|
57
|
+
<pre>
|
58
|
+
@customers = Customer.find_for_table(params,
|
59
|
+
name_mapping: {
|
60
|
+
name: '("addresses"."firstname" || \' \' || "addresses"."lastname")',
|
61
|
+
address: '("addresses"."street" || \' \' || "addresses"."zip_code" || \' \' || "addresses"."city")'
|
62
|
+
},
|
63
|
+
default_order: 'updated_at desc'
|
64
|
+
)
|
65
|
+
</pre>
|
66
|
+
|
67
|
+
* Added Mysql2Adapter to the ActiveRecord connection list (thanks to <a href="https://github.com/AaronLasseigne">AaronLasseigne</a>).
|
68
|
+
* Monkeypatch mongoid only if it is present. (thanks to <a href="https://github.com/rwz">rwz</a>)
|
69
|
+
|
70
|
+
h2. 0.3.0
|
71
|
+
|
72
|
+
* Converted into a Rails 3.1 engine and moved css and images to use the new asset pipeline. Works with 3.0.x -- 'opefully. Thanks to all that reported the problem.
|
73
|
+
* Header cells are now auto translated. Thanks to <a href="https://github.com/niedhui">niedhui</a>!
|
74
|
+
|
75
|
+
h2. 0.2.1
|
76
|
+
|
77
|
+
* Fixed a ruby 1.8 syntax issue. (Thanks to <a href="https://github.com/TBAA">TBAA</a> for reporting.)
|
78
|
+
|
79
|
+
h2. 0.2.0
|
80
|
+
|
81
|
+
* Mongoid can also be used in place of ActiveRecord
|
82
|
+
* fixed handling of the primary_key column and name
|
83
|
+
* Added dom_id to tables tr. Thanks to <a href="https://github.com/sterrym">sterrym (Tim Glen)</a>!
|
84
|
+
* Added note on "Request-URI Too Large error" to README
|
85
|
+
|
86
|
+
h2. 0.1.3
|
87
|
+
|
88
|
+
* nicer table headers. Thanks to <a href="https://github.com/troya2" target="_blank">troya2 (Troy Anderson)</a>!
|
89
|
+
|
90
|
+
h2. 0.1.2
|
91
|
+
|
92
|
+
* Fixed bug with nil exception on 'empty' belongs_to association. Thanks to <a href="https://github.com/dgm" target="_blank">dgm</a>!
|
93
|
+
|
94
|
+
h2. 0.1.1
|
95
|
+
|
96
|
+
* Fixed bug with "Select ..." buttons introduced in 0.1.0.
|
97
|
+
* Added tests for these buttons.
|
98
|
+
|
99
|
+
h2. v0.1.0
|
100
|
+
|
101
|
+
* new <tt>find_for_table</tt> option <tt>:stateful</tt>. If
|
102
|
+
|
103
|
+
<pre>
|
104
|
+
MyFancyModel.find_for_table params, :stateful => session
|
105
|
+
</pre>
|
106
|
+
|
107
|
+
is given, the current sorting, filtering, selecting and paging information is stored to the session and restored when reopened. Great for procession specifically filtered lists.
|
108
|
+
|
109
|
+
h2. v0.0.5 (2011-03-28)
|
110
|
+
|
111
|
+
* new column option :map (defaults to true) to disable automatic mapping on the enries of the association as in
|
112
|
+
|
113
|
+
<pre>
|
114
|
+
<%= table_for @products do |t|
|
115
|
+
...
|
116
|
+
t.association :tags, :title # mapped to all tags
|
117
|
+
t.association :tags, :count, :map => false # called on the list-of-tags
|
118
|
+
end %>
|
119
|
+
</pre>
|
120
|
+
|
121
|
+
|
122
|
+
h2. v0.0.4 (2011-03-27)
|
123
|
+
|
124
|
+
* fixed the path to paging/sorting images installed by generator. Thanks to <a href="https://github.com/sdsykes" target="_blank">sdsykes</a>!
|
data/Gemfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem 'tabulatr2', path: './', require: 'tabulatr'
|
6
|
+
|
7
|
+
gem 'jquery-rails'
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
group :development, :test do
|
12
|
+
gem 'sqlite3', :require => 'sqlite3'
|
13
|
+
gem 'rspec'
|
14
|
+
gem 'rspec-rails'
|
15
|
+
gem 'capybara'
|
16
|
+
gem 'launchy'
|
17
|
+
gem 'database_cleaner', '< 1.1.0'
|
18
|
+
gem 'poltergeist'
|
19
|
+
gem 'sass-rails', '~> 4.0.0'
|
20
|
+
gem 'bootstrap-sass', github: 'thomas-mcdonald/bootstrap-sass', branch: '3'
|
21
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2010-2011 by Provideal GmbH, Peter Horn
|
4
|
+
http://www.provideal.net, peter.horn@provideal.net
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
14
|
+
all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
23
|
+
|
data/README.md
ADDED
@@ -0,0 +1,242 @@
|
|
1
|
+
# Tabulatr2 - Index Tables made easy
|
2
|
+
[![Code Climate](https://codeclimate.com/github/provideal/tabulatr2.png)](https://codeclimate.com/github/provideal/tabulatr2)
|
3
|
+
|
4
|
+
**WARNING: Tabulatr2 is not production ready yet!**
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Require tabulatr2 in your Gemfile:
|
9
|
+
```ruby
|
10
|
+
gem 'tabulatr2', github: 'provideal/tabulatr2', require: 'tabulatr'
|
11
|
+
```
|
12
|
+
After that run `bundle` and `rails g tabulatr:install`.
|
13
|
+
|
14
|
+
Also add `//= require tabulatr` to your application js file.
|
15
|
+
|
16
|
+
### Security
|
17
|
+
|
18
|
+
Tabulatr2 tries to do its best to secure your application. Specifically its secured against
|
19
|
+
an attacker who tries to change the parameters of the table and include e.g. a `password` field.
|
20
|
+
|
21
|
+
**Important:** But in order to make it so secure you have to alter the two `secret_tokens`
|
22
|
+
in your `config/initializers/tabulatr.rb` file to different values.
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
Tabulatr.config do |c|
|
26
|
+
c.secret_tokens = ['???', '???']
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
### Models
|
35
|
+
|
36
|
+
We suppose we have a couple of models
|
37
|
+
* tags has and belong to many products
|
38
|
+
* vendors have many products
|
39
|
+
* products belong to vendors and have and belong to many tags
|
40
|
+
|
41
|
+
## Controller
|
42
|
+
|
43
|
+
In `ProductsController#index` we have:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
def index
|
47
|
+
tabulatr_for Product
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
_Hint:_ If you want to prefilter your table, you can do that too! Just pass an `ActiveRecord::Relation` to `tabulatr_for`:
|
52
|
+
```ruby
|
53
|
+
def index
|
54
|
+
tabulatr_for Product.where(active: true)
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
### View
|
59
|
+
|
60
|
+
To get a simple Table, all we need to do is
|
61
|
+
|
62
|
+
```erb
|
63
|
+
<%= table_for Product do |t|
|
64
|
+
t.column :title
|
65
|
+
t.column :price
|
66
|
+
t.column :active
|
67
|
+
t.association :vendor, :name
|
68
|
+
t.association :tags, :title
|
69
|
+
end %>
|
70
|
+
```
|
71
|
+
|
72
|
+
To add a checkbox column just add
|
73
|
+
```ruby
|
74
|
+
t.checkbox
|
75
|
+
```
|
76
|
+
|
77
|
+
|
78
|
+
To add e.g. edit-buttons, we would specify
|
79
|
+
|
80
|
+
```erb
|
81
|
+
t.action do |record|
|
82
|
+
link_to "Edit", edit_product_path(record.id)
|
83
|
+
end
|
84
|
+
```
|
85
|
+
|
86
|
+
To add a select box with batch-actions (i.e., actions that are to be performed on all selected rows),
|
87
|
+
we add an option to the table_for:
|
88
|
+
|
89
|
+
```erb
|
90
|
+
<%= table_for Product, batch_actions: {'foo' => 'Foo', 'delete' => "Delete"} do |t|
|
91
|
+
...
|
92
|
+
end %>
|
93
|
+
```
|
94
|
+
|
95
|
+
To handle the actual batch action, we have to add a block to the `find_for_table` call in the controller:
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
tabulatr_for Product do |batch_actions|
|
99
|
+
batch_actions.delete do |ids|
|
100
|
+
ids.each do |id|
|
101
|
+
Product.find(id).destroy
|
102
|
+
end
|
103
|
+
redirect_to index_select_products_path()
|
104
|
+
return
|
105
|
+
end
|
106
|
+
batch_actions.foo do |ids|
|
107
|
+
... do whatever is foo-ish to the records
|
108
|
+
end
|
109
|
+
end
|
110
|
+
```
|
111
|
+
|
112
|
+
where the `ids` parameter to the block is actually an Array containing the numeric ids of the currently selected rows.
|
113
|
+
|
114
|
+
|
115
|
+
## Features
|
116
|
+
|
117
|
+
Tabulatr aims at making the ever-recurring task of creating listings of ActiveRecord models simple and uniform.
|
118
|
+
|
119
|
+
We found ourselves reinventing the wheel in every project we made, by using
|
120
|
+
|
121
|
+
* different paging mechanisms,
|
122
|
+
* different ways of implementing filtering/searching,
|
123
|
+
* different ways of implementing selecting and batch actions,
|
124
|
+
* different layouts.
|
125
|
+
|
126
|
+
We finally thought that whilst gems like Formtastic or SimpleForm provide a really cool, uniform
|
127
|
+
and concise way to implement forms, it's time for a table builder.
|
128
|
+
During a project with Magento, we decided that their general tables are quite reasonable,
|
129
|
+
and enterprise-proven -- so that's our starting point.
|
130
|
+
|
131
|
+
Tabulatr tries to make these common tasks as simple/transparent as possible:
|
132
|
+
* paging
|
133
|
+
* selecting/checking/marking
|
134
|
+
* filtering
|
135
|
+
* batch actions
|
136
|
+
|
137
|
+
|
138
|
+
## Options
|
139
|
+
|
140
|
+
|
141
|
+
### Table Options
|
142
|
+
|
143
|
+
These options are to be specified at the `table_for` level and change the appearance and behaviour of the table.
|
144
|
+
|
145
|
+
```ruby
|
146
|
+
:table_class => 'tabulatr_table', # class for the actual data table
|
147
|
+
:control_div_class_before => 'table-controls', # class of upper div containing the paging and batch action controls
|
148
|
+
:control_div_class_after => 'table-controls', # class of lower div containing the paging and batch action controls
|
149
|
+
:paginator_div_class => 'pagination', # class of the div containing the paging controls
|
150
|
+
|
151
|
+
# which controls to be rendered above and below the table and in which order
|
152
|
+
:before_table_controls => [:filter, :paginator],
|
153
|
+
:after_table_controls => [],
|
154
|
+
|
155
|
+
:table_html => false, # a hash with html attributes for the table
|
156
|
+
:row_html => false, # a hash with html attributes for the normal trs
|
157
|
+
:header_html => false, # a hash with html attributes for the header trs
|
158
|
+
:filter_html => false, # a hash with html attributes for the filter trs
|
159
|
+
:filter => true, # false for no filter row at all
|
160
|
+
:paginate => false, # true to show paginator, false for endless scrolling.
|
161
|
+
# number for limit of items to show via pagination
|
162
|
+
:sortable => true, # true to allow sorting (can be specified for every sortable column)
|
163
|
+
:batch_actions => false, # :name => value hash of batch action stuff
|
164
|
+
:footer_content => false, # if given, add a <%= content_for <footer_content> %> before the </table>
|
165
|
+
:path => '#' # where to send the AJAX-requests to
|
166
|
+
```
|
167
|
+
|
168
|
+
### Column Options
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
:header => false, # a string to write into the header cell
|
172
|
+
:width => false, # the width of the cell
|
173
|
+
:align => false, # horizontal alignment
|
174
|
+
:valign => false, # vertical alignment
|
175
|
+
:wrap => true, # wraps
|
176
|
+
:type => :string, # :integer, :date
|
177
|
+
:th_html => false, # a hash with html attributes for the header cell
|
178
|
+
:filter_html => false, # a hash with html attributes for the filter cell
|
179
|
+
:filter => true, # false for no filter field,
|
180
|
+
# container for options_for_select
|
181
|
+
# String from options_from_collection_for_select or the like
|
182
|
+
# :range for range spec
|
183
|
+
# :checkbox for a 0/1 valued checkbox
|
184
|
+
:checkbox_value => '1', # value if checkbox is checked
|
185
|
+
:checkbox_label => '', # text behind the checkbox
|
186
|
+
:filter_width => '97%', # width of the filter <input>
|
187
|
+
:range_filter_symbol => '–', # put between the <inputs> of the range filter
|
188
|
+
:sortable => true, # if set, sorting-stuff is added to the header cell
|
189
|
+
:format_methods => [] # javascript method to execute on this column
|
190
|
+
```
|
191
|
+
|
192
|
+
|
193
|
+
## Dependencies
|
194
|
+
|
195
|
+
We use [whiny_hash](http://github.com/provideal/whiny_hash) to handle the options in a fail-early-manner.
|
196
|
+
|
197
|
+
## Known Bugs
|
198
|
+
|
199
|
+
### Request-URI Too Large error
|
200
|
+
|
201
|
+
This is a problem particulary when using WEBrick, because WEBricks URIs must not exceed 2048 characters.
|
202
|
+
And this limit is hard-coded IIRC. So – If you run into this limitation –
|
203
|
+
please consider using another server.
|
204
|
+
(Thanks to [stepheneb](https://github.com/stepheneb) for calling my attention back to this.)
|
205
|
+
|
206
|
+
## Other, new bugs
|
207
|
+
|
208
|
+
There are roughly another 997 bugs in Tabulatr2, although we do some testing.
|
209
|
+
If you hunt them, please file an issue.
|
210
|
+
|
211
|
+
## Contributing
|
212
|
+
|
213
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
214
|
+
* Check out the Issue tracker to make sure someone already hasn't requested it and/or contributed it
|
215
|
+
* Fork the project
|
216
|
+
* Start a feature/bugfix branch
|
217
|
+
* Commit and push until you are happy with your contribution
|
218
|
+
* Make sure to add tests for it, run them via `rspec spec` and check that they all pass.
|
219
|
+
* Please try not to mess with the Rakefile, version, or history.
|
220
|
+
If you want to have your own version, or is otherwise necessary, that is fine,
|
221
|
+
but please isolate to its own commit so I can cherry-pick around it.
|
222
|
+
* Feel free to send a pull request if you think others (me, for example) would like to have your change
|
223
|
+
incorporated into future versions of tabulatr.
|
224
|
+
|
225
|
+
## MIT License
|
226
|
+
|
227
|
+
Copyright (c) 2010-2013 Peter Horn, Provideal GmbH</a>
|
228
|
+
|
229
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
230
|
+
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
231
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
232
|
+
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
233
|
+
subject to the following conditions:
|
234
|
+
|
235
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
236
|
+
portions of the Software.
|
237
|
+
|
238
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
239
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
240
|
+
AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
241
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
242
|
+
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require 'bundler'
|
5
|
+
Bundler::GemHelper.install_tasks
|
6
|
+
|
7
|
+
require 'rspec/core'
|
8
|
+
require 'rspec/core/rake_task'
|
9
|
+
RSpec::Core::RakeTask.new(:spec)
|
10
|
+
|
11
|
+
task :default => :spec
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|