tabulatr2 0.9.38 → 0.9.43

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: 5fed58d0f324fcdad7814934b71ad0d1d98bb645f1cd3d11556c6cb78e59cd10
4
- data.tar.gz: 8490c3dd434a56a6861332d40263c8e09433381b43df97a3487d8ff01c0b6c9b
3
+ metadata.gz: 2fd922d9e3607591509ce645ab120be41b1684a9186cf3cd3ee8349aa448d4b3
4
+ data.tar.gz: 9437dec7454741490fb08c3866189ddaa52fd880c383554141d65de70351214e
5
5
  SHA512:
6
- metadata.gz: 8c815d8cac08355567a8744909fc56de7968b54ab0378cb0726d97b90e71ca7a3563b9c3aa6d0fe40679a86f2ecf738bb6915519338b86dc10857f5e76101d95
7
- data.tar.gz: 4b98da8ab572435d9eb1926a6d7489da794c1398d0d601159db912203fb422b7a19c2b4ae09710d2b435b78d9834e7db308b548261e1f890bd9127dd1e519245
6
+ metadata.gz: 2aacfc00dd329b4182964a50417616822ecd53bab1dc971dc7f3ac0ac8575728c0f5d71124fdd1d84dee973cd580bb99b0948473dfbc7d74ad7c37cf86becb83
7
+ data.tar.gz: '091abbb6286cb6277814faa00503786c31b775793b82cc2fb1541e7ca4a03d08aefb3bea5684c1b4ca36e53197b7e9b45e4c05c8a994d3c24c944465ea489357'
@@ -86,6 +86,10 @@ function tabulatrInitialize() {
86
86
  $(this).parents('form.tabulatr_filter_form').submit();
87
87
  });
88
88
 
89
+ $('form.tabulatr_filter_form input').on('dp.change', function(){
90
+ $(this).parents('form.tabulatr_filter_form').submit();
91
+ });
92
+
89
93
  $('form.tabulatr_filter_form').submit(function(){
90
94
  var tableId = $(this).data('table');
91
95
  var table_obj;
@@ -110,10 +110,10 @@ class Tabulatr::Data
110
110
  # Params
111
111
  #++
112
112
 
113
- def filter_params(params) params["#{Tabulatr::Utility.formatted_name(@base.name)}_filter"] end
114
- def search_param(params) params["#{Tabulatr::Utility.formatted_name(@base.name)}_search"] end
115
- def sort_params(params) params["#{Tabulatr::Utility.formatted_name(@base.name)}_sort"] end
116
- def batch_params(params) params["#{Tabulatr::Utility.formatted_name(@base.name)}_batch"] end
113
+ def filter_params(params) params["#{Tabulatr::Utility.formatted_name(@base.name)}_filter"] || params["filter"] end
114
+ def search_param(params) params["#{Tabulatr::Utility.formatted_name(@base.name)}_search"] || params["search"] end
115
+ def sort_params(params) params["#{Tabulatr::Utility.formatted_name(@base.name)}_sort"] || params["sort"] end
116
+ def batch_params(params) params["#{Tabulatr::Utility.formatted_name(@base.name)}_batch"] || params["batch"] end
117
117
  def check_params(params)
118
118
  tabulatr_checked = params["tabulatr_checked"]
119
119
  if tabulatr_checked.present?
@@ -24,7 +24,7 @@
24
24
  module Tabulatr::Data::Formatting
25
25
 
26
26
  def apply_formats(locals: {}, controller: nil)
27
- view = Data::Proxy.new(locals: locals, controller: controller)
27
+ view = Tabulatr::Data::Proxy.new(locals: locals, controller: controller)
28
28
  return @relation.map do |record|
29
29
  view.record = record
30
30
  h = HashWithIndifferentAccess.new
@@ -21,7 +21,7 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
 
24
- class Data::Proxy < ActionView::Base
24
+ class Tabulatr::Data::Proxy < ActionView::Base
25
25
 
26
26
  attr_accessor :record, :controller
27
27
 
@@ -41,9 +41,13 @@ module Tabulatr::Data::Sorting
41
41
  end
42
42
  sort_by(column, orientation)
43
43
  elsif @default_order.present?
44
- @relation = @relation.reorder(@default_order)
44
+ if @default_order.is_a? String
45
+ @relation = @relation.reorder(Arel.sql @default_order)
46
+ else
47
+ @relation = @relation.reorder(@default_order)
48
+ end
45
49
  else
46
- @relation = @relation.reorder("#{@table_name}.#{@base.primary_key} desc")
50
+ @relation = @relation.reorder(Arel.sql "#{@table_name}.#{@base.primary_key} desc")
47
51
  end
48
52
  end
49
53
 
@@ -52,7 +56,7 @@ module Tabulatr::Data::Sorting
52
56
  if sort_sql.respond_to? :call
53
57
  @relation = sort_sql.call(@relation, orientation, "#{@table_name}.#{@base.primary_key}", @base)
54
58
  else
55
- @relation = @relation.reorder("#{sort_sql} #{orientation}")
59
+ @relation = @relation.reorder(Arel.sql "#{sort_sql} #{orientation}, #{@table_name}.id desc")
56
60
  end
57
61
  end
58
62
 
@@ -108,6 +108,19 @@ class Tabulatr::Renderer::Column
108
108
  end
109
109
  end
110
110
 
111
+ def to_json
112
+ {
113
+ name: "#{table_name}:#{name}",
114
+ # name: name,
115
+ header: human_name,
116
+ # klassname: klassname,
117
+ # table_name: table_name,
118
+ filter: col_options.filter,
119
+ sortable: col_options.sortable,
120
+ data_html: col_options.data_html,
121
+ header_html: col_options.header_html,
122
+ }
123
+ end
111
124
 
112
125
  private
113
126
 
@@ -99,6 +99,10 @@ class Tabulatr::Renderer
99
99
  new(klass, view, toptions).build_table(columns, filters, tabulatr_data_class, &block)
100
100
  end
101
101
 
102
+ def columns_json(tabulatr_data_class_name=nil)
103
+ get_data_class(tabulatr_data_class_name).table_columns.map(&:to_json)
104
+ end
105
+
102
106
  private
103
107
 
104
108
  def get_requested_columns(available_columns, requested_columns)
@@ -22,5 +22,5 @@
22
22
  #++
23
23
 
24
24
  module Tabulatr
25
- VERSION = "0.9.38"
25
+ VERSION = "0.9.43"
26
26
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabulatr2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.38
4
+ version: 0.9.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Horn
8
8
  - Florian Thomas
9
9
  - René Sprotte
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-06-14 00:00:00.000000000 Z
13
+ date: 2020-07-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -263,7 +263,7 @@ homepage: http://github.com/metaminded/tabulatr2
263
263
  licenses:
264
264
  - MIT
265
265
  metadata: {}
266
- post_install_message:
266
+ post_install_message:
267
267
  rdoc_options:
268
268
  - "--charset=UTF-8"
269
269
  require_paths:
@@ -279,9 +279,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
279
279
  - !ruby/object:Gem::Version
280
280
  version: '0'
281
281
  requirements: []
282
- rubyforge_project:
283
- rubygems_version: 2.7.6
284
- signing_key:
282
+ rubygems_version: 3.0.3
283
+ signing_key:
285
284
  specification_version: 4
286
285
  summary: A tight DSL to build tables of ActiveRecord models with sorting, pagination,
287
286
  finding/filtering, selecting and batch actions.