effective_datatables 1.5.1 → 1.6.0

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
  SHA1:
3
- metadata.gz: 3b677a3b723e6af03c4a6b340a1250b8a6a4d1ef
4
- data.tar.gz: 4fcb4151ff1cc6a980bed317a9d3cb987b57e997
3
+ metadata.gz: b8857fc86c5d3eef83588add994b4ba7e61edfd7
4
+ data.tar.gz: ea235e3ec7aa3749bed5abc7d0ef3cf769dcefc4
5
5
  SHA512:
6
- metadata.gz: 49185a3c2478c7ee62c810e9972dac1a86bff80dfd57972c5eeed9a955447c1cf27c8cc1bdbe14184f50e0402250db31360e4de52fe24ec708e63c12fca31841
7
- data.tar.gz: f876d78bb2ef038cb564504e165a10a6e78780baacc4cd612928a02d07e5540672ad61945fb6f56dc1215a37942e0b44d977e125e6671f50fa667a6f387fda34
6
+ metadata.gz: 8e063515e21a8cb62ac464cd8ee51617c466fd23f84d04cac01aff49691de37406161369a865638c197c13ccd2ad699e955e2905774cd192c45eb8c0cd489c10
7
+ data.tar.gz: 4b84bfe945e48fbfb7a2ce2531d54c9f125c2c8d62b4d9c835ac98692f67aaa29fb195f459a2b98a2b40eaca293db95d4ed501c09c8ca19cde78d166d497175d
@@ -31,7 +31,24 @@ module Effective
31
31
  end
32
32
 
33
33
  def array_column(name, options = {}, proc = nil, &block)
34
- table_column(name, options.merge({:array_column => true}), proc, &block)
34
+ table_column(name, options.merge!({:array_column => true}), proc, &block)
35
+ end
36
+
37
+ def actions_column(options = {}, proc = nil, &block)
38
+ show = options.fetch(:show, false)
39
+ edit = options.fetch(:edit, true)
40
+ destroy = options.fetch(:destroy, true)
41
+ name = options.fetch(:name, 'actions')
42
+
43
+ opts = {
44
+ sortable: false,
45
+ filter: false,
46
+ partial: '/effective/datatables/actions_column',
47
+ partial_local: :resource,
48
+ partial_locals: { show_action: show, edit_action: edit, destroy_action: destroy }
49
+ }
50
+
51
+ table_column(name, opts, proc, &block)
35
52
  end
36
53
 
37
54
  def array_columns(*names)
@@ -296,12 +313,22 @@ module Effective
296
313
  rendered = {}
297
314
  table_columns.each do |name, opts|
298
315
  if opts[:partial]
316
+ locals = {
317
+ datatable: self,
318
+ table_column: table_columns[name],
319
+ controller_namespace: view.controller_path.split('/')[0...-1].map { |path| path.downcase.to_sym if path.present? }.compact,
320
+ show_action: (opts[:partial_locals] || {})[:show_action],
321
+ edit_action: (opts[:partial_locals] || {})[:edit_action],
322
+ destroy_action: (opts[:partial_locals] || {})[:destroy_action]
323
+ }
324
+ locals.merge!(opts[:partial_locals]) if opts[:partial_locals]
325
+
299
326
  rendered[name] = (render(
300
327
  :partial => opts[:partial],
301
328
  :as => opts[:partial_local],
302
329
  :collection => collection,
303
330
  :formats => :html,
304
- :locals => {:datatable => self},
331
+ :locals => locals,
305
332
  :spacer_template => '/effective/datatables/spacer_template',
306
333
  ) || '').split('EFFECTIVEDATATABLESSPACER')
307
334
  end
@@ -0,0 +1,14 @@
1
+ - if show_action
2
+ - url = (polymorphic_path([*controller_namespace, resource]) rescue nil) || (polymorphic_path(resource) rescue nil)
3
+ %a{href: (url || '#'), title: 'Show'}
4
+ %span.glyphicon.glyphicon-eye-open
5
+
6
+ - if edit_action
7
+ - url = (edit_polymorphic_path([*controller_namespace, resource]) rescue nil) || (edit_polymorphic_path(resource) rescue nil)
8
+ %a{href: (url || '#'), title: 'Edit'}
9
+ %span.glyphicon.glyphicon-edit
10
+
11
+ - if destroy_action
12
+ - url = (polymorphic_path([*controller_namespace, resource]) rescue nil) || (polymorphic_path(resource) rescue nil)
13
+ %a{href: (polymorphic_path([*controller_namespace, resource]) rescue '#'), title: 'Delete', data: {method: :delete, confirm: 'Are you sure?'}}
14
+ %span.glyphicon.glyphicon-trash
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '1.5.1'.freeze
2
+ VERSION = '1.6.0'.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: 1.5.1
4
+ version: 1.6.0
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-06-01 00:00:00.000000000 Z
11
+ date: 2015-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -123,6 +123,7 @@ files:
123
123
  - app/models/effective/active_record_datatable_tool.rb
124
124
  - app/models/effective/array_datatable_tool.rb
125
125
  - app/models/effective/datatable.rb
126
+ - app/views/effective/datatables/_actions_column.html.haml
126
127
  - app/views/effective/datatables/_datatable.html.haml
127
128
  - app/views/effective/datatables/_spacer_template.html
128
129
  - config/routes.rb