我需要将我的活动管理页面嵌入到父应用程序中。 活动管理页面将显示在iframe中,如果url query param embedded = true,我需要删除默认索引上的页眉和页脚,显示和编辑页面。
我在我的有效管理页面中继续这样做:
ActiveAdmin.register Followup, as: 'Followup_affectation' do
controller do
def setLayout
if params['embedded'] == 'true'
@layout = false
else
@layout = 'active_admin'
end
end
end
并采取一些自定义行动
render template: "admin/followups/mytemplate.html.haml", layout: @layout
但我想为索引做这件事。
我试过
def index
render :index, layout: @layout
end
和
def index
super
render :index, layout: @layout
end
我的索引定义非常经典:
index do
id_column
column :step
column :cycle
column :tag_rfid
column :quoteline
column :product_name
column :location
column :active
actions
end
提前感谢您的帮助
答案 0 :(得分:3)
我终于找到了解决方案。 1 - 在app / admin /
中创建header.rbmodule ActiveAdmin
module Views
class Header < Component
def build(namespace, menu)
super(id: "header")
#add a class hide wich diplay none on the menu
if params['embedded'] == 'true'
super(class: "hide")
end
@namespace = namespace
@menu = menu
@utility_menu = @namespace.fetch_menu(:utility_navigation)
build_site_title
build_global_navigation
build_utility_navigation
end
def build_site_title
insert_tag view_factory.site_title, @namespace
end
def build_global_navigation
#do not insert tag if params embedded is true
insert_tag view_factory.global_navigation, @menu, class: 'header-item tabs' unless params['embedded'] == 'true'
end
def build_utility_navigation
insert_tag view_factory.utility_navigation, @utility_menu, id: "utility_nav", class: 'header-item tabs'
end
end
end
end