Skip to content

Commit

Permalink
v0.2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
blocknotes committed Aug 28, 2020
1 parent add0129 commit dac4617
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
36 changes: 20 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ function on_change_category( el ) {

```rb
member_action :save, method: [:post] do
render ActiveAdmin::DynamicFields::update( resource, params )
# render ActiveAdmin::DynamicFields::update( resource, params, [:published] )
# render ActiveAdmin::DynamicFields::update( resource, params, Article::permit_params )
render ActiveAdmin::DynamicFields.update(resource, params)
# render ActiveAdmin::DynamicFields.update(resource, params, [:published])
# render ActiveAdmin::DynamicFields.update(resource, params, Article::permit_params)
end
```

Expand All @@ -119,24 +119,24 @@ end
```rb
# Edit a string:
column :title do |row|
div row.title, ActiveAdmin::DynamicFields::edit_string( :title, save_admin_article_path( row.id ) )
div row.title, ActiveAdmin::DynamicFields.edit_string(:title, save_admin_article_path(row.id))
end
# Edit a boolean:
column :published do |row|
status_tag row.published, ActiveAdmin::DynamicFields::edit_boolean( :published, save_admin_article_path( row.id ), row.published )
status_tag row.published, ActiveAdmin::DynamicFields.edit_boolean(:published, save_admin_article_path(row.id), row.published)
end
# Edit a select ([''] allow to have a blank value):
column :author do |row|
select ActiveAdmin::DynamicFields::edit_select( :author_id, save_admin_article_path( row.id ) ) do
options_for_select( [''] + Author.pluck( :name, :id ), row.author_id )
select ActiveAdmin::DynamicFields.edit_select(:author_id, save_admin_article_path(row.id)) do
options_for_select([''] + Author.pluck(:name, :id), row.author_id)
end
end
```

- In *show* config (less useful):
- In *show* config (inside `attributes_table` block):
```rb
row :title do |row|
div row.title, ActiveAdmin::DynamicFields::edit_string( :title, save_admin_article_path( row.id ) )
div row.title, ActiveAdmin::DynamicFields.edit_string(:title, save_admin_article_path(row.id))
end
```

Expand All @@ -150,12 +150,16 @@ Prepare the content dialog - in Active Admin Author config:
ActiveAdmin.register Author do
# ...
member_action :dialog do
content = '<dl style="margin: 12px">'
[:name, :age, :created_at].each do |field|
content += "<dt>#{Author.human_attribute_name(field)}:</dt><dd>#{resource[field]}</dd>"
record = resource
context = Arbre::Context.new do
dl do
%i[name age created_at].each do |field|
dt "#{Author.human_attribute_name(field)}:"
dd record[field]
end
end
end
content += '</dl>'
render plain: content
render plain: context
end
# ...
end
Expand All @@ -170,7 +174,7 @@ ActiveAdmin.register Article do
attributes_table do
# ...
row :author do
link_to object.author.name, dialog_admin_author_path( object.author ), title: object.author.name, 'data-df-dialog': true, 'data-df-icon': true
link_to object.author.name, dialog_admin_author_path(object.author), title: object.author.name, 'data-df-dialog': true, 'data-df-icon': true
end
end
end
Expand All @@ -188,7 +192,7 @@ Take a look at [other ActiveAdmin components](https://github.com/blocknotes?utf8

## Contributors

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

## License

Expand Down
2 changes: 1 addition & 1 deletion lib/activeadmin/dynamic_fields/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module ActiveAdmin
module DynamicFields
VERSION = '0.2.6'
VERSION = '0.2.8'
end
end

0 comments on commit dac4617

Please sign in to comment.