infotable 1.4.0 → 1.4.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 +4 -4
- data/app/assets/javascripts/infotable/controllers/table_controller.js +14 -5
- data/app/helpers/infotable/tables_helper.rb +11 -0
- data/app/views/infotable/tables/_table_rows.html.erb +1 -1
- data/app/views/infotable/tables/show.html.erb +1 -1
- data/lib/infotable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f00cd7591b4bc03f8f7443771dc1be2abc2e022602a2a2b14a61090d6eea76aa
|
|
4
|
+
data.tar.gz: 1c48ace8adb272674a1b0138b7aa1744dfe5154695b87ea5e1773cc918d912fc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9ed45ecaf4c41b844dd6a7df34e35bcecefe593fa146fbe352ec9c6e4b20501f7661464a383f6a6ae386190e13d6a4cb395765c6ea4450f1d2637f442256c148
|
|
7
|
+
data.tar.gz: 79fae3ddc36f3c98c826eb18fcb9856f810e5d8fd2681eb9244ba3577efa7a397b384eb8bb170c791cd1668c5c5f5e444f546553d55cffb0cd099813555366bd
|
|
@@ -848,11 +848,20 @@ export default class extends Controller {
|
|
|
848
848
|
const cells = table.querySelectorAll(`th[data-column-name="${escaped}"], td[data-column-name="${escaped}"]`)
|
|
849
849
|
|
|
850
850
|
cells.forEach(cell => {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
851
|
+
// Remember how the server rendered the cell (action columns have width/min-width but no max-width)
|
|
852
|
+
if (cell.dataset.defaultWidth === undefined) {
|
|
853
|
+
cell.dataset.defaultWidth = cell.style.width
|
|
854
|
+
cell.dataset.defaultMaxWidth = cell.style.maxWidth
|
|
855
|
+
cell.dataset.defaultMinWidth = cell.style.minWidth
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
if (width === null) {
|
|
859
|
+
cell.style.width = cell.dataset.defaultWidth
|
|
860
|
+
cell.style.maxWidth = cell.dataset.defaultMaxWidth
|
|
861
|
+
cell.style.minWidth = cell.dataset.defaultMinWidth
|
|
862
|
+
} else {
|
|
863
|
+
cell.style.width = cell.style.maxWidth = cell.style.minWidth = `${width}px`
|
|
864
|
+
}
|
|
856
865
|
})
|
|
857
866
|
}
|
|
858
867
|
|
|
@@ -28,6 +28,17 @@ module Infotable
|
|
|
28
28
|
render partial: "infotable/tables/table", locals: locals
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
# Inline width style for a header/body cell. Data columns are clipped to their width (ellipsis);
|
|
32
|
+
# action columns hold buttons, so their width is only a minimum and the column grows to fit all
|
|
33
|
+
# of them (a clipped "Delete" button is worse than a wider column).
|
|
34
|
+
def infotable_cell_width_style(column, ellipsis: false)
|
|
35
|
+
if %w[action actions].include?(column[:type].to_s)
|
|
36
|
+
"width: 1%; min-width: #{column[:width]}; white-space: nowrap;"
|
|
37
|
+
else
|
|
38
|
+
"width: #{column[:width]}; max-width: #{column[:width]}; overflow: hidden;#{' text-overflow: ellipsis;' if ellipsis}"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
31
42
|
# Format cell value based on column definition
|
|
32
43
|
def format_cell_value(record, column, table_class = nil)
|
|
33
44
|
value = (table_class || Infotable::Base).cell_value(record, column)
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<% table_class.columns.each do |column| %>
|
|
30
30
|
<td data-column-name="<%= column[:name] %>"
|
|
31
31
|
data-default-visible="<%= column[:visible] %>"
|
|
32
|
-
style="
|
|
32
|
+
style="<%= infotable_cell_width_style(column, ellipsis: true) %>"
|
|
33
33
|
class="<%= cell_padding %> whitespace-nowrap <%= text_size %> text-gray-700 dark:text-gray-300">
|
|
34
34
|
<%= format_cell_value(record, column, table_class) %>
|
|
35
35
|
</td>
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
data-column-name="<%= column[:name] %>"
|
|
35
35
|
data-default-visible="<%= column[:visible] %>"
|
|
36
36
|
<%= tag.attributes(data: { default_pinned: column[:pinned] }) if column[:pinned] %>
|
|
37
|
-
style="
|
|
37
|
+
style="<%= infotable_cell_width_style(column) %>"
|
|
38
38
|
class="<%= header_padding %> text-left text-xs font-semibold text-gray-900 dark:text-gray-100 tracking-wider select-none bg-gray-50 dark:bg-gray-800 sticky top-0 z-20">
|
|
39
39
|
<% if column[:sortable] %>
|
|
40
40
|
<% sort_index = current_sorts.index { |name, _| name == column[:name].to_s } %>
|
data/lib/infotable/version.rb
CHANGED