2013-06-07 33 views

Trả lời

10

Thành phần bố cục activeadmin rất dễ tùy chỉnh. Những gì bạn cần làm: Chỉ cần xác định một mô-đun mở ActiveAdmin :: Chế độ xem.

bạn có thể có custom_activeadmin_components.rb trong trình khởi tạo hoặc thư mục quản trị nơi bạn đã xác định tất cả tài nguyên activeadmin của mình. Tôi thích đặt nó vào thư mục nơi tài nguyên activeadmin của bạn. Sau đó ghi đè lên bất kỳ thành phần bạn muốn:

đây là một ví dụ:

module ActiveAdmin 
    module Views 
    class Header < Component 
     def build(namespace, menu) 
     super(:id => "header") 

     @namespace = namespace 
     @menu = menu 
     @utility_menu = @namespace.fetch_menu(:utility_navigation) 

     build_site_title 
     build_global_navigation 
     build_utility_navigation 
     #you can add any other component here in header section 
     end 

     def build_site_title 
     render "admin/parts/logo" 
     end 

     def build_global_navigation 
     render "admin/parts/main_nav" 
     end 

     def build_utility_navigation 
     render 'admin/parts/language_options' 
     insert_tag view_factory.global_navigation, @utility_menu, :id => "utility_nav", :class => 'header-item tabs' 
     render 'admin/parts/branch_in_header' 
     end 
    end 

    module Pages 
     class Base 
     def build_page_content 
      build_flash_messages 

      div :id => :wizard_progress_bar do 
      render 'admin/parts/wizard_progress_bar' 
      end 

      div :id => "active_admin_content", :class => (skip_sidebar? ? "without_sidebar" : "with_sidebar") do 
      build_main_content_wrapper 
      build_sidebar unless skip_sidebar? 
      end 
     end 
     end 
    end 
    end 
end 
+0

đặt nó trong thư mục nguồn không hoạt động. : ( –

+0

các tài nguyên khác của bạn ở đâu trong cùng một thư mục? – Muntasim

+0

hoạt động như một sự quyến rũ – Rubyrider

0

Bạn có thể tùy chỉnh trang quản trị tích cực trong admin/tập tin your_model.rb.

Mã mẫu cho quản trị viên hoạt động như sau.

ActiveAdmin.register User do 

    menu :label => "Our User", :priority => 3 #rename menu & set priority# 
    #for index page# 
    index :title => 'Our User' do #set page title# 
    # index :download_links => false do 
     selectable_column 
     column :title 
     column :category do |e| #want to change name of category 
     e.categoryone 
     end 
     column :address 
     default_actions#this will add default action i.e. show|edit|delete# 
    end 
    #end index# 

    #for controller# 
    controller do 
    actions :all, :except => [:edit, :new] # you can decide which all methods to be shown in show page. 
    end 
    #end controller# 

    #show start page# 
    show do |user| 
    h3 "User Details" 
    attributes_table do 
     row :title 
     row :description  
     row :address, :label=>"User Address" #overide address label 
     row :country 
     row :approval 
    end 

    h3 "Activity Photoes" 
    attributes_table do 
     user.uploads.each do |img| #call associated model. Here i want to display uploaded image of upload.rb file 
     row(" ") do 
      link_to image_tag(img.to_jq_upload['small_url']), admin_upload_path(img)#here i have added upload module to admin thats y i can directly give path to the upload record of admin module# 
     end 
     end 
    end 
    active_admin_comments # to show comment block of active admin 
    end 
    #show end# 

    #filer(search) start righthand side panel# 
    filter :title 
    filter :category 
    filter :address 
    #end filter# 

    #for menu on show page# 
    action_item only:[:show] do # this add "Approve User" button on the right hand side of show menu only as we have specified only show method 
    if User.find(params[:id]).approval == true 
     link_to "Approve User", approv_user_path(:id => params[:id])#call custom method of normal rails controller# 
    end 
    end 
    #end menu# 

    #start add side bar on page# 
    sidebar "Project Details" do 
    ul do 
     li link_to("Profile", new_project_path) 
    end 
    end 
    #end side bar# 

cuối

+4

Về bố cục không phải là trang cụ thể. – Muntasim

Các vấn đề liên quan