= stylesheet_link_tag 'rails_admin/rails_admin_sort_embedded' = javascript_include_tag 'rails_admin/rails_admin_sort_embedded' .controls %ul.nav.nav-tabs - sort_embedded_fields.each do |f| %li :ruby if f.is_a?(Hash) embedded_field = f.keys.first embedded_model_order_field = f.values.first embedded_model_order_field = embedded_model_order_field.last if embedded_model_order_field.is_a?(Array) i18n_path = "rails_admin.sort_embedded.#{@object.class.name.tableize}.#{embedded_field}.#{embedded_model_order_field}" i18n_path_default = "rails_admin.sort_embedded.#{@object.class.name.tableize}.#{embedded_field}" link = "#sort_embedded_#{embedded_field}_#{embedded_model_order_field}" title = I18n.t(i18n_path, default: I18n.t(i18n_path_default)) else i18n_path = "rails_admin.sort_embedded.#{@object.class.name.tableize}.#{f}.order" i18n_path_default = "rails_admin.sort_embedded.#{@object.class.name.tableize}.#{f}" link = "#sort_embedded_#{f}" title = I18n.t(i18n_path, default: I18n.t(i18n_path_default)) end = link_to I18n.t(i18n_path, default: I18n.t(i18n_path_default)), link, title: title, "data-toggle" => "tab" .tab-content - sort_embedded_fields.each do |f| - if f.is_a?(Hash) - embedded_field = f.keys.first - embedded_model_order_field = f.values.first - if embedded_model_order_field.is_a?(Array) - if embedded_model_order_field.size > 1 - embedded_model_ordered_scope = embedded_model_order_field[1] - else - embedded_model_ordered_scope = "#{embedded_model_order_field[0]}ed" - embedded_model_order_field = embedded_model_order_field[0] - else - embedded_model_ordered_scope = "#{embedded_model_order_field}ed" .tab-pane{id: "sort_embedded_#{embedded_field}_#{embedded_model_order_field}"} .row-fluid .span12.rails_admin_sort_embedded_block{id: "rails_admin_sort_embedded_#{embedded_field}_#{embedded_model_order_field}"} = rails_admin_sort_embedded @object.send(embedded_field).send(embedded_model_ordered_scope).to_a, {embedded_field: embedded_field, embedded_model_order_field: embedded_model_order_field} - else .tab-pane{id: "sort_embedded_#{f}"} .row-fluid .span12.rails_admin_sort_embedded_block{id: "rails_admin_sort_embedded_#{f}_order"} = rails_admin_sort_embedded @object.send(f).ordered.to_a, {embedded_field: f}