rollincode / rails_admin_theme

rails_admin theme flat theme
MIT License
149 stars 119 forks source link

Rails admin navigation parent doesn't work #12

Closed mmalek-sa closed 6 years ago

mmalek-sa commented 6 years ago

From rails admin wiki: https://github.com/sferik/rails_admin/wiki/Navigation

# Given there are the following models: League, Team and Division

config.model 'Team' do
  parent League
end

config.model 'Division' do
  parent League
end

You should be able to group models under parent models. This feature doesn't work with rollincode/rails_admin_theme. This is really nice feature when you have lots of models.

nicovak commented 6 years ago

It should works, I never had any issue on It. Have you configured your parent's model first ?

eg: https://github.com/rollincode/rollinbox/blob/master/app/models/concerns/rails_admin/parameter_admin.rb

mmalek-sa commented 6 years ago

I was suspicious at first regarding my own code, but then I just switched to default theme and it worked so I thought maybe it's a bug with theme. This is what I have in my config/initializers/rails_admin.rb which works with default theme:

config.model TemplateVersion do
    parent Template
    edit do
      field :version
      field :template
      field :content, :ck_editor
      field :active
      field :language
    end
  end
nicovak commented 6 years ago

Can you show your Template config please ?

mmalek-sa commented 6 years ago

It's an open source project, You can check the whole config here:

https://github.com/DataRights/MAPPED/blob/develop/config/initializers/rails_admin.rb

I'm not doing any config on Template model. I tested adding an empty config as well, but that didn't help either.

  config.model Template do
  end

  config.model User do
  end

  config.model TemplateVersion do
    parent Template
    edit do
      field :version
      field :template
      field :content, :ck_editor
      field :active
      field :language
    end
  end
nicovak commented 6 years ago

Can you try with this:

config.model Template do
    navigation_label 'Template'
end
mmalek-sa commented 6 years ago

Very cool! It works great! Thanks a ton. Sorry to waste your time I thought 'navigation_label' is optional.

nicovak commented 6 years ago

You'r welcome, I guess I already had a similar issue. Don't worry, I'm happy to help, happy coding ;)