8000 Unify specifying label in attributes_table component (#8458) · til/activeadmin@b87754a · GitHub
[go: up one dir, main page]

Skip to content

Commit b87754a

Browse files
authored
Unify specifying label in attributes_table component (activeadmin#8458)
* Unify specifying label in show -> attributes_table closes activeadmin#3359, closes activeadmin#167 * add specs
1 parent 1cf0414 commit b87754a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/active_admin/views/components/attributes_table.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def rows(*attrs)
2323

2424
def row(*args, &block)
2525
title = args[0]
26+
data = args[1] || args[0]
2627
options = args.extract_options!
2728
options["data-row"] = title.to_s.parameterize(separator: "_") if title.present?
2829

@@ -32,7 +33,7 @@ def row(*args, &block)
3233
end
3334
@collection.each do |record|
3435
td do
35-
content_for(record, block || title)
36+
content_for(record, block || data)
3637
end
3738
end
3839
end

spec/unit/views/components/attributes_table_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@
4747
end
4848
end
4949
},
50+
"when you create each row with a string and symbol" => proc {
51+
render_arbre_component(assigns) do
52+
attributes_table_for post do
53+
row "Id", :id
54+
row "Title", :title
55+
row "Body", :body
56+
end
57+
end
58+
},
5059
"when you create each row with a custom block that returns nil" => proc {
5160
render_arbre_component(assigns) do
5261
attributes_table_for post do

0 commit comments

Comments
 (0)
0