stimulus_rails_datatables 0.2.0 → 0.2.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: 2faf924c4d9e189532bc87d7ed9d73cead45a3006b794699376280ac1457cec8
4
- data.tar.gz: 56f11bedf42983e7ff412cd643282b4692fa95295fed81de36cea56eb4758c05
3
+ metadata.gz: 3f9b348bd0771be77c0c51038263df9c7a7dcf0f34e2358de9e4ebca5f197f32
4
+ data.tar.gz: 42cb89233770c34f3ec2357ee7746bd0f96595adbc4d07202a99d6f3548b195a
5
5
  SHA512:
6
- metadata.gz: 0a280c12462841c29655a33739029a5662e38b81a34ef91a5fca29cfdc22c99ba11a17c93330d0e416cff32c89c7f7f8f99086484ff2435c6a1db0d7d924ae22
7
- data.tar.gz: 9fd54a185d332a011a013d93ae0a9403761c38c5cc342988815580001c0bff5922ac370be25ac3fbd004aced0a610c47b21b9727b0d87208a16010be1879eb0c
6
+ metadata.gz: 6b4a7982772ca9aef709aaba60b1105a945e28ec0a5f799a0997a3d539207a8c5b7dc266e7b2cc60c16ae3955d8fd85b0d9778080fde8b0dd082e03c2a90a9ea
7
+ data.tar.gz: 6c8732a586a142ed9d3e804d410ac00da8fd714cfbfa43827364313b501ea2a1ffcf159237c58faf8c3b89c34b9ccab5fc730d84be5737914210140a9086d4ef
@@ -16,7 +16,8 @@ export default class extends Controller {
16
16
  processing: { type: Boolean, default: true },
17
17
  pagingType: { type: String, default: 'simple_numbers' },
18
18
  searching: { type: Boolean, default: true },
19
- lengthChange: { type: Boolean, default: true }
19
+ lengthChange: { type: Boolean, default: true },
20
+ responsive: { type: Boolean, default: true }
20
21
  }
21
22
 
22
23
  connect() {
@@ -82,6 +83,7 @@ export default class extends Controller {
82
83
  if (datatableWrapper === null) {
83
84
  Turbo.cache.exemptPageFromCache()
84
85
 
86
+ const responsiveValue = this.responsiveValue
85
87
  const options = {
86
88
  lengthMenu: [[10, 25, 50, 100], [10, 25, 50, 100]],
87
89
  searching: this.searchingValue,
@@ -93,7 +95,7 @@ export default class extends Controller {
93
95
  pagingType: this.pagingTypeValue,
94
96
  order: this.orderValue,
95
97
  columns: this.columnsValue,
96
- responsive: true,
98
+ responsive: this.responsiveValue,
97
99
  language: {
98
100
  processing: '<div class="spinner-border"></div><div class="mt-2">Loading...</div>',
99
101
  lengthMenu: 'show <span class="px-2">_MENU_</span> entries'
@@ -103,6 +105,15 @@ export default class extends Controller {
103
105
  topEnd: 'search',
104
106
  bottomStart: 'info',
105
107
  bottomEnd: 'paging'
108
+ },
109
+ initComplete: function() {
110
+ if (responsiveValue === false) {
111
+ // Add overflow-x only to the table wrapper (not the whole layout) this is alternative of scrollX
112
+ const tableWrapper = document.querySelector(`#${datatableId}_wrapper .dt-layout-table`)
113
+ if (tableWrapper) {
114
+ tableWrapper.classList.add('overflow-x-scroll')
115
+ }
116
+ }
106
117
  }
107
118
  }
108
119
 
@@ -7,7 +7,7 @@ module StimulusRailsDatatables
7
7
  searching = options.fetch(:searching, true)
8
8
  length_change = options.fetch(:length_change, true)
9
9
  state_save = options.fetch(:state_save, true)
10
- scroll_x = options.fetch(:scroll_x, false)
10
+ responsive = options.fetch(:responsive, true)
11
11
  columns = []
12
12
 
13
13
  yield DatatableBuilder.new(columns)
@@ -21,7 +21,7 @@ module StimulusRailsDatatables
21
21
  datatable_searching_value: searching,
22
22
  datatable_length_change_value: length_change,
23
23
  datatable_state_save_value: state_save,
24
- datatable_scroll_x_value: scroll_x
24
+ datatable_responsive_value: responsive
25
25
  }
26
26
 
27
27
  content_tag(:div, data: data) do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StimulusRailsDatatables
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimulus_rails_datatables
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Den Meralpis