effective_datatables 2.6.8 → 2.6.9

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
  SHA1:
3
- metadata.gz: 44d18b34dca0688f3e8e2ec25d2ed592f00ba43d
4
- data.tar.gz: a6383ebab0bc9427a63e3ad748ec0c7d56667a6f
3
+ metadata.gz: bfcfa607598e145978051831be4699b22abada93
4
+ data.tar.gz: 7400ddc7374fa28e61c06f620d82780de069be75
5
5
  SHA512:
6
- metadata.gz: 6befe569f7efeb2b855acaadcad8af346a14ed401c5fd89c0405f34e8e07e71650a578062ca596474fc54780c8032cc30205d8d845289379402d2d4d97b8f65f
7
- data.tar.gz: a94df95c8e87b9e80ed522b84dd98843a7a14737896daf880120b5ed797269b48d784d721142bbbb8bfcc7febe078b55e81f86e6270ad1f977136a050fc1c48f
6
+ metadata.gz: 008e48a5a8bb112d32a7b5c64df8c381d099371588af74321ff0ce30aae6ad9b95c14dbdb659b95469bdc9668a91d8bc217d27b44e8f3fcf6b5bda2e7cb0ed4b
7
+ data.tar.gz: c9dcca53071f78e3ab100e69f82d675be3bcce35bd9c97b586161dce402823fed45c856433c247419df061af9cece2c1057b8affc7b89ee2770674285086ca29
@@ -146,6 +146,8 @@ initializeDataTables = ->
146
146
 
147
147
  # Do the actual search
148
148
  dataTableSearch = ($input) -> # This is the function called by a select or input to run the search
149
+ return if $input.is(':invalid')
150
+
149
151
  table = $input.closest('table.dataTable')
150
152
  table.DataTable().column("#{$input.data('column-name')}:name").search($input.val()).draw()
151
153
 
@@ -156,6 +156,10 @@ table.dataTable.dtr-inline.collapsed > tbody > tr:not(.child) > th:first-child {
156
156
  table.dataTable tbody {
157
157
  td.col-price { text-align: right; }
158
158
 
159
+ td.col-actions {
160
+ white-space: nowrap;
161
+ }
162
+
159
163
  td.col-bulk_actions {
160
164
  input[type='checkbox'] { margin-left: 3px; }
161
165
  }
@@ -40,6 +40,8 @@ module Effective
40
40
  :data => [],
41
41
  :recordsTotal => 0,
42
42
  :recordsFiltered => 0,
43
+ :aggregates => [],
44
+ :charts => {}
43
45
  }.to_json
44
46
  end
45
47
 
@@ -89,27 +89,37 @@ module EffectiveDatatablesHelper
89
89
  return render(partial: opts[:header_partial], locals: {form: form, name: (opts[:label] || name), column: opts}) if opts[:header_partial].present?
90
90
 
91
91
  include_blank = opts[:filter].key?(:include_blank) ? opts[:filter][:include_blank] : (opts[:label] || name.titleize)
92
+ pattern = opts[:filter].key?(:pattern) ? opts[:filter][:pattern] : nil
92
93
  placeholder = opts[:filter].key?(:placeholder) ? opts[:filter][:placeholder] : (opts[:label] || name.titleize)
94
+ title = opts[:filter].key?(:title) ? opts[:filter][:title] : (opts[:label] || name.titleize)
93
95
 
94
96
  case opts[:filter][:as]
95
97
  when :string, :text, :number
96
98
  form.input name, label: false, required: false, value: value,
97
99
  as: :string,
98
100
  placeholder: placeholder,
99
- input_html: { name: nil, value: value, autocomplete: 'off', data: {'column-name' => opts[:name], 'column-index' => opts[:index]} }
101
+ input_html: { name: nil, value: value, title: title, pattern: pattern, autocomplete: 'off', data: {'column-name' => opts[:name], 'column-index' => opts[:index]} }
102
+ when :obfuscated_id
103
+ pattern ||= "[0-9]{3}-?[0-9]{4}-?[0-9]{3}"
104
+ title = opts[:filter].key?(:title) ? opts[:filter][:title] : "Expected format: XXX-XXXX-XXX"
105
+
106
+ form.input name, label: false, required: false, value: value,
107
+ as: :string,
108
+ placeholder: placeholder,
109
+ input_html: { name: nil, value: value, title: title, pattern: pattern, autocomplete: 'off', data: {'column-name' => opts[:name], 'column-index' => opts[:index]} }
100
110
  when :date
101
111
  form.input name, label: false, required: false, value: value,
102
112
  as: (ActionView::Helpers::FormBuilder.instance_methods.include?(:effective_date_picker) ? :effective_date_picker : :string),
103
113
  placeholder: placeholder,
104
114
  input_group: false,
105
- input_html: { name: nil, autocomplete: 'off', data: {'column-name' => opts[:name], 'column-index' => opts[:index]} },
115
+ input_html: { name: nil, value: value, title: title, autocomplete: 'off', data: {'column-name' => opts[:name], 'column-index' => opts[:index]} },
106
116
  input_js: { useStrict: true, keepInvalid: true }
107
117
  when :datetime
108
118
  form.input name, label: false, required: false, value: value,
109
119
  as: (ActionView::Helpers::FormBuilder.instance_methods.include?(:effective_date_time_picker) ? :effective_date_time_picker : :string),
110
120
  placeholder: placeholder,
111
121
  input_group: false,
112
- input_html: { name: nil, value: value, autocomplete: 'off', data: {'column-name' => opts[:name], 'column-index' => opts[:index]} },
122
+ input_html: { name: nil, value: value, title: title, autocomplete: 'off', data: {'column-name' => opts[:name], 'column-index' => opts[:index]} },
113
123
  input_js: { useStrict: true, keepInvalid: true } # Keep invalid format like "2015-11" so we can still filter by year, month or day
114
124
  when :select, :boolean
115
125
  form.input name, label: false, required: false, value: value,
@@ -118,7 +128,7 @@ module EffectiveDatatablesHelper
118
128
  selected: opts[:filter][:selected],
119
129
  multiple: opts[:filter][:multiple] == true,
120
130
  include_blank: include_blank,
121
- input_html: { name: nil, value: value, autocomplete: 'off', data: {'column-name' => opts[:name], 'column-index' => opts[:index]} },
131
+ input_html: { name: nil, value: value, title: title, autocomplete: 'off', data: {'column-name' => opts[:name], 'column-index' => opts[:index]} },
122
132
  input_js: { placeholder: placeholder }
123
133
  when :grouped_select
124
134
  form.input name, label: false, required: false, value: value,
@@ -131,7 +141,7 @@ module EffectiveDatatablesHelper
131
141
  polymorphic: opts[:filter][:polymorphic] == true,
132
142
  group_label_method: opts[:filter][:group_label_method] || :first,
133
143
  group_method: opts[:filter][:group_method] || :last,
134
- input_html: { name: nil, value: value, autocomplete: 'off', data: {'column-name' => opts[:name], 'column-index' => opts[:index]} },
144
+ input_html: { name: nil, value: value, title: title, autocomplete: 'off', data: {'column-name' => opts[:name], 'column-index' => opts[:index]} },
135
145
  input_js: { placeholder: placeholder }
136
146
  when :bulk_actions_column
137
147
  form.input name, label: false, required: false, value: nil,
@@ -10,16 +10,20 @@ module Effective
10
10
  def display_table_columns
11
11
  return nil if params[:columns].blank?
12
12
 
13
- @display_table_columns ||= params[:columns].each_with_object({}) do |(_, column), retval|
14
- retval[column[:name]] = table_columns[column[:name]] # Same order as ColReordernow
15
- retval[column[:name]][:visible] = (column[:visible] == 'true') # As per ColVis
16
- end
13
+ @display_table_columns ||= (
14
+ {}.tap do |retval|
15
+ params[:columns].each do |_, column|
16
+ retval[column[:name]] = table_columns[column[:name]] # Same order as ColReordernow
17
+ retval[column[:name]][:visible] = (column[:visible] == 'true') # As per ColVis
18
+ end
19
+ end
20
+ )
17
21
  end
18
22
 
19
23
  def order_name
20
24
  @order_name ||= begin
21
25
  if params[:order] && params[:columns]
22
- order_by_column_index = (params[:order].first[1][:column] rescue '0')
26
+ order_by_column_index = (params[:order]['0'][:column] rescue '0')
23
27
  (params[:columns][order_by_column_index] || {})[:name]
24
28
  elsif @default_order.present?
25
29
  @default_order.keys.first
@@ -33,7 +37,7 @@ module Effective
33
37
 
34
38
  def order_direction
35
39
  @order_direction ||= if params[:order].present?
36
- params[:order].first[1][:dir] == 'desc' ? :desc : :asc
40
+ params[:order]['0'][:dir] == 'desc' ? :desc : :asc
37
41
  elsif @default_order.present?
38
42
  @default_order.values.first.to_s.downcase == 'desc' ? :desc : :asc
39
43
  else
@@ -114,8 +114,12 @@ module Effective
114
114
  :has_and_belongs_to_many
115
115
  elsif cols[name][:bulk_actions_column]
116
116
  :bulk_actions_column
117
- elsif name.include?('_address') && (collection_class.new rescue nil).respond_to?(:effective_addresses)
117
+ elsif name.include?('_address') && defined?(EffectiveAddresses) && (collection_class.new rescue nil).respond_to?(:effective_addresses)
118
118
  :effective_address
119
+ elsif name == 'id' && defined?(EffectiveObfuscation) && collection.respond_to?(:deobfuscate)
120
+ :obfuscated_id
121
+ elsif name == 'roles' && defined?(EffectiveRoles) && collection.respond_to?(:with_role)
122
+ :effective_roles
119
123
  elsif sql_column.try(:type).present?
120
124
  sql_column.type
121
125
  elsif name.end_with?('_id')
@@ -132,22 +136,14 @@ module Effective
132
136
  cols[name][:format] = :non_formatted_integer
133
137
  end
134
138
 
135
- # We can't really sort a HasMany or EffectiveAddress field
136
- if [:has_many, :effective_address].include?(cols[name][:type])
139
+ # Sortable - Disable sorting on these types
140
+ if [:has_many, :effective_address, :obfuscated_id].include?(cols[name][:type])
137
141
  cols[name][:sortable] = false
138
142
  end
139
143
 
140
- # EffectiveObfuscation
141
- if name == 'id' && defined?(EffectiveObfuscation) && collection.respond_to?(:deobfuscate)
142
- cols[name][:sortable] = false
143
- cols[name][:type] = :obfuscated_id
144
- end
145
-
146
144
  # EffectiveRoles, if you do table_column :roles, everything just works
147
- if name == 'roles' && defined?(EffectiveRoles) && collection.respond_to?(:with_role)
148
- cols[name][:sortable] = true
145
+ if cols[name][:type] == :effective_roles
149
146
  cols[name][:column] = sql_table.present? ? "#{quote_sql(sql_table.name)}.#{quote_sql('roles_mask')}" : name
150
- cols[name][:type] = :effective_roles
151
147
  end
152
148
 
153
149
  if sql_table.present? && sql_column.blank? # This is a SELECT AS column, or a JOIN column
@@ -256,6 +252,8 @@ module Effective
256
252
  {as: :string}
257
253
  when :effective_roles
258
254
  {as: :select, collection: EffectiveRoles.roles}
255
+ when :obfuscated_id
256
+ {as: :obfuscated_id}
259
257
  when :integer
260
258
  {as: :number}
261
259
  when :boolean
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '2.6.8'.freeze
2
+ VERSION = '2.6.9'.freeze
3
3
  end
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: 2.6.8
4
+ version: 2.6.9
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: 2016-08-22 00:00:00.000000000 Z
11
+ date: 2016-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails