effective_datatables 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/effective_datatables/initialize.js.coffee.erb +1 -1
- data/app/models/effective/effective_datatable/dsl.rb +2 -1
- data/app/models/effective/effective_datatable/options.rb +5 -1
- data/app/models/effective/effective_datatable/rendering.rb +14 -1
- data/app/views/effective/datatables/_actions_column.html.haml +12 -2
- data/lib/effective_datatables.rb +1 -0
- data/lib/effective_datatables/version.rb +1 -1
- data/lib/generators/templates/effective_datatables.rb +6 -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: a7737d3c09cfab493da58775899fcfcec9cebf6e
|
4
|
+
data.tar.gz: 07baaea95de4d129716ec3b0c949c3adf427c93e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a298d125254e19d5450ecdf719b0a96246be4b2ced78f2806ba5066996c0bfab1957555b268c2a28069ebd769d7754df962d5b35a6eb09992330504d43190722
|
7
|
+
data.tar.gz: 9d4f06230ed4ecbf2e461afe72fcc5ed1f32eba2599ef99928b0293b335a0cdcd689d0ed39b3766c7069a0e2ac949d975c5df659d8085d9233dbede56370ff82
|
@@ -23,7 +23,7 @@ initializeDataTables = ->
|
|
23
23
|
serverParams: (params) ->
|
24
24
|
table = this.DataTable()
|
25
25
|
table.columns().flatten().each (index) => # Pass which columns are visible back to server
|
26
|
-
params['columns'][index]['visible'] =
|
26
|
+
params['columns'][index]['visible'] = table.column(index).visible()
|
27
27
|
colVis:
|
28
28
|
showAll: 'Show all'
|
29
29
|
restore: 'Show default'
|
@@ -39,13 +39,14 @@ module Effective
|
|
39
39
|
show = options.fetch(:show, (EffectiveDatatables.actions_column[:show] rescue false))
|
40
40
|
edit = options.fetch(:edit, (EffectiveDatatables.actions_column[:edit] rescue false))
|
41
41
|
destroy = options.fetch(:destroy, (EffectiveDatatables.actions_column[:destroy] rescue false))
|
42
|
+
unarchive = options.fetch(:unarchive, (EffectiveDatatables.actions_column[:unarchive] rescue false))
|
42
43
|
name = options.fetch(:name, 'actions')
|
43
44
|
|
44
45
|
opts = {
|
45
46
|
sortable: false,
|
46
47
|
filter: false,
|
47
48
|
partial_local: :resource,
|
48
|
-
partial_locals: { show_action: show, edit_action: edit, destroy_action: destroy }
|
49
|
+
partial_locals: { show_action: show, edit_action: edit, destroy_action: destroy, unarchive_action: unarchive }
|
49
50
|
}.merge(options)
|
50
51
|
|
51
52
|
opts[:partial] ||= '/effective/datatables/actions_column' unless (block_given? || proc.present?)
|
@@ -149,7 +149,11 @@ module Effective
|
|
149
149
|
when :integer
|
150
150
|
{type: :number}
|
151
151
|
when :boolean
|
152
|
-
|
152
|
+
if EffectiveDatatables.boolean_format == :yes_no
|
153
|
+
{type: :boolean, values: [['Yes', true], ['No', false]] }
|
154
|
+
else
|
155
|
+
{type: :boolean, values: [['true', true], ['false', false]] }
|
156
|
+
end
|
153
157
|
when :datetime
|
154
158
|
{type: :datetime}
|
155
159
|
when :date
|
@@ -67,7 +67,8 @@ module Effective
|
|
67
67
|
controller_namespace: view.controller_path.split('/')[0...-1].map { |path| path.downcase.to_sym if path.present? }.compact,
|
68
68
|
show_action: (opts[:partial_locals] || {})[:show_action],
|
69
69
|
edit_action: (opts[:partial_locals] || {})[:edit_action],
|
70
|
-
destroy_action: (opts[:partial_locals] || {})[:destroy_action]
|
70
|
+
destroy_action: (opts[:partial_locals] || {})[:destroy_action],
|
71
|
+
unarchive_action: (opts[:partial_locals] || {})[:unarchive_action]
|
71
72
|
}
|
72
73
|
locals.merge!(opts[:partial_locals]) if opts[:partial_locals]
|
73
74
|
|
@@ -83,6 +84,10 @@ module Effective
|
|
83
84
|
if locals[:destroy_action] == :authorize
|
84
85
|
locals[:destroy_action] = (EffectiveDatatables.authorized?(controller, :destroy, collection_class) rescue false)
|
85
86
|
end
|
87
|
+
|
88
|
+
if locals[:unarchive_action] == :authorize
|
89
|
+
locals[:unarchive_action] = (EffectiveDatatables.authorized?(controller, :unarchive, collection_class) rescue false)
|
90
|
+
end
|
86
91
|
end
|
87
92
|
|
88
93
|
rendered[name] = (render(
|
@@ -139,6 +144,14 @@ module Effective
|
|
139
144
|
else
|
140
145
|
value
|
141
146
|
end
|
147
|
+
when :boolean
|
148
|
+
if EffectiveDatatables.boolean_format == :yes_no && value == true
|
149
|
+
'Yes'
|
150
|
+
elsif EffectiveDatatables.boolean_format == :yes_no && value == false
|
151
|
+
'No'
|
152
|
+
else
|
153
|
+
value
|
154
|
+
end
|
142
155
|
else
|
143
156
|
value
|
144
157
|
end
|
@@ -13,5 +13,15 @@
|
|
13
13
|
- if destroy_action
|
14
14
|
- url = (polymorphic_path([*controller_namespace, resource]) rescue nil) || (polymorphic_path(resource) rescue nil)
|
15
15
|
- if url.present?
|
16
|
-
|
17
|
-
%
|
16
|
+
- if resource.respond_to?(:archived?) && !resource.archived?
|
17
|
+
%a{href: url, title: 'Archive', data: {method: :delete, confirm: "Are you sure you want to archive this item?"}}
|
18
|
+
%span.glyphicon.glyphicon-trash
|
19
|
+
- elsif resource.respond_to?(:archived?) == false
|
20
|
+
%a{href: url, title: 'Delete', data: {method: :delete, confirm: "Are you sure you want to delete this item?"}}
|
21
|
+
%span.glyphicon.glyphicon-trash
|
22
|
+
|
23
|
+
- if unarchive_action && resource.respond_to?(:archived?) && resource.archived?
|
24
|
+
- url = (polymorphic_path([*controller_namespace, resource], action: :unarchive) rescue nil) || (polymorphic_path(resource, action: :unarchive) rescue nil)
|
25
|
+
- if url.present?
|
26
|
+
%a{href: url, title: 'Unarchive', data: {confirm: 'Are you sure you want to unarchive this item?'}}
|
27
|
+
%span.glyphicon.glyphicon-retweet
|
data/lib/effective_datatables.rb
CHANGED
@@ -26,6 +26,10 @@ EffectiveDatatables.setup do |config|
|
|
26
26
|
config.date_format = '%Y-%m-%d'
|
27
27
|
config.datetime_format = '%Y-%m-%d %H:%M'
|
28
28
|
|
29
|
+
# Boolean format
|
30
|
+
# If :yes_no, display as yes_no instead of true/false
|
31
|
+
config.boolean_format = :yes_no
|
32
|
+
|
29
33
|
# Format integer columns with the following proc or function
|
30
34
|
config.integer_format = :number_with_delimiter
|
31
35
|
|
@@ -48,7 +52,8 @@ EffectiveDatatables.setup do |config|
|
|
48
52
|
config.actions_column = {
|
49
53
|
show: :authorize,
|
50
54
|
edit: :authorize,
|
51
|
-
destroy: :authorize
|
55
|
+
destroy: :authorize,
|
56
|
+
unarchive: :authorize
|
52
57
|
}
|
53
58
|
|
54
59
|
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.1.
|
4
|
+
version: 2.1.2
|
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: 2015-
|
11
|
+
date: 2015-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|