Sha256: e9699bfd46bc98b69fe83fba700d574fcd10f3f58785110c016b2e05a860578f

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

include ActiveAdmin::ActsAsList::Helper
include ActsAsPublished::ActiveAdminHelper

ActiveAdmin.register Ecm::Downloads::Download do
  # acts as list
  sortable_member_actions

  # acts as published
  acts_as_published_actions

  # config
  menu :parent => I18n.t('ecm.downloads.active_admin.menu')

  permit_params :asset,
                :description,
                :ecm_downloads_download_category_id,
                :name

  # scopes
  scope :all
  scope :published
  scope :unpublished

  form :html => { :enctype => "multipart/form-data" } do |f|
    f.inputs do
      f.input :ecm_downloads_download_category, :as => :select,
                                                :collection => nested_set_options(Ecm::Downloads::DownloadCategory) { |dc| "#{'-' * dc.level} #{dc.name}" }
      f.input :asset, :as => :file
      f.input :name
      f.input :published, :as => :boolean
      f.input :description
    end

    f.actions
  end

  index do
    selectable_column
    column :ecm_downloads_download_category
    column :name
    acts_as_published_columns
    column :asset_file_name
    column :asset_file_size, :sortable => :asset_file_size do |download|
      number_to_human_size(download.asset_file_size)
    end
    column :created_at
    actions
  end
end if defined?(ActiveAdmin)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ecm_downloads2-1.1.0 lib/ecm/downloads/active_admin/ecm_downloads_downloads.rb
ecm_downloads2-1.0.0 lib/ecm/downloads/active_admin/ecm_downloads_downloads.rb