# encoding:utf-8
class WxMenu < ActiveRecord::Base
  has_paper_trail
  self.table_name = "wx_menus"
  has_ancestry
  belongs_to :wx_gongzhonghao
  # attr_accessor   :ancestry
  validates :wx_gongzhonghao_id,:name,:action ,presence: true

  ACTION_ENUM = [["公众号", "root"],["链接", "view"], ["事件", "click"],["小程序","miniprogram"]]

  rails_admin do
    navigation_label '公众号管理'
    weight -350

    nestable_tree({
                    position_field: :position ,
                    max_depth: 3
    })

    list do
      filters [:wx_gongzhonghao,:position,:action]
      # include_all_fields
      field :id
      field :wx_gongzhonghao
      field :wx_gongzhonghao_id
      field :name
      field :ancestry
      field :action, :enum do
        enum do
          ACTION_ENUM
        end
      end
      field :content   
      field :appid
      field :pagepath   
      field :key
      field :position
      field :created_at
    end
    show do
      # include_all_fields
      field :id
      field :wx_gongzhonghao
      field :wx_gongzhonghao_id
      field :name
      field :ancestry
      field :action, :enum do
        enum do
          ACTION_ENUM
        end
      end
      field :content      
      field :appid
      field :pagepath 
      field :key
      field :position
      field :created_at
    end
    edit do
      include_all_fields
      field :action, :enum do
        enum do
          ACTION_ENUM
        end
      end
    end
  end

end
