trk_datatables 0.1.24 → 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/Gemfile.lock +1 -1
- data/README.md +10 -9
- data/lib/generators/trk_datatables/trk_datatables_generator.rb +2 -2
- data/lib/trk_datatables/render_html.rb +5 -6
- data/lib/trk_datatables/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d75c4de5838a5899996deab1a0737969b6a04294f0de0e7a0e2af1c82713f01
|
4
|
+
data.tar.gz: a307532660a052632e782a2a47d837b6b22c6071c30ee18027b0020084cc275b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11532df36b2a5be0a3b942112943bbb1d6f4aeb229c986435e11316a826aab8c82117b9e4550334988ef0b06ab5ce19368db7dbc691aff49802a6cedf02b2d67
|
7
|
+
data.tar.gz: a59f1cd547aad4b95be0859aade92c9d1fc49e6d031bc09fdfc790f0742ee17b28644121dab6d5cbdc6e1dcaa5883557c088ea4f1345ca0f3f0fae4a4d395d63
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -5,16 +5,16 @@ used with [trk_datatables npm package](https://www.npmjs.com/package/trk_datatab
|
|
5
5
|
|
6
6
|
Instead of using Rails scaffold generator you can use advanced [Datatables plug-in for jQuery library](https://datatables.net).
|
7
7
|
|
8
|
-
After [
|
9
|
-
you can use one line
|
8
|
+
After [installation](https://github.com/trkin/trk_datatables#installation)
|
9
|
+
you can use one line command `@datatable.render_html` to generate index page
|
10
10
|
that supports: global search, filtering and sorting, first page is prerendered
|
11
|
-
(so non-js crawlers can see it),
|
11
|
+
(so non-js crawlers can see it), map and other interesting features.
|
12
12
|
|
13
|
-
So instead of basic Rails scaffold
|
13
|
+
So instead of basic Rails scaffold
|
14
14
|
|
15
15
|
![rails scaffold](test/scaffold.png "Rails default scaffold")
|
16
16
|
|
17
|
-
|
17
|
+
you can get something like
|
18
18
|
|
19
19
|
![trk-datatables](test/trk_datatables_with_daterangepicker.png "TRK Datatables")
|
20
20
|
|
@@ -72,7 +72,7 @@ document.addEventListener('turbolinks:load', () => {
|
|
72
72
|
trkDatatables.initialise()
|
73
73
|
})
|
74
74
|
|
75
|
-
# app/
|
75
|
+
# app/javascript/stylesheet/application.css
|
76
76
|
/* here we include other packages so postcss-import plugin will load css file from style attribute from package.json */
|
77
77
|
@import 'bootstrap'
|
78
78
|
|
@@ -91,7 +91,7 @@ module.exports = environment
|
|
91
91
|
<%= stylesheet_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
|
92
92
|
```
|
93
93
|
|
94
|
-
|
94
|
+
Than add a gem and sample PostsDatatable
|
95
95
|
|
96
96
|
```
|
97
97
|
# Gemfile
|
@@ -302,7 +302,7 @@ class PostsDatatable < TrkDatatables::ActiveRecord
|
|
302
302
|
def columns
|
303
303
|
{
|
304
304
|
'posts.created_at': {}, # this column will have predefined_ranges
|
305
|
-
'posts.
|
305
|
+
'posts.published_on': { predefined_ranges: false }
|
306
306
|
end
|
307
307
|
end
|
308
308
|
```
|
@@ -430,7 +430,7 @@ in multiple values use array `[Post.statuses[:draft]]`.
|
|
430
430
|
<%= link_to 'Active posts for my@email.com', \
|
431
431
|
posts_path(
|
432
432
|
PostsDatatable.param_set('users.email', 'my@email.com')
|
433
|
-
.deep_merge(PostsDatatable.param_set('posts.
|
433
|
+
.deep_merge(PostsDatatable.param_set('posts.published_on', Date.parse('2019-10-20')..Date.parse('2019-10-22')))
|
434
434
|
.deep_merge(PostsDatatable.param_set('posts.status', Post.statuses.values_at(:published, :promoted))
|
435
435
|
.deep_merge(user_id: 1)
|
436
436
|
)
|
@@ -647,6 +647,7 @@ release a new version, update the version number and then publish with
|
|
647
647
|
|
648
648
|
```
|
649
649
|
vi lib/trk_datatables/version.rb
|
650
|
+
git commit -am'...'
|
650
651
|
bundle
|
651
652
|
bundle exec rake release
|
652
653
|
```
|
@@ -25,7 +25,7 @@ module TrkDatatables
|
|
25
25
|
You can use in your controller
|
26
26
|
|
27
27
|
# app/controllers/#{plural_name}_controller.rb
|
28
|
-
class #{class_name}Controller < ApplicationController
|
28
|
+
class #{class_name.pluralize}Controller < ApplicationController
|
29
29
|
def index
|
30
30
|
@datatable = #{@trk_class_name}.new view_context
|
31
31
|
end
|
@@ -36,7 +36,7 @@ module TrkDatatables
|
|
36
36
|
end
|
37
37
|
|
38
38
|
In your views mkdir app/views/#{plural_name}
|
39
|
-
# app/views/#{plural_name}/index.html
|
39
|
+
# app/views/#{plural_name}/index.html.erb
|
40
40
|
<h1>#{class_name.pluralize}</h1>
|
41
41
|
<%= @datatable.render_html search_#{plural_name}_path(format: :json) %>
|
42
42
|
|
@@ -58,12 +58,11 @@ module TrkDatatables
|
|
58
58
|
end
|
59
59
|
# rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity
|
60
60
|
|
61
|
-
|
61
|
+
# [{ key: 'draft', value: 0}, {key: 'published', value: 1, selected: 'selected}]
|
62
|
+
def _select_find_options(options, search_value)
|
62
63
|
selected = search_value.to_s.split(MULTIPLE_OPTION_SEPARATOR)
|
63
|
-
|
64
|
-
|
65
|
-
_content_tag :option, {value: value}.merge(selected.include?(value.to_s) ? {selected: 'selected'} : {}), key
|
66
|
-
end)
|
64
|
+
options.map do |key, value|
|
65
|
+
{key: key, value: value}.merge(selected.include?(value.to_s) ? {selected: 'selected'} : {})
|
67
66
|
end
|
68
67
|
end
|
69
68
|
|
@@ -106,7 +105,7 @@ module TrkDatatables
|
|
106
105
|
options['data-datatable-search-value'] = search_value if search_value.present?
|
107
106
|
# add eventual select element
|
108
107
|
select_options = column_key_option[:column_options][ColumnKeyOptions::SELECT_OPTIONS]
|
109
|
-
options['data-datatable-multiselect'] =
|
108
|
+
options['data-datatable-multiselect'] = _select_find_options select_options, search_value if select_options.present?
|
110
109
|
# all other options are pulled from column_key_option[:html_options]
|
111
110
|
_content_tag :th, options, column_key_option[:title]
|
112
111
|
end)
|
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.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dusan Orlovic
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
206
|
- !ruby/object:Gem::Version
|
207
207
|
version: '0'
|
208
208
|
requirements: []
|
209
|
-
rubygems_version: 3.
|
209
|
+
rubygems_version: 3.0.3
|
210
210
|
signing_key:
|
211
211
|
specification_version: 4
|
212
212
|
summary: Gem that simplify using datatables with Ruby on Rails and Sinatra.
|