effective_datatables 1.2.0 → 1.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 +47 -0
- data/app/helpers/effective_datatables_helper.rb +1 -1
- data/lib/effective_datatables/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a42cb00a5e666c63e32719f2a374815565081d6f
|
4
|
+
data.tar.gz: 7240887e0bf62acfbf1b8c9ea84384e8cdb62dc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d21b2e00f36bb5ba1a8c10261b546898ac87e6e22aa180ac217d79fb3d6d147ac8982b31a62a3164a181bee2ee117ad83493fb069346124f5ba001c539e0bf1a
|
7
|
+
data.tar.gz: 660ba3f0de0836cdb7099176885930e1eab311fed4d57f7191de2251ae1f2b8c60d70c910fdb1295724145e63ba29836adfc4b9b57ed948a9e5dc4142e78b9aa
|
data/README.md
CHANGED
@@ -457,6 +457,53 @@ table_column :user_id, :if => Proc.new { attributes[:user_id].blank? } do |post|
|
|
457
457
|
end
|
458
458
|
```
|
459
459
|
|
460
|
+
### Helper methods
|
461
|
+
|
462
|
+
Any non-private methods defined in the datatable model will be available to your table_columns and evaluated in the view_context.
|
463
|
+
|
464
|
+
```ruby
|
465
|
+
module Effective
|
466
|
+
module Datatables
|
467
|
+
class Posts < Effective::Datatable
|
468
|
+
table_column :title do |post|
|
469
|
+
format_post_title(post)
|
470
|
+
end
|
471
|
+
|
472
|
+
def collection
|
473
|
+
Post.all
|
474
|
+
end
|
475
|
+
|
476
|
+
def format_post_title(post)
|
477
|
+
if post.title.start_with?('important')
|
478
|
+
link_to(post.title.upcase, post_path(post))
|
479
|
+
else
|
480
|
+
link_to(post.title, post_path(post))
|
481
|
+
end
|
482
|
+
end
|
483
|
+
|
484
|
+
end
|
485
|
+
end
|
486
|
+
end
|
487
|
+
```
|
488
|
+
|
489
|
+
You can also get the same functionality by including a regular Rails helper within the datatable model.
|
490
|
+
|
491
|
+
```ruby
|
492
|
+
module PostHelper
|
493
|
+
end
|
494
|
+
```
|
495
|
+
|
496
|
+
```ruby
|
497
|
+
module Effective
|
498
|
+
module Datatables
|
499
|
+
class Posts < Effective::Datatable
|
500
|
+
include PostsHelper
|
501
|
+
|
502
|
+
end
|
503
|
+
end
|
504
|
+
end
|
505
|
+
```
|
506
|
+
|
460
507
|
## Array Backed collection
|
461
508
|
|
462
509
|
Don't want to use ActiveRecord? Not a problem.
|
@@ -71,7 +71,7 @@ module EffectiveDatatablesHelper
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def datatables_admin_path?
|
74
|
-
(attributes[:admin_path] || request.referer.
|
74
|
+
(attributes[:admin_path] || request.referer.chomp('/').end_with?('/admin')) rescue false
|
75
75
|
end
|
76
76
|
|
77
77
|
# TODO: Improve on this
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_datatables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|