Sha256: 92ebea1b6e2ae1138d2034530047fd9b84513ff50d01d968b34ba51be7f9b7fa

Contents?: true

Size: 789 Bytes

Versions: 10

Compression:

Stored size: 789 Bytes

Contents

# -*- coding: utf-8 -*-
module Hyrax
  module TrophyHelper
    def display_trophy_link(user, id, args = {}, &_block)
      return unless user
      trophy = user.trophies.where(work_id: id).first
      trophyclass = trophy ? "trophy-on" : "trophy-off"

      args[:add_text] ||= "Highlight Work on Profile"
      args[:remove_text] ||= "Unhighlight Work"
      text = trophy ? args[:remove_text] : args[:add_text]
      args[:class] = [args[:class], "trophy-class #{trophyclass}"].compact.join(' ')
      args[:data] ||= {}
      args[:data]['add-text'] = args[:add_text]
      args[:data]['remove-text'] = args[:remove_text]

      args[:data][:url] = hyrax.trophy_work_path(id)
      link_to '#', class: args[:class], data: args[:data] do
        yield(text)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 app/helpers/hyrax/trophy_helper.rb
hyrax-1.1.0 app/helpers/hyrax/trophy_helper.rb
hyrax-1.0.5 app/helpers/hyrax/trophy_helper.rb
hyrax-1.0.4 app/helpers/hyrax/trophy_helper.rb
hyrax-1.0.3 app/helpers/hyrax/trophy_helper.rb
hyrax-1.0.2 app/helpers/hyrax/trophy_helper.rb
hyrax-1.0.1 app/helpers/hyrax/trophy_helper.rb
hyrax-1.0.0.rc2 app/helpers/hyrax/trophy_helper.rb
hyrax-1.0.0.rc1 app/helpers/hyrax/trophy_helper.rb
test_hyrax-0.0.1.alpha app/helpers/hyrax/trophy_helper.rb