New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an options attribute to ProjectModule #829

Merged
merged 1 commit into from Apr 27, 2012

Conversation

Projects
None yet
4 participants
@simonc

simonc commented Apr 13, 2012

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:

# 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
<%# admin/views/layouts/application.erb %>
<div id="main-navigation">
  <ul class="wat-cf">
    <% project_modules.group_by { |pm| pm.options[:group] }.each do |group, modules| %>
      <% if group %>
        <li class="dropdown">
          <%= mt group %>
          <ul>
            <%= partial "shared/admin_menu_item", collection: modules %>
          </ul>
        </li>
      <% else %>
        <%= partial "shared/admin_menu_item", collection: modules %>
      <% end %>
  </ul>
</div>

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 :)

@skade

This comment has been minimized.

Show comment
Hide comment
@skade

skade Apr 13, 2012

Member

I have no objection to this: it just adds a free-form attribute that can be consumed by the user for interface customization. It doesn't change any other behaviour.

Member

skade commented Apr 13, 2012

I have no objection to this: it just adds a free-form attribute that can be consumed by the user for interface customization. It doesn't change any other behaviour.

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Apr 13, 2012

Member

Yeah looks fine. @DAddYE ?

Member

nesquena commented Apr 13, 2012

Yeah looks fine. @DAddYE ?

DAddYE added a commit that referenced this pull request Apr 27, 2012

Merge pull request #829 from simonc/adding-options-to-project-module
Adding an options attribute to ProjectModule

@DAddYE DAddYE merged commit fd716cb into padrino:master Apr 27, 2012

@DAddYE

This comment has been minimized.

Show comment
Hide comment
@DAddYE

DAddYE Apr 27, 2012

Member

Thanks @simonc

Member

DAddYE commented Apr 27, 2012

Thanks @simonc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment