Sha256: ac11ae81e9f1a65e1d4b0340c33049922886dfe8e2889d43cc2505173bfaa8ca

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

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

    collection_action :tags_api, method: :get do
      query = params[:q]
      tags = Lentil::Tag.where("name LIKE ?", "#{query}%").limit(20)

      render json: tags
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lentil-0.9.1 lib/lentil/admin/tags.rb
lentil-0.9.0 lib/lentil/admin/tags.rb
lentil-0.8.0 lib/lentil/admin/tags.rb