Sha256: 3182a8938c5551bb70104c2c03a1dabe455aefdae90d18bc8e52623e25123244

Contents?: true

Size: 977 Bytes

Versions: 4

Compression:

Stored size: 977 Bytes

Contents

module Worthwhile::CollectionsHelper
  def has_collection_search_parameters?
    params[:cq].present?
  end

  def collection_modal_id(collectible)
    "#{collectible.to_param.gsub(/:/, '-')}-modal"
  end

  def link_to_select_collection(collectible, opts={})
    html_class = opts[:class]
    link_to '#', data: { toggle: "modal", target: '#' + collection_modal_id(collectible) },
      class: "add-to-collection #{html_class}", title: "Add #{collectible.human_readable_type} to Collection" do
      icon('plus-sign') + ' Add to a Collection'
    end
  end

  # override hydra-collections
  def link_to_remove_from_collection(document, label = 'Remove From Collection')
    link_to collections.collection_path(@collection.id, collection: { members: 'remove'},
                batch_document_ids: [ document.id ]), method: :put do
      icon('minus-sign') + ' ' + label
    end
  end

  def icon(type)
    content_tag :span, '', class: "glyphicon glyphicon-#{type}"
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
worthwhile-0.1.1 app/helpers/worthwhile/collections_helper.rb
worthwhile-0.1.0 app/helpers/worthwhile/collections_helper.rb
worthwhile-0.0.3 app/helpers/worthwhile/collections_helper.rb
worthwhile-0.0.2 app/helpers/worthwhile/collections_helper.rb