Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Expose
region_name
to partials which hook into multiple regions
An extension can hook its view partial to multiple points in the admin UI: ## in MyExtension#activate admin.user.index[:thead].unshift 'users/index_extras' admin.user.index.add :thead, 'created_at_header', :after => 'roles_header' admin.user.index[:tbody].unshift 'users/index_extras' admin.user.index.add :tbody, 'created_at_cell', :after => 'roles_cell' Knowing the region name, the partial can adjust its output depending on the context. Here the extension changes user names to be displayed in uppercase caps and adds another column to the users overview table. It also pushes a custom stylesheet onto the stylesheets stack. ## in views/users/_index_extras.html.haml - if :thead == region_name - include_stylesheet 'admin/my_extension_extras' - defaults.created_at_header do %th.created_at Created at - elsif :tbody == region_name - defaults.title_cell do %td.user = link_to user.name.upcase, edit_admin_user_url(user) - defaults.created_at_cell do %td.created_at %time{ :datetime => user.created_at.xmlschema } &== #{time_ago_in_words(user.created_at)} ago
- Loading branch information