scarfacedeb / rails_admin_globalize_field

Tabbed interface and custom field type for globalize translations for Rails_admin
MIT License
50 stars 60 forks source link

Missing partial rails_admin/main/_form_globalize_tabs in ruby 3 #43

Open raelgc opened 1 year ago

raelgc commented 1 year ago

While using:

I'm getting the following error while trying to edit any model:

ActionView::MissingTemplate in RailsAdmin::Main#edit

Showing /home/rael/.rvm/gems/ruby-3.1.2@foobar-set/gems/rails_admin-3.0.0/app/views/rails_admin/main/edit.html.erb where line #2 raised:

Missing partial rails_admin/main/_form_globalize_tabs with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby]}. Searched in:
  * "/home/rael/Projects/www/foobar/app/views"
  * "/home/rael/.rvm/gems/ruby-3.1.2@foobar-set/gems/delayed-web-0.4.9/app/views"
  * "/home/rael/.rvm/gems/ruby-3.1.2@foobar-set/gems/rails_admin_globalize_field-1.2.0/app/views"
  * "/home/rael/.rvm/gems/ruby-3.1.2@foobar-set/gems/rails_admin-3.0.0/app/views"
Sankalp-Dwivedi commented 1 year ago

Hi, @raelgc did you got any luck with this? Things are also not working for rails 7. @scarfacedeb

raelgc commented 1 year ago

No luck, same issue with rails 7 too. Basically I've got ride of this gem and, as in our project we have only 1 admin, we've are leaving now with the raw i18n entries.

newfylox commented 1 year ago

Since haml format is no longer supported in new rails_admin 3, we need to override the template, using erb format for example.

Right now I have the form showing BUT the issue that I have right now is that it doesn't update my translation fields when saving the form.

Do you have an idea of what I need to change to make my nested form updates the fields?

<%# create a file app/views/rails_admin/main/_form_globalize_tabs.html.erb and put the code below %>

<div class="controls">
  <ul class="nav nav-tabs" role="tablist" style="margin-top:5px">
    <% field.tabs.each do |tab| %>
      <li class="nav-item" role="presentation">
        <button class="nav-link<%= (" active" if tab.active?) %><%= " text-danger" unless tab.valid? %>" id="<%= tab.label %>-tab" data-bs-toggle="tab" data-bs-target="#<%= tab.label %>" type="button" role="tab" aria-controls="<%= tab.label %>" aria-selected="true"><%= tab.label %></button>
      </li>
    <% end %>
  </ul>
</div>
<div class="tab-content">
  <% field.tabs.each do |tab| %>
    <%= form.fields_for field.name, tab.translation, wrapper: false do |f| %>
      <div class="tab-pane fade<%= (' show active' if tab.active?) %> fields" id="<%= tab.label %>" role="tabpanel" aria-labelledby="<%= tab.label %>-tab">
        <%= f.generate(action: :nested, model_config: field.associated_model_config, nested_in: field) %>
      </div>
    <% end %>
  <% end %>
</div>
Sankalp-Dwivedi commented 1 year ago

Yes, did the same but fails to add new or edit, says translation missing even when they are filled.

what I think is some code is failing in /lib/rails_admin_globalize_field/tab.rb on initialize method image

or in lib/rails_admin_globalize_field/globalize_tabs.rb on tabs method image

as while debugging I found that the translations records are not initializing even though the params have the value of the translation in the correct nested format. No feasible solution found yet still debugging it :(

newfylox commented 1 year ago

I don't have this issue. All those methods are being triggered when I put breakpoints and it's all good. Probably you missed something in configuration file? My problem is that even with those methods working good and my template showing correctly, the PUT form doesn't push my fields to params and it doesn't save.

here's my configuration

models/category.rb

class Category < ApplicationRecord
  # ...
  translates :eligible, :name
  accepts_nested_attributes_for :translations, allow_destroy: true
  # ...
end

config/initializers/rails_admin.rb

RailsAdmin.config do |config|
  # ...
  config.included_models = %w(Category Category::Translation)

  config.model 'Category' do
    configure :translations, :globalize_tabs
  end
  # ...
end