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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97ad579e4f968c5ee88cb8ad0605da46407b1723
4
- data.tar.gz: f9213e7655967748c32d8a943d24f42e439a7c5d
3
+ metadata.gz: a7737d3c09cfab493da58775899fcfcec9cebf6e
4
+ data.tar.gz: 07baaea95de4d129716ec3b0c949c3adf427c93e
5
5
  SHA512:
6
- metadata.gz: 78940c0eab2515f28183f6dbcda1305bc3788a09140f763db6477cb9fc4d2105739effd501a19551615cb0c130a3a8654db12ba4fbf2b82fca72d904ca8f2a6a
7
- data.tar.gz: da86c0c0e2beb673cc80c52f481181ea54d77ee1a798f4adce58957ced1103347f22f104c35bd275721b720ede63e21dbf4f3e2fcffd313b3c7e4ddb50df0eeb
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'] = table.column(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
- {type: :boolean, values: [true, false]}
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
- %a{href: url, title: 'Delete', data: {method: :delete, confirm: 'Are you sure?'}}
17
- %span.glyphicon.glyphicon-trash
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
@@ -8,6 +8,7 @@ module EffectiveDatatables
8
8
  mattr_accessor :date_format
9
9
  mattr_accessor :datetime_format
10
10
  mattr_accessor :integer_format
11
+ mattr_accessor :boolean_format
11
12
 
12
13
  mattr_accessor :default_entries
13
14
  mattr_accessor :actions_column # A Hash
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '2.1.1'.freeze
2
+ VERSION = '2.1.2'.freeze
3
3
  end
@@ -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.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-08-27 00:00:00.000000000 Z
11
+ date: 2015-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails