tabulatr2 0.9.46 → 0.9.48

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: f41f421f2b5c05c35dc912a034b114706e2281d52441f78441c9c3fadb09557f
4
- data.tar.gz: bb97bea3acf941cff212cc230cad2befcef4bcc6be21654c22e9a0307fe16905
3
+ metadata.gz: 529e1c4299c8377f6c5d108014e440fd5d3081c1c36694a54e38ff0d4aeac38c
4
+ data.tar.gz: a991342b3c04d2042687d4e728c937fdf9c8f919fb3840eef30d43da1fcb256b
5
5
  SHA512:
6
- metadata.gz: 1bce2f2d71ce8dbf4f49efffc567ad2d828dddde65a9e4fa1507636cfcbfa358c96dd5ad32321b840c8272ba1e5207d17c48929ab48576eead97bb4e316ed014
7
- data.tar.gz: a47a5311d2b87de12ac9fbb112cc26c18c2ef6e60a6404e82e5d2b558d7359580935f3f54a8aa06c2d4d5cf401dc97bbe4ca09495856a89333b1429e56128fa8
6
+ metadata.gz: edb0bd4150734762a714012297edc593367dbdb245e7e9feed72c10938e91a805f34b031d25687c2b6f3c1dfc1e2d43999e9150caf10753d0386b911c1fcfcb7
7
+ data.tar.gz: 3b70cd921bf2234566c7154e6320a04d574801937f7a365eaffabff03ad26cb0d2664f531940a53aa3c2176788bafeefb5c7329335060c4a768cd0e389209c43
@@ -34,6 +34,7 @@ module Tabulatr::Data::DSL
34
34
  opts = {
35
35
  sort_sql: sql_options[:sort_sql],
36
36
  filter: true,
37
+ default_filter: nil,
37
38
  sortable: true,
38
39
  filter_sql: sql_options[:filter_sql]}.merge(opts)
39
40
  table_column = Tabulatr::Renderer::Column.from(
@@ -42,8 +42,13 @@ module Tabulatr::Data::Filtering
42
42
  end
43
43
 
44
44
  def apply_filters(filter_params)
45
- return unless filter_params
46
- filter_params.permit!.to_hash.with_indifferent_access.each do |param|
45
+ default_filters = table_columns.map do |col|
46
+ next if col.col_options.default_filter.nil?
47
+ ["#{col.table_name}:#{col.name}", col.col_options.default_filter]
48
+ end.compact.to_h
49
+ return unless filter_params || default_filters.present?
50
+ filters = default_filters.merge(filter_params&.permit! || {})
51
+ filters.to_hash.with_indifferent_access.each do |param|
47
52
  name, value = param
48
53
  next unless value.present?
49
54
 
@@ -53,6 +53,7 @@ module Tabulatr::Data::Sorting
53
53
 
54
54
  def sort_by(column, orientation)
55
55
  sort_sql = column.col_options.sort_sql
56
+ orientation = 'asc' unless ['asc', 'desc'].member?(orientation.downcase)
56
57
  if sort_sql.respond_to? :call
57
58
  @relation = sort_sql.call(@relation, orientation, "#{@table_name}.#{@base.primary_key}", @base)
58
59
  else
@@ -2,7 +2,9 @@ module Tabulatr
2
2
  class ParamsBuilder
3
3
  ALLOWED_PARAMS = [:header, :filter, :sortable, :data_html,
4
4
  :header_html, :filter_sql, :sort_sql, :sql, :width,
5
- :align, :wrap, :format, :filter_label, :name, :classes]
5
+ :align, :wrap, :format, :filter_label, :name, :classes,
6
+ :default_filter
7
+ ]
6
8
  DEPRECATED_PARAMS = []
7
9
 
8
10
  attr_accessor *ALLOWED_PARAMS
@@ -22,5 +22,5 @@
22
22
  #++
23
23
 
24
24
  module Tabulatr
25
- VERSION = "0.9.46"
25
+ VERSION = "0.9.48"
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabulatr2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.46
4
+ version: 0.9.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Horn
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-01-10 00:00:00.000000000 Z
13
+ date: 2024-04-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails