trk_datatables 0.1.15 → 0.1.16
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +31 -2
- data/lib/trk_datatables/base_helpers.rb +1 -1
- data/lib/trk_datatables/dt_params.rb +5 -1
- data/lib/trk_datatables/version.rb +1 -1
- data/lib/trk_datatables.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1aa2f1569881e6948b2c1adf114f495269fe7f95094b440e5090d16d17153ce
|
4
|
+
data.tar.gz: c976b45043a85ee2312654b4f0b02b79357f909c6cd161d0b04cf92148d310a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf9fd299b20ab006efca8570a88ac32564429daba58ec8c0e77a92cb62be660899d4e737822be3ab7f0d04176ac05f7e26286ee17765ebb37202d4496848b7bf
|
7
|
+
data.tar.gz: cfb2323199e837430283a31a12cd5998975943a5cfa269567933ca60acd5a6cfab356bb925631bafa3c1a7cee316316b1b0b8f9ce1aef602359e704e31c73f1c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -475,6 +475,30 @@ class PostsDatatable < TrkDatatables::ActiveRecord
|
|
475
475
|
end
|
476
476
|
```
|
477
477
|
|
478
|
+
## Test your datatables
|
479
|
+
|
480
|
+
Here is example how you can test
|
481
|
+
|
482
|
+
```
|
483
|
+
# test/datatables/happ
|
484
|
+
require 'test_helper'
|
485
|
+
|
486
|
+
class PostsDatatableTest < ActiveSupport::TestCase
|
487
|
+
def sample_view_params(params = {})
|
488
|
+
OpenStruct.new(
|
489
|
+
params: params
|
490
|
+
)
|
491
|
+
end
|
492
|
+
|
493
|
+
test 'find kayaking posts' do
|
494
|
+
results = PostsDatatable.new(sample_view_params(activity_names: [activities(:kayaking).name])).all_items
|
495
|
+
|
496
|
+
assert_includes results, posts(:kayak_regata)
|
497
|
+
refute_includes results, posts(:half_marathon)
|
498
|
+
end
|
499
|
+
end
|
500
|
+
```
|
501
|
+
|
478
502
|
## Debug
|
479
503
|
|
480
504
|
You can override some of the methos and put byebug, for example
|
@@ -513,8 +537,13 @@ You can also run `bin/console` for an interactive prompt that will allow you to
|
|
513
537
|
|
514
538
|
To install this gem onto your local machine, run `bundle exec rake install`. To
|
515
539
|
release a new version, update the version number in
|
516
|
-
`lib/trk_datatables/version.rb`, and then run
|
517
|
-
|
540
|
+
`lib/trk_datatables/version.rb`, and then run
|
541
|
+
|
542
|
+
```
|
543
|
+
bundle exec rake release
|
544
|
+
```
|
545
|
+
|
546
|
+
which will create a git tag for the version, push git commits and tags, and push the
|
518
547
|
`.gem` file to [rubygems.org](https://rubygems.org).
|
519
548
|
|
520
549
|
Instead of installing you can point directly to your path
|
@@ -34,7 +34,7 @@ module TrkDatatables
|
|
34
34
|
|
35
35
|
# For range you can this helper to insert BETWEEN_SEPARATOR
|
36
36
|
def range_string(range)
|
37
|
-
raise
|
37
|
+
raise Error, "#{range} is not a Range" unless range.is_a? Range
|
38
38
|
|
39
39
|
from = range.min
|
40
40
|
to = range.max
|
@@ -88,11 +88,13 @@ module TrkDatatables
|
|
88
88
|
|
89
89
|
def search_all
|
90
90
|
@params.dig(:search, :value) || ''
|
91
|
+
rescue TypeError => e
|
92
|
+
raise Error, e.message + '. Global search is in a format: { "search": { "value": "ABC" } }'
|
91
93
|
end
|
92
94
|
|
93
95
|
def as_json(all_count, filtered_items_count, data, additional = {})
|
94
96
|
additional = {} if additional.nil?
|
95
|
-
raise
|
97
|
+
raise Error, 'additional_data_for_json needs to be a hash' unless additional.is_a? Hash
|
96
98
|
|
97
99
|
draw = @params[:draw].to_i
|
98
100
|
{
|
@@ -114,6 +116,8 @@ module TrkDatatables
|
|
114
116
|
|
115
117
|
def param_get(column_index)
|
116
118
|
@params.dig :columns, column_index.to_s, :search, :value
|
119
|
+
rescue TypeError => e
|
120
|
+
raise Error, e.message + '. Column search is in a format: { "columns": { "0": { "search": { "value": { "ABC" } } } } }'
|
117
121
|
end
|
118
122
|
|
119
123
|
def self.sample_view_params(options = {})
|
data/lib/trk_datatables.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trk_datatables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dusan Orlovic
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|