4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/tabledata/rails/view_helpers.rb', line 4
def render_tabledata(table, i18n_scope: nil)
content_tag(:table, class: "table table-striped".freeze) {
concat(
content_tag(:thead) {
content_tag(:tr) {
table..each_with_index { |, index|
next unless is_column_displayed?(table.column_definition(index))
concat(
content_tag(
:th,
t(
i18n_head_key(
table.column_definition(index).accessor,
i18n_scope
)
),
class: ["tabledata-header", table.column_definition(index).accessor],
)
)
}
}
}
).concat(
content_tag(:tbody) {
table.body.each { |row|
concat(
content_tag(:tr) {
row.present(:view).each_with_index { |column, index|
column_definition = table.column_definition(index)
next unless is_column_displayed?(column_definition)
concat(
content_tag(:td, class: error_classes(row, column_definition)) {
concat(column)
concat(
content_tag(
:i,
"".freeze,
class: "error-hint icon-info-sign alert".freeze,
data: {toggle: "tooltip".freeze, html: true},
title: error_text(row, column_definition, i18n_scope),
)
) if column_has_error?(row, column_definition)
}
)
}
}
)
}
}
)
}
end
|