padrino/padrino-framework — pull request #829 by simonc (2012-04-13 10:56:39+00:00)
Title: Adding an options attribute to ProjectModule

Hi,

Here is a patch to add an `options` attribute to the `ProjectModule` class in admin.
The cost is pretty lightweight but it allows to do some nice things in admin.

Using this patch I was able to make this:

``` ruby
# admin/app.rb
class Admin < Padrino::Application
# ...

access_control.roles_for :admin do |role|
role.project_module :thing_1, '/thing_1', :group => :things
role.project_module :thing_2, '/thing_2', :group => :things
role.project_module :stuff, '/stuff'
role.project_module :other, '/other'
role.project_module :accounts, '/accounts'
end
end
```

``` erb
<%# admin/views/layouts/application.erb %>

<% project_modules.group_by { |pm| pm.options[:group] }.each do |group, modules| %>
<% if group %>

<%= mt group %>

<%= partial "shared/admin_menu_item", collection: modules %>

<% else %>
<%= partial "shared/admin_menu_item", collection: modules %>
<% end %>

```

And now I have dropdown tabs in my admin :)

I know it's not the prettiest code in the world but it was just an example of what could be possible with just this very light addition :)