effective_datatables 4.36.1 → 4.37.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e64115315e92eab482dcf096351440e57bcf3aaf8fd260d766e0311dcf096df
4
- data.tar.gz: d7411c7a76eecc7623b75c9d6f628e1437318cc711feda532328544fa50d9fae
3
+ metadata.gz: d505ef855ff08e13f58590a636b1d7c9564e629dc36638e2c440b6935ad62cfa
4
+ data.tar.gz: d87b887564d7b12f1c617b7449cc237baa3623053f41e44da30e2b9e20c53ef1
5
5
  SHA512:
6
- metadata.gz: 95f03a5e84ddc2e485b6afa2f9fcf099cbcc051b86ca16ac7ac5447dc5f78f568e4eaa4a213ea3726cbef3ee8a466bbf85f50194be18ddc9b0032272ed04dbe8
7
- data.tar.gz: 78b37da7540c2893d05e452cdc85433da090f32ce9a229b75031b65b3be2bf7d4f59d205e960e5ceb4aa01c855e7a08a3b09cc611d7ba733042720f2a323a21d
6
+ metadata.gz: b231fcc5710c0001d73e7c27a3fe12a5fafaf596aa01b1d0b1beabd3eba096755b9cdf6a99977091c37d3b9bee70e44c3522a431892ed05a75b11888bac29d79
7
+ data.tar.gz: c62e21a13b203cc4397e655dbf8cdfbfcbb004432381c50e8c5008397012c5afb6c3a2990c0d4df92b07a11260de64fc0e140a8d42924c683d69ca62aae73920
@@ -44,11 +44,11 @@ module EffectiveDatatablesPrivateHelper
44
44
  def datatable_new_resource_button(datatable, name, column)
45
45
  return unless datatable.inline? && (column[:actions][:new] != false)
46
46
 
47
- # Override the default btn_class and use this one
48
- action = { action: :new, class: 'btn btn-sm btn-success', 'data-remote': true }
47
+ btn_class = EffectiveDatatables.new_action_button_class || 'btn-sm btn-success'
48
+ action = { action: :new, class: "btn #{btn_class}", 'data-remote': true }
49
49
 
50
50
  if column[:actions][:new].kind_of?(Hash) # This might be active_record_array_collection?
51
- actions = action.merge(column[:actions][:new])
51
+ action = action.merge(column[:actions][:new])
52
52
 
53
53
  effective_resource = (datatable.effective_resource || datatable.fallback_effective_resource)
54
54
  klass = (column[:actions][:new][:klass] || effective_resource&.klass || datatable.collection_class)
@@ -38,7 +38,7 @@ module Effective
38
38
  # Anything done in the block, is purely a format on the after sorted/ordered value
39
39
  # the original object == the computed value, which is yielded to the format block
40
40
  # You can't do compute with .col
41
- def col(name, action: nil, as: nil, col_class: nil, csv: true, label: nil, partial: nil, partial_as: nil, responsive: 10000, search: {}, sort: true, sql_column: nil, th: nil, th_append: nil, visible: true, &format)
41
+ def col(name, action: nil, as: nil, badge: true, col_class: nil, csv: true, label: nil, partial: nil, partial_as: nil, responsive: 10000, search: {}, sort: true, sql_column: nil, th: nil, th_append: nil, visible: true, &format)
42
42
  raise 'You cannot use partial: ... with the block syntax' if partial && block_given?
43
43
 
44
44
  name = name.to_sym unless name.to_s.include?('.')
@@ -46,6 +46,7 @@ module Effective
46
46
  datatable._columns[name] = Effective::DatatableColumn.new(
47
47
  action: action,
48
48
  as: as,
49
+ badge: badge,
49
50
  compute: nil,
50
51
  col_class: col_class,
51
52
  csv: csv,
@@ -67,7 +68,7 @@ module Effective
67
68
 
68
69
  # A val is a computed value that is then sorted/searched after the block is run
69
70
  # You can have another block by calling .format afterwards to work on the computed value itself
70
- def val(name, action: nil, as: nil, col_class: nil, csv: true, label: nil, partial: nil, partial_as: nil, responsive: 10000, search: {}, sort: true, sql_column: false, th: nil, th_append: nil, visible: true, &compute)
71
+ def val(name, action: nil, as: nil, badge: true, col_class: nil, csv: true, label: nil, partial: nil, partial_as: nil, responsive: 10000, search: {}, sort: true, sql_column: false, th: nil, th_append: nil, visible: true, &compute)
71
72
  raise 'You cannot use partial: ... with the block syntax' if partial && block_given?
72
73
 
73
74
  name = name.to_sym unless name.to_s.include?('.')
@@ -75,6 +76,7 @@ module Effective
75
76
  datatable._columns[name] = Effective::DatatableColumn.new(
76
77
  action: action,
77
78
  as: as,
79
+ badge: badge,
78
80
  compute: (compute if block_given?),
79
81
  col_class: col_class,
80
82
  csv: csv,
@@ -101,7 +103,7 @@ module Effective
101
103
  action: false,
102
104
  as: :actions,
103
105
  compute: nil,
104
- btn_class: (btn_class || 'btn-sm btn-outline-primary'),
106
+ btn_class: (btn_class || EffectiveDatatables.default_button_class || 'btn-sm btn-outline-primary'),
105
107
  col_class: col_class,
106
108
  csv: false,
107
109
  format: (format if block_given?),
@@ -11,3 +11,7 @@
11
11
  = link_to resource_to_s, path, title: resource_to_s
12
12
  - else
13
13
  = resource_to_s.to_s.html_safe
14
+
15
+ -# Automatically badge any acts_as_statused resource. Opt out with col(..., badge: false)
16
+ - if resource.class.try(:acts_as_statused?) && resource.status.present? && (local_assigns[:column].blank? || column[:badge] != false)
17
+ = badge(resource.status)
@@ -30,6 +30,10 @@ EffectiveDatatables.setup do |config|
30
30
  # Default class used on the <table> tag
31
31
  config.html_class = 'table table-hover'
32
32
 
33
+ # These are the button classes
34
+ # config.default_button_class = 'btn-outline-primary' # default class when btn_class option is unspecified
35
+ # config.new_action_button_class = 'btn-success' # overriding class on new action
36
+
33
37
  # Log search/sort information to the console
34
38
  config.debug = true
35
39
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.36.1'.freeze
2
+ VERSION = '4.37.1'.freeze
3
3
  end
@@ -12,6 +12,8 @@ module EffectiveDatatables
12
12
  mattr_accessor :length_menu
13
13
 
14
14
  mattr_accessor :html_class
15
+ mattr_accessor :default_button_class
16
+ mattr_accessor :new_action_button_class
15
17
  mattr_accessor :save_state
16
18
 
17
19
  mattr_accessor :cookie_max_size
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_datatables
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.36.1
4
+ version: 4.37.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-12 00:00:00.000000000 Z
11
+ date: 2026-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -211,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  - !ruby/object:Gem::Version
212
212
  version: '0'
213
213
  requirements: []
214
- rubygems_version: 3.5.6
214
+ rubygems_version: 3.5.9
215
215
  signing_key:
216
216
  specification_version: 4
217
217
  summary: Uniquely powerful server-side searching, sorting and filtering of any ActiveRecord