effective_datatables 2.12.2 → 3.0.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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +632 -512
  3. data/app/assets/javascripts/dataTables/buttons/buttons.html5.js +176 -177
  4. data/app/assets/javascripts/dataTables/buttons/buttons.print.js +2 -0
  5. data/app/assets/javascripts/dataTables/buttons/dataTables.buttons.js +14 -14
  6. data/app/assets/javascripts/dataTables/dataTables.bootstrap.js +1 -1
  7. data/app/assets/javascripts/dataTables/jquery.dataTables.js +246 -217
  8. data/app/assets/javascripts/effective_datatables.js +2 -3
  9. data/app/assets/javascripts/effective_datatables/events.js.coffee +7 -0
  10. data/app/assets/javascripts/effective_datatables/filters.js.coffee +6 -0
  11. data/app/assets/javascripts/effective_datatables/initialize.js.coffee +42 -39
  12. data/app/assets/javascripts/effective_datatables/reset.js.coffee +7 -0
  13. data/app/assets/javascripts/vendor/jquery.delayedChange.js +1 -1
  14. data/app/assets/stylesheets/dataTables/dataTables.bootstrap.css +0 -1
  15. data/app/assets/stylesheets/effective_datatables.scss +1 -2
  16. data/app/assets/stylesheets/effective_datatables/{_scopes.scss → _filters.scss} +1 -1
  17. data/app/assets/stylesheets/effective_datatables/_overrides.scss +1 -1
  18. data/app/controllers/effective/datatables_controller.rb +2 -4
  19. data/app/helpers/effective_datatables_helper.rb +56 -91
  20. data/app/helpers/effective_datatables_private_helper.rb +55 -64
  21. data/app/models/effective/datatable.rb +103 -177
  22. data/app/models/effective/datatable_column.rb +28 -0
  23. data/app/models/effective/datatable_column_tool.rb +110 -0
  24. data/app/models/effective/datatable_dsl_tool.rb +28 -0
  25. data/app/models/effective/datatable_value_tool.rb +142 -0
  26. data/app/models/effective/effective_datatable/attributes.rb +25 -0
  27. data/app/models/effective/effective_datatable/collection.rb +38 -0
  28. data/app/models/effective/effective_datatable/compute.rb +154 -0
  29. data/app/models/effective/effective_datatable/cookie.rb +29 -0
  30. data/app/models/effective/effective_datatable/dsl.rb +14 -8
  31. data/app/models/effective/effective_datatable/dsl/bulk_actions.rb +5 -6
  32. data/app/models/effective/effective_datatable/dsl/charts.rb +7 -9
  33. data/app/models/effective/effective_datatable/dsl/datatable.rb +107 -57
  34. data/app/models/effective/effective_datatable/dsl/filters.rb +50 -0
  35. data/app/models/effective/effective_datatable/format.rb +157 -0
  36. data/app/models/effective/effective_datatable/hooks.rb +0 -18
  37. data/app/models/effective/effective_datatable/params.rb +34 -0
  38. data/app/models/effective/effective_datatable/resource.rb +108 -0
  39. data/app/models/effective/effective_datatable/state.rb +178 -0
  40. data/app/views/effective/datatables/_actions_column.html.haml +9 -42
  41. data/app/views/effective/datatables/_bulk_actions_column.html.haml +1 -1
  42. data/app/views/effective/datatables/_bulk_actions_dropdown.html.haml +2 -3
  43. data/app/views/effective/datatables/_chart.html.haml +1 -1
  44. data/app/views/effective/datatables/_datatable.html.haml +7 -25
  45. data/app/views/effective/datatables/_filters.html.haml +21 -0
  46. data/app/views/effective/datatables/_reset.html.haml +2 -0
  47. data/app/views/effective/datatables/_resource_column.html.haml +8 -0
  48. data/app/views/effective/datatables/index.html.haml +0 -1
  49. data/config/effective_datatables.rb +9 -32
  50. data/lib/effective_datatables.rb +2 -6
  51. data/lib/effective_datatables/engine.rb +1 -1
  52. data/lib/effective_datatables/version.rb +1 -1
  53. data/lib/generators/effective_datatables/install_generator.rb +2 -2
  54. metadata +39 -19
  55. data/app/assets/javascripts/dataTables/colreorder/dataTables.colReorder.js +0 -27
  56. data/app/assets/javascripts/dataTables/jszip/jszip.js +0 -9155
  57. data/app/assets/javascripts/effective_datatables/scopes.js.coffee +0 -9
  58. data/app/models/effective/active_record_datatable_tool.rb +0 -242
  59. data/app/models/effective/array_datatable_tool.rb +0 -97
  60. data/app/models/effective/effective_datatable/ajax.rb +0 -101
  61. data/app/models/effective/effective_datatable/charts.rb +0 -20
  62. data/app/models/effective/effective_datatable/dsl/scopes.rb +0 -23
  63. data/app/models/effective/effective_datatable/helpers.rb +0 -24
  64. data/app/models/effective/effective_datatable/options.rb +0 -309
  65. data/app/models/effective/effective_datatable/rendering.rb +0 -365
  66. data/app/views/effective/datatables/_scopes.html.haml +0 -21
@@ -1,6 +1,5 @@
1
1
  //= require vendor/jquery.delayedChange
2
2
  //= require vendor/jquery.fileDownload
3
- //= require dataTables/jszip/jszip
4
3
 
5
4
  //= require dataTables/jquery.dataTables
6
5
  //= require dataTables/dataTables.bootstrap
@@ -10,14 +9,14 @@
10
9
  //= require dataTables/buttons/buttons.colVis
11
10
  //= require dataTables/buttons/buttons.html5
12
11
  //= require dataTables/buttons/buttons.print
13
- //= require dataTables/colreorder/dataTables.colReorder
14
12
  //= require dataTables/responsive/dataTables.responsive
15
13
  //= require dataTables/responsive/responsive.bootstrap
16
14
 
17
15
  //= require effective_datatables/bulk_actions
18
16
  //= require effective_datatables/events
17
+ //= require effective_datatables/filters
18
+ //= require effective_datatables/reset
19
19
  //= require effective_datatables/responsive
20
- //= require effective_datatables/scopes
21
20
 
22
21
  //= require effective_datatables/charts
23
22
  //= require effective_datatables/initialize
@@ -11,3 +11,10 @@ $(document).on 'column-visibility.dt', (event, settings, index, state) ->
11
11
  $.event.trigger('page:change')
12
12
  , 700)
13
13
  )
14
+
15
+ # Remove empty label (bulk actions) from ColVis dropdown
16
+ $(document).on 'click.dtb-collection', (event) ->
17
+ $colvis = $('.dt-button-collection:not(.initialized)')
18
+ return if $colvis.length == 0
19
+
20
+ $colvis.addClass('initialized').find('li > a:empty').each -> $(this).parent().remove()
@@ -0,0 +1,6 @@
1
+ $(document).on 'click', 'a[data-apply-datatable-filters]', (event) ->
2
+ event.preventDefault()
3
+ $form = $(event.currentTarget).closest('.effective-datatable-filters')
4
+ $table = $('#' + $form.attr('aria-controls'))
5
+ $table.DataTable().draw()
6
+
@@ -16,7 +16,7 @@ initializeDataTables = ->
16
16
  buttons: [
17
17
  {
18
18
  extend: 'colvis',
19
- text: 'Show / hide columns',
19
+ text: 'Show / Hide',
20
20
  postfixButtons: [
21
21
  { extend: 'colvisGroup', text: 'Show all', show: ':hidden'},
22
22
  { extend: 'colvisRestore', text: 'Show default'}
@@ -26,52 +26,57 @@ initializeDataTables = ->
26
26
  extend: 'copy',
27
27
  exportOptions:
28
28
  format:
29
- header: (str) -> $("<div>#{str}</div>").children('.filter-label').first().text()
29
+ header: (str) -> $("<div>#{str}</div>").children('.search-label').first().text()
30
30
  columns: buttons_export_columns
31
31
  },
32
32
  {
33
33
  extend: 'csv',
34
34
  exportOptions:
35
35
  format:
36
- header: (str) -> $("<div>#{str}</div>").children('.filter-label').first().text()
37
- columns: buttons_export_columns
38
- },
39
- {
40
- extend: 'excel',
41
- exportOptions:
42
- format:
43
- header: (str) -> $("<div>#{str}</div>").children('.filter-label').first().text()
36
+ header: (str) -> $("<div>#{str}</div>").children('.search-label').first().text()
44
37
  columns: buttons_export_columns
45
38
  },
46
39
  {
47
40
  extend: 'print',
48
41
  exportOptions:
49
42
  format:
50
- header: (str) -> $("<div>#{str}</div>").children('.filter-label').first().text()
43
+ header: (str) -> $("<div>#{str}</div>").children('.search-label').first().text()
51
44
  columns: ':visible:not(.col-actions)'
52
45
  },
53
46
  ]
54
- colReorder: !simple
55
47
  columns: datatable.data('columns')
56
48
  deferLoading: [datatable.data('display-records'), datatable.data('total-records')]
57
49
  deferRender: true
50
+ displayStart: datatable.data('display-start')
58
51
  dom: "<'row'<'col-sm-4'l><'col-sm-8'B>><'row'<'col-sm-12'tr>><'row'<'col-sm-6'i><'col-sm-6'p>>"
59
- iDisplayLength: datatable.data('display-entries')
52
+ iDisplayLength: datatable.data('display-length')
60
53
  language: { 'lengthMenu': 'Show _MENU_ per page'}
61
- lengthMenu: [[10, 25, 50, 100, 250, 1000, -1], ['10', '25', '50', '100', '250', '1000', 'All']]
62
- order: datatable.data('default-order')
54
+ lengthMenu: [[10, 25, 50, 100, 250, 1000, 9999999], ['10', '25', '50', '100', '250', '1000', 'All']]
55
+ order: datatable.data('display-order')
63
56
  processing: true
64
57
  responsive: true
65
58
  serverParams: (params) ->
66
- table = this.api()
67
- table.columns().flatten().each (index) =>
68
- params['columns'][index]['visible'] = table.column(index).visible()
59
+ api = this.api()
60
+ api.columns().flatten().each (index) => params['columns'][index]['visible'] = api.column(index).visible()
61
+
62
+ $table = $(api.table().node())
63
+ $form = $(".effective-datatable-filters[aria-controls='#{$table.attr('id')}']").first()
64
+
65
+ if $form.length > 0
66
+ params['scope'] = $form.find("input[id^='filters_scope']:checked").val() || ''
67
+ params['filter'] = {}
68
+
69
+ $form.find("[id^='filters_']:not(input[id^='filters_scope'])").each ->
70
+ $input = $(this)
71
+ params['filter'][$input.attr('id').substring(8, $input.attr('id').length)] = $input.val()
72
+
69
73
  serverSide: true
70
74
  scrollCollapse: true
71
75
  pagingType: 'simple_numbers'
72
76
  initComplete: (settings) ->
77
+ initializeReset(this.api())
73
78
  initializeBulkActions(this.api())
74
- initializeFilters(this.api())
79
+ initializeSearch(this.api())
75
80
  drawCallback: (settings) ->
76
81
  $table = $(this.api().table().node())
77
82
 
@@ -87,11 +92,15 @@ initializeDataTables = ->
87
92
  # Copies the bulk actions html, stored in a data attribute on the table, into the buttons area
88
93
  initializeBulkActions = (api) ->
89
94
  $table = $(api.table().node())
90
- bulkActions = $table.data('bulk-actions')
91
95
 
92
- if bulkActions
93
- $table.closest('.dataTables_wrapper').children().first()
94
- .find('.dt-buttons').first().prepend(bulkActions['dropdownHtml'])
96
+ if $table.data('bulk-actions')
97
+ $table.closest('.dataTables_wrapper').children().first().find('.dt-buttons').prepend($table.data('bulk-actions'))
98
+
99
+ initializeReset = (api) ->
100
+ $table = $(api.table().node())
101
+
102
+ if $table.data('reset')
103
+ $table.closest('.dataTables_wrapper').children().first().find('.dt-buttons').prepend($table.data('reset'))
95
104
 
96
105
  # After we perform a bulk action, we have to re-select the checkboxes manually and do a bit of house keeping
97
106
  drawBulkActions = ($table) ->
@@ -125,21 +134,21 @@ initializeDataTables = ->
125
134
  chart = new google.visualization[data['type']](obj)
126
135
  chart.draw(google.visualization.arrayToDataTable(data['data']), data['options'])
127
136
 
128
- # Appends the filter html, stored in the column definitions, into each column header
129
- initializeFilters = (api) ->
137
+ # Appends the search html, stored in the column definitions, into each column header
138
+ initializeSearch = (api) ->
130
139
  api.columns().flatten().each (index) =>
131
140
  $th = $(api.column(index).header())
132
141
  settings = api.settings()[0].aoColumns[index] # column specific settings
133
142
 
134
- if settings.filterSelectedValue # Assign preselected filter values
135
- api.settings()[0].aoPreSearchCols[index].sSearch = settings.filterSelectedValue
143
+ if settings.search && ('' + settings.search).length > 0 # Assign preselected values
144
+ api.settings()[0].aoPreSearchCols[index].sSearch = settings.search
136
145
 
137
- if settings.filterHtml # Append the html filter HTML and initialize input events
138
- $th.append('<br>' + settings.filterHtml)
139
- initializeFilterEvents($th)
146
+ if settings.searchHtml # Append the search html and initialize input events
147
+ $th.append('<br>' + settings.searchHtml)
148
+ initializeSearchEvents($th)
140
149
 
141
150
  # Sets up the proper events for each input
142
- initializeFilterEvents = ($th) ->
151
+ initializeSearchEvents = ($th) ->
143
152
  $th.find('input,select').each (_, input) ->
144
153
  $input = $(input)
145
154
 
@@ -169,23 +178,17 @@ initializeDataTables = ->
169
178
 
170
179
  # Apply EffectiveFormInputs to the Show x per page dropdown
171
180
  if datatable.data('effective-form-inputs')
172
- try table.closest('.dataTables_wrapper').find('.dataTables_length select').select2()
181
+ try table.closest('.dataTables_wrapper').find('.dataTables_length select').removeAttr('name').select2()
173
182
 
174
183
  destroyDataTables = ->
175
184
  $('table.effective-datatable').each ->
176
185
  if $.fn.DataTable.fnIsDataTable(this)
177
186
  $(this).DataTable().destroy()
178
187
 
179
- anotherDestroy = ->
180
- for settings in $.fn.dataTable.settings
181
- $(settings.nTableWrapper).unbind('.DT').find(':not(tbody *)').unbind('.DT')
182
- $(window).unbind('.DT-'+settings.sInstance)
183
-
184
- $.fn.dataTable.settings.length = 0
185
-
186
188
  $ -> initializeDataTables()
187
189
  $(document).on 'page:change', -> initializeDataTables()
188
190
  $(document).on 'turbolinks:load', -> initializeDataTables()
191
+ $(document).on 'turbolinks:render', -> initializeDataTables()
189
192
  $(document).on 'turbolinks:before-cache', -> destroyDataTables()
190
193
 
191
194
 
@@ -0,0 +1,7 @@
1
+ $(document).on 'click', 'a.buttons-reset-cookie', (event) ->
2
+ event.preventDefault()
3
+
4
+ $obj = $(event.currentTarget)
5
+ $obj.find('span').text('Resetting...')
6
+ document.cookie = "#{$obj.data('cookie-name')}=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/"
7
+ location.reload()
@@ -33,6 +33,6 @@
33
33
  onChange: function(element) { }
34
34
  }
35
35
 
36
- $.fn.delayedChange.oldVal = '';
36
+ $.fn.delayedChange.oldVal = 'NO_DELAYED_CHANGE_VALUE';
37
37
 
38
38
  })(jQuery);
@@ -8,7 +8,6 @@ table.dataTable {
8
8
  table.dataTable td,
9
9
  table.dataTable th {
10
10
  -webkit-box-sizing: content-box;
11
- -moz-box-sizing: content-box;
12
11
  box-sizing: content-box;
13
12
  }
14
13
  table.dataTable td.dataTables_empty,
@@ -4,6 +4,5 @@
4
4
  @import 'dataTables/colReorder/colReorder.bootstrap';
5
5
  @import 'dataTables/responsive/responsive.bootstrap';
6
6
 
7
+ @import 'effective_datatables/filters';
7
8
  @import 'effective_datatables/overrides';
8
-
9
- @import 'effective_datatables/scopes';
@@ -1,4 +1,4 @@
1
- .effective-datatable-scopes {
1
+ .effective-datatable-filters {
2
2
  .form-inline {
3
3
  .form-group { margin-right: 10px; }
4
4
  .control-label { margin-right: 10px; }
@@ -46,7 +46,7 @@ table.dataTable.sort-hidden thead .sorting_desc { background-image: none; }
46
46
  table.dataTable .form-group { width: 100%; margin-left: 0px; margin-right: 0px; }
47
47
  table.dataTable select { width: 100%; }
48
48
  table.dataTable .form-control { width: 100%; }
49
- table.dataTable .form-group.datatable_filter_bulk_actions { margin-left: 4px; }
49
+ table.dataTable .form-group.datatable_search_bulk_actions { margin-left: 4px; }
50
50
 
51
51
  // Processing popup
52
52
  div.dataTables_wrapper div.dataTables_processing {
@@ -4,10 +4,7 @@ module Effective
4
4
 
5
5
  # This will respond to both a GET and a POST
6
6
  def show
7
- attributes = (params[:attributes].presence || {}).merge(referer: request.referer)
8
- scopes = (params[:scopes].presence || {})
9
-
10
- @datatable = find_datatable(params[:id]).try(:new, attributes.merge(scopes))
7
+ @datatable = find_datatable(params[:id]).try(:new)
11
8
  @datatable.view = view_context if !@datatable.nil?
12
9
 
13
10
  EffectiveDatatables.authorized?(self, :index, @datatable.try(:collection_class))
@@ -28,6 +25,7 @@ module Effective
28
25
  private
29
26
 
30
27
  def find_datatable(id)
28
+ id = id.gsub('-', '/')
31
29
  id.classify.safe_constantize || id.classify.pluralize.safe_constantize
32
30
  end
33
31
 
@@ -1,7 +1,7 @@
1
1
  # These are expected to be called by a developer. They are part of the datatables DSL.
2
2
  module EffectiveDatatablesHelper
3
3
 
4
- def render_datatable(datatable, input_js_options = nil)
4
+ def render_datatable(datatable, input_js: {}, charts: true, filters: true, simple: false)
5
5
  raise 'expected datatable to be present' unless datatable
6
6
 
7
7
  datatable.view ||= self
@@ -12,121 +12,86 @@ module EffectiveDatatablesHelper
12
12
  return content_tag(:p, "You are not authorized to view this datatable. (cannot :index, #{datatable.collection_class})")
13
13
  end
14
14
 
15
- render partial: 'effective/datatables/datatable',
16
- locals: { datatable: datatable, input_js_options: input_js_options.try(:to_json) }
17
- end
15
+ charts = charts && datatable._charts.present?
16
+ filters = filters && (datatable._scopes.present? || datatable._filters.present?)
17
+
18
+ effective_datatable_params = {
19
+ id: datatable.to_param,
20
+ class: datatable.table_html_class,
21
+ data: {
22
+ 'effective-form-inputs' => defined?(EffectiveFormInputs),
23
+ 'bulk-actions' => datatable_bulk_actions(datatable),
24
+ 'columns' => datatable_columns(datatable),
25
+ 'display-length' => datatable.display_length,
26
+ 'display-order' => [datatable.order_index, datatable.order_direction].to_json(),
27
+ 'display-records' => datatable.to_json[:recordsFiltered],
28
+ 'display-start' => datatable.display_start,
29
+ 'input-js-options' => (input_js || {}).to_json,
30
+ 'reset' => datatable_reset(datatable),
31
+ 'simple' => datatable.simple?.to_s,
32
+ 'source' => effective_datatables.datatable_path(datatable, {format: 'json'}),
33
+ 'total-records' => datatable.to_json[:recordsTotal]
34
+ }
35
+ }
36
+
37
+ if (charts || filters) && !simple
38
+ output = ''.html_safe
39
+
40
+ if charts
41
+ datatable._charts.each { |name, _| output << render_datatable_chart(datatable, name) }
42
+ end
18
43
 
19
- def render_simple_datatable(datatable, input_js_options = nil)
20
- raise 'expected datatable to be present' unless datatable
44
+ if filters
45
+ output << render_datatable_filters(datatable)
46
+ end
21
47
 
22
- datatable.view ||= self
23
- datatable.simple = true
48
+ output << render(partial: 'effective/datatables/datatable',
49
+ locals: { datatable: datatable, effective_datatable_params: effective_datatable_params }
50
+ )
24
51
 
25
- begin
26
- EffectiveDatatables.authorized?(controller, :index, datatable.collection_class) || raise(Effective::AccessDenied)
27
- rescue Effective::AccessDenied => e
28
- return content_tag(:p, "You are not authorized to view this datatable. (cannot :index, #{datatable.collection_class})})")
29
- end
52
+ output
53
+ else
54
+ datatable.attributes[:simple] = true if simple
30
55
 
31
- render partial: 'effective/datatables/datatable',
32
- locals: {datatable: datatable, input_js_options: input_js_options.try(:to_json) }
56
+ render(partial: 'effective/datatables/datatable',
57
+ locals: { datatable: datatable, effective_datatable_params: effective_datatable_params }
58
+ )
59
+ end
33
60
  end
34
61
 
35
- def render_datatable_scopes(datatable)
62
+ def render_datatable_filters(datatable)
36
63
  raise 'expected datatable to be present' unless datatable
37
64
 
38
- return unless datatable.scopes.present?
39
65
  datatable.view ||= self
66
+ return unless datatable._scopes.present? || datatable._filters.present?
67
+
68
+ if datatable._filters_form_required?
69
+ render partial: 'effective/datatables/filters', locals: { datatable: datatable }
70
+ else
71
+ render(partial: 'effective/datatables/filters', locals: { datatable: datatable }).gsub('<form', '<div').gsub('/form>', '/div>').html_safe
72
+ end
40
73
 
41
- render partial: 'effective/datatables/scopes', locals: { datatable: datatable }
42
74
  end
43
75
 
44
76
  def render_datatable_charts(datatable)
45
77
  raise 'expected datatable to be present' unless datatable
46
78
 
47
- return unless datatable.charts.present?
48
79
  datatable.view ||= self
80
+ return unless datatable._charts.present?
49
81
 
50
- datatable.charts.map { |name, _| render_datatable_chart(datatable, name) }.join.html_safe
82
+ datatable._charts.map { |name, _| render_datatable_chart(datatable, name) }.join.html_safe
51
83
  end
52
84
 
53
85
  def render_datatable_chart(datatable, name)
54
86
  raise 'expected datatable to be present' unless datatable
55
87
 
56
- return unless datatable.charts.present?
57
- return unless datatable.charts[name].present?
58
88
  datatable.view ||= self
89
+ return unless datatable._charts[name].present?
59
90
 
60
- options = datatable.charts[name]
61
- chart = datatable.to_json[:charts][name]
62
-
63
- render partial: (options[:partial] || 'effective/datatables/chart'),
64
- locals: { datatable: datatable, chart: chart }
65
- end
66
-
67
- def datatables_admin_path?
68
- @datatables_admin_path ||= (
69
- path = request.path.to_s.downcase.chomp('/') + '/'
70
- referer = request.referer.to_s.downcase.chomp('/') + '/'
71
- (attributes[:admin_path] || referer.include?('/admin/') || path.include?('/admin/')) rescue false
72
- )
73
- end
74
-
75
- # TODO: Improve on this
76
- def datatables_active_admin_path?
77
- attributes[:active_admin_path] rescue false
78
- end
79
-
80
- ### Icon Helpers for actions_column or elsewhere
81
- def show_icon_to(path, options = {})
82
- glyphicon_to('eye-open', path, {title: 'Show'}.merge(options))
83
- end
84
-
85
- def edit_icon_to(path, options = {})
86
- glyphicon_to('edit', path, {title: 'Edit'}.merge(options))
87
- end
88
-
89
- def destroy_icon_to(path, options = {})
90
- defaults = {title: 'Destroy', data: {method: :delete, confirm: 'Delete this item?'}}
91
- glyphicon_to('trash', path, defaults.merge(options))
92
- end
91
+ chart = datatable._charts[name]
92
+ chart_data = datatable.to_json[:charts][name][:data]
93
93
 
94
- def archive_icon_to(path, options = {})
95
- defaults = {title: 'Archive', data: {method: :delete, confirm: 'Archive this item?'}}
96
- glyphicon_to('trash', path, defaults.merge(options))
97
- end
98
-
99
- def unarchive_icon_to(path, options = {})
100
- defaults = {title: 'Unarchive', data: {confirm: 'Unarchive this item?'}}
101
- glyphicon_to('retweet', path, defaults.merge(options))
102
- end
103
-
104
- def settings_icon_to(path, options = {})
105
- glyphicon_to('cog', path, {title: 'Settings'}.merge(options))
106
- end
107
-
108
- def ok_icon_to(path, options = {})
109
- glyphicon_to('ok', path, {title: 'OK'}.merge(options))
110
- end
111
-
112
- def approve_icon_to(path, options = {})
113
- glyphicon_to('ok', path, {title: 'Approve'}.merge(options))
114
- end
115
-
116
- def remove_icon_to(path, options = {})
117
- glyphicon_to('remove', path, {title: 'Remove'}.merge(options))
118
- end
119
-
120
- def glyphicon_to(icon, path, options = {})
121
- content_tag(:a, options.merge(href: path)) do
122
- if icon.start_with?('glyphicon-')
123
- content_tag(:span, '', class: "glyphicon #{icon}")
124
- else
125
- content_tag(:span, '', class: "glyphicon glyphicon-#{icon}")
126
- end
127
- end
94
+ render partial: chart[:partial], locals: { datatable: datatable, chart: chart, chart_data: chart_data }
128
95
  end
129
- alias_method :bootstrap_icon_to, :glyphicon_to
130
- alias_method :glyph_icon_to, :glyphicon_to
131
96
 
132
97
  end