Sha256: e9b1c57f0013fa386620913f26389f84dfe8702c435be1022b03c117995fed45

Contents?: true

Size: 923 Bytes

Versions: 2

Compression:

Stored size: 923 Bytes

Contents

if defined?(ActiveAdmin)
  ActiveAdmin.register Lentil::Tag do
    actions :index, :create, :new

    config.batch_actions = false
    config.sort_order = "name_asc"

    filter :name
    filter :tagsets_title, :as => :string, :label => "Tagsets"

    scope :all, :default => true
    scope "Harvesting", :harvestable
    scope "Not Harvesting", :not_harvestable
    scope "Not in a Tagset", :no_tagsets

    index :download_links => false do
      harvestable_ids = Lentil::Tag.harvestable.map(&:id)

      column :id
      column :name
      column "Harvestable" do |tag|
        if harvestable_ids.include?(tag.id)
          "True"
        else
          "False"
        end
      end
      column "Tagsets" do |tag|
        tag.tagsets.sort_by(&:title).map{ |t| t.title}.join(' | ')
      end
    end

    controller do
      def scoped_collection
        super.includes :taggings, :tagsets
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lentil-0.7.1 lib/lentil/admin/tags.rb
lentil-0.6.0 lib/lentil/admin/tags.rb