trk_datatables 0.2.3 → 0.2.4

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
  SHA256:
3
- metadata.gz: 2dc7cec68c0ec6e71ac428ac6a966f3db8ddc102d63c226dc52f619f10a5d41d
4
- data.tar.gz: 8ba50a886703bced435b29b696e35915215bfe018b6a5bd2a77c2b48568b0e4e
3
+ metadata.gz: 94acc0f23e22979cbdfbbd78356012328d0da999b00706bee6b8feb28e98c7bb
4
+ data.tar.gz: 458f2c1fdb9400faf491b494d5866b17397643464431bf8e6a4e115211cbbaca
5
5
  SHA512:
6
- metadata.gz: e1931363aa5fceb1393d961203b7c67d27e5dbe7ad8f4c45875e2c919ec1547257f0309ce68208f1cbfe58ad494168223c8958727cc5f875d15d702522aaf113
7
- data.tar.gz: e15ac3cc6eab551c55010e10fa9f39d465a35266ed07d2e9817f39d72c978e20648e8fef43d8a23467cb515d7ab83e2b33908b46e9d8813c65a3c6659923da44
6
+ metadata.gz: b48507c0815c0ab7946eb4fd770cdd317d5fceca8845c1f007556b627cfc5f77d5816497ed2825d1dce4974aa530def7bd455441e2f785131a6cd11fb1281614
7
+ data.tar.gz: 609e99cc22a0a195f3903af22f214d9ce8d6e5ffbf221862844389d3af3f0e90c30e82f66ad830d808bf97023f146655d2df55d76638033a2e4c3b733b0ab6e0
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trk_datatables (0.2.3)
4
+ trk_datatables (0.2.4)
5
5
  activesupport
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -18,6 +18,10 @@ you can get something like
18
18
 
19
19
  ![trk-datatables](test/trk_datatables_with_daterangepicker.png "TRK Datatables")
20
20
 
21
+ Currenlty it supports:
22
+ * ActiveRecord
23
+ * Neo4j
24
+
21
25
  ## Table of Contents
22
26
  <!--ts-->
23
27
  * [Trk Datatables](#trk-datatables)
@@ -502,10 +506,14 @@ class MostLikedPostsDatatable < TrkDatatables::ActiveRecord
502
506
  ))
503
507
  end
504
508
 
509
+ # This is used for filtering so you can move this to main query if
510
+ # you have { search: false }
505
511
  def title_and_body
506
512
  "concat(posts.title, ' ', posts.body)"
507
513
  end
508
514
 
515
+ # This is used for filtering so you can move this to main query if
516
+ # you have { search: false }
509
517
  def comments_count
510
518
  <<~SQL
511
519
  (SELECT COUNT(*) FROM comments
@@ -760,6 +768,36 @@ end
760
768
 
761
769
  ```
762
770
 
771
+ ## Neo4j
772
+
773
+ User `.as(:users)` so we know which node us used
774
+
775
+ ```
776
+ class UsersDatatable < TrkDatatables::Neo4j
777
+ def columns
778
+ {
779
+ 'users.email': {},
780
+ 'users.created_at': {},
781
+ }
782
+ end
783
+
784
+ def all_items
785
+ User
786
+ .as(:users)
787
+ .with_associations(moves: { from_group: [:location], to_groups: [:location] })
788
+ end
789
+
790
+ def rows(filtered)
791
+ filtered.map do |user|
792
+ [
793
+ @view.link_to(user.email, @view.admin_user_path(user)),
794
+ user.created_at.to_s(:long),
795
+ ]
796
+ end
797
+ end
798
+ end
799
+ ```
800
+
763
801
  ## Alternatives
764
802
 
765
803
  There are alternatives, for example:
@@ -12,6 +12,9 @@ module TrkDatatables
12
12
  end
13
13
  class StringCalculatedInDb < CalculatedInDb; end
14
14
  class IntegerCalculatedInDb < CalculatedInDb; end
15
+ class DateCalculatedInDb < CalculatedInDb; end
16
+ class DatetimeCalculatedInDb < CalculatedInDb; end
17
+ class BooleanCalculatedInDb < CalculatedInDb; end
15
18
 
16
19
  class ColumnKeyOptions
17
20
  include Enumerable
@@ -107,7 +110,7 @@ module TrkDatatables
107
110
  # in calculated columns table_name is used only to determine type
108
111
  column_key = column_name
109
112
  elsif table_name.present? && column_name.nil?
110
- raise Error, 'Unless table name ends with _calculad_in_db, column key needs to have one dot for example: posts.name'
113
+ raise Error, 'Unless table name ends with _calculated_in_db, column key needs to have one dot for example: posts.name'
111
114
  end
112
115
 
113
116
  if table_name.blank?
@@ -150,6 +153,8 @@ module TrkDatatables
150
153
  end
151
154
 
152
155
  def _set_global_search_cols(global_search_cols)
156
+ raise Error, 'global_search_cols should be array, for example %w[users.name]' unless global_search_cols.is_a? Array
157
+
153
158
  @global_search_cols = global_search_cols.each_with_object([]) do |column_key, arr|
154
159
  table_name, column_name = column_key.to_s.split '.'
155
160
  table_class = _determine_table_class table_name
@@ -191,7 +196,7 @@ module TrkDatatables
191
196
  end
192
197
 
193
198
  def _determine_column_name(table_class, column_name)
194
- return column_name.humanize if table_class.blank?
199
+ return column_name.titleize if table_class.blank?
195
200
 
196
201
  # maybe we should check if human_attribute_name exists
197
202
  table_class.human_attribute_name column_name
@@ -1,3 +1,3 @@
1
1
  module TrkDatatables
2
- VERSION = '0.2.3'.freeze
2
+ VERSION = '0.2.4'.freeze
3
3
  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.2.3
4
+ version: 0.2.4
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-09-09 00:00:00.000000000 Z
11
+ date: 2020-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport