effective_datatables 3.0.14 → 3.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/effective_datatables_private_helper.rb +3 -15
- data/app/models/effective/datatable_value_tool.rb +14 -9
- data/app/models/effective/effective_datatable/dsl/datatable.rb +1 -1
- data/app/models/effective/effective_datatable/resource.rb +2 -2
- data/lib/effective_datatables/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0a7e266b00b4bc168dbf066d2be5a0b5a3d00a8
|
4
|
+
data.tar.gz: b5b54094cdf557a848a0466c27bdb4efce57d210
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 680dc369209e29efcdbce860039d2f6f9108c033f182cdcead1e3834df7cd50a6a105f548132decac8049bb16e229a08269f1089814455f04d13d49d9d9f9b90
|
7
|
+
data.tar.gz: baeb9a1a4428b1acf8eb6493fe7e63a54a4c71316177adead6b9513ac78f900c692b4808b617ba0caa89a925e226e41b0df3045091493208918fce17a78075c6
|
@@ -42,7 +42,6 @@ module EffectiveDatatablesPrivateHelper
|
|
42
42
|
value: value,
|
43
43
|
title: title,
|
44
44
|
pattern: pattern,
|
45
|
-
autocomplete: 'off',
|
46
45
|
data: {'column-name' => name, 'column-index' => opts[:index]}
|
47
46
|
}.delete_if { |k, v| v.blank? && k != :name }
|
48
47
|
|
@@ -77,24 +76,13 @@ module EffectiveDatatablesPrivateHelper
|
|
77
76
|
as: (ActionView::Helpers::FormBuilder.instance_methods.include?(:effective_select) ? :effective_select : :select),
|
78
77
|
collection: opts[:search][:collection],
|
79
78
|
selected: opts[:search][:value],
|
80
|
-
multiple: opts[:search][:multiple]
|
79
|
+
multiple: opts[:search][:multiple],
|
80
|
+
grouped: opts[:search][:grouped],
|
81
|
+
polymorphic: opts[:search][:polymorphic],
|
81
82
|
include_blank: include_blank,
|
82
83
|
wrapper_html: wrapper_html,
|
83
84
|
input_html: input_html,
|
84
85
|
input_js: { placeholder: placeholder }
|
85
|
-
when :grouped_select
|
86
|
-
form.input name, label: false, required: false, value: value,
|
87
|
-
as: (ActionView::Helpers::FormBuilder.instance_methods.include?(:effective_select) ? :effective_select : :grouped_select),
|
88
|
-
collection: opts[:search][:collection],
|
89
|
-
selected: opts[:search][:value],
|
90
|
-
multiple: opts[:search][:multiple] == true,
|
91
|
-
grouped: true,
|
92
|
-
polymorphic: opts[:search][:polymorphic] == true,
|
93
|
-
group_label_method: opts[:search][:group_label_method] || :first,
|
94
|
-
group_method: opts[:search][:group_method] || :last,
|
95
|
-
wrapper_html: wrapper_html,
|
96
|
-
input_html: input_html,
|
97
|
-
input_js: { placeholder: placeholder }
|
98
86
|
when :bulk_actions
|
99
87
|
input_html[:data]['role'] = 'bulk-actions-all'
|
100
88
|
|
@@ -74,6 +74,7 @@ module Effective
|
|
74
74
|
fuzzy = column[:search][:fuzzy]
|
75
75
|
term = Effective::Attribute.new(column[:as]).parse(value, name: column[:name])
|
76
76
|
term_downcased = term.downcase if fuzzy && term.kind_of?(String)
|
77
|
+
macros = Effective::Resource.new('').macros
|
77
78
|
|
78
79
|
if term == 'nil'
|
79
80
|
return (collection.select! { |row| row[index].nil? } || collection)
|
@@ -102,24 +103,28 @@ module Effective
|
|
102
103
|
else
|
103
104
|
row[index] == term
|
104
105
|
end
|
105
|
-
when :resource
|
106
|
+
when *macros, :resource
|
106
107
|
Array(row[index]).any? do |resource|
|
108
|
+
if column[:as] != :resource
|
109
|
+
resource = resource.send(column[:name])
|
110
|
+
end
|
111
|
+
|
112
|
+
matched = false
|
113
|
+
|
107
114
|
if term.kind_of?(Integer) && resource.respond_to?(:id)
|
108
|
-
resource.id == term || resource.to_param == term
|
115
|
+
matched ||= (resource.id == term || resource.to_param == term)
|
109
116
|
elsif term.kind_of?(Array) && resource.respond_to?(:id)
|
110
|
-
term.any? { |term| resource.id == term || resource.to_param == term || resource.to_param == value }
|
111
|
-
else
|
112
|
-
fuzzy ? resource.to_s.downcase == term_downcased : resource.to_s == term
|
117
|
+
matched ||= term.any? { |term| resource.id == term || resource.to_param == term || resource.to_param == value }
|
113
118
|
end
|
119
|
+
|
120
|
+
matched ||= (fuzzy ? resource.to_s.downcase.include?(term_downcased) : resource.to_s == term)
|
114
121
|
end
|
115
|
-
|
122
|
+
else # :string, :text, :email
|
116
123
|
if fuzzy
|
117
124
|
row[index].to_s.downcase.include?(term_downcased)
|
118
125
|
else
|
119
|
-
row[index].to_s == term.to_s
|
126
|
+
row[index] == term || (row[index].to_s == term.to_s)
|
120
127
|
end
|
121
|
-
else
|
122
|
-
row[index] == term
|
123
128
|
end
|
124
129
|
end || collection
|
125
130
|
end
|
@@ -45,7 +45,7 @@ module Effective
|
|
45
45
|
|
46
46
|
# A val is a computed value that is then sorted/searched after the block is run
|
47
47
|
# You can have another block by calling .format afterwards to work on the computed value itself
|
48
|
-
def val(name, action: nil, as: nil, col_class: nil, label: nil, partial: nil, partial_as: nil, responsive: 10000, search: {}, sort: true, sql_column:
|
48
|
+
def val(name, action: nil, as: nil, col_class: nil, label: nil, partial: nil, partial_as: nil, responsive: 10000, search: {}, sort: true, sql_column: false, th: nil, th_append: nil, visible: true, &compute)
|
49
49
|
raise 'You cannot use partial: ... with the block syntax' if partial && block_given?
|
50
50
|
|
51
51
|
datatable._columns[name.to_sym] = Effective::DatatableColumn.new(
|
@@ -24,12 +24,12 @@ module Effective
|
|
24
24
|
case opts[:as]
|
25
25
|
when *resource.macros
|
26
26
|
opts[:resource] = Effective::Resource.new(resource.associated(name), namespace: controller_namespace)
|
27
|
-
opts[:sql_column]
|
27
|
+
(opts[:sql_column] = name) if opts[:sql_column].nil?
|
28
28
|
when Class
|
29
29
|
if opts[:as].ancestors.include?(ActiveRecord::Base)
|
30
30
|
opts[:resource] = Effective::Resource.new(opts[:as], namespace: controller_namespace)
|
31
31
|
opts[:as] = :resource
|
32
|
-
opts[:sql_column]
|
32
|
+
(opts[:sql_column] = name) if opts[:sql_column].nil?
|
33
33
|
end
|
34
34
|
when :effective_addresses
|
35
35
|
opts[:resource] = Effective::Resource.new(resource.associated(name), namespace: controller_namespace)
|
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: 3.0.
|
4
|
+
version: 3.0.15
|
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: 2017-07-
|
11
|
+
date: 2017-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|