# encoding:utf-8
class PushAfterSub< ActiveRecord::Base
  has_paper_trail
  self.table_name = "push_after_subs"
  validates_presence_of :push_type, :remark
  PUSH_TYPE_ENUM = [["图片","image"],["文字","text"],["图文","article"]]

  IMG_STORE_PATH = "push_after_sub"

  rails_admin do
    navigation_label '推送管理'
    # parent ChannelQrcode
    weight -220

    list do
      filters [:id, :push_title]
      field :id
      field :push_title
      field :push_type, :enum do
        enum do
          PUSH_TYPE_ENUM
        end
      end
      field :cover do
        formatted_value do
            bindings[:view].tag(:img, {:src => bindings[:object].cover,
              :style => 'width: 100px;height: 100px;cursor: pointer;display: block;max-width: 100px;',
              :onClick => "javascript:window.open('#{bindings[:object].cover}')"})
        end
      end
      field :word
      field :url
      field :remark
      field :created_at
      field :updated_at
    end

    show do
      field :id
      field :push_title
      field :push_type, :enum do
        enum do
          PUSH_TYPE_ENUM
        end
      end
      field :cover do
        formatted_value do
            bindings[:view].tag(:img, {:src => bindings[:object].cover,
              :style => 'width: 100px;height: 100px;cursor: pointer;display: block;max-width: 100px;',
              :onClick => "javascript:window.open('#{bindings[:object].cover}')"})
        end
      end
      field :word
      field :url
      field :remark
      field :created_at
      field :updated_at
    end

    edit do
      field :push_title
      field :push_type, :enum do
        enum do
          PUSH_TYPE_ENUM
        end
      end
      field :cover
      field :word
      field :url
      field :remark
    end
  end

end
