Skip to content

Commit dac4617

Browse files
committed
v0.2.8
1 parent add0129 commit dac4617

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ function on_change_category( el ) {
108108

109109
```rb
110110
member_action :save, method: [:post] do
111-
render ActiveAdmin::DynamicFields::update( resource, params )
112-
# render ActiveAdmin::DynamicFields::update( resource, params, [:published] )
113-
# render ActiveAdmin::DynamicFields::update( resource, params, Article::permit_params )
111+
render ActiveAdmin::DynamicFields.update(resource, params)
112+
# render ActiveAdmin::DynamicFields.update(resource, params, [:published])
113+
# render ActiveAdmin::DynamicFields.update(resource, params, Article::permit_params)
114114
end
115115
```
116116

@@ -119,24 +119,24 @@ end
119119
```rb
120120
# Edit a string:
121121
column :title do |row|
122-
div row.title, ActiveAdmin::DynamicFields::edit_string( :title, save_admin_article_path( row.id ) )
122+
div row.title, ActiveAdmin::DynamicFields.edit_string(:title, save_admin_article_path(row.id))
123123
end
124124
# Edit a boolean:
125125
column :published do |row|
126-
status_tag row.published, ActiveAdmin::DynamicFields::edit_boolean( :published, save_admin_article_path( row.id ), row.published )
126+
status_tag row.published, ActiveAdmin::DynamicFields.edit_boolean(:published, save_admin_article_path(row.id), row.published)
127127
end
128128
# Edit a select ([''] allow to have a blank value):
129129
column :author do |row|
130-
select ActiveAdmin::DynamicFields::edit_select( :author_id, save_admin_article_path( row.id ) ) do
131-
options_for_select( [''] + Author.pluck( :name, :id ), row.author_id )
130+
select ActiveAdmin::DynamicFields.edit_select(:author_id, save_admin_article_path(row.id)) do
131+
options_for_select([''] + Author.pluck(:name, :id), row.author_id)
132132
end
133133
end
134134
```
135135

136-
- In *show* config (less useful):
136+
- In *show* config (inside `attributes_table` block):
137137
```rb
138138
row :title do |row|
139-
div row.title, ActiveAdmin::DynamicFields::edit_string( :title, save_admin_article_path( row.id ) )
139+
div row.title, ActiveAdmin::DynamicFields.edit_string(:title, save_admin_article_path(row.id))
140140
end
141141
```
142142

@@ -150,12 +150,16 @@ Prepare the content dialog - in Active Admin Author config:
150150
ActiveAdmin.register Author do
151151
# ...
152152
member_action :dialog do
153-
content = '<dl style="margin: 12px">'
154-
[:name, :age, :created_at].each do |field|
155-
content += "<dt>#{Author.human_attribute_name(field)}:</dt><dd>#{resource[field]}</dd>"
153+
record = resource
154+
context = Arbre::Context.new do
155+
dl do
156+
%i[name age created_at].each do |field|
157+
dt "#{Author.human_attribute_name(field)}:"
158+
dd record[field]
159+
end
160+
end
156161
end
157-
content += '</dl>'
158-
render plain: content
162+
render plain: context
159163
end
160164
# ...
161165
end
@@ -170,7 +174,7 @@ ActiveAdmin.register Article do
170174
attributes_table do
171175
# ...
172176
row :author do
173-
link_to object.author.name, dialog_admin_author_path( object.author ), title: object.author.name, 'data-df-dialog': true, 'data-df-icon': true
177+
link_to object.author.name, dialog_admin_author_path(object.author), title: object.author.name, 'data-df-dialog': true, 'data-df-icon': true
174178
end
175179
end
176180
end
@@ -188,7 +192,7 @@ Take a look at [other ActiveAdmin components](https://github.com/blocknotes?utf8
188192

189193
## Contributors
190194

191-
- [Mattia Roccoberton](http://blocknot.es) - creator, maintainer
195+
- [Mattia Roccoberton](http://blocknot.es): author
192196

193197
## License
194198

lib/activeadmin/dynamic_fields/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module ActiveAdmin
44
module DynamicFields
5-
VERSION = '0.2.6'
5+
VERSION = '0.2.8'
66
end
77
end

0 commit comments

Comments
 (0)