effective_datatables 4.34.0 → 4.35.1

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
  SHA256:
3
- metadata.gz: 26894b39aa930851150fb6139d8207d61dd054910d78b78a88cb8d961291b10e
4
- data.tar.gz: d1c9d28d703e5db73743f23ca73c147e334d81b930219f8e756f72189ba03c1c
3
+ metadata.gz: 58ba852489ca6c3a824b03443eaeadde149e051212055e2bd62a1d8b59972f26
4
+ data.tar.gz: a112f67a6cc67a2d082f9f19ebd70b8dc8ef6b8537851cb1508782159d7598c4
5
5
  SHA512:
6
- metadata.gz: 2bfb288465fbb24ae508957762bc62f2f9b16628460304ff0d94337726b92535ecd82115d9fe518ddda0a9569a507e6a6d91e8a19a192ec56904ae5ee39558b6
7
- data.tar.gz: fb1a9edee1c2d47158ac6cf352926ef05566d36bf88a54f0ad6dca288f2b89c44a73f2733576e57b76b1e8316edf72119e535abfb4ae591545f1867ab7ada703
6
+ metadata.gz: d46724dd25b495e4ccb796e688ddb9e0ea2c341d00755486419b1fa37efd2700b96a0becc6e0725e49354cec4eedae86295d13ffa168fa2ec7b806b92b05f4dd
7
+ data.tar.gz: a75f57a5ce59fd95997b5a550787e330019c286ff5ce9bb8782e2120b3312568c0f3eff47e0629df011a4a273f4cfb7006d059a1678be452f4c4d18ee1e72779
@@ -3,6 +3,7 @@ initializeDataTables = (target) ->
3
3
  datatable = $(this)
4
4
  options = datatable.data('options') || {}
5
5
  buttons_export_columns = options['buttons_export_columns'] || ':not(.col-actions)'
6
+ nested = datatable.data('nested')
6
7
  reorder = datatable.data('reorder')
7
8
 
8
9
  if datatable.data('inline') && datatable.closest('form').length > 0
@@ -178,6 +179,9 @@ initializeDataTables = (target) ->
178
179
  if reorder
179
180
  table.DataTable().on('row-reorder', (event, diff, edit) -> $(event.target).DataTable().reorder(event, diff, edit))
180
181
 
182
+ if nested
183
+ table.closest('.dataTables_wrapper').addClass('dataTables_wrapper_nested')
184
+
181
185
  table.addClass('initialized')
182
186
  table.children('thead').trigger('effective-bootstrap:initialize')
183
187
  table.children('thead').find('input[autofocus]').first().focus()
@@ -9,6 +9,7 @@ $(document).on 'ajax:before', '.dataTables_wrapper .col-actions', (event) ->
9
9
  $table = $(event.target).closest('table')
10
10
 
11
11
  return true if ('' + $action.data('inline')) == 'false'
12
+ return true if ('' + $action.data('nested-datatable')) == 'true'
12
13
 
13
14
  $params = $.param(
14
15
  {
@@ -156,7 +157,12 @@ afterEdit = ($action) ->
156
157
  $tr = $action.closest('tr')
157
158
  $table = $tr.closest('table')
158
159
 
159
- html = buildRow($tr.children('td').length, EffectiveForm.remote_form_payload)
160
+ nestedDatatableAction = $tr.find('a[data-nested-datatable]')
161
+
162
+ html = if nestedDatatableAction.length > 0
163
+ buildNestedDatatableRow($tr.children('td').length, EffectiveForm.remote_form_payload, nestedDatatableAction.attr('title'))
164
+ else
165
+ buildRow($tr.children('td').length, EffectiveForm.remote_form_payload)
160
166
 
161
167
  $tr.data('inline-form-original-html', $tr.children().detach())
162
168
  $tr.html(html)
@@ -200,6 +206,12 @@ buildRow = (length, payload) ->
200
206
  "<a href='#' class='btn btn-sm btn-outline-primary' title='Cancel' data-role='inline-form-cancel'>Cancel</a>" +
201
207
  "</td>"
202
208
 
209
+ buildNestedDatatableRow = (length, payload, title) ->
210
+ "<td class='col-inline-form' colspan='#{length-1}'><div class='nested-datatable-container-parent'><div class='nested-datatable-container'><div class='nested-datatable-title'>#{title || ''}</div>#{payload}</div></div></td>" +
211
+ "<td class='col-actions col-actions-inline-form'>" +
212
+ "<a href='#' class='btn btn-sm btn-outline-primary' title='Cancel' data-role='inline-form-cancel'>Cancel</a>" +
213
+ "</td>"
214
+
203
215
  expand = ($table) ->
204
216
  $wrapper = $table.closest('.dataTables_wrapper').addClass('effective-datatables-inline-expanded')
205
217
  $table.on 'draw.dt', (event) ->
@@ -0,0 +1,5 @@
1
+ # Make all links for nested datatables open in new tabs
2
+ $(document).on 'click', '.dataTables_wrapper_nested a', (event) ->
3
+ $link = $(event.currentTarget)
4
+ $link.attr('target', '_blank')
5
+ true
@@ -72,7 +72,7 @@ table.dataTable > thead .sorting_desc {
72
72
  table.dataTable thead {
73
73
  th.col-actions {
74
74
  text-align: right;
75
- span { display: block; height: 1.25em; }
75
+ span { display: block; }
76
76
  }
77
77
  }
78
78
 
@@ -103,6 +103,15 @@ table.dataTable thead {
103
103
  }
104
104
  }
105
105
 
106
+ // When Inline Expanded with Nested
107
+ .dataTables_wrapper.effective-datatables-inline-expanded {
108
+ .dataTables_wrapper_nested {
109
+ .dt-buttons { opacity: inherit; }
110
+ .dataTables_entries { opacity: inherit; }
111
+ .dataTables_paginate { opacity: inherit; }
112
+ }
113
+ }
114
+
106
115
  table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
107
116
  table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
108
117
  color: #0275d8;
@@ -175,6 +184,10 @@ table.dataTable > thead {
175
184
  p { margin-bottom: 0; }
176
185
  }
177
186
 
187
+ .form-group.datatables-filters-present {
188
+ margin-top: 1.75em;
189
+ }
190
+
178
191
  // Processing div
179
192
  div.dataTables_wrapper div.dataTables_processing {
180
193
  margin: -26px 25% 0px 25%;
@@ -312,3 +325,14 @@ div.dt-button-collection .dt-button-active:after {
312
325
  right: auto;
313
326
  left: 0.5rem;
314
327
  }
328
+
329
+ // Nested Datatables
330
+ .nested-datatable-container-parent {
331
+ padding-left: 0.25em;
332
+ padding-right: 0.25em;
333
+ container-type: inline-size;
334
+ }
335
+
336
+ .nested-datatable-container {
337
+ width: 100%;
338
+ }
@@ -2,7 +2,7 @@
2
2
 
3
3
  # These are expected to be called by a developer. They are part of the datatables DSL.
4
4
  module EffectiveDatatablesHelper
5
- def render_datatable(datatable, input_js: {}, buttons: true, charts: true, download: nil, entries: true, filters: true, inline: false, namespace: nil, pagination: true, search: true, simple: false, short: false, sort: true)
5
+ def render_datatable(datatable, input_js: {}, buttons: true, charts: true, download: nil, entries: true, filters: true, inline: false, namespace: nil, nested: false, pagination: true, search: true, simple: false, short: false, sort: true)
6
6
  raise 'expected datatable to be present' unless datatable
7
7
  raise 'expected input_js to be a Hash' unless input_js.kind_of?(Hash)
8
8
 
@@ -19,6 +19,7 @@ module EffectiveDatatablesHelper
19
19
  end
20
20
 
21
21
  datatable.attributes[:inline] = true if inline
22
+ datatable.attributes[:nested] = true if nested
22
23
  datatable.attributes[:sortable] = false unless sort
23
24
  datatable.attributes[:searchable] = false unless search
24
25
  datatable.attributes[:downloadable] = false unless download
@@ -68,6 +69,7 @@ module EffectiveDatatablesHelper
68
69
  'inline' => inline.to_s,
69
70
  'language' => EffectiveDatatables.language(I18n.locale),
70
71
  'length-menu' => datatable_length_menu(datatable),
72
+ 'nested' => nested.to_s,
71
73
  'options' => input_js.to_json,
72
74
  'reorder' => datatable.reorder?.to_s,
73
75
  'reorder-index' => (datatable.columns[:_reorder][:index] if datatable.reorder?).to_s,
@@ -133,4 +135,11 @@ module EffectiveDatatablesHelper
133
135
  @_inline_datatable ||= datatable
134
136
  end
135
137
 
138
+ def nested_datatable_link_to(title, path, options = {})
139
+ options[:class] ||= 'btn btn-sm btn-link'
140
+ options['data-remote'] = true
141
+ options['data-nested-datatable'] = true
142
+
143
+ link_to(title, path, options)
144
+ end
136
145
  end
@@ -5,7 +5,10 @@ module Effective
5
5
  module Dsl
6
6
 
7
7
  def bulk_actions(&block)
8
- define_method('initialize_bulk_actions') { dsl_tool.instance_exec(&block); dsl_tool.bulk_actions_col }
8
+ define_method('initialize_bulk_actions') do
9
+ actions = dsl_tool.instance_exec(&block)
10
+ dsl_tool.bulk_actions_col if actions.present?
11
+ end
9
12
  end
10
13
 
11
14
  def charts(&block)
@@ -11,7 +11,7 @@
11
11
  - else
12
12
  = datatable_filter_tag(form, datatable, name, opts)
13
13
 
14
- .form-group.col-auto
14
+ .form-group.col-auto{class: (datatable._filters.present? ? 'datatables-filters-present' : 'datatables-filters-blank')}
15
15
  - if datatable._filters_form_required?
16
16
  = form.save t('effective_datatables.apply'), 'data-disable-with': t('effective_datatables.applying'), class: 'btn btn-sm btn-secondary'
17
17
  - else
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.34.0'.freeze
2
+ VERSION = '4.35.1'.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: 4.34.0
4
+ version: 4.35.1
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: 2025-04-29 00:00:00.000000000 Z
11
+ date: 2025-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -118,6 +118,7 @@ files:
118
118
  - app/assets/javascripts/effective_datatables/flash.js.coffee
119
119
  - app/assets/javascripts/effective_datatables/initialize.js.coffee
120
120
  - app/assets/javascripts/effective_datatables/inline_crud.js.coffee
121
+ - app/assets/javascripts/effective_datatables/nested.js.coffee
121
122
  - app/assets/javascripts/effective_datatables/overrides.js.coffee
122
123
  - app/assets/javascripts/effective_datatables/params.js.coffee
123
124
  - app/assets/javascripts/effective_datatables/reorder.js.coffee